diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..7a4975a --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,30 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build OpenFGA + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '8' ] + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml diff --git a/.github/workflows/semgrep.yaml b/.github/workflows/semgrep.yaml new file mode 100644 index 0000000..66e24d3 --- /dev/null +++ b/.github/workflows/semgrep.yaml @@ -0,0 +1,17 @@ +name: Semgrep +on: + push: + branches: + - main +jobs: + semgrep: + name: Scan + runs-on: ubuntu-latest + container: + image: returntocorp/semgrep + if: (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot') + steps: + - uses: actions/checkout@v3 + - run: semgrep ci + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100644 index 0000000..0c58fed --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,7 @@ +**/ServerConfiguration.java +**/ServerVariable.java +src/main/AndroidManifest.xml +build.sbt +pom.xml +git_push.sh +.travis.yml diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 0000000..6d7ae27 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,206 @@ +.fossa.yml +.github/CODEOWNERS +.github/ISSUE_TEMPLATE/bug_report.md +.github/ISSUE_TEMPLATE/feature_request.md +.github/workflows/maven.yml +.github/workflows/semgrep.yaml +.gitignore +CHANGELOG.md +CONTRIBUTING.md +LICENSE +NOTICE.txt +README.md +VERSION.txt +api/openapi.yaml +build.gradle +docs/Any.md +docs/Assertion.md +docs/AuthorizationModel.md +docs/CheckRequest.md +docs/CheckResponse.md +docs/Computed.md +docs/ContextualTupleKeys.md +docs/CreateStoreRequest.md +docs/CreateStoreResponse.md +docs/Difference.md +docs/ErrorCode.md +docs/ExpandRequest.md +docs/ExpandResponse.md +docs/GetStoreResponse.md +docs/InternalErrorCode.md +docs/InternalErrorMessageResponse.md +docs/Leaf.md +docs/ListObjectsRequest.md +docs/ListObjectsResponse.md +docs/ListStoresResponse.md +docs/Metadata.md +docs/Node.md +docs/Nodes.md +docs/NotFoundErrorCode.md +docs/ObjectRelation.md +docs/OpenFgaApi.md +docs/PathUnknownErrorMessageResponse.md +docs/ReadAssertionsResponse.md +docs/ReadAuthorizationModelResponse.md +docs/ReadAuthorizationModelsResponse.md +docs/ReadChangesResponse.md +docs/ReadRequest.md +docs/ReadResponse.md +docs/RelationMetadata.md +docs/RelationReference.md +docs/Status.md +docs/Store.md +docs/Tuple.md +docs/TupleChange.md +docs/TupleKey.md +docs/TupleKeys.md +docs/TupleOperation.md +docs/TupleToUserset.md +docs/TypeDefinition.md +docs/Users.md +docs/Userset.md +docs/UsersetTree.md +docs/UsersetTreeDifference.md +docs/UsersetTreeTupleToUserset.md +docs/Usersets.md +docs/ValidationErrorMessageResponse.md +docs/WriteAssertionsRequest.md +docs/WriteAuthorizationModelRequest.md +docs/WriteAuthorizationModelResponse.md +docs/WriteRequest.md +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +settings.gradle +src/main/java/dev/openfga/sdk/api/OpenFgaApi.java +src/main/java/dev/openfga/sdk/api/client/ApiBearerToken.java +src/main/java/dev/openfga/sdk/api/client/ApiClient.java +src/main/java/dev/openfga/sdk/api/client/ApiException.java +src/main/java/dev/openfga/sdk/api/client/ApiResponse.java +src/main/java/dev/openfga/sdk/api/client/BaseConfiguration.java +src/main/java/dev/openfga/sdk/api/client/ClientCredentials.java +src/main/java/dev/openfga/sdk/api/client/Configuration.java +src/main/java/dev/openfga/sdk/api/client/Configuration.java +src/main/java/dev/openfga/sdk/api/client/CredentialsMethod.java +src/main/java/dev/openfga/sdk/api/client/JSON.java +src/main/java/dev/openfga/sdk/api/client/Pair.java +src/main/java/dev/openfga/sdk/api/client/RFC3339DateFormat.java +src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java +src/main/java/dev/openfga/sdk/api/model/Any.java +src/main/java/dev/openfga/sdk/api/model/Assertion.java +src/main/java/dev/openfga/sdk/api/model/AuthorizationModel.java +src/main/java/dev/openfga/sdk/api/model/CheckRequest.java +src/main/java/dev/openfga/sdk/api/model/CheckResponse.java +src/main/java/dev/openfga/sdk/api/model/Computed.java +src/main/java/dev/openfga/sdk/api/model/ContextualTupleKeys.java +src/main/java/dev/openfga/sdk/api/model/CreateStoreRequest.java +src/main/java/dev/openfga/sdk/api/model/CreateStoreResponse.java +src/main/java/dev/openfga/sdk/api/model/Difference.java +src/main/java/dev/openfga/sdk/api/model/ErrorCode.java +src/main/java/dev/openfga/sdk/api/model/ExpandRequest.java +src/main/java/dev/openfga/sdk/api/model/ExpandResponse.java +src/main/java/dev/openfga/sdk/api/model/GetStoreResponse.java +src/main/java/dev/openfga/sdk/api/model/InternalErrorCode.java +src/main/java/dev/openfga/sdk/api/model/InternalErrorMessageResponse.java +src/main/java/dev/openfga/sdk/api/model/Leaf.java +src/main/java/dev/openfga/sdk/api/model/ListObjectsRequest.java +src/main/java/dev/openfga/sdk/api/model/ListObjectsResponse.java +src/main/java/dev/openfga/sdk/api/model/ListStoresResponse.java +src/main/java/dev/openfga/sdk/api/model/Metadata.java +src/main/java/dev/openfga/sdk/api/model/Node.java +src/main/java/dev/openfga/sdk/api/model/Nodes.java +src/main/java/dev/openfga/sdk/api/model/NotFoundErrorCode.java +src/main/java/dev/openfga/sdk/api/model/ObjectRelation.java +src/main/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponse.java +src/main/java/dev/openfga/sdk/api/model/ReadAssertionsResponse.java +src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponse.java +src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponse.java +src/main/java/dev/openfga/sdk/api/model/ReadChangesResponse.java +src/main/java/dev/openfga/sdk/api/model/ReadRequest.java +src/main/java/dev/openfga/sdk/api/model/ReadResponse.java +src/main/java/dev/openfga/sdk/api/model/RelationMetadata.java +src/main/java/dev/openfga/sdk/api/model/RelationReference.java +src/main/java/dev/openfga/sdk/api/model/Status.java +src/main/java/dev/openfga/sdk/api/model/Store.java +src/main/java/dev/openfga/sdk/api/model/Tuple.java +src/main/java/dev/openfga/sdk/api/model/TupleChange.java +src/main/java/dev/openfga/sdk/api/model/TupleKey.java +src/main/java/dev/openfga/sdk/api/model/TupleKeys.java +src/main/java/dev/openfga/sdk/api/model/TupleOperation.java +src/main/java/dev/openfga/sdk/api/model/TupleToUserset.java +src/main/java/dev/openfga/sdk/api/model/TypeDefinition.java +src/main/java/dev/openfga/sdk/api/model/Users.java +src/main/java/dev/openfga/sdk/api/model/Userset.java +src/main/java/dev/openfga/sdk/api/model/UsersetTree.java +src/main/java/dev/openfga/sdk/api/model/UsersetTreeDifference.java +src/main/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUserset.java +src/main/java/dev/openfga/sdk/api/model/Usersets.java +src/main/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponse.java +src/main/java/dev/openfga/sdk/api/model/WriteAssertionsRequest.java +src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequest.java +src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponse.java +src/main/java/dev/openfga/sdk/api/model/WriteRequest.java +src/main/java/dev/openfga/sdk/errors/FgaInvalidParameterException.java +src/main/java/dev/openfga/util/StringUtil.java +src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java +src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java +src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java +src/test/java/dev/openfga/sdk/api/client/ClientCredentialsTest.java +src/test/java/dev/openfga/sdk/api/client/ConfigurationTest.java +src/test/java/dev/openfga/sdk/api/model/AnyTest.java +src/test/java/dev/openfga/sdk/api/model/AssertionTest.java +src/test/java/dev/openfga/sdk/api/model/AuthorizationModelTest.java +src/test/java/dev/openfga/sdk/api/model/CheckRequestTest.java +src/test/java/dev/openfga/sdk/api/model/CheckResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ComputedTest.java +src/test/java/dev/openfga/sdk/api/model/ContextualTupleKeysTest.java +src/test/java/dev/openfga/sdk/api/model/CreateStoreRequestTest.java +src/test/java/dev/openfga/sdk/api/model/CreateStoreResponseTest.java +src/test/java/dev/openfga/sdk/api/model/DifferenceTest.java +src/test/java/dev/openfga/sdk/api/model/ErrorCodeTest.java +src/test/java/dev/openfga/sdk/api/model/ExpandRequestTest.java +src/test/java/dev/openfga/sdk/api/model/ExpandResponseTest.java +src/test/java/dev/openfga/sdk/api/model/GetStoreResponseTest.java +src/test/java/dev/openfga/sdk/api/model/InternalErrorCodeTest.java +src/test/java/dev/openfga/sdk/api/model/InternalErrorMessageResponseTest.java +src/test/java/dev/openfga/sdk/api/model/LeafTest.java +src/test/java/dev/openfga/sdk/api/model/ListObjectsRequestTest.java +src/test/java/dev/openfga/sdk/api/model/ListObjectsResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ListStoresResponseTest.java +src/test/java/dev/openfga/sdk/api/model/MetadataTest.java +src/test/java/dev/openfga/sdk/api/model/NodeTest.java +src/test/java/dev/openfga/sdk/api/model/NodesTest.java +src/test/java/dev/openfga/sdk/api/model/NotFoundErrorCodeTest.java +src/test/java/dev/openfga/sdk/api/model/ObjectRelationTest.java +src/test/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ReadAssertionsResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ReadChangesResponseTest.java +src/test/java/dev/openfga/sdk/api/model/ReadRequestTest.java +src/test/java/dev/openfga/sdk/api/model/ReadResponseTest.java +src/test/java/dev/openfga/sdk/api/model/RelationMetadataTest.java +src/test/java/dev/openfga/sdk/api/model/RelationReferenceTest.java +src/test/java/dev/openfga/sdk/api/model/StatusTest.java +src/test/java/dev/openfga/sdk/api/model/StoreTest.java +src/test/java/dev/openfga/sdk/api/model/TupleChangeTest.java +src/test/java/dev/openfga/sdk/api/model/TupleKeyTest.java +src/test/java/dev/openfga/sdk/api/model/TupleKeysTest.java +src/test/java/dev/openfga/sdk/api/model/TupleOperationTest.java +src/test/java/dev/openfga/sdk/api/model/TupleTest.java +src/test/java/dev/openfga/sdk/api/model/TupleToUsersetTest.java +src/test/java/dev/openfga/sdk/api/model/TypeDefinitionTest.java +src/test/java/dev/openfga/sdk/api/model/UsersTest.java +src/test/java/dev/openfga/sdk/api/model/UsersetTest.java +src/test/java/dev/openfga/sdk/api/model/UsersetTreeDifferenceTest.java +src/test/java/dev/openfga/sdk/api/model/UsersetTreeTest.java +src/test/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUsersetTest.java +src/test/java/dev/openfga/sdk/api/model/UsersetsTest.java +src/test/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponseTest.java +src/test/java/dev/openfga/sdk/api/model/WriteAssertionsRequestTest.java +src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequestTest.java +src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponseTest.java +src/test/java/dev/openfga/sdk/api/model/WriteRequestTest.java +src/test/java/dev/openfga/util/StringUtilTest.java diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 0000000..c0be8a7 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.4.0 \ No newline at end of file diff --git a/README.md b/README.md index 395c95d..5610756 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# .NET SDK for OpenFGA +# Java SDK for OpenFGA [![Release](https://img.shields.io/github/v/release/openfga/java-sdk?sort=semver&color=green)](https://github.com/openfga/java-sdk/releases) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fopenfga%2Fjava-sdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fopenfga%2Fjava-sdk?ref=badge_shield) -[![Discord Server](https://img.shields.io/discord/759188666072825867?color=7289da&logo=discord "Discord Server")](https://discord.com/channels/759188666072825867/930524706854031421) +[![Discord Server](https://img.shields.io/discord/759188666072825867?color=7289da&logo=discord "Discord Server")](https://discord.gg/8naAwJfWN6) [![Twitter](https://img.shields.io/twitter/follow/openfga?color=%23179CF0&logo=twitter&style=flat-square "@openfga on Twitter")](https://twitter.com/openfga) -This is an autogenerated SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api). +This is an autogenerated java SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api). ## Table of Contents @@ -65,28 +65,14 @@ OpenFGA is designed to make it easy for application builders to model their perm ## Installation + + ## Getting Started ### Initializing the API Client [Learn how to initialize your SDK](https://openfga.dev/docs/getting-started/setup-sdk-client) -> The SdkClient will by default retry API requests up to 15 times on 429 and 5xx errors. - -#### No Credentials - -```java -``` - -#### API Token - -```java -``` - -#### Client Credentials - -```java -``` ### Get your Store ID @@ -97,201 +83,16 @@ If your server is configured with [authentication enabled](https://openfga.dev/d ### Calling the API -#### Stores - -##### List Stores - -Get a paginated list of stores. - -[API Documentation](https://openfga.dev/api/service/docs/api#/Stores/ListStores) - -```java -``` - -##### Create Store - -Initialize a store. - -[API Documentation](https://openfga.dev/api/service/docs/api#/Stores/CreateStore) - -```java -``` - -##### Get Store - -Get information about the current store. - -[API Documentation](https://openfga.dev/api/service/docs/api#/Stores/GetStore) - -> Requires a client initialized with a storeId - -```java -``` - -##### Delete Store - -Delete a store. - -[API Documentation](https://openfga.dev/api/service/docs/api#/Stores/DeleteStore) - -> Requires a client initialized with a storeId - -```java -``` - -#### Authorization Models - -##### Read Authorization Models - -Read all authorization models in the store. - -[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/ReadAuthorizationModels) - -```java -``` - -##### Write Authorization Model - -Create a new authorization model. - -[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/WriteAuthorizationModel) - -> Note: To learn how to build your authorization model, check the Docs at https://openfga.dev/docs. - -> Learn more about [the OpenFGA configuration language](https://openfga.dev/docs/configuration-language). - -> You can use the [OpenFGA Syntax Transformer](https://github.com/openfga/syntax-transformer) to convert between the friendly DSL and the JSON authorization model. - -```java -``` - -#### Read a Single Authorization Model - -Read a particular authorization model. - -[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/ReadAuthorizationModel) - -```java -``` - -##### Read the Latest Authorization Model - -Reads the latest authorization model (note: this ignores the model id in configuration). - -[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/ReadAuthorizationModel) - -```java -``` - -#### Relationship Tuples -##### Read Relationship Tuple Changes (Watch) -Reads the list of historical relationship tuple writes and deletes. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/ReadChanges) - -```java -``` - -##### Read Relationship Tuples - -Reads the relationship tuples stored in the database. It does not evaluate nor exclude invalid tuples according to the authorization model. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Read) - -```java -``` - -##### Write (Create and Delete) Relationship Tuples - -Create and/or delete relationship tuples to update the system state. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Write) - -###### Transaction mode (default) - -By default, write runs in a transaction mode where any invalid operation (deleting a non-existing tuple, creating an existing tuple, one of the tuples was invalid) or a server error will fail the entire operation. - -```java -``` - -Convenience `WriteTuples` and `DeleteTuples` methods are also available. - -###### Non-transaction mode - -The SDK will split the writes into separate requests and send them sequentially to avoid violating rate limits. - -```java -``` - -#### Relationship Queries - -##### Check - -Check if a user has a particular relation with an object. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/Check) - -```java -``` - -##### Batch Check - -Run a set of [checks](#check). Batch Check will return `allowed: false` if it encounters an error, and will return the error in the body. -If 429s or 5xxs are encountered, the underlying check will retry up to 15 times before giving up. - -```java -``` - -##### Expand - -Expands the relationships in userset tree format. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/Expand) - -```java -``` - -#### List Objects - -List the objects of a particular type a user has access to. - -[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/ListObjects) - -```java -``` - -#### List Relations - -List the relations a user has on an object. - -```java -``` - -### Assertions - -#### Read Assertions - -Read assertions for a particular authorization model. - -[API Documentation](https://openfga.dev/api/service#/Assertions/Read%20Assertions) - -```java -``` - -#### Write Assertions +### API Endpoints -Update the assertions for a particular authorization model. -[API Documentation](https://openfga.dev/api/service#/Assertions/Write%20Assertions) -```java -``` +### Models -### API Endpoints +[Models](https://github.com/openfga/java-sdk/blob/main/apiModel.ts) -### Models ## Contributing @@ -311,4 +112,5 @@ All changes made to this repo will be overwritten on the next generation, so we This project is licensed under the Apache-2.0 license. See the [LICENSE](https://github.com/openfga/java-sdk/blob/main/LICENSE) file for more info. -The code in this repo was auto generated by [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from a template based on the [java template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/Java), licensed under the [Apache License 2.0](https://github.com/OpenAPITools/openapi-generator/blob/master/LICENSE). \ No newline at end of file +The code in this repo was auto generated by [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from a template based on the [Java template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/Java), licensed under the [Apache License 2.0](https://github.com/OpenAPITools/openapi-generator/blob/master/LICENSE). + diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.0.1 diff --git a/api/openapi.yaml b/api/openapi.yaml new file mode 100644 index 0000000..8507247 --- /dev/null +++ b/api/openapi.yaml @@ -0,0 +1,1912 @@ +openapi: 3.0.1 +info: + contact: + email: community@openfga.dev + name: OpenFGA + url: https://openfga.dev + description: A high performance and flexible authorization/permission engine built + for developers and inspired by Google Zanzibar. + license: + name: Apache-2.0 + url: https://github.com/openfga/openfga/blob/main/LICENSE + title: OpenFGA + version: "0.1" +servers: +- url: / +tags: +- name: OpenFga +paths: + /stores: + get: + description: | + Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. + The continuation token will be empty if there are no more stores. + operationId: ListStores + parameters: + - in: query + name: page_size + schema: + format: int32 + type: integer + - in: query + name: continuation_token + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ListStoresResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: List all stores + tags: + - OpenFga + x-accepts: application/json + post: + description: Create a unique OpenFGA store which will be used to store authorization + models and relationship tuples. + operationId: CreateStore + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateStoreRequest' + required: true + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/CreateStoreResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Create a store + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}: + delete: + description: "Delete an OpenFGA store. This does not delete the data associated\ + \ with the store, like tuples or authorization models." + operationId: DeleteStore + parameters: + - in: path + name: store_id + required: true + schema: + type: string + responses: + "204": + content: {} + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Delete a store + tags: + - OpenFga + x-accepts: application/json + get: + description: Returns an OpenFGA store by its identifier + operationId: GetStore + parameters: + - in: path + name: store_id + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GetStoreResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Get a store + tags: + - OpenFga + x-accepts: application/json + /stores/{store_id}/assertions/{authorization_model_id}: + get: + description: "The ReadAssertions API will return, for a given authorization\ + \ model id, all the assertions stored for it. An assertion is an object that\ + \ contains a tuple key, and the expectation of whether a call to the Check\ + \ API of that tuple key will return true or false. " + operationId: ReadAssertions + parameters: + - in: path + name: store_id + required: true + schema: + type: string + - in: path + name: authorization_model_id + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ReadAssertionsResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Read assertions for an authorization model ID + tags: + - OpenFga + x-accepts: application/json + put: + description: "The WriteAssertions API will upsert new assertions for an authorization\ + \ model id, or overwrite the existing ones. An assertion is an object that\ + \ contains a tuple key, and the expectation of whether a call to the Check\ + \ API of that tuple key will return true or false. " + operationId: WriteAssertions + parameters: + - in: path + name: store_id + required: true + schema: + type: string + - in: path + name: authorization_model_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/WriteAssertions_request' + required: true + responses: + "204": + content: {} + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Upsert assertions for an authorization model ID + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/authorization-models: + get: + description: | + The ReadAuthorizationModels API will return all the authorization models for a certain store. + OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. + + ## Example + Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: + ```json + { + "authorization_models": [ + { + "id": "01G50QVV17PECNVAHX1GG4Y5NC", + "type_definitions": [...] + }, + { + "id": "01G4ZW8F4A07AKQ8RHSVG9RW04", + "type_definitions": [...] + }, + ], + "continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==" + } + ``` + If there are no more authorization models available, the `continuation_token` field will be empty + ```json + { + "authorization_models": [ + { + "id": "01G50QVV17PECNVAHX1GG4Y5NC", + "type_definitions": [...] + }, + { + "id": "01G4ZW8F4A07AKQ8RHSVG9RW04", + "type_definitions": [...] + }, + ], + "continuation_token": "" + } + ``` + operationId: ReadAuthorizationModels + parameters: + - in: path + name: store_id + required: true + schema: + type: string + - in: query + name: page_size + schema: + format: int32 + type: integer + - in: query + name: continuation_token + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ReadAuthorizationModelsResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Return all the authorization models for a particular store + tags: + - OpenFga + x-accepts: application/json + post: + description: "The WriteAuthorizationModel API will add a new authorization model\ + \ to a store.\nEach item in the `type_definitions` array is a type definition\ + \ as specified in the field `type_definition`.\nThe response will return the\ + \ authorization model's ID in the `id` field.\n\n## Example\nTo add an authorization\ + \ model with `user` and `document` type definitions, call POST authorization-models\ + \ API with the body: \n```json\n{\n \"type_definitions\":[\n {\n \ + \ \"type\":\"user\"\n },\n {\n \"type\":\"document\",\n \"\ + relations\":{\n \"reader\":{\n \"union\":{\n \"\ + child\":[\n {\n \"this\":{}\n },\n\ + \ {\n \"computedUserset\":{\n \ + \ \"object\":\"\",\n \"relation\":\"writer\"\n \ + \ }\n }\n ]\n }\n },\n \ + \ \"writer\":{\n \"this\":{}\n }\n }\n }\n ]\n\ + }\n```\nOpenFGA's response will include the version id for this authorization\ + \ model, which will look like \n```\n{\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"\ + }\n```\n" + operationId: WriteAuthorizationModel + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/WriteAuthorizationModel_request' + required: true + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/WriteAuthorizationModelResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Create a new authorization model + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/authorization-models/{id}: + get: + description: |- + The ReadAuthorizationModel API returns an authorization model by its identifier. + The response will return the authorization model for the particular version. + + ## Example + To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: + ```json + { + "authorization_model":{ + "id":"01G5JAVJ41T49E9TT3SKVS7X1J", + "type_definitions":[ + { + "type":"user" + }, + { + "type":"document", + "relations":{ + "reader":{ + "union":{ + "child":[ + { + "this":{} + }, + { + "computedUserset":{ + "object":"", + "relation":"writer" + } + } + ] + } + }, + "writer":{ + "this":{} + } + } + } + ] + } + } + ``` + In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`). + operationId: ReadAuthorizationModel + parameters: + - in: path + name: store_id + required: true + schema: + type: string + - in: path + name: id + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ReadAuthorizationModelResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Return a particular version of an authorization model + tags: + - OpenFga + x-accepts: application/json + /stores/{store_id}/changes: + get: + description: | + The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. + You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. + operationId: ReadChanges + parameters: + - in: path + name: store_id + required: true + schema: + type: string + - in: query + name: type + schema: + type: string + - in: query + name: page_size + schema: + format: int32 + type: integer + - in: query + name: continuation_token + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ReadChangesResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Return a list of all the tuple changes + tags: + - OpenFga + x-accepts: application/json + /stores/{store_id}/check: + post: + description: |- + The Check API queries to check if the user has a certain relationship with an object in a certain store. + A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. + You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. + The response will return whether the relationship exists in the field `allowed`. + + ## Example + In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple + ```json + { + "user": "user:anne", + "relation": "member", + "object": "time_slot:office_hours" + } + ``` + the Check API can be used with the following request body: + ```json + { + "tuple_key": { + "user": "user:anne", + "relation": "reader", + "object": "document:2021-budget" + }, + "contextual_tuples": { + "tuple_keys": [ + { + "user": "user:anne", + "relation": "member", + "object": "time_slot:office_hours" + } + ] + }, + "authorization_model_id": "01G50QVV17PECNVAHX1GG4Y5NC" + } + ``` + OpenFGA's response will include `{ "allowed": true }` if there is a relationship and `{ "allowed": false }` if there isn't. + operationId: Check + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Check_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/CheckResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Check whether a user is authorized to access an object + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/expand: + post: + description: |- + The Expand API will return all users and usersets that have certain relationship with an object in a certain store. + This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. + Body parameters `tuple_key.object` and `tuple_key.relation` are all required. + The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. + + ## Example + To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body + ```json + { + "tuple_key": { + "object": "document:2021-budget", + "relation": "reader" + }, + "authorization_model_id": "01G50QVV17PECNVAHX1GG4Y5NC" + } + ``` + OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. + ```json + { + "tree":{ + "root":{ + "type":"document:2021-budget#reader", + "union":{ + "nodes":[ + { + "type":"document:2021-budget#reader", + "leaf":{ + "users":{ + "users":[ + "user:bob" + ] + } + } + }, + { + "type":"document:2021-budget#reader", + "leaf":{ + "computed":{ + "userset":"document:2021-budget#writer" + } + } + } + ] + } + } + } + } + ``` + The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. + operationId: Expand + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Expand_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ExpandResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: "Expand all relationships in userset tree format, and following userset\ + \ rewrite rules. Useful to reason about and debug a certain relationship" + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/list-objects: + post: + description: |- + The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. + An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. + You may also specify `contextual_tuples` that will be treated as regular tuples. + The response will contain the related objects in an array in the "objects" field of the response and they will be strings in the object format `:` (e.g. "document:roadmap"). + The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + operationId: ListObjects + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ListObjects_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ListObjectsResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: List all objects of the given type that the user has a relation with + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/read: + post: + description: "The Read API will return the tuples for a certain store that match\ + \ a query filter specified in the body of the request. It is different from\ + \ the `/stores/{store_id}/expand` API in that it only returns relationship\ + \ tuples that are stored in the system and satisfy the query. \nIn the body:\n\ + 1. `tuple_key` is optional. If not specified, it will return all tuples in\ + \ the store.\n2. `tuple_key.object` is mandatory if `tuple_key` is specified.\ + \ It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`).\n\ + 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the\ + \ `tuple_key.object` is a type only.\n## Examples\n### Query for all objects\ + \ in a type definition\nTo query for all objects that `user:bob` has `reader`\ + \ relationship in the `document` type definition, call read API with body\ + \ of\n```json\n{\n \"tuple_key\": {\n \"user\": \"user:bob\",\n \"\ + relation\": \"reader\",\n \"object\": \"document:\"\n }\n}\n```\nThe\ + \ API will return tuples and a continuation token, something like\n```json\n\ + {\n \"tuples\": [\n {\n \"key\": {\n \"user\": \"user:bob\"\ + ,\n \"relation\": \"reader\",\n \"object\": \"document:2021-budget\"\ + \n },\n \"timestamp\": \"2021-10-06T15:32:11.128Z\"\n }\n ],\n\ + \ \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\"\ + \n}\n```\nThis means that `user:bob` has a `reader` relationship with 1 document\ + \ `document:2021-budget`. Note that this API, unlike the List Objects API,\ + \ does not evaluate the tuples in the store.\nThe continuation token will\ + \ be empty if there are no more tuples to query.### Query for all stored relationship\ + \ tuples that have a particular relation and object\nTo query for all users\ + \ that have `reader` relationship with `document:2021-budget`, call read API\ + \ with body of \n```json\n{\n \"tuple_key\": {\n \"object\": \"document:2021-budget\"\ + ,\n \"relation\": \"reader\"\n }\n}\n```\nThe API will return something\ + \ like \n```json\n{\n \"tuples\": [\n {\n \"key\": {\n \"\ + user\": \"user:bob\",\n \"relation\": \"reader\",\n \"object\"\ + : \"document:2021-budget\"\n },\n \"timestamp\": \"2021-10-06T15:32:11.128Z\"\ + \n }\n ],\n \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\"\ + \n}\n```\nThis means that `document:2021-budget` has 1 `reader` (`user:bob`).\ + \ Note that, even if the model said that all `writers` are also `readers`,\ + \ the API will not return writers such as `user:anne` because it only returns\ + \ tuples and does not evaluate them.\n### Query for all users with all relationships\ + \ for a particular document\nTo query for all users that have any relationship\ + \ with `document:2021-budget`, call read API with body of \n```json\n{\n \ + \ \"tuple_key\": {\n \"object\": \"document:2021-budget\"\n }\n}\n\ + ```\nThe API will return something like \n```json\n{\n \"tuples\": [\n \ + \ {\n \"key\": {\n \"user\": \"user:anne\",\n \"relation\"\ + : \"writer\",\n \"object\": \"document:2021-budget\"\n },\n \ + \ \"timestamp\": \"2021-10-05T13:42:12.356Z\"\n },\n {\n \"\ + key\": {\n \"user\": \"user:bob\",\n \"relation\": \"reader\"\ + ,\n \"object\": \"document:2021-budget\"\n },\n \"timestamp\"\ + : \"2021-10-06T15:32:11.128Z\"\n }\n ],\n \"continuation_token\": \"\ + eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\"\ + \n}\n```\nThis means that `document:2021-budget` has 1 `reader` (`user:bob`)\ + \ and 1 `writer` (`user:anne`).\n" + operationId: Read + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Read_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ReadResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: "Get tuples from the store that matches a query, without following\ + \ userset rewrite rules" + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json + /stores/{store_id}/write: + post: + description: "The Write API will update the tuples for a certain store. Tuples\ + \ and type definitions allow OpenFGA to determine whether a relationship exists\ + \ between an object and an user.\nIn the body, `writes` adds new tuples while\ + \ `deletes` removes existing tuples. The API is not idempotent: if, later\ + \ on, you try to add the same tuple, or if you try to delete a non-existing\ + \ tuple, it will throw an error.\nAn `authorization_model_id` may be specified\ + \ in the body. If it is, it will be used to assert that each written tuple\ + \ (not deleted) is valid for the model specified. If it is not specified,\ + \ the latest authorization model ID will be used.\n## Example\n### Adding\ + \ relationships\nTo add `user:anne` as a `writer` for `document:2021-budget`,\ + \ call write API with the following \n```json\n{\n \"writes\": {\n \"\ + tuple_keys\": [\n {\n \"user\": \"user:anne\",\n \"relation\"\ + : \"writer\",\n \"object\": \"document:2021-budget\"\n }\n \ + \ ]\n },\n \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"\n\ + }\n```\n### Removing relationships\nTo remove `user:bob` as a `reader` for\ + \ `document:2021-budget`, call write API with the following \n```json\n{\n\ + \ \"deletes\": {\n \"tuple_keys\": [\n {\n \"user\": \"user:bob\"\ + ,\n \"relation\": \"reader\",\n \"object\": \"document:2021-budget\"\ + \n }\n ]\n }\n}\n```\n" + operationId: Write + parameters: + - in: path + name: store_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Write_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/WriteResponse' + description: A successful response. + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationErrorMessageResponse' + description: Request failed due to invalid input. + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/PathUnknownErrorMessageResponse' + description: Request failed due to incorrect path. + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/InternalErrorMessageResponse' + description: Request failed due to internal server error. + summary: Add or delete tuples from the store + tags: + - OpenFga + x-codegen-request-body-name: body + x-content-type: application/json + x-accepts: application/json +components: + schemas: + Any: + additionalProperties: + type: object + properties: + '@type': + type: string + type: object + Assertion: + example: + tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + expectation: true + properties: + tuple_key: + $ref: '#/components/schemas/TupleKey' + expectation: + type: boolean + required: + - expectation + - tuple_key + type: object + AuthorizationModel: + example: + schema_version: schema_version + type_definitions: + - type: user + - type: document + relations: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + metadata: + relations: + reader: + directly_related_user_types: + - type: user + writer: + directly_related_user_types: + - type: user + id: 01G5JAVJ41T49E9TT3SKVS7X1J + properties: + id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + schema_version: + type: string + type_definitions: + example: + - type: user + - type: document + relations: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + metadata: + relations: + reader: + directly_related_user_types: + - type: user + writer: + directly_related_user_types: + - type: user + items: + $ref: '#/components/schemas/TypeDefinition' + type: array + required: + - schema_version + type: object + CheckResponse: + example: + allowed: true + resolution: resolution + properties: + allowed: + example: true + type: boolean + resolution: + description: For internal use only. + type: string + type: object + Computed: + example: + userset: userset + properties: + userset: + type: string + type: object + ContextualTupleKeys: + properties: + tuple_keys: + items: + $ref: '#/components/schemas/TupleKey' + type: array + required: + - tuple_keys + type: object + CreateStoreRequest: + example: + name: my-store-name + properties: + name: + example: my-store-name + type: string + required: + - name + type: object + CreateStoreResponse: + example: + updated_at: 2000-01-23T04:56:07.000+00:00 + name: name + created_at: 2000-01-23T04:56:07.000+00:00 + id: 01YCP46JKYM8FJCQ37NMBYHE5X + properties: + id: + example: 01YCP46JKYM8FJCQ37NMBYHE5X + type: string + name: + type: string + created_at: + format: date-time + type: string + updated_at: + format: date-time + type: string + type: object + DeleteStoreResponse: + type: object + DirectUserset: + description: |- + A DirectUserset is a sentinel message for referencing + the direct members specified by an object/relation mapping. + type: object + ErrorCode: + default: no_error + enum: + - no_error + - validation_error + - authorization_model_not_found + - authorization_model_resolution_too_complex + - invalid_write_input + - cannot_allow_duplicate_tuples_in_one_request + - cannot_allow_duplicate_types_in_one_request + - cannot_allow_multiple_references_to_one_relation + - invalid_continuation_token + - invalid_tuple_set + - invalid_check_input + - invalid_expand_input + - unsupported_user_set + - invalid_object_format + - write_failed_due_to_invalid_input + - authorization_model_assertions_not_found + - latest_authorization_model_not_found + - type_not_found + - relation_not_found + - empty_relation_definition + - invalid_user + - invalid_tuple + - unknown_relation + - store_id_invalid_length + - assertions_too_many_items + - id_too_long + - authorization_model_id_too_long + - tuple_key_value_not_specified + - tuple_keys_too_many_or_too_few_items + - page_size_invalid + - param_missing_value + - difference_base_missing_value + - subtract_base_missing_value + - object_too_long + - relation_too_long + - type_definitions_too_few_items + - type_invalid_length + - type_invalid_pattern + - relations_too_few_items + - relations_too_long + - relations_invalid_pattern + - object_invalid_pattern + - query_string_type_continuation_token_mismatch + - exceeded_entity_limit + - invalid_contextual_tuple + - duplicate_contextual_tuple + - invalid_authorization_model + - unsupported_schema_version + type: string + ExpandResponse: + example: + tree: + root: + intersection: + nodes: + - null + - null + name: name + difference: + subtract: null + base: null + union: + nodes: + - null + - null + leaf: + computed: + userset: userset + tupleToUserset: + computed: + - userset: userset + - userset: userset + tupleset: tupleset + users: + users: + - users + - users + properties: + tree: + $ref: '#/components/schemas/UsersetTree' + type: object + GetStoreResponse: + example: + updated_at: 2000-01-23T04:56:07.000+00:00 + name: name + created_at: 2000-01-23T04:56:07.000+00:00 + id: 01YCP46JKYM8FJCQ37NMBYHE5X + properties: + id: + example: 01YCP46JKYM8FJCQ37NMBYHE5X + type: string + name: + type: string + created_at: + format: date-time + type: string + updated_at: + format: date-time + type: string + type: object + InternalErrorCode: + default: no_internal_error + enum: + - no_internal_error + - internal_error + - cancelled + - deadline_exceeded + - already_exists + - resource_exhausted + - failed_precondition + - aborted + - out_of_range + - unavailable + - data_loss + type: string + InternalErrorMessageResponse: + example: + code: internal_error + message: Internal Server Error + properties: + code: + $ref: '#/components/schemas/InternalErrorCode' + message: + type: string + type: object + Leaf: + description: |- + A leaf node contains either + - a set of users (which may be individual users, or usersets + referencing other relations) + - a computed node, which is the result of a computed userset + value in the authorization model + - a tupleToUserset nodes, containing the result of expanding + a tupleToUserset value in a authorization model. + example: + computed: + userset: userset + tupleToUserset: + computed: + - userset: userset + - userset: userset + tupleset: tupleset + users: + users: + - users + - users + properties: + users: + $ref: '#/components/schemas/Users' + computed: + $ref: '#/components/schemas/Computed' + tupleToUserset: + $ref: '#/components/schemas/UsersetTree.TupleToUserset' + type: object + ListObjectsResponse: + example: + objects: + - document:roadmap + - document:planning + properties: + objects: + example: + - document:roadmap + - document:planning + items: + type: string + type: array + type: object + ListStoresResponse: + example: + continuation_token: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + stores: + - updated_at: 2000-01-23T04:56:07.000+00:00 + name: name + created_at: 2000-01-23T04:56:07.000+00:00 + id: id + deleted_at: 2000-01-23T04:56:07.000+00:00 + - updated_at: 2000-01-23T04:56:07.000+00:00 + name: name + created_at: 2000-01-23T04:56:07.000+00:00 + id: id + deleted_at: 2000-01-23T04:56:07.000+00:00 + properties: + stores: + items: + $ref: '#/components/schemas/Store' + type: array + continuation_token: + description: The continuation token will be empty if there are no more stores. + example: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + type: string + type: object + Metadata: + properties: + relations: + additionalProperties: + $ref: '#/components/schemas/RelationMetadata' + type: object + type: object + Node: + example: + intersection: + nodes: + - null + - null + name: name + difference: + subtract: null + base: null + union: + nodes: + - null + - null + leaf: + computed: + userset: userset + tupleToUserset: + computed: + - userset: userset + - userset: userset + tupleset: tupleset + users: + users: + - users + - users + properties: + name: + type: string + leaf: + $ref: '#/components/schemas/Leaf' + difference: + $ref: '#/components/schemas/UsersetTree.Difference' + union: + $ref: '#/components/schemas/Nodes' + intersection: + $ref: '#/components/schemas/Nodes' + type: object + Nodes: + example: + nodes: + - null + - null + properties: + nodes: + items: + $ref: '#/components/schemas/Node' + type: array + type: object + NotFoundErrorCode: + default: no_not_found_error + enum: + - no_not_found_error + - undefined_endpoint + - store_id_not_found + - unimplemented + type: string + ObjectRelation: + properties: + object: + type: string + relation: + type: string + type: object + PathUnknownErrorMessageResponse: + example: + code: undefined_endpoint + message: Endpoint not enabled + properties: + code: + $ref: '#/components/schemas/NotFoundErrorCode' + message: + type: string + type: object + ReadAssertionsResponse: + example: + assertions: + - tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + expectation: true + - tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + expectation: true + authorization_model_id: 01G5JAVJ41T49E9TT3SKVS7X1J + properties: + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + assertions: + items: + $ref: '#/components/schemas/Assertion' + type: array + type: object + ReadAuthorizationModelResponse: + example: + authorization_model: + schema_version: schema_version + type_definitions: + - type: user + - type: document + relations: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + metadata: + relations: + reader: + directly_related_user_types: + - type: user + writer: + directly_related_user_types: + - type: user + id: 01G5JAVJ41T49E9TT3SKVS7X1J + properties: + authorization_model: + $ref: '#/components/schemas/AuthorizationModel' + type: object + ReadAuthorizationModelsResponse: + example: + continuation_token: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + authorization_models: + - schema_version: schema_version + type_definitions: + - type: user + - type: document + relations: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + metadata: + relations: + reader: + directly_related_user_types: + - type: user + writer: + directly_related_user_types: + - type: user + id: 01G5JAVJ41T49E9TT3SKVS7X1J + - schema_version: schema_version + type_definitions: + - type: user + - type: document + relations: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + metadata: + relations: + reader: + directly_related_user_types: + - type: user + writer: + directly_related_user_types: + - type: user + id: 01G5JAVJ41T49E9TT3SKVS7X1J + properties: + authorization_models: + items: + $ref: '#/components/schemas/AuthorizationModel' + type: array + continuation_token: + description: The continuation token will be empty if there are no more models. + example: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + type: string + type: object + ReadChangesResponse: + example: + continuation_token: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + changes: + - tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + operation: null + timestamp: 2000-01-23T04:56:07.000+00:00 + - tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + operation: null + timestamp: 2000-01-23T04:56:07.000+00:00 + properties: + changes: + items: + $ref: '#/components/schemas/TupleChange' + type: array + continuation_token: + description: The continuation token will be identical if there are no new + changes. + example: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + type: string + type: object + ReadResponse: + example: + continuation_token: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + tuples: + - key: + user: user:anne + object: document:2021-budget + relation: reader + timestamp: 2000-01-23T04:56:07.000+00:00 + - key: + user: user:anne + object: document:2021-budget + relation: reader + timestamp: 2000-01-23T04:56:07.000+00:00 + properties: + tuples: + items: + $ref: '#/components/schemas/Tuple' + type: array + continuation_token: + description: The continuation token will be empty if there are no more tuples. + example: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + type: string + type: object + RelationMetadata: + properties: + directly_related_user_types: + items: + $ref: '#/components/schemas/RelationReference' + type: array + type: object + RelationReference: + description: RelationReference represents a relation of a particular object + type (e.g. 'document#viewer'). + properties: + type: + example: group + type: string + relation: + example: member + type: string + wildcard: + type: object + required: + - type + type: object + Status: + properties: + code: + format: int32 + type: integer + message: + type: string + details: + items: + $ref: '#/components/schemas/Any' + type: array + type: object + Store: + example: + updated_at: 2000-01-23T04:56:07.000+00:00 + name: name + created_at: 2000-01-23T04:56:07.000+00:00 + id: id + deleted_at: 2000-01-23T04:56:07.000+00:00 + properties: + id: + type: string + name: + type: string + created_at: + format: date-time + type: string + updated_at: + format: date-time + type: string + deleted_at: + format: date-time + type: string + type: object + Tuple: + example: + key: + user: user:anne + object: document:2021-budget + relation: reader + timestamp: 2000-01-23T04:56:07.000+00:00 + properties: + key: + $ref: '#/components/schemas/TupleKey' + timestamp: + format: date-time + type: string + type: object + TupleChange: + example: + tuple_key: + user: user:anne + object: document:2021-budget + relation: reader + operation: null + timestamp: 2000-01-23T04:56:07.000+00:00 + properties: + tuple_key: + $ref: '#/components/schemas/TupleKey' + operation: + $ref: '#/components/schemas/TupleOperation' + timestamp: + format: date-time + type: string + type: object + TupleKey: + example: + user: user:anne + object: document:2021-budget + relation: reader + properties: + object: + example: document:2021-budget + maxLength: 256 + type: string + relation: + example: reader + maxLength: 50 + type: string + user: + example: user:anne + maxLength: 512 + type: string + type: object + TupleKeys: + properties: + tuple_keys: + items: + $ref: '#/components/schemas/TupleKey' + type: array + required: + - tuple_keys + type: object + TupleOperation: + default: TUPLE_OPERATION_WRITE + enum: + - TUPLE_OPERATION_WRITE + - TUPLE_OPERATION_DELETE + title: buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX + type: string + TypeDefinition: + properties: + type: + example: document + type: string + relations: + additionalProperties: + $ref: '#/components/schemas/Userset' + example: + reader: + union: + child: + - this: {} + - computedUserset: + object: "" + relation: writer + writer: + this: {} + type: object + metadata: + $ref: '#/components/schemas/Metadata' + required: + - type + type: object + Users: + example: + users: + - users + - users + properties: + users: + items: + type: string + type: array + type: object + Userset: + properties: + this: + description: |- + A DirectUserset is a sentinel message for referencing + the direct members specified by an object/relation mapping. + type: object + computedUserset: + $ref: '#/components/schemas/ObjectRelation' + tupleToUserset: + $ref: '#/components/schemas/TupleToUserset' + union: + $ref: '#/components/schemas/Usersets' + intersection: + $ref: '#/components/schemas/Usersets' + difference: + $ref: '#/components/schemas/Difference' + type: object + UsersetTree: + description: A UsersetTree contains the result of an Expansion. + example: + root: + intersection: + nodes: + - null + - null + name: name + difference: + subtract: null + base: null + union: + nodes: + - null + - null + leaf: + computed: + userset: userset + tupleToUserset: + computed: + - userset: userset + - userset: userset + tupleset: tupleset + users: + users: + - users + - users + properties: + root: + $ref: '#/components/schemas/Node' + type: object + UsersetTree.Difference: + example: + subtract: null + base: null + properties: + base: + $ref: '#/components/schemas/Node' + subtract: + $ref: '#/components/schemas/Node' + type: object + UsersetTree.TupleToUserset: + example: + computed: + - userset: userset + - userset: userset + tupleset: tupleset + properties: + tupleset: + type: string + computed: + items: + $ref: '#/components/schemas/Computed' + type: array + type: object + Usersets: + properties: + child: + items: + $ref: '#/components/schemas/Userset' + type: array + type: object + ValidationErrorMessageResponse: + example: + code: validation_error + message: Generic validation error + properties: + code: + $ref: '#/components/schemas/ErrorCode' + message: + type: string + type: object + Wildcard: + type: object + WriteAssertionsResponse: + type: object + WriteAuthorizationModelResponse: + example: + authorization_model_id: 01G5JAVJ41T49E9TT3SKVS7X1J + properties: + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + type: object + WriteResponse: + type: object + Difference: + properties: + base: + $ref: '#/components/schemas/Userset' + subtract: + $ref: '#/components/schemas/Userset' + required: + - base + - subtract + type: object + TupleToUserset: + properties: + tupleset: + $ref: '#/components/schemas/ObjectRelation' + computedUserset: + $ref: '#/components/schemas/ObjectRelation' + type: object + WriteAssertions_request: + properties: + assertions: + items: + $ref: '#/components/schemas/Assertion' + type: array + required: + - assertions + type: object + WriteAuthorizationModel_request: + properties: + type_definitions: + items: + $ref: '#/components/schemas/TypeDefinition' + type: array + schema_version: + type: string + required: + - type_definitions + type: object + Check_request: + properties: + tuple_key: + $ref: '#/components/schemas/TupleKey' + contextual_tuples: + $ref: '#/components/schemas/ContextualTupleKeys' + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + trace: + description: Defaults to false. Making it true has performance implications. + example: false + readOnly: true + type: boolean + required: + - tuple_key + type: object + Expand_request: + properties: + tuple_key: + $ref: '#/components/schemas/TupleKey' + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + required: + - tuple_key + type: object + ListObjects_request: + properties: + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + type: + example: document + type: string + relation: + example: reader + type: string + user: + example: user:anne + maxLength: 512 + minLength: 1 + type: string + contextual_tuples: + $ref: '#/components/schemas/ContextualTupleKeys' + required: + - relation + - type + - user + type: object + Read_request: + properties: + tuple_key: + $ref: '#/components/schemas/TupleKey' + page_size: + example: 50 + format: int32 + type: integer + continuation_token: + example: eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ== + type: string + type: object + Write_request: + properties: + writes: + $ref: '#/components/schemas/TupleKeys' + deletes: + $ref: '#/components/schemas/TupleKeys' + authorization_model_id: + example: 01G5JAVJ41T49E9TT3SKVS7X1J + type: string + type: object +x-original-swagger-version: "2.0" + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9da6117 --- /dev/null +++ b/build.gradle @@ -0,0 +1,121 @@ +plugins { + id 'java' + id 'jvm-test-suite' + id 'maven-publish' + id 'idea' + id 'eclipse' + id 'com.diffplug.spotless' version '6.20.0' +} + +group = 'dev.openfga' +version = '0.1' + +repositories { + mavenCentral() +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'openfga-sdk' + from components.java + } + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + + withJavadocJar() + withSourcesJar() +} + +javadoc { + // Ignore warnings. + options.addStringOption('Xdoclint:none', '-quiet') +} + +ext { + jackson_version = "2.14.1" + jakarta_annotation_version = "1.3.5" + junit_version = "5.7.1" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + implementation "org.openapitools:jackson-databind-nullable:0.2.1" + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" +} + +testing { + suites { + test { + useJUnitJupiter() + + dependencies { + implementation project() + implementation "org.junit.jupiter:junit-jupiter:$junit_version" + implementation "org.mockito:mockito-core:3.+" + runtimeOnly "org.junit.platform:junit-platform-launcher" + + // This test-only dependency is convenient but not widely used. + // Review project activity before updating the version here. + // See also: https://github.com/PGSSoft/HttpClientMock/issues/3 + implementation "com.pgs-soft:HttpClientMock:1.0.0" + } + } + integration(JvmTestSuite) { + testType = TestSuiteType.INTEGRATION_TEST + useJUnitJupiter() + + dependencies { + implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + implementation project() + } + + sources { + java { + srcDirs = ['src/test-integration/java'] + } + } + } + } +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + palantirJavaFormat() + removeUnusedImports() + importOrder() + } +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +tasks.register('fmt') { + dependsOn 'spotlessApply' +} + +tasks.register('test-integration') { + dependsOn testing.suites.integration +} diff --git a/docs/Any.md b/docs/Any.md new file mode 100644 index 0000000..4d330a7 --- /dev/null +++ b/docs/Any.md @@ -0,0 +1,13 @@ + + +# Any + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**atType** | **String** | | [optional] | + + + diff --git a/docs/Assertion.md b/docs/Assertion.md new file mode 100644 index 0000000..3b41516 --- /dev/null +++ b/docs/Assertion.md @@ -0,0 +1,14 @@ + + +# Assertion + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKey** | [**TupleKey**](TupleKey.md) | | | +|**expectation** | **Boolean** | | | + + + diff --git a/docs/AuthorizationModel.md b/docs/AuthorizationModel.md new file mode 100644 index 0000000..88ffd2b --- /dev/null +++ b/docs/AuthorizationModel.md @@ -0,0 +1,15 @@ + + +# AuthorizationModel + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | | [optional] | +|**schemaVersion** | **String** | | | +|**typeDefinitions** | [**List<TypeDefinition>**](TypeDefinition.md) | | [optional] | + + + diff --git a/docs/CheckRequest.md b/docs/CheckRequest.md new file mode 100644 index 0000000..bdce51d --- /dev/null +++ b/docs/CheckRequest.md @@ -0,0 +1,16 @@ + + +# CheckRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKey** | [**TupleKey**](TupleKey.md) | | | +|**contextualTuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional] | +|**authorizationModelId** | **String** | | [optional] | +|**trace** | **Boolean** | Defaults to false. Making it true has performance implications. | [optional] [readonly] | + + + diff --git a/docs/CheckResponse.md b/docs/CheckResponse.md new file mode 100644 index 0000000..c9434da --- /dev/null +++ b/docs/CheckResponse.md @@ -0,0 +1,14 @@ + + +# CheckResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**allowed** | **Boolean** | | [optional] | +|**resolution** | **String** | For internal use only. | [optional] | + + + diff --git a/docs/Computed.md b/docs/Computed.md new file mode 100644 index 0000000..5d388e9 --- /dev/null +++ b/docs/Computed.md @@ -0,0 +1,13 @@ + + +# Computed + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**userset** | **String** | | [optional] | + + + diff --git a/docs/ContextualTupleKeys.md b/docs/ContextualTupleKeys.md new file mode 100644 index 0000000..0935cfa --- /dev/null +++ b/docs/ContextualTupleKeys.md @@ -0,0 +1,13 @@ + + +# ContextualTupleKeys + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKeys** | [**List<TupleKey>**](TupleKey.md) | | | + + + diff --git a/docs/CreateStoreRequest.md b/docs/CreateStoreRequest.md new file mode 100644 index 0000000..8ae7b55 --- /dev/null +++ b/docs/CreateStoreRequest.md @@ -0,0 +1,13 @@ + + +# CreateStoreRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | | + + + diff --git a/docs/CreateStoreResponse.md b/docs/CreateStoreResponse.md new file mode 100644 index 0000000..0a080bb --- /dev/null +++ b/docs/CreateStoreResponse.md @@ -0,0 +1,16 @@ + + +# CreateStoreResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | | [optional] | +|**name** | **String** | | [optional] | +|**createdAt** | **OffsetDateTime** | | [optional] | +|**updatedAt** | **OffsetDateTime** | | [optional] | + + + diff --git a/docs/Difference.md b/docs/Difference.md new file mode 100644 index 0000000..0b9203b --- /dev/null +++ b/docs/Difference.md @@ -0,0 +1,14 @@ + + +# Difference + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**base** | [**Userset**](Userset.md) | | | +|**subtract** | [**Userset**](Userset.md) | | | + + + diff --git a/docs/ErrorCode.md b/docs/ErrorCode.md new file mode 100644 index 0000000..995351b --- /dev/null +++ b/docs/ErrorCode.md @@ -0,0 +1,107 @@ + + +# ErrorCode + +## Enum + + +* `NO_ERROR` (value: `"no_error"`) + +* `VALIDATION_ERROR` (value: `"validation_error"`) + +* `AUTHORIZATION_MODEL_NOT_FOUND` (value: `"authorization_model_not_found"`) + +* `AUTHORIZATION_MODEL_RESOLUTION_TOO_COMPLEX` (value: `"authorization_model_resolution_too_complex"`) + +* `INVALID_WRITE_INPUT` (value: `"invalid_write_input"`) + +* `CANNOT_ALLOW_DUPLICATE_TUPLES_IN_ONE_REQUEST` (value: `"cannot_allow_duplicate_tuples_in_one_request"`) + +* `CANNOT_ALLOW_DUPLICATE_TYPES_IN_ONE_REQUEST` (value: `"cannot_allow_duplicate_types_in_one_request"`) + +* `CANNOT_ALLOW_MULTIPLE_REFERENCES_TO_ONE_RELATION` (value: `"cannot_allow_multiple_references_to_one_relation"`) + +* `INVALID_CONTINUATION_TOKEN` (value: `"invalid_continuation_token"`) + +* `INVALID_TUPLE_SET` (value: `"invalid_tuple_set"`) + +* `INVALID_CHECK_INPUT` (value: `"invalid_check_input"`) + +* `INVALID_EXPAND_INPUT` (value: `"invalid_expand_input"`) + +* `UNSUPPORTED_USER_SET` (value: `"unsupported_user_set"`) + +* `INVALID_OBJECT_FORMAT` (value: `"invalid_object_format"`) + +* `WRITE_FAILED_DUE_TO_INVALID_INPUT` (value: `"write_failed_due_to_invalid_input"`) + +* `AUTHORIZATION_MODEL_ASSERTIONS_NOT_FOUND` (value: `"authorization_model_assertions_not_found"`) + +* `LATEST_AUTHORIZATION_MODEL_NOT_FOUND` (value: `"latest_authorization_model_not_found"`) + +* `TYPE_NOT_FOUND` (value: `"type_not_found"`) + +* `RELATION_NOT_FOUND` (value: `"relation_not_found"`) + +* `EMPTY_RELATION_DEFINITION` (value: `"empty_relation_definition"`) + +* `INVALID_USER` (value: `"invalid_user"`) + +* `INVALID_TUPLE` (value: `"invalid_tuple"`) + +* `UNKNOWN_RELATION` (value: `"unknown_relation"`) + +* `STORE_ID_INVALID_LENGTH` (value: `"store_id_invalid_length"`) + +* `ASSERTIONS_TOO_MANY_ITEMS` (value: `"assertions_too_many_items"`) + +* `ID_TOO_LONG` (value: `"id_too_long"`) + +* `AUTHORIZATION_MODEL_ID_TOO_LONG` (value: `"authorization_model_id_too_long"`) + +* `TUPLE_KEY_VALUE_NOT_SPECIFIED` (value: `"tuple_key_value_not_specified"`) + +* `TUPLE_KEYS_TOO_MANY_OR_TOO_FEW_ITEMS` (value: `"tuple_keys_too_many_or_too_few_items"`) + +* `PAGE_SIZE_INVALID` (value: `"page_size_invalid"`) + +* `PARAM_MISSING_VALUE` (value: `"param_missing_value"`) + +* `DIFFERENCE_BASE_MISSING_VALUE` (value: `"difference_base_missing_value"`) + +* `SUBTRACT_BASE_MISSING_VALUE` (value: `"subtract_base_missing_value"`) + +* `OBJECT_TOO_LONG` (value: `"object_too_long"`) + +* `RELATION_TOO_LONG` (value: `"relation_too_long"`) + +* `TYPE_DEFINITIONS_TOO_FEW_ITEMS` (value: `"type_definitions_too_few_items"`) + +* `TYPE_INVALID_LENGTH` (value: `"type_invalid_length"`) + +* `TYPE_INVALID_PATTERN` (value: `"type_invalid_pattern"`) + +* `RELATIONS_TOO_FEW_ITEMS` (value: `"relations_too_few_items"`) + +* `RELATIONS_TOO_LONG` (value: `"relations_too_long"`) + +* `RELATIONS_INVALID_PATTERN` (value: `"relations_invalid_pattern"`) + +* `OBJECT_INVALID_PATTERN` (value: `"object_invalid_pattern"`) + +* `QUERY_STRING_TYPE_CONTINUATION_TOKEN_MISMATCH` (value: `"query_string_type_continuation_token_mismatch"`) + +* `EXCEEDED_ENTITY_LIMIT` (value: `"exceeded_entity_limit"`) + +* `INVALID_CONTEXTUAL_TUPLE` (value: `"invalid_contextual_tuple"`) + +* `DUPLICATE_CONTEXTUAL_TUPLE` (value: `"duplicate_contextual_tuple"`) + +* `INVALID_AUTHORIZATION_MODEL` (value: `"invalid_authorization_model"`) + +* `UNSUPPORTED_SCHEMA_VERSION` (value: `"unsupported_schema_version"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/ExpandRequest.md b/docs/ExpandRequest.md new file mode 100644 index 0000000..c5b6442 --- /dev/null +++ b/docs/ExpandRequest.md @@ -0,0 +1,14 @@ + + +# ExpandRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKey** | [**TupleKey**](TupleKey.md) | | | +|**authorizationModelId** | **String** | | [optional] | + + + diff --git a/docs/ExpandResponse.md b/docs/ExpandResponse.md new file mode 100644 index 0000000..c01fbb1 --- /dev/null +++ b/docs/ExpandResponse.md @@ -0,0 +1,13 @@ + + +# ExpandResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tree** | [**UsersetTree**](UsersetTree.md) | | [optional] | + + + diff --git a/docs/GetStoreResponse.md b/docs/GetStoreResponse.md new file mode 100644 index 0000000..d802015 --- /dev/null +++ b/docs/GetStoreResponse.md @@ -0,0 +1,16 @@ + + +# GetStoreResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | | [optional] | +|**name** | **String** | | [optional] | +|**createdAt** | **OffsetDateTime** | | [optional] | +|**updatedAt** | **OffsetDateTime** | | [optional] | + + + diff --git a/docs/InternalErrorCode.md b/docs/InternalErrorCode.md new file mode 100644 index 0000000..0b14c21 --- /dev/null +++ b/docs/InternalErrorCode.md @@ -0,0 +1,33 @@ + + +# InternalErrorCode + +## Enum + + +* `NO_INTERNAL_ERROR` (value: `"no_internal_error"`) + +* `INTERNAL_ERROR` (value: `"internal_error"`) + +* `CANCELLED` (value: `"cancelled"`) + +* `DEADLINE_EXCEEDED` (value: `"deadline_exceeded"`) + +* `ALREADY_EXISTS` (value: `"already_exists"`) + +* `RESOURCE_EXHAUSTED` (value: `"resource_exhausted"`) + +* `FAILED_PRECONDITION` (value: `"failed_precondition"`) + +* `ABORTED` (value: `"aborted"`) + +* `OUT_OF_RANGE` (value: `"out_of_range"`) + +* `UNAVAILABLE` (value: `"unavailable"`) + +* `DATA_LOSS` (value: `"data_loss"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/InternalErrorMessageResponse.md b/docs/InternalErrorMessageResponse.md new file mode 100644 index 0000000..258ac23 --- /dev/null +++ b/docs/InternalErrorMessageResponse.md @@ -0,0 +1,14 @@ + + +# InternalErrorMessageResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **InternalErrorCode** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/docs/Leaf.md b/docs/Leaf.md new file mode 100644 index 0000000..46664c5 --- /dev/null +++ b/docs/Leaf.md @@ -0,0 +1,16 @@ + + +# Leaf + +A leaf node contains either - a set of users (which may be individual users, or usersets referencing other relations) - a computed node, which is the result of a computed userset value in the authorization model - a tupleToUserset nodes, containing the result of expanding a tupleToUserset value in a authorization model. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**users** | [**Users**](Users.md) | | [optional] | +|**computed** | [**Computed**](Computed.md) | | [optional] | +|**tupleToUserset** | [**UsersetTreeTupleToUserset**](UsersetTreeTupleToUserset.md) | | [optional] | + + + diff --git a/docs/ListObjectsRequest.md b/docs/ListObjectsRequest.md new file mode 100644 index 0000000..2919fe3 --- /dev/null +++ b/docs/ListObjectsRequest.md @@ -0,0 +1,17 @@ + + +# ListObjectsRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**authorizationModelId** | **String** | | [optional] | +|**type** | **String** | | | +|**relation** | **String** | | | +|**user** | **String** | | | +|**contextualTuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional] | + + + diff --git a/docs/ListObjectsResponse.md b/docs/ListObjectsResponse.md new file mode 100644 index 0000000..68a8566 --- /dev/null +++ b/docs/ListObjectsResponse.md @@ -0,0 +1,13 @@ + + +# ListObjectsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**objects** | **List<String>** | | [optional] | + + + diff --git a/docs/ListStoresResponse.md b/docs/ListStoresResponse.md new file mode 100644 index 0000000..3088fb4 --- /dev/null +++ b/docs/ListStoresResponse.md @@ -0,0 +1,14 @@ + + +# ListStoresResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**stores** | [**List<Store>**](Store.md) | | [optional] | +|**continuationToken** | **String** | The continuation token will be empty if there are no more stores. | [optional] | + + + diff --git a/docs/Metadata.md b/docs/Metadata.md new file mode 100644 index 0000000..f3c8d45 --- /dev/null +++ b/docs/Metadata.md @@ -0,0 +1,13 @@ + + +# Metadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**relations** | [**Map<String, RelationMetadata>**](RelationMetadata.md) | | [optional] | + + + diff --git a/docs/Node.md b/docs/Node.md new file mode 100644 index 0000000..6f89e9e --- /dev/null +++ b/docs/Node.md @@ -0,0 +1,17 @@ + + +# Node + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [optional] | +|**leaf** | [**Leaf**](Leaf.md) | | [optional] | +|**difference** | [**UsersetTreeDifference**](UsersetTreeDifference.md) | | [optional] | +|**union** | [**Nodes**](Nodes.md) | | [optional] | +|**intersection** | [**Nodes**](Nodes.md) | | [optional] | + + + diff --git a/docs/Nodes.md b/docs/Nodes.md new file mode 100644 index 0000000..d637207 --- /dev/null +++ b/docs/Nodes.md @@ -0,0 +1,13 @@ + + +# Nodes + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**nodes** | [**List<Node>**](Node.md) | | [optional] | + + + diff --git a/docs/NotFoundErrorCode.md b/docs/NotFoundErrorCode.md new file mode 100644 index 0000000..5ff45b1 --- /dev/null +++ b/docs/NotFoundErrorCode.md @@ -0,0 +1,19 @@ + + +# NotFoundErrorCode + +## Enum + + +* `NO_NOT_FOUND_ERROR` (value: `"no_not_found_error"`) + +* `UNDEFINED_ENDPOINT` (value: `"undefined_endpoint"`) + +* `STORE_ID_NOT_FOUND` (value: `"store_id_not_found"`) + +* `UNIMPLEMENTED` (value: `"unimplemented"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/ObjectRelation.md b/docs/ObjectRelation.md new file mode 100644 index 0000000..d73bd14 --- /dev/null +++ b/docs/ObjectRelation.md @@ -0,0 +1,14 @@ + + +# ObjectRelation + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**_object** | **String** | | [optional] | +|**relation** | **String** | | [optional] | + + + diff --git a/docs/OpenFgaApi.md b/docs/OpenFgaApi.md new file mode 100644 index 0000000..9b9fc08 --- /dev/null +++ b/docs/OpenFgaApi.md @@ -0,0 +1,2333 @@ +# OpenFgaApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**check**](OpenFgaApi.md#check) | **POST** /stores/{store_id}/check | Check whether a user is authorized to access an object | +| [**checkWithHttpInfo**](OpenFgaApi.md#checkWithHttpInfo) | **POST** /stores/{store_id}/check | Check whether a user is authorized to access an object | +| [**createStore**](OpenFgaApi.md#createStore) | **POST** /stores | Create a store | +| [**createStoreWithHttpInfo**](OpenFgaApi.md#createStoreWithHttpInfo) | **POST** /stores | Create a store | +| [**deleteStore**](OpenFgaApi.md#deleteStore) | **DELETE** /stores/{store_id} | Delete a store | +| [**deleteStoreWithHttpInfo**](OpenFgaApi.md#deleteStoreWithHttpInfo) | **DELETE** /stores/{store_id} | Delete a store | +| [**expand**](OpenFgaApi.md#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship | +| [**expandWithHttpInfo**](OpenFgaApi.md#expandWithHttpInfo) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship | +| [**getStore**](OpenFgaApi.md#getStore) | **GET** /stores/{store_id} | Get a store | +| [**getStoreWithHttpInfo**](OpenFgaApi.md#getStoreWithHttpInfo) | **GET** /stores/{store_id} | Get a store | +| [**listObjects**](OpenFgaApi.md#listObjects) | **POST** /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with | +| [**listObjectsWithHttpInfo**](OpenFgaApi.md#listObjectsWithHttpInfo) | **POST** /stores/{store_id}/list-objects | List all objects of the given type that the user has a relation with | +| [**listStores**](OpenFgaApi.md#listStores) | **GET** /stores | List all stores | +| [**listStoresWithHttpInfo**](OpenFgaApi.md#listStoresWithHttpInfo) | **GET** /stores | List all stores | +| [**read**](OpenFgaApi.md#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules | +| [**readWithHttpInfo**](OpenFgaApi.md#readWithHttpInfo) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules | +| [**readAssertions**](OpenFgaApi.md#readAssertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID | +| [**readAssertionsWithHttpInfo**](OpenFgaApi.md#readAssertionsWithHttpInfo) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID | +| [**readAuthorizationModel**](OpenFgaApi.md#readAuthorizationModel) | **GET** /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model | +| [**readAuthorizationModelWithHttpInfo**](OpenFgaApi.md#readAuthorizationModelWithHttpInfo) | **GET** /stores/{store_id}/authorization-models/{id} | Return a particular version of an authorization model | +| [**readAuthorizationModels**](OpenFgaApi.md#readAuthorizationModels) | **GET** /stores/{store_id}/authorization-models | Return all the authorization models for a particular store | +| [**readAuthorizationModelsWithHttpInfo**](OpenFgaApi.md#readAuthorizationModelsWithHttpInfo) | **GET** /stores/{store_id}/authorization-models | Return all the authorization models for a particular store | +| [**readChanges**](OpenFgaApi.md#readChanges) | **GET** /stores/{store_id}/changes | Return a list of all the tuple changes | +| [**readChangesWithHttpInfo**](OpenFgaApi.md#readChangesWithHttpInfo) | **GET** /stores/{store_id}/changes | Return a list of all the tuple changes | +| [**write**](OpenFgaApi.md#write) | **POST** /stores/{store_id}/write | Add or delete tuples from the store | +| [**writeWithHttpInfo**](OpenFgaApi.md#writeWithHttpInfo) | **POST** /stores/{store_id}/write | Add or delete tuples from the store | +| [**writeAssertions**](OpenFgaApi.md#writeAssertions) | **PUT** /stores/{store_id}/assertions/{authorization_model_id} | Upsert assertions for an authorization model ID | +| [**writeAssertionsWithHttpInfo**](OpenFgaApi.md#writeAssertionsWithHttpInfo) | **PUT** /stores/{store_id}/assertions/{authorization_model_id} | Upsert assertions for an authorization model ID | +| [**writeAuthorizationModel**](OpenFgaApi.md#writeAuthorizationModel) | **POST** /stores/{store_id}/authorization-models | Create a new authorization model | +| [**writeAuthorizationModelWithHttpInfo**](OpenFgaApi.md#writeAuthorizationModelWithHttpInfo) | **POST** /stores/{store_id}/authorization-models | Create a new authorization model | + + + +## check + +> CompletableFuture check(storeId, body) + +Check whether a user is authorized to access an object + +The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + CheckRequest body = new CheckRequest(); // CheckRequest | + try { + CompletableFuture result = apiInstance.check(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#check"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**CheckRequest**](CheckRequest.md)| | | + +### Return type + +CompletableFuture<[**CheckResponse**](CheckResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## checkWithHttpInfo + +> CompletableFuture> check checkWithHttpInfo(storeId, body) + +Check whether a user is authorized to access an object + +The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + CheckRequest body = new CheckRequest(); // CheckRequest | + try { + CompletableFuture> response = apiInstance.checkWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#check"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#check"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**CheckRequest**](CheckRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## createStore + +> CompletableFuture createStore(body) + +Create a store + +Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + CreateStoreRequest body = new CreateStoreRequest(); // CreateStoreRequest | + try { + CompletableFuture result = apiInstance.createStore(body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#createStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **body** | [**CreateStoreRequest**](CreateStoreRequest.md)| | | + +### Return type + +CompletableFuture<[**CreateStoreResponse**](CreateStoreResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## createStoreWithHttpInfo + +> CompletableFuture> createStore createStoreWithHttpInfo(body) + +Create a store + +Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + CreateStoreRequest body = new CreateStoreRequest(); // CreateStoreRequest | + try { + CompletableFuture> response = apiInstance.createStoreWithHttpInfo(body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#createStore"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#createStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **body** | [**CreateStoreRequest**](CreateStoreRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## deleteStore + +> CompletableFuture deleteStore(storeId) + +Delete a store + +Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + try { + CompletableFuture result = apiInstance.deleteStore(storeId); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#deleteStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | + +### Return type + + +CompletableFuture (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## deleteStoreWithHttpInfo + +> CompletableFuture> deleteStore deleteStoreWithHttpInfo(storeId) + +Delete a store + +Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + try { + CompletableFuture> response = apiInstance.deleteStoreWithHttpInfo(storeId); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#deleteStore"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#deleteStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | + +### Return type + + +CompletableFuture> + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## expand + +> CompletableFuture expand(storeId, body) + +Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship + +The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ExpandRequest body = new ExpandRequest(); // ExpandRequest | + try { + CompletableFuture result = apiInstance.expand(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#expand"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ExpandRequest**](ExpandRequest.md)| | | + +### Return type + +CompletableFuture<[**ExpandResponse**](ExpandResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## expandWithHttpInfo + +> CompletableFuture> expand expandWithHttpInfo(storeId, body) + +Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship + +The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ExpandRequest body = new ExpandRequest(); // ExpandRequest | + try { + CompletableFuture> response = apiInstance.expandWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#expand"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#expand"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ExpandRequest**](ExpandRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## getStore + +> CompletableFuture getStore(storeId) + +Get a store + +Returns an OpenFGA store by its identifier + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + try { + CompletableFuture result = apiInstance.getStore(storeId); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#getStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | + +### Return type + +CompletableFuture<[**GetStoreResponse**](GetStoreResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## getStoreWithHttpInfo + +> CompletableFuture> getStore getStoreWithHttpInfo(storeId) + +Get a store + +Returns an OpenFGA store by its identifier + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + try { + CompletableFuture> response = apiInstance.getStoreWithHttpInfo(storeId); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#getStore"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#getStore"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## listObjects + +> CompletableFuture listObjects(storeId, body) + +List all objects of the given type that the user has a relation with + +The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | + try { + CompletableFuture result = apiInstance.listObjects(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#listObjects"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ListObjectsRequest**](ListObjectsRequest.md)| | | + +### Return type + +CompletableFuture<[**ListObjectsResponse**](ListObjectsResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## listObjectsWithHttpInfo + +> CompletableFuture> listObjects listObjectsWithHttpInfo(storeId, body) + +List all objects of the given type that the user has a relation with + +The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ListObjectsRequest body = new ListObjectsRequest(); // ListObjectsRequest | + try { + CompletableFuture> response = apiInstance.listObjectsWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#listObjects"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#listObjects"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ListObjectsRequest**](ListObjectsRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## listStores + +> CompletableFuture listStores(pageSize, continuationToken) + +List all stores + +Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture result = apiInstance.listStores(pageSize, continuationToken); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#listStores"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture<[**ListStoresResponse**](ListStoresResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## listStoresWithHttpInfo + +> CompletableFuture> listStores listStoresWithHttpInfo(pageSize, continuationToken) + +List all stores + +Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture> response = apiInstance.listStoresWithHttpInfo(pageSize, continuationToken); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#listStores"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#listStores"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## read + +> CompletableFuture read(storeId, body) + +Get tuples from the store that matches a query, without following userset rewrite rules + +The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`). + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ReadRequest body = new ReadRequest(); // ReadRequest | + try { + CompletableFuture result = apiInstance.read(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#read"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ReadRequest**](ReadRequest.md)| | | + +### Return type + +CompletableFuture<[**ReadResponse**](ReadResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## readWithHttpInfo + +> CompletableFuture> read readWithHttpInfo(storeId, body) + +Get tuples from the store that matches a query, without following userset rewrite rules + +The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`). + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + ReadRequest body = new ReadRequest(); // ReadRequest | + try { + CompletableFuture> response = apiInstance.readWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#read"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#read"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**ReadRequest**](ReadRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## readAssertions + +> CompletableFuture readAssertions(storeId, authorizationModelId) + +Read assertions for an authorization model ID + +The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String authorizationModelId = "authorizationModelId_example"; // String | + try { + CompletableFuture result = apiInstance.readAssertions(storeId, authorizationModelId); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAssertions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **authorizationModelId** | **String**| | | + +### Return type + +CompletableFuture<[**ReadAssertionsResponse**](ReadAssertionsResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## readAssertionsWithHttpInfo + +> CompletableFuture> readAssertions readAssertionsWithHttpInfo(storeId, authorizationModelId) + +Read assertions for an authorization model ID + +The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String authorizationModelId = "authorizationModelId_example"; // String | + try { + CompletableFuture> response = apiInstance.readAssertionsWithHttpInfo(storeId, authorizationModelId); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#readAssertions"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAssertions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **authorizationModelId** | **String**| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## readAuthorizationModel + +> CompletableFuture readAuthorizationModel(storeId, id) + +Return a particular version of an authorization model + +The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`). + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String id = "id_example"; // String | + try { + CompletableFuture result = apiInstance.readAuthorizationModel(storeId, id); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **id** | **String**| | | + +### Return type + +CompletableFuture<[**ReadAuthorizationModelResponse**](ReadAuthorizationModelResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## readAuthorizationModelWithHttpInfo + +> CompletableFuture> readAuthorizationModel readAuthorizationModelWithHttpInfo(storeId, id) + +Return a particular version of an authorization model + +The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`). + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String id = "id_example"; // String | + try { + CompletableFuture> response = apiInstance.readAuthorizationModelWithHttpInfo(storeId, id); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **id** | **String**| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## readAuthorizationModels + +> CompletableFuture readAuthorizationModels(storeId, pageSize, continuationToken) + +Return all the authorization models for a particular store + +The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture result = apiInstance.readAuthorizationModels(storeId, pageSize, continuationToken); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture<[**ReadAuthorizationModelsResponse**](ReadAuthorizationModelsResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## readAuthorizationModelsWithHttpInfo + +> CompletableFuture> readAuthorizationModels readAuthorizationModelsWithHttpInfo(storeId, pageSize, continuationToken) + +Return all the authorization models for a particular store + +The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture> response = apiInstance.readAuthorizationModelsWithHttpInfo(storeId, pageSize, continuationToken); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readAuthorizationModels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## readChanges + +> CompletableFuture readChanges(storeId, type, pageSize, continuationToken) + +Return a list of all the tuple changes + +The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String type = "type_example"; // String | + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture result = apiInstance.readChanges(storeId, type, pageSize, continuationToken); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readChanges"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **type** | **String**| | [optional] | +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture<[**ReadChangesResponse**](ReadChangesResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## readChangesWithHttpInfo + +> CompletableFuture> readChanges readChangesWithHttpInfo(storeId, type, pageSize, continuationToken) + +Return a list of all the tuple changes + +The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String type = "type_example"; // String | + Integer pageSize = 56; // Integer | + String continuationToken = "continuationToken_example"; // String | + try { + CompletableFuture> response = apiInstance.readChangesWithHttpInfo(storeId, type, pageSize, continuationToken); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#readChanges"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#readChanges"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **type** | **String**| | [optional] | +| **pageSize** | **Integer**| | [optional] | +| **continuationToken** | **String**| | [optional] | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## write + +> CompletableFuture write(storeId, body) + +Add or delete tuples from the store + +The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + WriteRequest body = new WriteRequest(); // WriteRequest | + try { + CompletableFuture result = apiInstance.write(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#write"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**WriteRequest**](WriteRequest.md)| | | + +### Return type + +CompletableFuture<**Object**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## writeWithHttpInfo + +> CompletableFuture> write writeWithHttpInfo(storeId, body) + +Add or delete tuples from the store + +The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + WriteRequest body = new WriteRequest(); // WriteRequest | + try { + CompletableFuture> response = apiInstance.writeWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#write"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#write"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**WriteRequest**](WriteRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## writeAssertions + +> CompletableFuture writeAssertions(storeId, authorizationModelId, body) + +Upsert assertions for an authorization model ID + +The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String authorizationModelId = "authorizationModelId_example"; // String | + WriteAssertionsRequest body = new WriteAssertionsRequest(); // WriteAssertionsRequest | + try { + CompletableFuture result = apiInstance.writeAssertions(storeId, authorizationModelId, body); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#writeAssertions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **authorizationModelId** | **String**| | | +| **body** | [**WriteAssertionsRequest**](WriteAssertionsRequest.md)| | | + +### Return type + + +CompletableFuture (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## writeAssertionsWithHttpInfo + +> CompletableFuture> writeAssertions writeAssertionsWithHttpInfo(storeId, authorizationModelId, body) + +Upsert assertions for an authorization model ID + +The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + String authorizationModelId = "authorizationModelId_example"; // String | + WriteAssertionsRequest body = new WriteAssertionsRequest(); // WriteAssertionsRequest | + try { + CompletableFuture> response = apiInstance.writeAssertionsWithHttpInfo(storeId, authorizationModelId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#writeAssertions"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#writeAssertions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **authorizationModelId** | **String**| | | +| **body** | [**WriteAssertionsRequest**](WriteAssertionsRequest.md)| | | + +### Return type + + +CompletableFuture> + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + + +## writeAuthorizationModel + +> CompletableFuture writeAuthorizationModel(storeId, body) + +Create a new authorization model + +The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + WriteAuthorizationModelRequest body = new WriteAuthorizationModelRequest(); // WriteAuthorizationModelRequest | + try { + CompletableFuture result = apiInstance.writeAuthorizationModel(storeId, body); + System.out.println(result.get()); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**WriteAuthorizationModelRequest**](WriteAuthorizationModelRequest.md)| | | + +### Return type + +CompletableFuture<[**WriteAuthorizationModelResponse**](WriteAuthorizationModelResponse.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + +## writeAuthorizationModelWithHttpInfo + +> CompletableFuture> writeAuthorizationModel writeAuthorizationModelWithHttpInfo(storeId, body) + +Create a new authorization model + +The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ``` + +### Example + +```java +// Import classes: +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.models.*; +import dev.openfga.sdk.api.OpenFgaApi; +import java.util.concurrent.CompletableFuture; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + OpenFgaApi apiInstance = new OpenFgaApi(defaultClient); + String storeId = "storeId_example"; // String | + WriteAuthorizationModelRequest body = new WriteAuthorizationModelRequest(); // WriteAuthorizationModelRequest | + try { + CompletableFuture> response = apiInstance.writeAuthorizationModelWithHttpInfo(storeId, body); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling OpenFgaApi#writeAuthorizationModel"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **storeId** | **String**| | | +| **body** | [**WriteAuthorizationModelRequest**](WriteAuthorizationModelRequest.md)| | | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | A successful response. | - | +| **400** | Request failed due to invalid input. | - | +| **404** | Request failed due to incorrect path. | - | +| **500** | Request failed due to internal server error. | - | + diff --git a/docs/PathUnknownErrorMessageResponse.md b/docs/PathUnknownErrorMessageResponse.md new file mode 100644 index 0000000..4958e74 --- /dev/null +++ b/docs/PathUnknownErrorMessageResponse.md @@ -0,0 +1,14 @@ + + +# PathUnknownErrorMessageResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **NotFoundErrorCode** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/docs/ReadAssertionsResponse.md b/docs/ReadAssertionsResponse.md new file mode 100644 index 0000000..48c60ad --- /dev/null +++ b/docs/ReadAssertionsResponse.md @@ -0,0 +1,14 @@ + + +# ReadAssertionsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**authorizationModelId** | **String** | | [optional] | +|**assertions** | [**List<Assertion>**](Assertion.md) | | [optional] | + + + diff --git a/docs/ReadAuthorizationModelResponse.md b/docs/ReadAuthorizationModelResponse.md new file mode 100644 index 0000000..b2d7dd7 --- /dev/null +++ b/docs/ReadAuthorizationModelResponse.md @@ -0,0 +1,13 @@ + + +# ReadAuthorizationModelResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**authorizationModel** | [**AuthorizationModel**](AuthorizationModel.md) | | [optional] | + + + diff --git a/docs/ReadAuthorizationModelsResponse.md b/docs/ReadAuthorizationModelsResponse.md new file mode 100644 index 0000000..616b47c --- /dev/null +++ b/docs/ReadAuthorizationModelsResponse.md @@ -0,0 +1,14 @@ + + +# ReadAuthorizationModelsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**authorizationModels** | [**List<AuthorizationModel>**](AuthorizationModel.md) | | [optional] | +|**continuationToken** | **String** | The continuation token will be empty if there are no more models. | [optional] | + + + diff --git a/docs/ReadChangesResponse.md b/docs/ReadChangesResponse.md new file mode 100644 index 0000000..fca87b4 --- /dev/null +++ b/docs/ReadChangesResponse.md @@ -0,0 +1,14 @@ + + +# ReadChangesResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**changes** | [**List<TupleChange>**](TupleChange.md) | | [optional] | +|**continuationToken** | **String** | The continuation token will be identical if there are no new changes. | [optional] | + + + diff --git a/docs/ReadRequest.md b/docs/ReadRequest.md new file mode 100644 index 0000000..f8f7047 --- /dev/null +++ b/docs/ReadRequest.md @@ -0,0 +1,15 @@ + + +# ReadRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKey** | [**TupleKey**](TupleKey.md) | | [optional] | +|**pageSize** | **Integer** | | [optional] | +|**continuationToken** | **String** | | [optional] | + + + diff --git a/docs/ReadResponse.md b/docs/ReadResponse.md new file mode 100644 index 0000000..55c981b --- /dev/null +++ b/docs/ReadResponse.md @@ -0,0 +1,14 @@ + + +# ReadResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tuples** | [**List<Tuple>**](Tuple.md) | | [optional] | +|**continuationToken** | **String** | The continuation token will be empty if there are no more tuples. | [optional] | + + + diff --git a/docs/RelationMetadata.md b/docs/RelationMetadata.md new file mode 100644 index 0000000..428f9b0 --- /dev/null +++ b/docs/RelationMetadata.md @@ -0,0 +1,13 @@ + + +# RelationMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**directlyRelatedUserTypes** | [**List<RelationReference>**](RelationReference.md) | | [optional] | + + + diff --git a/docs/RelationReference.md b/docs/RelationReference.md new file mode 100644 index 0000000..ed98991 --- /dev/null +++ b/docs/RelationReference.md @@ -0,0 +1,16 @@ + + +# RelationReference + +RelationReference represents a relation of a particular object type (e.g. 'document#viewer'). + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **String** | | | +|**relation** | **String** | | [optional] | +|**wildcard** | **Object** | | [optional] | + + + diff --git a/docs/Status.md b/docs/Status.md new file mode 100644 index 0000000..f2905b6 --- /dev/null +++ b/docs/Status.md @@ -0,0 +1,15 @@ + + +# Status + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**message** | **String** | | [optional] | +|**details** | **List<Any>** | | [optional] | + + + diff --git a/docs/Store.md b/docs/Store.md new file mode 100644 index 0000000..b2b74ca --- /dev/null +++ b/docs/Store.md @@ -0,0 +1,17 @@ + + +# Store + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | | [optional] | +|**name** | **String** | | [optional] | +|**createdAt** | **OffsetDateTime** | | [optional] | +|**updatedAt** | **OffsetDateTime** | | [optional] | +|**deletedAt** | **OffsetDateTime** | | [optional] | + + + diff --git a/docs/Tuple.md b/docs/Tuple.md new file mode 100644 index 0000000..04d434b --- /dev/null +++ b/docs/Tuple.md @@ -0,0 +1,14 @@ + + +# Tuple + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**key** | [**TupleKey**](TupleKey.md) | | [optional] | +|**timestamp** | **OffsetDateTime** | | [optional] | + + + diff --git a/docs/TupleChange.md b/docs/TupleChange.md new file mode 100644 index 0000000..f6751f6 --- /dev/null +++ b/docs/TupleChange.md @@ -0,0 +1,15 @@ + + +# TupleChange + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKey** | [**TupleKey**](TupleKey.md) | | [optional] | +|**operation** | **TupleOperation** | | [optional] | +|**timestamp** | **OffsetDateTime** | | [optional] | + + + diff --git a/docs/TupleKey.md b/docs/TupleKey.md new file mode 100644 index 0000000..fc35d4b --- /dev/null +++ b/docs/TupleKey.md @@ -0,0 +1,15 @@ + + +# TupleKey + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**_object** | **String** | | [optional] | +|**relation** | **String** | | [optional] | +|**user** | **String** | | [optional] | + + + diff --git a/docs/TupleKeys.md b/docs/TupleKeys.md new file mode 100644 index 0000000..72dbe13 --- /dev/null +++ b/docs/TupleKeys.md @@ -0,0 +1,13 @@ + + +# TupleKeys + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleKeys** | [**List<TupleKey>**](TupleKey.md) | | | + + + diff --git a/docs/TupleOperation.md b/docs/TupleOperation.md new file mode 100644 index 0000000..fa6a9f6 --- /dev/null +++ b/docs/TupleOperation.md @@ -0,0 +1,15 @@ + + +# TupleOperation + +## Enum + + +* `WRITE` (value: `"TUPLE_OPERATION_WRITE"`) + +* `DELETE` (value: `"TUPLE_OPERATION_DELETE"`) + +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + + + diff --git a/docs/TupleToUserset.md b/docs/TupleToUserset.md new file mode 100644 index 0000000..40802b3 --- /dev/null +++ b/docs/TupleToUserset.md @@ -0,0 +1,14 @@ + + +# TupleToUserset + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleset** | [**ObjectRelation**](ObjectRelation.md) | | [optional] | +|**computedUserset** | [**ObjectRelation**](ObjectRelation.md) | | [optional] | + + + diff --git a/docs/TypeDefinition.md b/docs/TypeDefinition.md new file mode 100644 index 0000000..f384cc4 --- /dev/null +++ b/docs/TypeDefinition.md @@ -0,0 +1,15 @@ + + +# TypeDefinition + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **String** | | | +|**relations** | [**Map<String, Userset>**](Userset.md) | | [optional] | +|**metadata** | [**Metadata**](Metadata.md) | | [optional] | + + + diff --git a/docs/Users.md b/docs/Users.md new file mode 100644 index 0000000..5fa6b79 --- /dev/null +++ b/docs/Users.md @@ -0,0 +1,13 @@ + + +# Users + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**users** | **List<String>** | | [optional] | + + + diff --git a/docs/Userset.md b/docs/Userset.md new file mode 100644 index 0000000..a5a04c3 --- /dev/null +++ b/docs/Userset.md @@ -0,0 +1,18 @@ + + +# Userset + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**_this** | **Object** | A DirectUserset is a sentinel message for referencing the direct members specified by an object/relation mapping. | [optional] | +|**computedUserset** | [**ObjectRelation**](ObjectRelation.md) | | [optional] | +|**tupleToUserset** | [**TupleToUserset**](TupleToUserset.md) | | [optional] | +|**union** | [**Usersets**](Usersets.md) | | [optional] | +|**intersection** | [**Usersets**](Usersets.md) | | [optional] | +|**difference** | [**Difference**](Difference.md) | | [optional] | + + + diff --git a/docs/UsersetTree.md b/docs/UsersetTree.md new file mode 100644 index 0000000..f97d8d3 --- /dev/null +++ b/docs/UsersetTree.md @@ -0,0 +1,14 @@ + + +# UsersetTree + +A UsersetTree contains the result of an Expansion. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**root** | [**Node**](Node.md) | | [optional] | + + + diff --git a/docs/UsersetTreeDifference.md b/docs/UsersetTreeDifference.md new file mode 100644 index 0000000..4370408 --- /dev/null +++ b/docs/UsersetTreeDifference.md @@ -0,0 +1,14 @@ + + +# UsersetTreeDifference + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**base** | [**Node**](Node.md) | | [optional] | +|**subtract** | [**Node**](Node.md) | | [optional] | + + + diff --git a/docs/UsersetTreeTupleToUserset.md b/docs/UsersetTreeTupleToUserset.md new file mode 100644 index 0000000..3cf3f37 --- /dev/null +++ b/docs/UsersetTreeTupleToUserset.md @@ -0,0 +1,14 @@ + + +# UsersetTreeTupleToUserset + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**tupleset** | **String** | | [optional] | +|**computed** | [**List<Computed>**](Computed.md) | | [optional] | + + + diff --git a/docs/Usersets.md b/docs/Usersets.md new file mode 100644 index 0000000..6ddd670 --- /dev/null +++ b/docs/Usersets.md @@ -0,0 +1,13 @@ + + +# Usersets + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**child** | [**List<Userset>**](Userset.md) | | [optional] | + + + diff --git a/docs/ValidationErrorMessageResponse.md b/docs/ValidationErrorMessageResponse.md new file mode 100644 index 0000000..de28998 --- /dev/null +++ b/docs/ValidationErrorMessageResponse.md @@ -0,0 +1,14 @@ + + +# ValidationErrorMessageResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **ErrorCode** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/docs/WriteAssertionsRequest.md b/docs/WriteAssertionsRequest.md new file mode 100644 index 0000000..0b655f1 --- /dev/null +++ b/docs/WriteAssertionsRequest.md @@ -0,0 +1,13 @@ + + +# WriteAssertionsRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**assertions** | [**List<Assertion>**](Assertion.md) | | | + + + diff --git a/docs/WriteAuthorizationModelRequest.md b/docs/WriteAuthorizationModelRequest.md new file mode 100644 index 0000000..a99da15 --- /dev/null +++ b/docs/WriteAuthorizationModelRequest.md @@ -0,0 +1,14 @@ + + +# WriteAuthorizationModelRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**typeDefinitions** | [**List<TypeDefinition>**](TypeDefinition.md) | | | +|**schemaVersion** | **String** | | [optional] | + + + diff --git a/docs/WriteAuthorizationModelResponse.md b/docs/WriteAuthorizationModelResponse.md new file mode 100644 index 0000000..5ba44eb --- /dev/null +++ b/docs/WriteAuthorizationModelResponse.md @@ -0,0 +1,13 @@ + + +# WriteAuthorizationModelResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**authorizationModelId** | **String** | | [optional] | + + + diff --git a/docs/WriteRequest.md b/docs/WriteRequest.md new file mode 100644 index 0000000..4b6b36c --- /dev/null +++ b/docs/WriteRequest.md @@ -0,0 +1,15 @@ + + +# WriteRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**writes** | [**TupleKeys**](TupleKeys.md) | | [optional] | +|**deletes** | [**TupleKeys**](TupleKeys.md) | | [optional] | +|**authorizationModelId** | **String** | | [optional] | + + + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..033e24c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a1f2792 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..005bcde --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..6a68175 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..a9ad0d1 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'openfga-sdk' \ No newline at end of file diff --git a/src/main/java/dev/openfga/sdk/api/OpenFgaApi.java b/src/main/java/dev/openfga/sdk/api/OpenFgaApi.java new file mode 100644 index 0000000..53a1bab --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/OpenFgaApi.java @@ -0,0 +1,1666 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import dev.openfga.sdk.api.client.ApiClient; +import dev.openfga.sdk.api.client.ApiException; +import dev.openfga.sdk.api.client.ApiResponse; +import dev.openfga.sdk.api.client.Configuration; +import dev.openfga.sdk.api.client.Pair; +import dev.openfga.sdk.api.model.CheckRequest; +import dev.openfga.sdk.api.model.CheckResponse; +import dev.openfga.sdk.api.model.CreateStoreRequest; +import dev.openfga.sdk.api.model.CreateStoreResponse; +import dev.openfga.sdk.api.model.ExpandRequest; +import dev.openfga.sdk.api.model.ExpandResponse; +import dev.openfga.sdk.api.model.GetStoreResponse; +import dev.openfga.sdk.api.model.ListObjectsRequest; +import dev.openfga.sdk.api.model.ListObjectsResponse; +import dev.openfga.sdk.api.model.ListStoresResponse; +import dev.openfga.sdk.api.model.ReadAssertionsResponse; +import dev.openfga.sdk.api.model.ReadAuthorizationModelResponse; +import dev.openfga.sdk.api.model.ReadAuthorizationModelsResponse; +import dev.openfga.sdk.api.model.ReadChangesResponse; +import dev.openfga.sdk.api.model.ReadRequest; +import dev.openfga.sdk.api.model.ReadResponse; +import dev.openfga.sdk.api.model.WriteAssertionsRequest; +import dev.openfga.sdk.api.model.WriteAuthorizationModelRequest; +import dev.openfga.sdk.api.model.WriteAuthorizationModelResponse; +import dev.openfga.sdk.api.model.WriteRequest; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class OpenFgaApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final Configuration memberVarConfiguration; + private final String memberVarBaseUri; + private final Duration memberVarReadTimeout; + private final Consumer memberVarInterceptor; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public OpenFgaApi(ApiClient apiClient, Configuration configuration) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarConfiguration = configuration; + memberVarBaseUri = configuration.getApiUrl(); + memberVarReadTimeout = configuration.getReadTimeout(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + private ApiException getApiException(String operationId, HttpResponse response) { + String message = formatExceptionMessage(operationId, response.statusCode(), response.body()); + return new ApiException(response.statusCode(), message, response.headers(), response.body()); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Check whether a user is authorized to access an object + * The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<CheckResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture check(String storeId, CheckRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = checkRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("check", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Check whether a user is authorized to access an object + * The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<CheckResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> checkWithHttpInfo(String storeId, CheckRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = checkRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("check", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder checkRequestBuilder(String storeId, CheckRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling check"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling check"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/check".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Create a store + * Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. + * @param body (required) + * @return CompletableFuture<CreateStoreResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture createStore(CreateStoreRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = createStoreRequestBuilder(body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("createStore", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Create a store + * Create a unique OpenFGA store which will be used to store authorization models and relationship tuples. + * @param body (required) + * @return CompletableFuture<ApiResponse<CreateStoreResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> createStoreWithHttpInfo(CreateStoreRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = createStoreRequestBuilder(body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("createStore", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder createStoreRequestBuilder(CreateStoreRequest body) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createStore"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Delete a store + * Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models. + * @param storeId (required) + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture deleteStore(String storeId) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = deleteStoreRequestBuilder(storeId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("deleteStore", localVarResponse)); + } + return CompletableFuture.completedFuture(null); + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Delete a store + * Delete an OpenFGA store. This does not delete the data associated with the store, like tuples or authorization models. + * @param storeId (required) + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> deleteStoreWithHttpInfo(String storeId) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = deleteStoreRequestBuilder(storeId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("deleteStore", localVarResponse)); + } + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null)); + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder deleteStoreRequestBuilder(String storeId) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling deleteStore"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship + * The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ExpandResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture expand(String storeId, ExpandRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = expandRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("expand", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship + * The Expand API will return all users and usersets that have certain relationship with an object in a certain store. This is different from the `/stores/{store_id}/read` API in that both users and computed usersets are returned. Body parameters `tuple_key.object` and `tuple_key.relation` are all required. The response will return a tree whose leaves are the specific users and usersets. Union, intersection and difference operator are located in the intermediate nodes. ## Example To expand all users that have the `reader` relationship with object `document:2021-budget`, use the Expand API with the following request body ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will be a userset tree of the users and usersets that have read access to the document. ```json { \"tree\":{ \"root\":{ \"type\":\"document:2021-budget#reader\", \"union\":{ \"nodes\":[ { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"users\":{ \"users\":[ \"user:bob\" ] } } }, { \"type\":\"document:2021-budget#reader\", \"leaf\":{ \"computed\":{ \"userset\":\"document:2021-budget#writer\" } } } ] } } } } ``` The caller can then call expand API for the `writer` relationship for the `document:2021-budget`. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<ExpandResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> expandWithHttpInfo(String storeId, ExpandRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = expandRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("expand", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder expandRequestBuilder(String storeId, ExpandRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling expand"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling expand"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/stores/{store_id}/expand".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Get a store + * Returns an OpenFGA store by its identifier + * @param storeId (required) + * @return CompletableFuture<GetStoreResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture getStore(String storeId) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = getStoreRequestBuilder(storeId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("getStore", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Get a store + * Returns an OpenFGA store by its identifier + * @param storeId (required) + * @return CompletableFuture<ApiResponse<GetStoreResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getStoreWithHttpInfo(String storeId) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = getStoreRequestBuilder(storeId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("getStore", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder getStoreRequestBuilder(String storeId) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling getStore"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * List all objects of the given type that the user has a relation with + * The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ListObjectsResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture listObjects(String storeId, ListObjectsRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = listObjectsRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("listObjects", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * List all objects of the given type that the user has a relation with + * The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `<type>:<id>` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<ListObjectsResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> listObjectsWithHttpInfo( + String storeId, ListObjectsRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = listObjectsRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("listObjects", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder listObjectsRequestBuilder(String storeId, ListObjectsRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling listObjects"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling listObjects"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/stores/{store_id}/list-objects".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * List all stores + * Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores. + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ListStoresResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture listStores(Integer pageSize, String continuationToken) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = listStoresRequestBuilder(pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("listStores", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * List all stores + * Returns a paginated list of OpenFGA stores and a continuation token to get additional stores. The continuation token will be empty if there are no more stores. + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ApiResponse<ListStoresResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> listStoresWithHttpInfo( + Integer pageSize, String continuationToken) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = listStoresRequestBuilder(pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("listStores", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder listStoresRequestBuilder(Integer pageSize, String continuationToken) + throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "page_size"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("page_size", pageSize)); + localVarQueryParameterBaseName = "continuation_token"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("continuation_token", continuationToken)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Get tuples from the store that matches a query, without following userset rewrite rules + * The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`). + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ReadResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture read(String storeId, ReadRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("read", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Get tuples from the store that matches a query, without following userset rewrite rules + * The Read API will return the tuples for a certain store that match a query filter specified in the body of the request. It is different from the `/stores/{store_id}/expand` API in that it only returns relationship tuples that are stored in the system and satisfy the query. In the body: 1. `tuple_key` is optional. If not specified, it will return all tuples in the store. 2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., `type:object_id`) or type only (e.g., `type:`). 3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. ## Examples ### Query for all objects in a type definition To query for all objects that `user:bob` has `reader` relationship in the `document` type definition, call read API with body of ```json { \"tuple_key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:\" } } ``` The API will return tuples and a continuation token, something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `user:bob` has a `reader` relationship with 1 document `document:2021-budget`. Note that this API, unlike the List Objects API, does not evaluate the tuples in the store. The continuation token will be empty if there are no more tuples to query.### Query for all stored relationship tuples that have a particular relation and object To query for all users that have `reader` relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\", \"relation\": \"reader\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`). Note that, even if the model said that all `writers` are also `readers`, the API will not return writers such as `user:anne` because it only returns tuples and does not evaluate them. ### Query for all users with all relationships for a particular document To query for all users that have any relationship with `document:2021-budget`, call read API with body of ```json { \"tuple_key\": { \"object\": \"document:2021-budget\" } } ``` The API will return something like ```json { \"tuples\": [ { \"key\": { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-05T13:42:12.356Z\" }, { \"key\": { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"timestamp\": \"2021-10-06T15:32:11.128Z\" } ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` This means that `document:2021-budget` has 1 `reader` (`user:bob`) and 1 `writer` (`user:anne`). + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<ReadResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> readWithHttpInfo(String storeId, ReadRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("read", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder readRequestBuilder(String storeId, ReadRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling read"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling read"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/read".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Read assertions for an authorization model ID + * The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + * @param storeId (required) + * @param authorizationModelId (required) + * @return CompletableFuture<ReadAssertionsResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture readAssertions(String storeId, String authorizationModelId) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readAssertionsRequestBuilder(storeId, authorizationModelId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("readAssertions", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Read assertions for an authorization model ID + * The ReadAssertions API will return, for a given authorization model id, all the assertions stored for it. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + * @param storeId (required) + * @param authorizationModelId (required) + * @return CompletableFuture<ApiResponse<ReadAssertionsResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> readAssertionsWithHttpInfo( + String storeId, String authorizationModelId) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readAssertionsRequestBuilder(storeId, authorizationModelId); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("readAssertions", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder readAssertionsRequestBuilder(String storeId, String authorizationModelId) + throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling readAssertions"); + } + // verify the required parameter 'authorizationModelId' is set + if (authorizationModelId == null) { + throw new ApiException( + 400, "Missing the required parameter 'authorizationModelId' when calling readAssertions"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/assertions/{authorization_model_id}" + .replace("{store_id}", ApiClient.urlEncode(storeId.toString())) + .replace("{authorization_model_id}", ApiClient.urlEncode(authorizationModelId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Return a particular version of an authorization model + * The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`). + * @param storeId (required) + * @param id (required) + * @return CompletableFuture<ReadAuthorizationModelResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture readAuthorizationModel(String storeId, String id) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readAuthorizationModelRequestBuilder(storeId, id); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("readAuthorizationModel", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Return a particular version of an authorization model + * The ReadAuthorizationModel API returns an authorization model by its identifier. The response will return the authorization model for the particular version. ## Example To retrieve the authorization model with ID `01G5JAVJ41T49E9TT3SKVS7X1J` for the store, call the GET authorization-models by ID API with `01G5JAVJ41T49E9TT3SKVS7X1J` as the `id` path parameter. The API will return: ```json { \"authorization_model\":{ \"id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\", \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } } ``` In the above example, there are 2 types (`user` and `document`). The `document` type has 2 relations (`writer` and `reader`). + * @param storeId (required) + * @param id (required) + * @return CompletableFuture<ApiResponse<ReadAuthorizationModelResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> readAuthorizationModelWithHttpInfo( + String storeId, String id) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = readAuthorizationModelRequestBuilder(storeId, id); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("readAuthorizationModel", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder readAuthorizationModelRequestBuilder(String storeId, String id) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling readAuthorizationModel"); + } + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling readAuthorizationModel"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/authorization-models/{id}" + .replace("{store_id}", ApiClient.urlEncode(storeId.toString())) + .replace("{id}", ApiClient.urlEncode(id.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Return all the authorization models for a particular store + * The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ``` + * @param storeId (required) + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ReadAuthorizationModelsResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture readAuthorizationModels( + String storeId, Integer pageSize, String continuationToken) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + readAuthorizationModelsRequestBuilder(storeId, pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("readAuthorizationModels", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Return all the authorization models for a particular store + * The ReadAuthorizationModels API will return all the authorization models for a certain store. OpenFGA's response will contain an array of all authorization models, sorted in descending order of creation. ## Example Assume that a store's authorization model has been configured twice. To get all the authorization models that have been created in this store, call GET authorization-models. The API will return a response that looks like: ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==\" } ``` If there are no more authorization models available, the `continuation_token` field will be empty ```json { \"authorization_models\": [ { \"id\": \"01G50QVV17PECNVAHX1GG4Y5NC\", \"type_definitions\": [...] }, { \"id\": \"01G4ZW8F4A07AKQ8RHSVG9RW04\", \"type_definitions\": [...] }, ], \"continuation_token\": \"\" } ``` + * @param storeId (required) + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ApiResponse<ReadAuthorizationModelsResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> readAuthorizationModelsWithHttpInfo( + String storeId, Integer pageSize, String continuationToken) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + readAuthorizationModelsRequestBuilder(storeId, pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("readAuthorizationModels", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder readAuthorizationModelsRequestBuilder( + String storeId, Integer pageSize, String continuationToken) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException( + 400, "Missing the required parameter 'storeId' when calling readAuthorizationModels"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/authorization-models" + .replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "page_size"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("page_size", pageSize)); + localVarQueryParameterBaseName = "continuation_token"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("continuation_token", continuationToken)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Return a list of all the tuple changes + * The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. + * @param storeId (required) + * @param type (optional) + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ReadChangesResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture readChanges( + String storeId, String type, Integer pageSize, String continuationToken) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + readChangesRequestBuilder(storeId, type, pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("readChanges", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Return a list of all the tuple changes + * The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. + * @param storeId (required) + * @param type (optional) + * @param pageSize (optional) + * @param continuationToken (optional) + * @return CompletableFuture<ApiResponse<ReadChangesResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> readChangesWithHttpInfo( + String storeId, String type, Integer pageSize, String continuationToken) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + readChangesRequestBuilder(storeId, type, pageSize, continuationToken); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("readChanges", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder readChangesRequestBuilder( + String storeId, String type, Integer pageSize, String continuationToken) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling readChanges"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/stores/{store_id}/changes".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "type"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("type", type)); + localVarQueryParameterBaseName = "page_size"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("page_size", pageSize)); + localVarQueryParameterBaseName = "continuation_token"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("continuation_token", continuationToken)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Add or delete tuples from the store + * The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<Object> + * @throws ApiException if fails to make API call + */ + public CompletableFuture write(String storeId, WriteRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = writeRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("write", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Add or delete tuples from the store + * The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Object>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> writeWithHttpInfo(String storeId, WriteRequest body) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = writeRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("write", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder writeRequestBuilder(String storeId, WriteRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling write"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling write"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/write".replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Upsert assertions for an authorization model ID + * The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + * @param storeId (required) + * @param authorizationModelId (required) + * @param body (required) + * @return CompletableFuture<Void> + * @throws ApiException if fails to make API call + */ + public CompletableFuture writeAssertions( + String storeId, String authorizationModelId, WriteAssertionsRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + writeAssertionsRequestBuilder(storeId, authorizationModelId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("writeAssertions", localVarResponse)); + } + return CompletableFuture.completedFuture(null); + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Upsert assertions for an authorization model ID + * The WriteAssertions API will upsert new assertions for an authorization model id, or overwrite the existing ones. An assertion is an object that contains a tuple key, and the expectation of whether a call to the Check API of that tuple key will return true or false. + * @param storeId (required) + * @param authorizationModelId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Void>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> writeAssertionsWithHttpInfo( + String storeId, String authorizationModelId, WriteAssertionsRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + writeAssertionsRequestBuilder(storeId, authorizationModelId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture(getApiException("writeAssertions", localVarResponse)); + } + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null)); + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder writeAssertionsRequestBuilder( + String storeId, String authorizationModelId, WriteAssertionsRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException(400, "Missing the required parameter 'storeId' when calling writeAssertions"); + } + // verify the required parameter 'authorizationModelId' is set + if (authorizationModelId == null) { + throw new ApiException( + 400, "Missing the required parameter 'authorizationModelId' when calling writeAssertions"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling writeAssertions"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/assertions/{authorization_model_id}" + .replace("{store_id}", ApiClient.urlEncode(storeId.toString())) + .replace("{authorization_model_id}", ApiClient.urlEncode(authorizationModelId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Create a new authorization model + * The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ``` + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<WriteAuthorizationModelResponse> + * @throws ApiException if fails to make API call + */ + public CompletableFuture writeAuthorizationModel( + String storeId, WriteAuthorizationModelRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = writeAuthorizationModelRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("writeAuthorizationModel", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {})); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + /** + * Create a new authorization model + * The WriteAuthorizationModel API will add a new authorization model to a store. Each item in the `type_definitions` array is a type definition as specified in the field `type_definition`. The response will return the authorization model's ID in the `id` field. ## Example To add an authorization model with `user` and `document` type definitions, call POST authorization-models API with the body: ```json { \"type_definitions\":[ { \"type\":\"user\" }, { \"type\":\"document\", \"relations\":{ \"reader\":{ \"union\":{ \"child\":[ { \"this\":{} }, { \"computedUserset\":{ \"object\":\"\", \"relation\":\"writer\" } } ] } }, \"writer\":{ \"this\":{} } } } ] } ``` OpenFGA's response will include the version id for this authorization model, which will look like ``` {\"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\"} ``` + * @param storeId (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<WriteAuthorizationModelResponse>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> writeAuthorizationModelWithHttpInfo( + String storeId, WriteAuthorizationModelRequest body) throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = writeAuthorizationModelRequestBuilder(storeId, body); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync(localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException("writeAuthorizationModel", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture(new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder writeAuthorizationModelRequestBuilder( + String storeId, WriteAuthorizationModelRequest body) throws ApiException { + // verify the required parameter 'storeId' is set + if (storeId == null) { + throw new ApiException( + 400, "Missing the required parameter 'storeId' when calling writeAuthorizationModel"); + } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling writeAuthorizationModel"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/stores/{store_id}/authorization-models" + .replace("{store_id}", ApiClient.urlEncode(storeId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/ApiBearerToken.java b/src/main/java/dev/openfga/sdk/api/client/ApiBearerToken.java new file mode 100644 index 0000000..03108eb --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/ApiBearerToken.java @@ -0,0 +1,29 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +public class ApiBearerToken { + private String token; + + public ApiBearerToken(String token) { + this.token = token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getToken() { + return this.token; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/ApiClient.java b/src/main/java/dev/openfga/sdk/api/client/ApiClient.java new file mode 100644 index 0000000..f1a710d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/ApiClient.java @@ -0,0 +1,327 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.InputStream; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import org.openapitools.jackson.nullable.JsonNullableModule; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ApiClient { + + private HttpClient.Builder builder; + private ObjectMapper mapper; + private Consumer interceptor; + private Consumer> responseInterceptor; + private Consumer> asyncResponseInterceptor; + + /** + * Create an instance of ApiClient. + */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + interceptor = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + *

+ * In other contexts, note that any settings in a {@link Configuration} + * will take precedence over equivalent settings in the + * {@link HttpClient.Builder} here. + * + * @param builder Http client builder. + * @param mapper Object mapper. + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper) { + this.builder = builder; + this.mapper = mapper; + interceptor = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + private static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. + * + *

The value can be null, in which case an empty list is returned.

+ * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. + */ + public static List parameterToPairs(String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch (format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + protected ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "http://localhost"; + } + + protected HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. + *

+ * In other contexts, note that any settings in a {@link Configuration} + * will take precedence over equivalent settings in the + * {@link HttpClient.Builder} here. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe.

+ * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

+ * + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables

+ * + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/ApiException.java b/src/main/java/dev/openfga/sdk/api/client/ApiException.java new file mode 100644 index 0000000..71d5299 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/ApiException.java @@ -0,0 +1,92 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import java.net.http.HttpHeaders; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ApiException extends Exception { + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException( + String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/ApiResponse.java b/src/main/java/dev/openfga/sdk/api/client/ApiResponse.java new file mode 100644 index 0000000..143a9c5 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/ApiResponse.java @@ -0,0 +1,64 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + Map> responseHeaders = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + for (Entry> entry : headers.entrySet()) { + responseHeaders.put(entry.getKey().toLowerCase(), entry.getValue()); + } + this.headers = responseHeaders; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/BaseConfiguration.java b/src/main/java/dev/openfga/sdk/api/client/BaseConfiguration.java new file mode 100644 index 0000000..d1f4ce0 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/BaseConfiguration.java @@ -0,0 +1,28 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import dev.openfga.sdk.errors.FgaInvalidParameterException; +import java.time.Duration; + +public interface BaseConfiguration { + void assertValid() throws FgaInvalidParameterException; + + String getApiUrl(); + + String getUserAgent(); + + Duration getReadTimeout(); + + Duration getConnectTimeout(); +} diff --git a/src/main/java/dev/openfga/sdk/api/client/ClientCredentials.java b/src/main/java/dev/openfga/sdk/api/client/ClientCredentials.java new file mode 100644 index 0000000..dcf859a --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/ClientCredentials.java @@ -0,0 +1,80 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import static dev.openfga.util.StringUtil.isNullOrWhitespace; + +import dev.openfga.sdk.errors.FgaInvalidParameterException; + +public class ClientCredentials { + private String clientId; + private String clientSecret; + private String apiTokenIssuer; + private String apiAudience; + + public ClientCredentials() {} + + public ClientCredentials clientId(String clientId) { + this.clientId = clientId; + return this; + } + + public void assertValid() throws FgaInvalidParameterException { + if (isNullOrWhitespace(clientId)) { + throw new FgaInvalidParameterException("clientId", "ClientCredentials"); + } + + if (isNullOrWhitespace(clientSecret)) { + throw new FgaInvalidParameterException("clientSecret", "ClientCredentials"); + } + + if (isNullOrWhitespace(apiTokenIssuer)) { + throw new FgaInvalidParameterException("apiTokenIssuer", "ClientCredentials"); + } + + if (isNullOrWhitespace(apiAudience)) { + throw new FgaInvalidParameterException("apiAudience", "ClientCredentials"); + } + } + + public String getClientId() { + return this.clientId; + } + + public ClientCredentials clientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + + public String getClientSecret() { + return this.clientSecret; + } + + public ClientCredentials apiTokenIssuer(String apiTokenIssuer) { + this.apiTokenIssuer = apiTokenIssuer; + return this; + } + + public String getApiTokenIssuer() { + return this.apiTokenIssuer; + } + + public ClientCredentials apiAudience(String apiAudience) { + this.apiAudience = apiAudience; + return this; + } + + public String getApiAudience() { + return this.apiAudience; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/Configuration.java b/src/main/java/dev/openfga/sdk/api/client/Configuration.java new file mode 100644 index 0000000..aa9af11 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/Configuration.java @@ -0,0 +1,179 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import static dev.openfga.util.StringUtil.isNullOrWhitespace; + +import dev.openfga.sdk.errors.FgaInvalidParameterException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.time.Duration; + +/** + * Configurations for an ApiClient. + */ +public class Configuration implements BaseConfiguration { + public static final String VERSION = "0.0.1"; + + private static final String DEFAULT_API_URL = "http://localhost:8080"; + private static final String DEFAULT_USER_AGENT = "openfga-sdk java/0.0.1"; + private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(10); + private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(10); + + private String apiUrl; + private String userAgent; + private Duration readTimeout; + private Duration connectTimeout; + + public Configuration(String apiUrl) { + this.apiUrl = apiUrl; + this.userAgent = DEFAULT_USER_AGENT; + this.readTimeout = DEFAULT_READ_TIMEOUT; + this.connectTimeout = DEFAULT_CONNECT_TIMEOUT; + } + + /** + * Assert that the configuration is valid. + */ + @Override + public void assertValid() throws FgaInvalidParameterException { + // If apiUrl is null/empty/whitespace it will resolve to + // DEFAULT_API_URL when getApiUrl is called. + if (!isNullOrWhitespace(apiUrl)) { + URI uri; + + try { + uri = URI.create(apiUrl); + URL _url = uri.toURL(); + } catch (MalformedURLException | IllegalArgumentException cause) { + throw new FgaInvalidParameterException("apiUrl", "Configuration", cause); + } + + if (isNullOrWhitespace(uri.getScheme())) { + throw new FgaInvalidParameterException("scheme", "Configuration"); + } + + if (isNullOrWhitespace(uri.getHost())) { + throw new FgaInvalidParameterException("hostname", "Configuration"); + } + } + } + + /** + * Set the API URL for the http client. + * + * @param apiUrl The URL. + * @return This object. + */ + public BaseConfiguration apiUrl(String apiUrl) { + this.apiUrl = apiUrl; + return this; + } + + /** + * Get the API URL that was set. + * + * @return The url. + */ + @Override + public String getApiUrl() { + if (isNullOrWhitespace(apiUrl)) { + return DEFAULT_API_URL; + } + + return apiUrl; + } + + /** + * Set the user agent. + * + * @param userAgent The user agent. + * @return This object. + */ + public BaseConfiguration userAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + + /** + * Get the user agent. + * + * @return The user agent. + */ + @Override + public String getUserAgent() { + return userAgent; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

+ * + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. + * @return This object. + */ + public BaseConfiguration readTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. + */ + @Override + public Duration getReadTimeout() { + return readTimeout; + } + + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest, BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest, BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * @return This object. + */ + public BaseConfiguration connectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + @Override + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/CredentialsMethod.java b/src/main/java/dev/openfga/sdk/api/client/CredentialsMethod.java new file mode 100644 index 0000000..5bec856 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/CredentialsMethod.java @@ -0,0 +1,41 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +/** + * + */ +public enum CredentialsMethod { + NONE, + API_BEARER_TOKEN, + CLIENT_CREDENTIALS; + + private ApiBearerToken apiBearerToken; + private ClientCredentials clientCredentials; + + public static CredentialsMethod none() { + return NONE; + } + + public static CredentialsMethod apiBearerToken(ApiBearerToken apiBearerToken) { + CredentialsMethod it = API_BEARER_TOKEN; + it.apiBearerToken = apiBearerToken; + return it; + } + + public static CredentialsMethod clientCredentials(ClientCredentials clientCredentials) { + CredentialsMethod it = CLIENT_CREDENTIALS; + it.clientCredentials = clientCredentials; + return it; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/JSON.java b/src/main/java/dev/openfga/sdk/api/client/JSON.java new file mode 100644 index 0000000..176f9ac --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/JSON.java @@ -0,0 +1,254 @@ +package dev.openfga.sdk.api.client; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import dev.openfga.sdk.api.model.*; +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.openapitools.jackson.nullable.JsonNullableModule; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = JsonMapper.builder() + .configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) + .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true) + .build(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.setDateFormat(new RFC3339DateFormat()); + mapper.registerModule(new JavaTimeModule()); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { + return mapper; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator( + Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/Pair.java b/src/main/java/dev/openfga/sdk/api/client/Pair.java new file mode 100644 index 0000000..18995fd --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/Pair.java @@ -0,0 +1,58 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair(String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/src/main/java/dev/openfga/sdk/api/client/RFC3339DateFormat.java b/src/main/java/dev/openfga/sdk/api/client/RFC3339DateFormat.java new file mode 100644 index 0000000..eb342be --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/client/RFC3339DateFormat.java @@ -0,0 +1,55 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import com.fasterxml.jackson.databind.util.StdDateFormat; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = + new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java b/src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..c0d5af4 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Map; +import java.util.Objects; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Any.java b/src/main/java/dev/openfga/sdk/api/model/Any.java new file mode 100644 index 0000000..882a1bb --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Any.java @@ -0,0 +1,196 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Any + */ +@JsonPropertyOrder({Any.JSON_PROPERTY_AT_TYPE}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Any extends HashMap { + public static final String JSON_PROPERTY_AT_TYPE = "@type"; + private String atType; + + public Any() {} + + public Any atType(String atType) { + this.atType = atType; + return this; + } + + /** + * Get atType + * @return atType + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAtType() { + return atType; + } + + @JsonProperty(JSON_PROPERTY_AT_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAtType(String atType) { + this.atType = atType; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * @param key the name of the property + * @param value the value of the property + * @return self reference + */ + @JsonAnySetter + public Any putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) properties. + * @return the additional (undeclared) properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * @param key the name of the property + * @return the additional (undeclared) property with the specified name + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this Any object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Any any = (Any) o; + return Objects.equals(this.atType, any.atType) + && Objects.equals(this.additionalProperties, any.additionalProperties) + && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(atType, super.hashCode(), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Any {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" atType: ").append(toIndentedString(atType)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `@type` to the URL query string + if (getAtType() != null) { + joiner.add(String.format( + "%s@type%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAtType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Assertion.java b/src/main/java/dev/openfga/sdk/api/model/Assertion.java new file mode 100644 index 0000000..e7c8280 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Assertion.java @@ -0,0 +1,174 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Assertion + */ +@JsonPropertyOrder({Assertion.JSON_PROPERTY_TUPLE_KEY, Assertion.JSON_PROPERTY_EXPECTATION}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Assertion { + public static final String JSON_PROPERTY_TUPLE_KEY = "tuple_key"; + private TupleKey tupleKey; + + public static final String JSON_PROPERTY_EXPECTATION = "expectation"; + private Boolean expectation; + + public Assertion() {} + + public Assertion tupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + return this; + } + + /** + * Get tupleKey + * @return tupleKey + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TupleKey getTupleKey() { + return tupleKey; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + } + + public Assertion expectation(Boolean expectation) { + this.expectation = expectation; + return this; + } + + /** + * Get expectation + * @return expectation + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_EXPECTATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getExpectation() { + return expectation; + } + + @JsonProperty(JSON_PROPERTY_EXPECTATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setExpectation(Boolean expectation) { + this.expectation = expectation; + } + + /** + * Return true if this Assertion object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Assertion assertion = (Assertion) o; + return Objects.equals(this.tupleKey, assertion.tupleKey) + && Objects.equals(this.expectation, assertion.expectation); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKey, expectation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Assertion {\n"); + sb.append(" tupleKey: ").append(toIndentedString(tupleKey)).append("\n"); + sb.append(" expectation: ").append(toIndentedString(expectation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_key` to the URL query string + if (getTupleKey() != null) { + joiner.add(getTupleKey().toUrlQueryString(prefix + "tuple_key" + suffix)); + } + + // add `expectation` to the URL query string + if (getExpectation() != null) { + joiner.add(String.format( + "%sexpectation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getExpectation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/AuthorizationModel.java b/src/main/java/dev/openfga/sdk/api/model/AuthorizationModel.java new file mode 100644 index 0000000..96bf26b --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/AuthorizationModel.java @@ -0,0 +1,239 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * AuthorizationModel + */ +@JsonPropertyOrder({ + AuthorizationModel.JSON_PROPERTY_ID, + AuthorizationModel.JSON_PROPERTY_SCHEMA_VERSION, + AuthorizationModel.JSON_PROPERTY_TYPE_DEFINITIONS +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class AuthorizationModel { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_SCHEMA_VERSION = "schema_version"; + private String schemaVersion; + + public static final String JSON_PROPERTY_TYPE_DEFINITIONS = "type_definitions"; + private List typeDefinitions = new ArrayList<>(); + + public AuthorizationModel() {} + + public AuthorizationModel id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + public AuthorizationModel schemaVersion(String schemaVersion) { + this.schemaVersion = schemaVersion; + return this; + } + + /** + * Get schemaVersion + * @return schemaVersion + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_SCHEMA_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSchemaVersion() { + return schemaVersion; + } + + @JsonProperty(JSON_PROPERTY_SCHEMA_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setSchemaVersion(String schemaVersion) { + this.schemaVersion = schemaVersion; + } + + public AuthorizationModel typeDefinitions(List typeDefinitions) { + this.typeDefinitions = typeDefinitions; + return this; + } + + public AuthorizationModel addTypeDefinitionsItem(TypeDefinition typeDefinitionsItem) { + if (this.typeDefinitions == null) { + this.typeDefinitions = new ArrayList<>(); + } + this.typeDefinitions.add(typeDefinitionsItem); + return this; + } + + /** + * Get typeDefinitions + * @return typeDefinitions + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE_DEFINITIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTypeDefinitions() { + return typeDefinitions; + } + + @JsonProperty(JSON_PROPERTY_TYPE_DEFINITIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTypeDefinitions(List typeDefinitions) { + this.typeDefinitions = typeDefinitions; + } + + /** + * Return true if this AuthorizationModel object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizationModel authorizationModel = (AuthorizationModel) o; + return Objects.equals(this.id, authorizationModel.id) + && Objects.equals(this.schemaVersion, authorizationModel.schemaVersion) + && Objects.equals(this.typeDefinitions, authorizationModel.typeDefinitions); + } + + @Override + public int hashCode() { + return Objects.hash(id, schemaVersion, typeDefinitions); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AuthorizationModel {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" schemaVersion: ").append(toIndentedString(schemaVersion)).append("\n"); + sb.append(" typeDefinitions: ") + .append(toIndentedString(typeDefinitions)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `schema_version` to the URL query string + if (getSchemaVersion() != null) { + joiner.add(String.format( + "%sschema_version%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getSchemaVersion()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `type_definitions` to the URL query string + if (getTypeDefinitions() != null) { + for (int i = 0; i < getTypeDefinitions().size(); i++) { + if (getTypeDefinitions().get(i) != null) { + joiner.add(getTypeDefinitions() + .get(i) + .toUrlQueryString(String.format( + "%stype_definitions%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/CheckRequest.java b/src/main/java/dev/openfga/sdk/api/model/CheckRequest.java new file mode 100644 index 0000000..3c4eb77 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/CheckRequest.java @@ -0,0 +1,248 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * CheckRequest + */ +@JsonPropertyOrder({ + CheckRequest.JSON_PROPERTY_TUPLE_KEY, + CheckRequest.JSON_PROPERTY_CONTEXTUAL_TUPLES, + CheckRequest.JSON_PROPERTY_AUTHORIZATION_MODEL_ID, + CheckRequest.JSON_PROPERTY_TRACE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class CheckRequest { + public static final String JSON_PROPERTY_TUPLE_KEY = "tuple_key"; + private TupleKey tupleKey; + + public static final String JSON_PROPERTY_CONTEXTUAL_TUPLES = "contextual_tuples"; + private ContextualTupleKeys contextualTuples; + + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public static final String JSON_PROPERTY_TRACE = "trace"; + private Boolean trace; + + public CheckRequest() {} + + @JsonCreator + public CheckRequest(@JsonProperty(JSON_PROPERTY_TRACE) Boolean trace) { + this(); + this.trace = trace; + } + + public CheckRequest tupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + return this; + } + + /** + * Get tupleKey + * @return tupleKey + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TupleKey getTupleKey() { + return tupleKey; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + } + + public CheckRequest contextualTuples(ContextualTupleKeys contextualTuples) { + this.contextualTuples = contextualTuples; + return this; + } + + /** + * Get contextualTuples + * @return contextualTuples + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTEXTUAL_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ContextualTupleKeys getContextualTuples() { + return contextualTuples; + } + + @JsonProperty(JSON_PROPERTY_CONTEXTUAL_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContextualTuples(ContextualTupleKeys contextualTuples) { + this.contextualTuples = contextualTuples; + } + + public CheckRequest authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + /** + * Defaults to false. Making it true has performance implications. + * @return trace + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TRACE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getTrace() { + return trace; + } + + /** + * Return true if this Check_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CheckRequest checkRequest = (CheckRequest) o; + return Objects.equals(this.tupleKey, checkRequest.tupleKey) + && Objects.equals(this.contextualTuples, checkRequest.contextualTuples) + && Objects.equals(this.authorizationModelId, checkRequest.authorizationModelId) + && Objects.equals(this.trace, checkRequest.trace); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKey, contextualTuples, authorizationModelId, trace); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CheckRequest {\n"); + sb.append(" tupleKey: ").append(toIndentedString(tupleKey)).append("\n"); + sb.append(" contextualTuples: ") + .append(toIndentedString(contextualTuples)) + .append("\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append(" trace: ").append(toIndentedString(trace)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_key` to the URL query string + if (getTupleKey() != null) { + joiner.add(getTupleKey().toUrlQueryString(prefix + "tuple_key" + suffix)); + } + + // add `contextual_tuples` to the URL query string + if (getContextualTuples() != null) { + joiner.add(getContextualTuples().toUrlQueryString(prefix + "contextual_tuples" + suffix)); + } + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `trace` to the URL query string + if (getTrace() != null) { + joiner.add(String.format( + "%strace%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getTrace()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/CheckResponse.java b/src/main/java/dev/openfga/sdk/api/model/CheckResponse.java new file mode 100644 index 0000000..9d8ebe0 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/CheckResponse.java @@ -0,0 +1,179 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * CheckResponse + */ +@JsonPropertyOrder({CheckResponse.JSON_PROPERTY_ALLOWED, CheckResponse.JSON_PROPERTY_RESOLUTION}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class CheckResponse { + public static final String JSON_PROPERTY_ALLOWED = "allowed"; + private Boolean allowed; + + public static final String JSON_PROPERTY_RESOLUTION = "resolution"; + private String resolution; + + public CheckResponse() {} + + public CheckResponse allowed(Boolean allowed) { + this.allowed = allowed; + return this; + } + + /** + * Get allowed + * @return allowed + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ALLOWED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getAllowed() { + return allowed; + } + + @JsonProperty(JSON_PROPERTY_ALLOWED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAllowed(Boolean allowed) { + this.allowed = allowed; + } + + public CheckResponse resolution(String resolution) { + this.resolution = resolution; + return this; + } + + /** + * For internal use only. + * @return resolution + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RESOLUTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getResolution() { + return resolution; + } + + @JsonProperty(JSON_PROPERTY_RESOLUTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setResolution(String resolution) { + this.resolution = resolution; + } + + /** + * Return true if this CheckResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CheckResponse checkResponse = (CheckResponse) o; + return Objects.equals(this.allowed, checkResponse.allowed) + && Objects.equals(this.resolution, checkResponse.resolution); + } + + @Override + public int hashCode() { + return Objects.hash(allowed, resolution); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CheckResponse {\n"); + sb.append(" allowed: ").append(toIndentedString(allowed)).append("\n"); + sb.append(" resolution: ").append(toIndentedString(resolution)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `allowed` to the URL query string + if (getAllowed() != null) { + joiner.add(String.format( + "%sallowed%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAllowed()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `resolution` to the URL query string + if (getResolution() != null) { + joiner.add(String.format( + "%sresolution%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getResolution()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Computed.java b/src/main/java/dev/openfga/sdk/api/model/Computed.java new file mode 100644 index 0000000..ecbc6b3 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Computed.java @@ -0,0 +1,142 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Computed + */ +@JsonPropertyOrder({Computed.JSON_PROPERTY_USERSET}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Computed { + public static final String JSON_PROPERTY_USERSET = "userset"; + private String userset; + + public Computed() {} + + public Computed userset(String userset) { + this.userset = userset; + return this; + } + + /** + * Get userset + * @return userset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUserset() { + return userset; + } + + @JsonProperty(JSON_PROPERTY_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserset(String userset) { + this.userset = userset; + } + + /** + * Return true if this Computed object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Computed computed = (Computed) o; + return Objects.equals(this.userset, computed.userset); + } + + @Override + public int hashCode() { + return Objects.hash(userset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Computed {\n"); + sb.append(" userset: ").append(toIndentedString(userset)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `userset` to the URL query string + if (getUserset() != null) { + joiner.add(String.format( + "%suserset%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUserset()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ContextualTupleKeys.java b/src/main/java/dev/openfga/sdk/api/model/ContextualTupleKeys.java new file mode 100644 index 0000000..5407ff9 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ContextualTupleKeys.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ContextualTupleKeys + */ +@JsonPropertyOrder({ContextualTupleKeys.JSON_PROPERTY_TUPLE_KEYS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ContextualTupleKeys { + public static final String JSON_PROPERTY_TUPLE_KEYS = "tuple_keys"; + private List tupleKeys = new ArrayList<>(); + + public ContextualTupleKeys() {} + + public ContextualTupleKeys tupleKeys(List tupleKeys) { + this.tupleKeys = tupleKeys; + return this; + } + + public ContextualTupleKeys addTupleKeysItem(TupleKey tupleKeysItem) { + if (this.tupleKeys == null) { + this.tupleKeys = new ArrayList<>(); + } + this.tupleKeys.add(tupleKeysItem); + return this; + } + + /** + * Get tupleKeys + * @return tupleKeys + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TUPLE_KEYS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTupleKeys() { + return tupleKeys; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEYS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTupleKeys(List tupleKeys) { + this.tupleKeys = tupleKeys; + } + + /** + * Return true if this ContextualTupleKeys object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ContextualTupleKeys contextualTupleKeys = (ContextualTupleKeys) o; + return Objects.equals(this.tupleKeys, contextualTupleKeys.tupleKeys); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ContextualTupleKeys {\n"); + sb.append(" tupleKeys: ").append(toIndentedString(tupleKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_keys` to the URL query string + if (getTupleKeys() != null) { + for (int i = 0; i < getTupleKeys().size(); i++) { + if (getTupleKeys().get(i) != null) { + joiner.add(getTupleKeys() + .get(i) + .toUrlQueryString(String.format( + "%stuple_keys%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/CreateStoreRequest.java b/src/main/java/dev/openfga/sdk/api/model/CreateStoreRequest.java new file mode 100644 index 0000000..80ff36c --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/CreateStoreRequest.java @@ -0,0 +1,142 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * CreateStoreRequest + */ +@JsonPropertyOrder({CreateStoreRequest.JSON_PROPERTY_NAME}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class CreateStoreRequest { + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public CreateStoreRequest() {} + + public CreateStoreRequest name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setName(String name) { + this.name = name; + } + + /** + * Return true if this CreateStoreRequest object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateStoreRequest createStoreRequest = (CreateStoreRequest) o; + return Objects.equals(this.name, createStoreRequest.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateStoreRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/CreateStoreResponse.java b/src/main/java/dev/openfga/sdk/api/model/CreateStoreResponse.java new file mode 100644 index 0000000..37bfbda --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/CreateStoreResponse.java @@ -0,0 +1,259 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * CreateStoreResponse + */ +@JsonPropertyOrder({ + CreateStoreResponse.JSON_PROPERTY_ID, + CreateStoreResponse.JSON_PROPERTY_NAME, + CreateStoreResponse.JSON_PROPERTY_CREATED_AT, + CreateStoreResponse.JSON_PROPERTY_UPDATED_AT +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class CreateStoreResponse { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_UPDATED_AT = "updated_at"; + private OffsetDateTime updatedAt; + + public CreateStoreResponse() {} + + public CreateStoreResponse id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + public CreateStoreResponse name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public CreateStoreResponse createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public CreateStoreResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Get updatedAt + * @return updatedAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + /** + * Return true if this CreateStoreResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateStoreResponse createStoreResponse = (CreateStoreResponse) o; + return Objects.equals(this.id, createStoreResponse.id) + && Objects.equals(this.name, createStoreResponse.name) + && Objects.equals(this.createdAt, createStoreResponse.createdAt) + && Objects.equals(this.updatedAt, createStoreResponse.updatedAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, createdAt, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateStoreResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `created_at` to the URL query string + if (getCreatedAt() != null) { + joiner.add(String.format( + "%screated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `updated_at` to the URL query string + if (getUpdatedAt() != null) { + joiner.add(String.format( + "%supdated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUpdatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Difference.java b/src/main/java/dev/openfga/sdk/api/model/Difference.java new file mode 100644 index 0000000..cd0270b --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Difference.java @@ -0,0 +1,166 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Difference + */ +@JsonPropertyOrder({Difference.JSON_PROPERTY_BASE, Difference.JSON_PROPERTY_SUBTRACT}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Difference { + public static final String JSON_PROPERTY_BASE = "base"; + private Userset base; + + public static final String JSON_PROPERTY_SUBTRACT = "subtract"; + private Userset subtract; + + public Difference() {} + + public Difference base(Userset base) { + this.base = base; + return this; + } + + /** + * Get base + * @return base + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_BASE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Userset getBase() { + return base; + } + + @JsonProperty(JSON_PROPERTY_BASE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBase(Userset base) { + this.base = base; + } + + public Difference subtract(Userset subtract) { + this.subtract = subtract; + return this; + } + + /** + * Get subtract + * @return subtract + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_SUBTRACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Userset getSubtract() { + return subtract; + } + + @JsonProperty(JSON_PROPERTY_SUBTRACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setSubtract(Userset subtract) { + this.subtract = subtract; + } + + /** + * Return true if this Difference object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Difference difference = (Difference) o; + return Objects.equals(this.base, difference.base) && Objects.equals(this.subtract, difference.subtract); + } + + @Override + public int hashCode() { + return Objects.hash(base, subtract); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Difference {\n"); + sb.append(" base: ").append(toIndentedString(base)).append("\n"); + sb.append(" subtract: ").append(toIndentedString(subtract)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `base` to the URL query string + if (getBase() != null) { + joiner.add(getBase().toUrlQueryString(prefix + "base" + suffix)); + } + + // add `subtract` to the URL query string + if (getSubtract() != null) { + joiner.add(getSubtract().toUrlQueryString(prefix + "subtract" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ErrorCode.java b/src/main/java/dev/openfga/sdk/api/model/ErrorCode.java new file mode 100644 index 0000000..4c1a235 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ErrorCode.java @@ -0,0 +1,159 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets ErrorCode + */ +public enum ErrorCode { + NO_ERROR("no_error"), + + VALIDATION_ERROR("validation_error"), + + AUTHORIZATION_MODEL_NOT_FOUND("authorization_model_not_found"), + + AUTHORIZATION_MODEL_RESOLUTION_TOO_COMPLEX("authorization_model_resolution_too_complex"), + + INVALID_WRITE_INPUT("invalid_write_input"), + + CANNOT_ALLOW_DUPLICATE_TUPLES_IN_ONE_REQUEST("cannot_allow_duplicate_tuples_in_one_request"), + + CANNOT_ALLOW_DUPLICATE_TYPES_IN_ONE_REQUEST("cannot_allow_duplicate_types_in_one_request"), + + CANNOT_ALLOW_MULTIPLE_REFERENCES_TO_ONE_RELATION("cannot_allow_multiple_references_to_one_relation"), + + INVALID_CONTINUATION_TOKEN("invalid_continuation_token"), + + INVALID_TUPLE_SET("invalid_tuple_set"), + + INVALID_CHECK_INPUT("invalid_check_input"), + + INVALID_EXPAND_INPUT("invalid_expand_input"), + + UNSUPPORTED_USER_SET("unsupported_user_set"), + + INVALID_OBJECT_FORMAT("invalid_object_format"), + + WRITE_FAILED_DUE_TO_INVALID_INPUT("write_failed_due_to_invalid_input"), + + AUTHORIZATION_MODEL_ASSERTIONS_NOT_FOUND("authorization_model_assertions_not_found"), + + LATEST_AUTHORIZATION_MODEL_NOT_FOUND("latest_authorization_model_not_found"), + + TYPE_NOT_FOUND("type_not_found"), + + RELATION_NOT_FOUND("relation_not_found"), + + EMPTY_RELATION_DEFINITION("empty_relation_definition"), + + INVALID_USER("invalid_user"), + + INVALID_TUPLE("invalid_tuple"), + + UNKNOWN_RELATION("unknown_relation"), + + STORE_ID_INVALID_LENGTH("store_id_invalid_length"), + + ASSERTIONS_TOO_MANY_ITEMS("assertions_too_many_items"), + + ID_TOO_LONG("id_too_long"), + + AUTHORIZATION_MODEL_ID_TOO_LONG("authorization_model_id_too_long"), + + TUPLE_KEY_VALUE_NOT_SPECIFIED("tuple_key_value_not_specified"), + + TUPLE_KEYS_TOO_MANY_OR_TOO_FEW_ITEMS("tuple_keys_too_many_or_too_few_items"), + + PAGE_SIZE_INVALID("page_size_invalid"), + + PARAM_MISSING_VALUE("param_missing_value"), + + DIFFERENCE_BASE_MISSING_VALUE("difference_base_missing_value"), + + SUBTRACT_BASE_MISSING_VALUE("subtract_base_missing_value"), + + OBJECT_TOO_LONG("object_too_long"), + + RELATION_TOO_LONG("relation_too_long"), + + TYPE_DEFINITIONS_TOO_FEW_ITEMS("type_definitions_too_few_items"), + + TYPE_INVALID_LENGTH("type_invalid_length"), + + TYPE_INVALID_PATTERN("type_invalid_pattern"), + + RELATIONS_TOO_FEW_ITEMS("relations_too_few_items"), + + RELATIONS_TOO_LONG("relations_too_long"), + + RELATIONS_INVALID_PATTERN("relations_invalid_pattern"), + + OBJECT_INVALID_PATTERN("object_invalid_pattern"), + + QUERY_STRING_TYPE_CONTINUATION_TOKEN_MISMATCH("query_string_type_continuation_token_mismatch"), + + EXCEEDED_ENTITY_LIMIT("exceeded_entity_limit"), + + INVALID_CONTEXTUAL_TUPLE("invalid_contextual_tuple"), + + DUPLICATE_CONTEXTUAL_TUPLE("duplicate_contextual_tuple"), + + INVALID_AUTHORIZATION_MODEL("invalid_authorization_model"), + + UNSUPPORTED_SCHEMA_VERSION("unsupported_schema_version"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ErrorCode(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ErrorCode fromValue(String value) { + for (ErrorCode b : ErrorCode.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + if (prefix == null) { + prefix = ""; + } + + return String.format("%s=%s", prefix, this.toString()); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ExpandRequest.java b/src/main/java/dev/openfga/sdk/api/model/ExpandRequest.java new file mode 100644 index 0000000..c72bc6c --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ExpandRequest.java @@ -0,0 +1,176 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ExpandRequest + */ +@JsonPropertyOrder({ExpandRequest.JSON_PROPERTY_TUPLE_KEY, ExpandRequest.JSON_PROPERTY_AUTHORIZATION_MODEL_ID}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ExpandRequest { + public static final String JSON_PROPERTY_TUPLE_KEY = "tuple_key"; + private TupleKey tupleKey; + + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public ExpandRequest() {} + + public ExpandRequest tupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + return this; + } + + /** + * Get tupleKey + * @return tupleKey + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TupleKey getTupleKey() { + return tupleKey; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + } + + public ExpandRequest authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + /** + * Return true if this Expand_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExpandRequest expandRequest = (ExpandRequest) o; + return Objects.equals(this.tupleKey, expandRequest.tupleKey) + && Objects.equals(this.authorizationModelId, expandRequest.authorizationModelId); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKey, authorizationModelId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExpandRequest {\n"); + sb.append(" tupleKey: ").append(toIndentedString(tupleKey)).append("\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_key` to the URL query string + if (getTupleKey() != null) { + joiner.add(getTupleKey().toUrlQueryString(prefix + "tuple_key" + suffix)); + } + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ExpandResponse.java b/src/main/java/dev/openfga/sdk/api/model/ExpandResponse.java new file mode 100644 index 0000000..398f97d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ExpandResponse.java @@ -0,0 +1,135 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ExpandResponse + */ +@JsonPropertyOrder({ExpandResponse.JSON_PROPERTY_TREE}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ExpandResponse { + public static final String JSON_PROPERTY_TREE = "tree"; + private UsersetTree tree; + + public ExpandResponse() {} + + public ExpandResponse tree(UsersetTree tree) { + this.tree = tree; + return this; + } + + /** + * Get tree + * @return tree + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TREE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsersetTree getTree() { + return tree; + } + + @JsonProperty(JSON_PROPERTY_TREE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTree(UsersetTree tree) { + this.tree = tree; + } + + /** + * Return true if this ExpandResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExpandResponse expandResponse = (ExpandResponse) o; + return Objects.equals(this.tree, expandResponse.tree); + } + + @Override + public int hashCode() { + return Objects.hash(tree); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExpandResponse {\n"); + sb.append(" tree: ").append(toIndentedString(tree)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tree` to the URL query string + if (getTree() != null) { + joiner.add(getTree().toUrlQueryString(prefix + "tree" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/GetStoreResponse.java b/src/main/java/dev/openfga/sdk/api/model/GetStoreResponse.java new file mode 100644 index 0000000..1b50d1f --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/GetStoreResponse.java @@ -0,0 +1,259 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * GetStoreResponse + */ +@JsonPropertyOrder({ + GetStoreResponse.JSON_PROPERTY_ID, + GetStoreResponse.JSON_PROPERTY_NAME, + GetStoreResponse.JSON_PROPERTY_CREATED_AT, + GetStoreResponse.JSON_PROPERTY_UPDATED_AT +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class GetStoreResponse { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_UPDATED_AT = "updated_at"; + private OffsetDateTime updatedAt; + + public GetStoreResponse() {} + + public GetStoreResponse id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + public GetStoreResponse name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public GetStoreResponse createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public GetStoreResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Get updatedAt + * @return updatedAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + /** + * Return true if this GetStoreResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetStoreResponse getStoreResponse = (GetStoreResponse) o; + return Objects.equals(this.id, getStoreResponse.id) + && Objects.equals(this.name, getStoreResponse.name) + && Objects.equals(this.createdAt, getStoreResponse.createdAt) + && Objects.equals(this.updatedAt, getStoreResponse.updatedAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, createdAt, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetStoreResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `created_at` to the URL query string + if (getCreatedAt() != null) { + joiner.add(String.format( + "%screated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `updated_at` to the URL query string + if (getUpdatedAt() != null) { + joiner.add(String.format( + "%supdated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUpdatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/InternalErrorCode.java b/src/main/java/dev/openfga/sdk/api/model/InternalErrorCode.java new file mode 100644 index 0000000..e0b5b0e --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/InternalErrorCode.java @@ -0,0 +1,85 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets InternalErrorCode + */ +public enum InternalErrorCode { + NO_INTERNAL_ERROR("no_internal_error"), + + INTERNAL_ERROR("internal_error"), + + CANCELLED("cancelled"), + + DEADLINE_EXCEEDED("deadline_exceeded"), + + ALREADY_EXISTS("already_exists"), + + RESOURCE_EXHAUSTED("resource_exhausted"), + + FAILED_PRECONDITION("failed_precondition"), + + ABORTED("aborted"), + + OUT_OF_RANGE("out_of_range"), + + UNAVAILABLE("unavailable"), + + DATA_LOSS("data_loss"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + InternalErrorCode(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InternalErrorCode fromValue(String value) { + for (InternalErrorCode b : InternalErrorCode.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + if (prefix == null) { + prefix = ""; + } + + return String.format("%s=%s", prefix, this.toString()); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/InternalErrorMessageResponse.java b/src/main/java/dev/openfga/sdk/api/model/InternalErrorMessageResponse.java new file mode 100644 index 0000000..bfad17d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/InternalErrorMessageResponse.java @@ -0,0 +1,180 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * InternalErrorMessageResponse + */ +@JsonPropertyOrder({InternalErrorMessageResponse.JSON_PROPERTY_CODE, InternalErrorMessageResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class InternalErrorMessageResponse { + public static final String JSON_PROPERTY_CODE = "code"; + private InternalErrorCode code = InternalErrorCode.NO_INTERNAL_ERROR; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public InternalErrorMessageResponse() {} + + public InternalErrorMessageResponse code(InternalErrorCode code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InternalErrorCode getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(InternalErrorCode code) { + this.code = code; + } + + public InternalErrorMessageResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + /** + * Return true if this InternalErrorMessageResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InternalErrorMessageResponse internalErrorMessageResponse = (InternalErrorMessageResponse) o; + return Objects.equals(this.code, internalErrorMessageResponse.code) + && Objects.equals(this.message, internalErrorMessageResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InternalErrorMessageResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format( + "%scode%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format( + "%smessage%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Leaf.java b/src/main/java/dev/openfga/sdk/api/model/Leaf.java new file mode 100644 index 0000000..2f19981 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Leaf.java @@ -0,0 +1,201 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * A leaf node contains either - a set of users (which may be individual users, or usersets referencing other relations) - a computed node, which is the result of a computed userset value in the authorization model - a tupleToUserset nodes, containing the result of expanding a tupleToUserset value in a authorization model. + */ +@JsonPropertyOrder({Leaf.JSON_PROPERTY_USERS, Leaf.JSON_PROPERTY_COMPUTED, Leaf.JSON_PROPERTY_TUPLE_TO_USERSET}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Leaf { + public static final String JSON_PROPERTY_USERS = "users"; + private Users users; + + public static final String JSON_PROPERTY_COMPUTED = "computed"; + private Computed computed; + + public static final String JSON_PROPERTY_TUPLE_TO_USERSET = "tupleToUserset"; + private UsersetTreeTupleToUserset tupleToUserset; + + public Leaf() {} + + public Leaf users(Users users) { + this.users = users; + return this; + } + + /** + * Get users + * @return users + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Users getUsers() { + return users; + } + + @JsonProperty(JSON_PROPERTY_USERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsers(Users users) { + this.users = users; + } + + public Leaf computed(Computed computed) { + this.computed = computed; + return this; + } + + /** + * Get computed + * @return computed + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPUTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Computed getComputed() { + return computed; + } + + @JsonProperty(JSON_PROPERTY_COMPUTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComputed(Computed computed) { + this.computed = computed; + } + + public Leaf tupleToUserset(UsersetTreeTupleToUserset tupleToUserset) { + this.tupleToUserset = tupleToUserset; + return this; + } + + /** + * Get tupleToUserset + * @return tupleToUserset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLE_TO_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsersetTreeTupleToUserset getTupleToUserset() { + return tupleToUserset; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_TO_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleToUserset(UsersetTreeTupleToUserset tupleToUserset) { + this.tupleToUserset = tupleToUserset; + } + + /** + * Return true if this Leaf object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Leaf leaf = (Leaf) o; + return Objects.equals(this.users, leaf.users) + && Objects.equals(this.computed, leaf.computed) + && Objects.equals(this.tupleToUserset, leaf.tupleToUserset); + } + + @Override + public int hashCode() { + return Objects.hash(users, computed, tupleToUserset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Leaf {\n"); + sb.append(" users: ").append(toIndentedString(users)).append("\n"); + sb.append(" computed: ").append(toIndentedString(computed)).append("\n"); + sb.append(" tupleToUserset: ") + .append(toIndentedString(tupleToUserset)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `users` to the URL query string + if (getUsers() != null) { + joiner.add(getUsers().toUrlQueryString(prefix + "users" + suffix)); + } + + // add `computed` to the URL query string + if (getComputed() != null) { + joiner.add(getComputed().toUrlQueryString(prefix + "computed" + suffix)); + } + + // add `tupleToUserset` to the URL query string + if (getTupleToUserset() != null) { + joiner.add(getTupleToUserset().toUrlQueryString(prefix + "tupleToUserset" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ListObjectsRequest.java b/src/main/java/dev/openfga/sdk/api/model/ListObjectsRequest.java new file mode 100644 index 0000000..50691ed --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ListObjectsRequest.java @@ -0,0 +1,295 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ListObjectsRequest + */ +@JsonPropertyOrder({ + ListObjectsRequest.JSON_PROPERTY_AUTHORIZATION_MODEL_ID, + ListObjectsRequest.JSON_PROPERTY_TYPE, + ListObjectsRequest.JSON_PROPERTY_RELATION, + ListObjectsRequest.JSON_PROPERTY_USER, + ListObjectsRequest.JSON_PROPERTY_CONTEXTUAL_TUPLES +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ListObjectsRequest { + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_RELATION = "relation"; + private String relation; + + public static final String JSON_PROPERTY_USER = "user"; + private String user; + + public static final String JSON_PROPERTY_CONTEXTUAL_TUPLES = "contextual_tuples"; + private ContextualTupleKeys contextualTuples; + + public ListObjectsRequest() {} + + public ListObjectsRequest authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + public ListObjectsRequest type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public ListObjectsRequest relation(String relation) { + this.relation = relation; + return this; + } + + /** + * Get relation + * @return relation + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRelation() { + return relation; + } + + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRelation(String relation) { + this.relation = relation; + } + + public ListObjectsRequest user(String user) { + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_USER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUser() { + return user; + } + + @JsonProperty(JSON_PROPERTY_USER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setUser(String user) { + this.user = user; + } + + public ListObjectsRequest contextualTuples(ContextualTupleKeys contextualTuples) { + this.contextualTuples = contextualTuples; + return this; + } + + /** + * Get contextualTuples + * @return contextualTuples + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTEXTUAL_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ContextualTupleKeys getContextualTuples() { + return contextualTuples; + } + + @JsonProperty(JSON_PROPERTY_CONTEXTUAL_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContextualTuples(ContextualTupleKeys contextualTuples) { + this.contextualTuples = contextualTuples; + } + + /** + * Return true if this ListObjects_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListObjectsRequest listObjectsRequest = (ListObjectsRequest) o; + return Objects.equals(this.authorizationModelId, listObjectsRequest.authorizationModelId) + && Objects.equals(this.type, listObjectsRequest.type) + && Objects.equals(this.relation, listObjectsRequest.relation) + && Objects.equals(this.user, listObjectsRequest.user) + && Objects.equals(this.contextualTuples, listObjectsRequest.contextualTuples); + } + + @Override + public int hashCode() { + return Objects.hash(authorizationModelId, type, relation, user, contextualTuples); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListObjectsRequest {\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" relation: ").append(toIndentedString(relation)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" contextualTuples: ") + .append(toIndentedString(contextualTuples)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `relation` to the URL query string + if (getRelation() != null) { + joiner.add(String.format( + "%srelation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getRelation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `user` to the URL query string + if (getUser() != null) { + joiner.add(String.format( + "%suser%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUser()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `contextual_tuples` to the URL query string + if (getContextualTuples() != null) { + joiner.add(getContextualTuples().toUrlQueryString(prefix + "contextual_tuples" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ListObjectsResponse.java b/src/main/java/dev/openfga/sdk/api/model/ListObjectsResponse.java new file mode 100644 index 0000000..cd4864f --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ListObjectsResponse.java @@ -0,0 +1,155 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ListObjectsResponse + */ +@JsonPropertyOrder({ListObjectsResponse.JSON_PROPERTY_OBJECTS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ListObjectsResponse { + public static final String JSON_PROPERTY_OBJECTS = "objects"; + private List objects = new ArrayList<>(); + + public ListObjectsResponse() {} + + public ListObjectsResponse objects(List objects) { + this.objects = objects; + return this; + } + + public ListObjectsResponse addObjectsItem(String objectsItem) { + if (this.objects == null) { + this.objects = new ArrayList<>(); + } + this.objects.add(objectsItem); + return this; + } + + /** + * Get objects + * @return objects + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OBJECTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getObjects() { + return objects; + } + + @JsonProperty(JSON_PROPERTY_OBJECTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setObjects(List objects) { + this.objects = objects; + } + + /** + * Return true if this ListObjectsResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListObjectsResponse listObjectsResponse = (ListObjectsResponse) o; + return Objects.equals(this.objects, listObjectsResponse.objects); + } + + @Override + public int hashCode() { + return Objects.hash(objects); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListObjectsResponse {\n"); + sb.append(" objects: ").append(toIndentedString(objects)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `objects` to the URL query string + if (getObjects() != null) { + for (int i = 0; i < getObjects().size(); i++) { + joiner.add(String.format( + "%sobjects%s%s=%s", + prefix, + suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getObjects().get(i)), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ListStoresResponse.java b/src/main/java/dev/openfga/sdk/api/model/ListStoresResponse.java new file mode 100644 index 0000000..661c3bb --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ListStoresResponse.java @@ -0,0 +1,198 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ListStoresResponse + */ +@JsonPropertyOrder({ListStoresResponse.JSON_PROPERTY_STORES, ListStoresResponse.JSON_PROPERTY_CONTINUATION_TOKEN}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ListStoresResponse { + public static final String JSON_PROPERTY_STORES = "stores"; + private List stores = new ArrayList<>(); + + public static final String JSON_PROPERTY_CONTINUATION_TOKEN = "continuation_token"; + private String continuationToken; + + public ListStoresResponse() {} + + public ListStoresResponse stores(List stores) { + this.stores = stores; + return this; + } + + public ListStoresResponse addStoresItem(Store storesItem) { + if (this.stores == null) { + this.stores = new ArrayList<>(); + } + this.stores.add(storesItem); + return this; + } + + /** + * Get stores + * @return stores + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STORES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getStores() { + return stores; + } + + @JsonProperty(JSON_PROPERTY_STORES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStores(List stores) { + this.stores = stores; + } + + public ListStoresResponse continuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * The continuation token will be empty if there are no more stores. + * @return continuationToken + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContinuationToken() { + return continuationToken; + } + + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + } + + /** + * Return true if this ListStoresResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListStoresResponse listStoresResponse = (ListStoresResponse) o; + return Objects.equals(this.stores, listStoresResponse.stores) + && Objects.equals(this.continuationToken, listStoresResponse.continuationToken); + } + + @Override + public int hashCode() { + return Objects.hash(stores, continuationToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListStoresResponse {\n"); + sb.append(" stores: ").append(toIndentedString(stores)).append("\n"); + sb.append(" continuationToken: ") + .append(toIndentedString(continuationToken)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `stores` to the URL query string + if (getStores() != null) { + for (int i = 0; i < getStores().size(); i++) { + if (getStores().get(i) != null) { + joiner.add(getStores() + .get(i) + .toUrlQueryString(String.format( + "%sstores%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `continuation_token` to the URL query string + if (getContinuationToken() != null) { + joiner.add(String.format( + "%scontinuation_token%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getContinuationToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Metadata.java b/src/main/java/dev/openfga/sdk/api/model/Metadata.java new file mode 100644 index 0000000..b4d552e --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Metadata.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Metadata + */ +@JsonPropertyOrder({Metadata.JSON_PROPERTY_RELATIONS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Metadata { + public static final String JSON_PROPERTY_RELATIONS = "relations"; + private Map relations = new HashMap<>(); + + public Metadata() {} + + public Metadata relations(Map relations) { + this.relations = relations; + return this; + } + + public Metadata putRelationsItem(String key, RelationMetadata relationsItem) { + if (this.relations == null) { + this.relations = new HashMap<>(); + } + this.relations.put(key, relationsItem); + return this; + } + + /** + * Get relations + * @return relations + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getRelations() { + return relations; + } + + @JsonProperty(JSON_PROPERTY_RELATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRelations(Map relations) { + this.relations = relations; + } + + /** + * Return true if this Metadata object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Metadata metadata = (Metadata) o; + return Objects.equals(this.relations, metadata.relations); + } + + @Override + public int hashCode() { + return Objects.hash(relations); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Metadata {\n"); + sb.append(" relations: ").append(toIndentedString(relations)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `relations` to the URL query string + if (getRelations() != null) { + for (String _key : getRelations().keySet()) { + if (getRelations().get(_key) != null) { + joiner.add(getRelations() + .get(_key) + .toUrlQueryString(String.format( + "%srelations%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Node.java b/src/main/java/dev/openfga/sdk/api/model/Node.java new file mode 100644 index 0000000..9a5455d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Node.java @@ -0,0 +1,276 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Node + */ +@JsonPropertyOrder({ + Node.JSON_PROPERTY_NAME, + Node.JSON_PROPERTY_LEAF, + Node.JSON_PROPERTY_DIFFERENCE, + Node.JSON_PROPERTY_UNION, + Node.JSON_PROPERTY_INTERSECTION +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Node { + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_LEAF = "leaf"; + private Leaf leaf; + + public static final String JSON_PROPERTY_DIFFERENCE = "difference"; + private UsersetTreeDifference difference; + + public static final String JSON_PROPERTY_UNION = "union"; + private Nodes union; + + public static final String JSON_PROPERTY_INTERSECTION = "intersection"; + private Nodes intersection; + + public Node() {} + + public Node name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public Node leaf(Leaf leaf) { + this.leaf = leaf; + return this; + } + + /** + * Get leaf + * @return leaf + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LEAF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Leaf getLeaf() { + return leaf; + } + + @JsonProperty(JSON_PROPERTY_LEAF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLeaf(Leaf leaf) { + this.leaf = leaf; + } + + public Node difference(UsersetTreeDifference difference) { + this.difference = difference; + return this; + } + + /** + * Get difference + * @return difference + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DIFFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsersetTreeDifference getDifference() { + return difference; + } + + @JsonProperty(JSON_PROPERTY_DIFFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDifference(UsersetTreeDifference difference) { + this.difference = difference; + } + + public Node union(Nodes union) { + this.union = union; + return this; + } + + /** + * Get union + * @return union + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UNION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Nodes getUnion() { + return union; + } + + @JsonProperty(JSON_PROPERTY_UNION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUnion(Nodes union) { + this.union = union; + } + + public Node intersection(Nodes intersection) { + this.intersection = intersection; + return this; + } + + /** + * Get intersection + * @return intersection + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INTERSECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Nodes getIntersection() { + return intersection; + } + + @JsonProperty(JSON_PROPERTY_INTERSECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setIntersection(Nodes intersection) { + this.intersection = intersection; + } + + /** + * Return true if this Node object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Node node = (Node) o; + return Objects.equals(this.name, node.name) + && Objects.equals(this.leaf, node.leaf) + && Objects.equals(this.difference, node.difference) + && Objects.equals(this.union, node.union) + && Objects.equals(this.intersection, node.intersection); + } + + @Override + public int hashCode() { + return Objects.hash(name, leaf, difference, union, intersection); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Node {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" leaf: ").append(toIndentedString(leaf)).append("\n"); + sb.append(" difference: ").append(toIndentedString(difference)).append("\n"); + sb.append(" union: ").append(toIndentedString(union)).append("\n"); + sb.append(" intersection: ").append(toIndentedString(intersection)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `leaf` to the URL query string + if (getLeaf() != null) { + joiner.add(getLeaf().toUrlQueryString(prefix + "leaf" + suffix)); + } + + // add `difference` to the URL query string + if (getDifference() != null) { + joiner.add(getDifference().toUrlQueryString(prefix + "difference" + suffix)); + } + + // add `union` to the URL query string + if (getUnion() != null) { + joiner.add(getUnion().toUrlQueryString(prefix + "union" + suffix)); + } + + // add `intersection` to the URL query string + if (getIntersection() != null) { + joiner.add(getIntersection().toUrlQueryString(prefix + "intersection" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Nodes.java b/src/main/java/dev/openfga/sdk/api/model/Nodes.java new file mode 100644 index 0000000..d5b1dee --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Nodes.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Nodes + */ +@JsonPropertyOrder({Nodes.JSON_PROPERTY_NODES}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Nodes { + public static final String JSON_PROPERTY_NODES = "nodes"; + private List nodes = new ArrayList<>(); + + public Nodes() {} + + public Nodes nodes(List nodes) { + this.nodes = nodes; + return this; + } + + public Nodes addNodesItem(Node nodesItem) { + if (this.nodes == null) { + this.nodes = new ArrayList<>(); + } + this.nodes.add(nodesItem); + return this; + } + + /** + * Get nodes + * @return nodes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NODES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getNodes() { + return nodes; + } + + @JsonProperty(JSON_PROPERTY_NODES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNodes(List nodes) { + this.nodes = nodes; + } + + /** + * Return true if this Nodes object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Nodes nodes = (Nodes) o; + return Objects.equals(this.nodes, nodes.nodes); + } + + @Override + public int hashCode() { + return Objects.hash(nodes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Nodes {\n"); + sb.append(" nodes: ").append(toIndentedString(nodes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `nodes` to the URL query string + if (getNodes() != null) { + for (int i = 0; i < getNodes().size(); i++) { + if (getNodes().get(i) != null) { + joiner.add(getNodes() + .get(i) + .toUrlQueryString(String.format( + "%snodes%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/NotFoundErrorCode.java b/src/main/java/dev/openfga/sdk/api/model/NotFoundErrorCode.java new file mode 100644 index 0000000..d6cfdab --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/NotFoundErrorCode.java @@ -0,0 +1,71 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets NotFoundErrorCode + */ +public enum NotFoundErrorCode { + NO_NOT_FOUND_ERROR("no_not_found_error"), + + UNDEFINED_ENDPOINT("undefined_endpoint"), + + STORE_ID_NOT_FOUND("store_id_not_found"), + + UNIMPLEMENTED("unimplemented"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + NotFoundErrorCode(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static NotFoundErrorCode fromValue(String value) { + for (NotFoundErrorCode b : NotFoundErrorCode.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + if (prefix == null) { + prefix = ""; + } + + return String.format("%s=%s", prefix, this.toString()); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ObjectRelation.java b/src/main/java/dev/openfga/sdk/api/model/ObjectRelation.java new file mode 100644 index 0000000..85ce445 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ObjectRelation.java @@ -0,0 +1,179 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ObjectRelation + */ +@JsonPropertyOrder({ObjectRelation.JSON_PROPERTY_OBJECT, ObjectRelation.JSON_PROPERTY_RELATION}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ObjectRelation { + public static final String JSON_PROPERTY_OBJECT = "object"; + private String _object; + + public static final String JSON_PROPERTY_RELATION = "relation"; + private String relation; + + public ObjectRelation() {} + + public ObjectRelation _object(String _object) { + this._object = _object; + return this; + } + + /** + * Get _object + * @return _object + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OBJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getObject() { + return _object; + } + + @JsonProperty(JSON_PROPERTY_OBJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setObject(String _object) { + this._object = _object; + } + + public ObjectRelation relation(String relation) { + this.relation = relation; + return this; + } + + /** + * Get relation + * @return relation + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRelation() { + return relation; + } + + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRelation(String relation) { + this.relation = relation; + } + + /** + * Return true if this ObjectRelation object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObjectRelation objectRelation = (ObjectRelation) o; + return Objects.equals(this._object, objectRelation._object) + && Objects.equals(this.relation, objectRelation.relation); + } + + @Override + public int hashCode() { + return Objects.hash(_object, relation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObjectRelation {\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" relation: ").append(toIndentedString(relation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `object` to the URL query string + if (getObject() != null) { + joiner.add(String.format( + "%sobject%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getObject()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `relation` to the URL query string + if (getRelation() != null) { + joiner.add(String.format( + "%srelation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getRelation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponse.java b/src/main/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponse.java new file mode 100644 index 0000000..c49cba4 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponse.java @@ -0,0 +1,182 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * PathUnknownErrorMessageResponse + */ +@JsonPropertyOrder({ + PathUnknownErrorMessageResponse.JSON_PROPERTY_CODE, + PathUnknownErrorMessageResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class PathUnknownErrorMessageResponse { + public static final String JSON_PROPERTY_CODE = "code"; + private NotFoundErrorCode code = NotFoundErrorCode.NO_NOT_FOUND_ERROR; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public PathUnknownErrorMessageResponse() {} + + public PathUnknownErrorMessageResponse code(NotFoundErrorCode code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotFoundErrorCode getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(NotFoundErrorCode code) { + this.code = code; + } + + public PathUnknownErrorMessageResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + /** + * Return true if this PathUnknownErrorMessageResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PathUnknownErrorMessageResponse pathUnknownErrorMessageResponse = (PathUnknownErrorMessageResponse) o; + return Objects.equals(this.code, pathUnknownErrorMessageResponse.code) + && Objects.equals(this.message, pathUnknownErrorMessageResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PathUnknownErrorMessageResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format( + "%scode%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format( + "%smessage%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadAssertionsResponse.java b/src/main/java/dev/openfga/sdk/api/model/ReadAssertionsResponse.java new file mode 100644 index 0000000..a000837 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadAssertionsResponse.java @@ -0,0 +1,201 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadAssertionsResponse + */ +@JsonPropertyOrder({ + ReadAssertionsResponse.JSON_PROPERTY_AUTHORIZATION_MODEL_ID, + ReadAssertionsResponse.JSON_PROPERTY_ASSERTIONS +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadAssertionsResponse { + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public static final String JSON_PROPERTY_ASSERTIONS = "assertions"; + private List assertions = new ArrayList<>(); + + public ReadAssertionsResponse() {} + + public ReadAssertionsResponse authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + public ReadAssertionsResponse assertions(List assertions) { + this.assertions = assertions; + return this; + } + + public ReadAssertionsResponse addAssertionsItem(Assertion assertionsItem) { + if (this.assertions == null) { + this.assertions = new ArrayList<>(); + } + this.assertions.add(assertionsItem); + return this; + } + + /** + * Get assertions + * @return assertions + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ASSERTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAssertions() { + return assertions; + } + + @JsonProperty(JSON_PROPERTY_ASSERTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAssertions(List assertions) { + this.assertions = assertions; + } + + /** + * Return true if this ReadAssertionsResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadAssertionsResponse readAssertionsResponse = (ReadAssertionsResponse) o; + return Objects.equals(this.authorizationModelId, readAssertionsResponse.authorizationModelId) + && Objects.equals(this.assertions, readAssertionsResponse.assertions); + } + + @Override + public int hashCode() { + return Objects.hash(authorizationModelId, assertions); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadAssertionsResponse {\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append(" assertions: ").append(toIndentedString(assertions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `assertions` to the URL query string + if (getAssertions() != null) { + for (int i = 0; i < getAssertions().size(); i++) { + if (getAssertions().get(i) != null) { + joiner.add(getAssertions() + .get(i) + .toUrlQueryString(String.format( + "%sassertions%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponse.java b/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponse.java new file mode 100644 index 0000000..451790a --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponse.java @@ -0,0 +1,137 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadAuthorizationModelResponse + */ +@JsonPropertyOrder({ReadAuthorizationModelResponse.JSON_PROPERTY_AUTHORIZATION_MODEL}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadAuthorizationModelResponse { + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL = "authorization_model"; + private AuthorizationModel authorizationModel; + + public ReadAuthorizationModelResponse() {} + + public ReadAuthorizationModelResponse authorizationModel(AuthorizationModel authorizationModel) { + this.authorizationModel = authorizationModel; + return this; + } + + /** + * Get authorizationModel + * @return authorizationModel + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AuthorizationModel getAuthorizationModel() { + return authorizationModel; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModel(AuthorizationModel authorizationModel) { + this.authorizationModel = authorizationModel; + } + + /** + * Return true if this ReadAuthorizationModelResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadAuthorizationModelResponse readAuthorizationModelResponse = (ReadAuthorizationModelResponse) o; + return Objects.equals(this.authorizationModel, readAuthorizationModelResponse.authorizationModel); + } + + @Override + public int hashCode() { + return Objects.hash(authorizationModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadAuthorizationModelResponse {\n"); + sb.append(" authorizationModel: ") + .append(toIndentedString(authorizationModel)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `authorization_model` to the URL query string + if (getAuthorizationModel() != null) { + joiner.add(getAuthorizationModel().toUrlQueryString(prefix + "authorization_model" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponse.java b/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponse.java new file mode 100644 index 0000000..160e448 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponse.java @@ -0,0 +1,203 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadAuthorizationModelsResponse + */ +@JsonPropertyOrder({ + ReadAuthorizationModelsResponse.JSON_PROPERTY_AUTHORIZATION_MODELS, + ReadAuthorizationModelsResponse.JSON_PROPERTY_CONTINUATION_TOKEN +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadAuthorizationModelsResponse { + public static final String JSON_PROPERTY_AUTHORIZATION_MODELS = "authorization_models"; + private List authorizationModels = new ArrayList<>(); + + public static final String JSON_PROPERTY_CONTINUATION_TOKEN = "continuation_token"; + private String continuationToken; + + public ReadAuthorizationModelsResponse() {} + + public ReadAuthorizationModelsResponse authorizationModels(List authorizationModels) { + this.authorizationModels = authorizationModels; + return this; + } + + public ReadAuthorizationModelsResponse addAuthorizationModelsItem(AuthorizationModel authorizationModelsItem) { + if (this.authorizationModels == null) { + this.authorizationModels = new ArrayList<>(); + } + this.authorizationModels.add(authorizationModelsItem); + return this; + } + + /** + * Get authorizationModels + * @return authorizationModels + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODELS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAuthorizationModels() { + return authorizationModels; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODELS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModels(List authorizationModels) { + this.authorizationModels = authorizationModels; + } + + public ReadAuthorizationModelsResponse continuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * The continuation token will be empty if there are no more models. + * @return continuationToken + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContinuationToken() { + return continuationToken; + } + + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + } + + /** + * Return true if this ReadAuthorizationModelsResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadAuthorizationModelsResponse readAuthorizationModelsResponse = (ReadAuthorizationModelsResponse) o; + return Objects.equals(this.authorizationModels, readAuthorizationModelsResponse.authorizationModels) + && Objects.equals(this.continuationToken, readAuthorizationModelsResponse.continuationToken); + } + + @Override + public int hashCode() { + return Objects.hash(authorizationModels, continuationToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadAuthorizationModelsResponse {\n"); + sb.append(" authorizationModels: ") + .append(toIndentedString(authorizationModels)) + .append("\n"); + sb.append(" continuationToken: ") + .append(toIndentedString(continuationToken)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `authorization_models` to the URL query string + if (getAuthorizationModels() != null) { + for (int i = 0; i < getAuthorizationModels().size(); i++) { + if (getAuthorizationModels().get(i) != null) { + joiner.add(getAuthorizationModels() + .get(i) + .toUrlQueryString(String.format( + "%sauthorization_models%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `continuation_token` to the URL query string + if (getContinuationToken() != null) { + joiner.add(String.format( + "%scontinuation_token%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getContinuationToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadChangesResponse.java b/src/main/java/dev/openfga/sdk/api/model/ReadChangesResponse.java new file mode 100644 index 0000000..9513006 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadChangesResponse.java @@ -0,0 +1,198 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadChangesResponse + */ +@JsonPropertyOrder({ReadChangesResponse.JSON_PROPERTY_CHANGES, ReadChangesResponse.JSON_PROPERTY_CONTINUATION_TOKEN}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadChangesResponse { + public static final String JSON_PROPERTY_CHANGES = "changes"; + private List changes = new ArrayList<>(); + + public static final String JSON_PROPERTY_CONTINUATION_TOKEN = "continuation_token"; + private String continuationToken; + + public ReadChangesResponse() {} + + public ReadChangesResponse changes(List changes) { + this.changes = changes; + return this; + } + + public ReadChangesResponse addChangesItem(TupleChange changesItem) { + if (this.changes == null) { + this.changes = new ArrayList<>(); + } + this.changes.add(changesItem); + return this; + } + + /** + * Get changes + * @return changes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getChanges() { + return changes; + } + + @JsonProperty(JSON_PROPERTY_CHANGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setChanges(List changes) { + this.changes = changes; + } + + public ReadChangesResponse continuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * The continuation token will be identical if there are no new changes. + * @return continuationToken + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContinuationToken() { + return continuationToken; + } + + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + } + + /** + * Return true if this ReadChangesResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadChangesResponse readChangesResponse = (ReadChangesResponse) o; + return Objects.equals(this.changes, readChangesResponse.changes) + && Objects.equals(this.continuationToken, readChangesResponse.continuationToken); + } + + @Override + public int hashCode() { + return Objects.hash(changes, continuationToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadChangesResponse {\n"); + sb.append(" changes: ").append(toIndentedString(changes)).append("\n"); + sb.append(" continuationToken: ") + .append(toIndentedString(continuationToken)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `changes` to the URL query string + if (getChanges() != null) { + for (int i = 0; i < getChanges().size(); i++) { + if (getChanges().get(i) != null) { + joiner.add(getChanges() + .get(i) + .toUrlQueryString(String.format( + "%schanges%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `continuation_token` to the URL query string + if (getContinuationToken() != null) { + joiner.add(String.format( + "%scontinuation_token%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getContinuationToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadRequest.java b/src/main/java/dev/openfga/sdk/api/model/ReadRequest.java new file mode 100644 index 0000000..4bb875e --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadRequest.java @@ -0,0 +1,217 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadRequest + */ +@JsonPropertyOrder({ + ReadRequest.JSON_PROPERTY_TUPLE_KEY, + ReadRequest.JSON_PROPERTY_PAGE_SIZE, + ReadRequest.JSON_PROPERTY_CONTINUATION_TOKEN +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadRequest { + public static final String JSON_PROPERTY_TUPLE_KEY = "tuple_key"; + private TupleKey tupleKey; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + private Integer pageSize; + + public static final String JSON_PROPERTY_CONTINUATION_TOKEN = "continuation_token"; + private String continuationToken; + + public ReadRequest() {} + + public ReadRequest tupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + return this; + } + + /** + * Get tupleKey + * @return tupleKey + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleKey getTupleKey() { + return tupleKey; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + } + + public ReadRequest pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Get pageSize + * @return pageSize + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPageSize() { + return pageSize; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public ReadRequest continuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * Get continuationToken + * @return continuationToken + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContinuationToken() { + return continuationToken; + } + + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + } + + /** + * Return true if this Read_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadRequest readRequest = (ReadRequest) o; + return Objects.equals(this.tupleKey, readRequest.tupleKey) + && Objects.equals(this.pageSize, readRequest.pageSize) + && Objects.equals(this.continuationToken, readRequest.continuationToken); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKey, pageSize, continuationToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadRequest {\n"); + sb.append(" tupleKey: ").append(toIndentedString(tupleKey)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" continuationToken: ") + .append(toIndentedString(continuationToken)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_key` to the URL query string + if (getTupleKey() != null) { + joiner.add(getTupleKey().toUrlQueryString(prefix + "tuple_key" + suffix)); + } + + // add `page_size` to the URL query string + if (getPageSize() != null) { + joiner.add(String.format( + "%spage_size%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getPageSize()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `continuation_token` to the URL query string + if (getContinuationToken() != null) { + joiner.add(String.format( + "%scontinuation_token%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getContinuationToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ReadResponse.java b/src/main/java/dev/openfga/sdk/api/model/ReadResponse.java new file mode 100644 index 0000000..761e71c --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ReadResponse.java @@ -0,0 +1,198 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ReadResponse + */ +@JsonPropertyOrder({ReadResponse.JSON_PROPERTY_TUPLES, ReadResponse.JSON_PROPERTY_CONTINUATION_TOKEN}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ReadResponse { + public static final String JSON_PROPERTY_TUPLES = "tuples"; + private List tuples = new ArrayList<>(); + + public static final String JSON_PROPERTY_CONTINUATION_TOKEN = "continuation_token"; + private String continuationToken; + + public ReadResponse() {} + + public ReadResponse tuples(List tuples) { + this.tuples = tuples; + return this; + } + + public ReadResponse addTuplesItem(Tuple tuplesItem) { + if (this.tuples == null) { + this.tuples = new ArrayList<>(); + } + this.tuples.add(tuplesItem); + return this; + } + + /** + * Get tuples + * @return tuples + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTuples() { + return tuples; + } + + @JsonProperty(JSON_PROPERTY_TUPLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTuples(List tuples) { + this.tuples = tuples; + } + + public ReadResponse continuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * The continuation token will be empty if there are no more tuples. + * @return continuationToken + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContinuationToken() { + return continuationToken; + } + + @JsonProperty(JSON_PROPERTY_CONTINUATION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + } + + /** + * Return true if this ReadResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadResponse readResponse = (ReadResponse) o; + return Objects.equals(this.tuples, readResponse.tuples) + && Objects.equals(this.continuationToken, readResponse.continuationToken); + } + + @Override + public int hashCode() { + return Objects.hash(tuples, continuationToken); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadResponse {\n"); + sb.append(" tuples: ").append(toIndentedString(tuples)).append("\n"); + sb.append(" continuationToken: ") + .append(toIndentedString(continuationToken)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuples` to the URL query string + if (getTuples() != null) { + for (int i = 0; i < getTuples().size(); i++) { + if (getTuples().get(i) != null) { + joiner.add(getTuples() + .get(i) + .toUrlQueryString(String.format( + "%stuples%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `continuation_token` to the URL query string + if (getContinuationToken() != null) { + joiner.add(String.format( + "%scontinuation_token%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getContinuationToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/RelationMetadata.java b/src/main/java/dev/openfga/sdk/api/model/RelationMetadata.java new file mode 100644 index 0000000..60d6722 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/RelationMetadata.java @@ -0,0 +1,159 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * RelationMetadata + */ +@JsonPropertyOrder({RelationMetadata.JSON_PROPERTY_DIRECTLY_RELATED_USER_TYPES}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class RelationMetadata { + public static final String JSON_PROPERTY_DIRECTLY_RELATED_USER_TYPES = "directly_related_user_types"; + private List directlyRelatedUserTypes = new ArrayList<>(); + + public RelationMetadata() {} + + public RelationMetadata directlyRelatedUserTypes(List directlyRelatedUserTypes) { + this.directlyRelatedUserTypes = directlyRelatedUserTypes; + return this; + } + + public RelationMetadata addDirectlyRelatedUserTypesItem(RelationReference directlyRelatedUserTypesItem) { + if (this.directlyRelatedUserTypes == null) { + this.directlyRelatedUserTypes = new ArrayList<>(); + } + this.directlyRelatedUserTypes.add(directlyRelatedUserTypesItem); + return this; + } + + /** + * Get directlyRelatedUserTypes + * @return directlyRelatedUserTypes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DIRECTLY_RELATED_USER_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDirectlyRelatedUserTypes() { + return directlyRelatedUserTypes; + } + + @JsonProperty(JSON_PROPERTY_DIRECTLY_RELATED_USER_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDirectlyRelatedUserTypes(List directlyRelatedUserTypes) { + this.directlyRelatedUserTypes = directlyRelatedUserTypes; + } + + /** + * Return true if this RelationMetadata object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelationMetadata relationMetadata = (RelationMetadata) o; + return Objects.equals(this.directlyRelatedUserTypes, relationMetadata.directlyRelatedUserTypes); + } + + @Override + public int hashCode() { + return Objects.hash(directlyRelatedUserTypes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelationMetadata {\n"); + sb.append(" directlyRelatedUserTypes: ") + .append(toIndentedString(directlyRelatedUserTypes)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `directly_related_user_types` to the URL query string + if (getDirectlyRelatedUserTypes() != null) { + for (int i = 0; i < getDirectlyRelatedUserTypes().size(); i++) { + if (getDirectlyRelatedUserTypes().get(i) != null) { + joiner.add(getDirectlyRelatedUserTypes() + .get(i) + .toUrlQueryString(String.format( + "%sdirectly_related_user_types%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/RelationReference.java b/src/main/java/dev/openfga/sdk/api/model/RelationReference.java new file mode 100644 index 0000000..ea8636d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/RelationReference.java @@ -0,0 +1,220 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * RelationReference represents a relation of a particular object type (e.g. 'document#viewer'). + */ +@JsonPropertyOrder({ + RelationReference.JSON_PROPERTY_TYPE, + RelationReference.JSON_PROPERTY_RELATION, + RelationReference.JSON_PROPERTY_WILDCARD +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class RelationReference { + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_RELATION = "relation"; + private String relation; + + public static final String JSON_PROPERTY_WILDCARD = "wildcard"; + private Object wildcard; + + public RelationReference() {} + + public RelationReference type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public RelationReference relation(String relation) { + this.relation = relation; + return this; + } + + /** + * Get relation + * @return relation + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRelation() { + return relation; + } + + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRelation(String relation) { + this.relation = relation; + } + + public RelationReference wildcard(Object wildcard) { + this.wildcard = wildcard; + return this; + } + + /** + * Get wildcard + * @return wildcard + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_WILDCARD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getWildcard() { + return wildcard; + } + + @JsonProperty(JSON_PROPERTY_WILDCARD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWildcard(Object wildcard) { + this.wildcard = wildcard; + } + + /** + * Return true if this RelationReference object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelationReference relationReference = (RelationReference) o; + return Objects.equals(this.type, relationReference.type) + && Objects.equals(this.relation, relationReference.relation) + && Objects.equals(this.wildcard, relationReference.wildcard); + } + + @Override + public int hashCode() { + return Objects.hash(type, relation, wildcard); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelationReference {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" relation: ").append(toIndentedString(relation)).append("\n"); + sb.append(" wildcard: ").append(toIndentedString(wildcard)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `relation` to the URL query string + if (getRelation() != null) { + joiner.add(String.format( + "%srelation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getRelation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `wildcard` to the URL query string + if (getWildcard() != null) { + joiner.add(String.format( + "%swildcard%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getWildcard()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Status.java b/src/main/java/dev/openfga/sdk/api/model/Status.java new file mode 100644 index 0000000..67d8bf9 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Status.java @@ -0,0 +1,231 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Status + */ +@JsonPropertyOrder({Status.JSON_PROPERTY_CODE, Status.JSON_PROPERTY_MESSAGE, Status.JSON_PROPERTY_DETAILS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Status { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public static final String JSON_PROPERTY_DETAILS = "details"; + private List details = new ArrayList<>(); + + public Status() {} + + public Status code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + public Status message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + public Status details(List details) { + this.details = details; + return this; + } + + public Status addDetailsItem(Any detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * @return details + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDetails() { + return details; + } + + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetails(List details) { + this.details = details; + } + + /** + * Return true if this Status object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Status status = (Status) o; + return Objects.equals(this.code, status.code) + && Objects.equals(this.message, status.message) + && Objects.equals(this.details, status.details); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, details); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Status {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format( + "%scode%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format( + "%smessage%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `details` to the URL query string + if (getDetails() != null) { + for (int i = 0; i < getDetails().size(); i++) { + if (getDetails().get(i) != null) { + joiner.add(String.format( + "%sdetails%s%s=%s", + prefix, + suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getDetails().get(i)), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Store.java b/src/main/java/dev/openfga/sdk/api/model/Store.java new file mode 100644 index 0000000..9153840 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Store.java @@ -0,0 +1,297 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Store + */ +@JsonPropertyOrder({ + Store.JSON_PROPERTY_ID, + Store.JSON_PROPERTY_NAME, + Store.JSON_PROPERTY_CREATED_AT, + Store.JSON_PROPERTY_UPDATED_AT, + Store.JSON_PROPERTY_DELETED_AT +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Store { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_UPDATED_AT = "updated_at"; + private OffsetDateTime updatedAt; + + public static final String JSON_PROPERTY_DELETED_AT = "deleted_at"; + private OffsetDateTime deletedAt; + + public Store() {} + + public Store id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + public Store name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public Store createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public Store updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Get updatedAt + * @return updatedAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public Store deletedAt(OffsetDateTime deletedAt) { + this.deletedAt = deletedAt; + return this; + } + + /** + * Get deletedAt + * @return deletedAt + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DELETED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getDeletedAt() { + return deletedAt; + } + + @JsonProperty(JSON_PROPERTY_DELETED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeletedAt(OffsetDateTime deletedAt) { + this.deletedAt = deletedAt; + } + + /** + * Return true if this Store object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Store store = (Store) o; + return Objects.equals(this.id, store.id) + && Objects.equals(this.name, store.name) + && Objects.equals(this.createdAt, store.createdAt) + && Objects.equals(this.updatedAt, store.updatedAt) + && Objects.equals(this.deletedAt, store.deletedAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, createdAt, updatedAt, deletedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Store {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" deletedAt: ").append(toIndentedString(deletedAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `created_at` to the URL query string + if (getCreatedAt() != null) { + joiner.add(String.format( + "%screated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `updated_at` to the URL query string + if (getUpdatedAt() != null) { + joiner.add(String.format( + "%supdated_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUpdatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `deleted_at` to the URL query string + if (getDeletedAt() != null) { + joiner.add(String.format( + "%sdeleted_at%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getDeletedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Tuple.java b/src/main/java/dev/openfga/sdk/api/model/Tuple.java new file mode 100644 index 0000000..ee2cf60 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Tuple.java @@ -0,0 +1,174 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Tuple + */ +@JsonPropertyOrder({Tuple.JSON_PROPERTY_KEY, Tuple.JSON_PROPERTY_TIMESTAMP}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Tuple { + public static final String JSON_PROPERTY_KEY = "key"; + private TupleKey key; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private OffsetDateTime timestamp; + + public Tuple() {} + + public Tuple key(TupleKey key) { + this.key = key; + return this; + } + + /** + * Get key + * @return key + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleKey getKey() { + return key; + } + + @JsonProperty(JSON_PROPERTY_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setKey(TupleKey key) { + this.key = key; + } + + public Tuple timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * @return timestamp + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Return true if this Tuple object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tuple tuple = (Tuple) o; + return Objects.equals(this.key, tuple.key) && Objects.equals(this.timestamp, tuple.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(key, timestamp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tuple {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `key` to the URL query string + if (getKey() != null) { + joiner.add(getKey().toUrlQueryString(prefix + "key" + suffix)); + } + + // add `timestamp` to the URL query string + if (getTimestamp() != null) { + joiner.add(String.format( + "%stimestamp%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getTimestamp()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TupleChange.java b/src/main/java/dev/openfga/sdk/api/model/TupleChange.java new file mode 100644 index 0000000..4597ecd --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TupleChange.java @@ -0,0 +1,216 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * TupleChange + */ +@JsonPropertyOrder({ + TupleChange.JSON_PROPERTY_TUPLE_KEY, + TupleChange.JSON_PROPERTY_OPERATION, + TupleChange.JSON_PROPERTY_TIMESTAMP +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class TupleChange { + public static final String JSON_PROPERTY_TUPLE_KEY = "tuple_key"; + private TupleKey tupleKey; + + public static final String JSON_PROPERTY_OPERATION = "operation"; + private TupleOperation operation = TupleOperation.WRITE; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private OffsetDateTime timestamp; + + public TupleChange() {} + + public TupleChange tupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + return this; + } + + /** + * Get tupleKey + * @return tupleKey + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleKey getTupleKey() { + return tupleKey; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleKey(TupleKey tupleKey) { + this.tupleKey = tupleKey; + } + + public TupleChange operation(TupleOperation operation) { + this.operation = operation; + return this; + } + + /** + * Get operation + * @return operation + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OPERATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleOperation getOperation() { + return operation; + } + + @JsonProperty(JSON_PROPERTY_OPERATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperation(TupleOperation operation) { + this.operation = operation; + } + + public TupleChange timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * @return timestamp + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Return true if this TupleChange object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TupleChange tupleChange = (TupleChange) o; + return Objects.equals(this.tupleKey, tupleChange.tupleKey) + && Objects.equals(this.operation, tupleChange.operation) + && Objects.equals(this.timestamp, tupleChange.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKey, operation, timestamp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TupleChange {\n"); + sb.append(" tupleKey: ").append(toIndentedString(tupleKey)).append("\n"); + sb.append(" operation: ").append(toIndentedString(operation)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_key` to the URL query string + if (getTupleKey() != null) { + joiner.add(getTupleKey().toUrlQueryString(prefix + "tuple_key" + suffix)); + } + + // add `operation` to the URL query string + if (getOperation() != null) { + joiner.add(String.format( + "%soperation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getOperation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `timestamp` to the URL query string + if (getTimestamp() != null) { + joiner.add(String.format( + "%stimestamp%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getTimestamp()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TupleKey.java b/src/main/java/dev/openfga/sdk/api/model/TupleKey.java new file mode 100644 index 0000000..2ff5438 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TupleKey.java @@ -0,0 +1,216 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * TupleKey + */ +@JsonPropertyOrder({TupleKey.JSON_PROPERTY_OBJECT, TupleKey.JSON_PROPERTY_RELATION, TupleKey.JSON_PROPERTY_USER}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class TupleKey { + public static final String JSON_PROPERTY_OBJECT = "object"; + private String _object; + + public static final String JSON_PROPERTY_RELATION = "relation"; + private String relation; + + public static final String JSON_PROPERTY_USER = "user"; + private String user; + + public TupleKey() {} + + public TupleKey _object(String _object) { + this._object = _object; + return this; + } + + /** + * Get _object + * @return _object + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OBJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getObject() { + return _object; + } + + @JsonProperty(JSON_PROPERTY_OBJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setObject(String _object) { + this._object = _object; + } + + public TupleKey relation(String relation) { + this.relation = relation; + return this; + } + + /** + * Get relation + * @return relation + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRelation() { + return relation; + } + + @JsonProperty(JSON_PROPERTY_RELATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRelation(String relation) { + this.relation = relation; + } + + public TupleKey user(String user) { + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUser() { + return user; + } + + @JsonProperty(JSON_PROPERTY_USER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUser(String user) { + this.user = user; + } + + /** + * Return true if this TupleKey object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TupleKey tupleKey = (TupleKey) o; + return Objects.equals(this._object, tupleKey._object) + && Objects.equals(this.relation, tupleKey.relation) + && Objects.equals(this.user, tupleKey.user); + } + + @Override + public int hashCode() { + return Objects.hash(_object, relation, user); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TupleKey {\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" relation: ").append(toIndentedString(relation)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `object` to the URL query string + if (getObject() != null) { + joiner.add(String.format( + "%sobject%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getObject()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `relation` to the URL query string + if (getRelation() != null) { + joiner.add(String.format( + "%srelation%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getRelation()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `user` to the URL query string + if (getUser() != null) { + joiner.add(String.format( + "%suser%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getUser()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TupleKeys.java b/src/main/java/dev/openfga/sdk/api/model/TupleKeys.java new file mode 100644 index 0000000..182d3a1 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TupleKeys.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * TupleKeys + */ +@JsonPropertyOrder({TupleKeys.JSON_PROPERTY_TUPLE_KEYS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class TupleKeys { + public static final String JSON_PROPERTY_TUPLE_KEYS = "tuple_keys"; + private List tupleKeys = new ArrayList<>(); + + public TupleKeys() {} + + public TupleKeys tupleKeys(List tupleKeys) { + this.tupleKeys = tupleKeys; + return this; + } + + public TupleKeys addTupleKeysItem(TupleKey tupleKeysItem) { + if (this.tupleKeys == null) { + this.tupleKeys = new ArrayList<>(); + } + this.tupleKeys.add(tupleKeysItem); + return this; + } + + /** + * Get tupleKeys + * @return tupleKeys + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TUPLE_KEYS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTupleKeys() { + return tupleKeys; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_KEYS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTupleKeys(List tupleKeys) { + this.tupleKeys = tupleKeys; + } + + /** + * Return true if this TupleKeys object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TupleKeys tupleKeys = (TupleKeys) o; + return Objects.equals(this.tupleKeys, tupleKeys.tupleKeys); + } + + @Override + public int hashCode() { + return Objects.hash(tupleKeys); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TupleKeys {\n"); + sb.append(" tupleKeys: ").append(toIndentedString(tupleKeys)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tuple_keys` to the URL query string + if (getTupleKeys() != null) { + for (int i = 0; i < getTupleKeys().size(); i++) { + if (getTupleKeys().get(i) != null) { + joiner.add(getTupleKeys() + .get(i) + .toUrlQueryString(String.format( + "%stuple_keys%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TupleOperation.java b/src/main/java/dev/openfga/sdk/api/model/TupleOperation.java new file mode 100644 index 0000000..b1025ff --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TupleOperation.java @@ -0,0 +1,67 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Gets or Sets TupleOperation + */ +public enum TupleOperation { + WRITE("TUPLE_OPERATION_WRITE"), + + DELETE("TUPLE_OPERATION_DELETE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TupleOperation(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TupleOperation fromValue(String value) { + for (TupleOperation b : TupleOperation.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + if (prefix == null) { + prefix = ""; + } + + return String.format("%s=%s", prefix, this.toString()); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TupleToUserset.java b/src/main/java/dev/openfga/sdk/api/model/TupleToUserset.java new file mode 100644 index 0000000..c42e069 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TupleToUserset.java @@ -0,0 +1,169 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * TupleToUserset + */ +@JsonPropertyOrder({TupleToUserset.JSON_PROPERTY_TUPLESET, TupleToUserset.JSON_PROPERTY_COMPUTED_USERSET}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class TupleToUserset { + public static final String JSON_PROPERTY_TUPLESET = "tupleset"; + private ObjectRelation tupleset; + + public static final String JSON_PROPERTY_COMPUTED_USERSET = "computedUserset"; + private ObjectRelation computedUserset; + + public TupleToUserset() {} + + public TupleToUserset tupleset(ObjectRelation tupleset) { + this.tupleset = tupleset; + return this; + } + + /** + * Get tupleset + * @return tupleset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLESET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObjectRelation getTupleset() { + return tupleset; + } + + @JsonProperty(JSON_PROPERTY_TUPLESET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleset(ObjectRelation tupleset) { + this.tupleset = tupleset; + } + + public TupleToUserset computedUserset(ObjectRelation computedUserset) { + this.computedUserset = computedUserset; + return this; + } + + /** + * Get computedUserset + * @return computedUserset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPUTED_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObjectRelation getComputedUserset() { + return computedUserset; + } + + @JsonProperty(JSON_PROPERTY_COMPUTED_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComputedUserset(ObjectRelation computedUserset) { + this.computedUserset = computedUserset; + } + + /** + * Return true if this TupleToUserset object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TupleToUserset tupleToUserset = (TupleToUserset) o; + return Objects.equals(this.tupleset, tupleToUserset.tupleset) + && Objects.equals(this.computedUserset, tupleToUserset.computedUserset); + } + + @Override + public int hashCode() { + return Objects.hash(tupleset, computedUserset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TupleToUserset {\n"); + sb.append(" tupleset: ").append(toIndentedString(tupleset)).append("\n"); + sb.append(" computedUserset: ") + .append(toIndentedString(computedUserset)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tupleset` to the URL query string + if (getTupleset() != null) { + joiner.add(getTupleset().toUrlQueryString(prefix + "tupleset" + suffix)); + } + + // add `computedUserset` to the URL query string + if (getComputedUserset() != null) { + joiner.add(getComputedUserset().toUrlQueryString(prefix + "computedUserset" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/TypeDefinition.java b/src/main/java/dev/openfga/sdk/api/model/TypeDefinition.java new file mode 100644 index 0000000..83a4c55 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/TypeDefinition.java @@ -0,0 +1,232 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * TypeDefinition + */ +@JsonPropertyOrder({ + TypeDefinition.JSON_PROPERTY_TYPE, + TypeDefinition.JSON_PROPERTY_RELATIONS, + TypeDefinition.JSON_PROPERTY_METADATA +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class TypeDefinition { + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_RELATIONS = "relations"; + private Map relations = new HashMap<>(); + + public static final String JSON_PROPERTY_METADATA = "metadata"; + private Metadata metadata; + + public TypeDefinition() {} + + public TypeDefinition type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public TypeDefinition relations(Map relations) { + this.relations = relations; + return this; + } + + public TypeDefinition putRelationsItem(String key, Userset relationsItem) { + if (this.relations == null) { + this.relations = new HashMap<>(); + } + this.relations.put(key, relationsItem); + return this; + } + + /** + * Get relations + * @return relations + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getRelations() { + return relations; + } + + @JsonProperty(JSON_PROPERTY_RELATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRelations(Map relations) { + this.relations = relations; + } + + public TypeDefinition metadata(Metadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get metadata + * @return metadata + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Metadata getMetadata() { + return metadata; + } + + @JsonProperty(JSON_PROPERTY_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMetadata(Metadata metadata) { + this.metadata = metadata; + } + + /** + * Return true if this TypeDefinition object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TypeDefinition typeDefinition = (TypeDefinition) o; + return Objects.equals(this.type, typeDefinition.type) + && Objects.equals(this.relations, typeDefinition.relations) + && Objects.equals(this.metadata, typeDefinition.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(type, relations, metadata); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TypeDefinition {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" relations: ").append(toIndentedString(relations)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `relations` to the URL query string + if (getRelations() != null) { + for (String _key : getRelations().keySet()) { + if (getRelations().get(_key) != null) { + joiner.add(getRelations() + .get(_key) + .toUrlQueryString(String.format( + "%srelations%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + } + } + } + + // add `metadata` to the URL query string + if (getMetadata() != null) { + joiner.add(getMetadata().toUrlQueryString(prefix + "metadata" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Users.java b/src/main/java/dev/openfga/sdk/api/model/Users.java new file mode 100644 index 0000000..dad9f86 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Users.java @@ -0,0 +1,155 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Users + */ +@JsonPropertyOrder({Users.JSON_PROPERTY_USERS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Users { + public static final String JSON_PROPERTY_USERS = "users"; + private List users = new ArrayList<>(); + + public Users() {} + + public Users users(List users) { + this.users = users; + return this; + } + + public Users addUsersItem(String usersItem) { + if (this.users == null) { + this.users = new ArrayList<>(); + } + this.users.add(usersItem); + return this; + } + + /** + * Get users + * @return users + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getUsers() { + return users; + } + + @JsonProperty(JSON_PROPERTY_USERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUsers(List users) { + this.users = users; + } + + /** + * Return true if this Users object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Users users = (Users) o; + return Objects.equals(this.users, users.users); + } + + @Override + public int hashCode() { + return Objects.hash(users); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Users {\n"); + sb.append(" users: ").append(toIndentedString(users)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `users` to the URL query string + if (getUsers() != null) { + for (int i = 0; i < getUsers().size(); i++) { + joiner.add(String.format( + "%susers%s%s=%s", + prefix, + suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getUsers().get(i)), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Userset.java b/src/main/java/dev/openfga/sdk/api/model/Userset.java new file mode 100644 index 0000000..d97f810 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Userset.java @@ -0,0 +1,313 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Userset + */ +@JsonPropertyOrder({ + Userset.JSON_PROPERTY_THIS, + Userset.JSON_PROPERTY_COMPUTED_USERSET, + Userset.JSON_PROPERTY_TUPLE_TO_USERSET, + Userset.JSON_PROPERTY_UNION, + Userset.JSON_PROPERTY_INTERSECTION, + Userset.JSON_PROPERTY_DIFFERENCE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Userset { + public static final String JSON_PROPERTY_THIS = "this"; + private Object _this; + + public static final String JSON_PROPERTY_COMPUTED_USERSET = "computedUserset"; + private ObjectRelation computedUserset; + + public static final String JSON_PROPERTY_TUPLE_TO_USERSET = "tupleToUserset"; + private TupleToUserset tupleToUserset; + + public static final String JSON_PROPERTY_UNION = "union"; + private Usersets union; + + public static final String JSON_PROPERTY_INTERSECTION = "intersection"; + private Usersets intersection; + + public static final String JSON_PROPERTY_DIFFERENCE = "difference"; + private Difference difference; + + public Userset() {} + + public Userset _this(Object _this) { + this._this = _this; + return this; + } + + /** + * A DirectUserset is a sentinel message for referencing the direct members specified by an object/relation mapping. + * @return _this + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_THIS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Object getThis() { + return _this; + } + + @JsonProperty(JSON_PROPERTY_THIS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setThis(Object _this) { + this._this = _this; + } + + public Userset computedUserset(ObjectRelation computedUserset) { + this.computedUserset = computedUserset; + return this; + } + + /** + * Get computedUserset + * @return computedUserset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPUTED_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObjectRelation getComputedUserset() { + return computedUserset; + } + + @JsonProperty(JSON_PROPERTY_COMPUTED_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComputedUserset(ObjectRelation computedUserset) { + this.computedUserset = computedUserset; + } + + public Userset tupleToUserset(TupleToUserset tupleToUserset) { + this.tupleToUserset = tupleToUserset; + return this; + } + + /** + * Get tupleToUserset + * @return tupleToUserset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLE_TO_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleToUserset getTupleToUserset() { + return tupleToUserset; + } + + @JsonProperty(JSON_PROPERTY_TUPLE_TO_USERSET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleToUserset(TupleToUserset tupleToUserset) { + this.tupleToUserset = tupleToUserset; + } + + public Userset union(Usersets union) { + this.union = union; + return this; + } + + /** + * Get union + * @return union + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UNION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Usersets getUnion() { + return union; + } + + @JsonProperty(JSON_PROPERTY_UNION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUnion(Usersets union) { + this.union = union; + } + + public Userset intersection(Usersets intersection) { + this.intersection = intersection; + return this; + } + + /** + * Get intersection + * @return intersection + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INTERSECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Usersets getIntersection() { + return intersection; + } + + @JsonProperty(JSON_PROPERTY_INTERSECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setIntersection(Usersets intersection) { + this.intersection = intersection; + } + + public Userset difference(Difference difference) { + this.difference = difference; + return this; + } + + /** + * Get difference + * @return difference + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DIFFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Difference getDifference() { + return difference; + } + + @JsonProperty(JSON_PROPERTY_DIFFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDifference(Difference difference) { + this.difference = difference; + } + + /** + * Return true if this Userset object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Userset userset = (Userset) o; + return Objects.equals(this._this, userset._this) + && Objects.equals(this.computedUserset, userset.computedUserset) + && Objects.equals(this.tupleToUserset, userset.tupleToUserset) + && Objects.equals(this.union, userset.union) + && Objects.equals(this.intersection, userset.intersection) + && Objects.equals(this.difference, userset.difference); + } + + @Override + public int hashCode() { + return Objects.hash(_this, computedUserset, tupleToUserset, union, intersection, difference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Userset {\n"); + sb.append(" _this: ").append(toIndentedString(_this)).append("\n"); + sb.append(" computedUserset: ") + .append(toIndentedString(computedUserset)) + .append("\n"); + sb.append(" tupleToUserset: ") + .append(toIndentedString(tupleToUserset)) + .append("\n"); + sb.append(" union: ").append(toIndentedString(union)).append("\n"); + sb.append(" intersection: ").append(toIndentedString(intersection)).append("\n"); + sb.append(" difference: ").append(toIndentedString(difference)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `this` to the URL query string + if (getThis() != null) { + joiner.add(String.format( + "%sthis%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getThis()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `computedUserset` to the URL query string + if (getComputedUserset() != null) { + joiner.add(getComputedUserset().toUrlQueryString(prefix + "computedUserset" + suffix)); + } + + // add `tupleToUserset` to the URL query string + if (getTupleToUserset() != null) { + joiner.add(getTupleToUserset().toUrlQueryString(prefix + "tupleToUserset" + suffix)); + } + + // add `union` to the URL query string + if (getUnion() != null) { + joiner.add(getUnion().toUrlQueryString(prefix + "union" + suffix)); + } + + // add `intersection` to the URL query string + if (getIntersection() != null) { + joiner.add(getIntersection().toUrlQueryString(prefix + "intersection" + suffix)); + } + + // add `difference` to the URL query string + if (getDifference() != null) { + joiner.add(getDifference().toUrlQueryString(prefix + "difference" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/UsersetTree.java b/src/main/java/dev/openfga/sdk/api/model/UsersetTree.java new file mode 100644 index 0000000..98b89ed --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/UsersetTree.java @@ -0,0 +1,135 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * A UsersetTree contains the result of an Expansion. + */ +@JsonPropertyOrder({UsersetTree.JSON_PROPERTY_ROOT}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class UsersetTree { + public static final String JSON_PROPERTY_ROOT = "root"; + private Node root; + + public UsersetTree() {} + + public UsersetTree root(Node root) { + this.root = root; + return this; + } + + /** + * Get root + * @return root + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ROOT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Node getRoot() { + return root; + } + + @JsonProperty(JSON_PROPERTY_ROOT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRoot(Node root) { + this.root = root; + } + + /** + * Return true if this UsersetTree object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsersetTree usersetTree = (UsersetTree) o; + return Objects.equals(this.root, usersetTree.root); + } + + @Override + public int hashCode() { + return Objects.hash(root); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsersetTree {\n"); + sb.append(" root: ").append(toIndentedString(root)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `root` to the URL query string + if (getRoot() != null) { + joiner.add(getRoot().toUrlQueryString(prefix + "root" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/UsersetTreeDifference.java b/src/main/java/dev/openfga/sdk/api/model/UsersetTreeDifference.java new file mode 100644 index 0000000..561fc29 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/UsersetTreeDifference.java @@ -0,0 +1,167 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * UsersetTreeDifference + */ +@JsonPropertyOrder({UsersetTreeDifference.JSON_PROPERTY_BASE, UsersetTreeDifference.JSON_PROPERTY_SUBTRACT}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class UsersetTreeDifference { + public static final String JSON_PROPERTY_BASE = "base"; + private Node base; + + public static final String JSON_PROPERTY_SUBTRACT = "subtract"; + private Node subtract; + + public UsersetTreeDifference() {} + + public UsersetTreeDifference base(Node base) { + this.base = base; + return this; + } + + /** + * Get base + * @return base + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_BASE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Node getBase() { + return base; + } + + @JsonProperty(JSON_PROPERTY_BASE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBase(Node base) { + this.base = base; + } + + public UsersetTreeDifference subtract(Node subtract) { + this.subtract = subtract; + return this; + } + + /** + * Get subtract + * @return subtract + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUBTRACT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Node getSubtract() { + return subtract; + } + + @JsonProperty(JSON_PROPERTY_SUBTRACT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubtract(Node subtract) { + this.subtract = subtract; + } + + /** + * Return true if this UsersetTree.Difference object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsersetTreeDifference usersetTreeDifference = (UsersetTreeDifference) o; + return Objects.equals(this.base, usersetTreeDifference.base) + && Objects.equals(this.subtract, usersetTreeDifference.subtract); + } + + @Override + public int hashCode() { + return Objects.hash(base, subtract); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsersetTreeDifference {\n"); + sb.append(" base: ").append(toIndentedString(base)).append("\n"); + sb.append(" subtract: ").append(toIndentedString(subtract)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `base` to the URL query string + if (getBase() != null) { + joiner.add(getBase().toUrlQueryString(prefix + "base" + suffix)); + } + + // add `subtract` to the URL query string + if (getSubtract() != null) { + joiner.add(getSubtract().toUrlQueryString(prefix + "subtract" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUserset.java b/src/main/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUserset.java new file mode 100644 index 0000000..df7a3c2 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUserset.java @@ -0,0 +1,196 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * UsersetTreeTupleToUserset + */ +@JsonPropertyOrder({UsersetTreeTupleToUserset.JSON_PROPERTY_TUPLESET, UsersetTreeTupleToUserset.JSON_PROPERTY_COMPUTED}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class UsersetTreeTupleToUserset { + public static final String JSON_PROPERTY_TUPLESET = "tupleset"; + private String tupleset; + + public static final String JSON_PROPERTY_COMPUTED = "computed"; + private List computed = new ArrayList<>(); + + public UsersetTreeTupleToUserset() {} + + public UsersetTreeTupleToUserset tupleset(String tupleset) { + this.tupleset = tupleset; + return this; + } + + /** + * Get tupleset + * @return tupleset + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TUPLESET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTupleset() { + return tupleset; + } + + @JsonProperty(JSON_PROPERTY_TUPLESET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTupleset(String tupleset) { + this.tupleset = tupleset; + } + + public UsersetTreeTupleToUserset computed(List computed) { + this.computed = computed; + return this; + } + + public UsersetTreeTupleToUserset addComputedItem(Computed computedItem) { + if (this.computed == null) { + this.computed = new ArrayList<>(); + } + this.computed.add(computedItem); + return this; + } + + /** + * Get computed + * @return computed + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPUTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getComputed() { + return computed; + } + + @JsonProperty(JSON_PROPERTY_COMPUTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setComputed(List computed) { + this.computed = computed; + } + + /** + * Return true if this UsersetTree.TupleToUserset object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsersetTreeTupleToUserset usersetTreeTupleToUserset = (UsersetTreeTupleToUserset) o; + return Objects.equals(this.tupleset, usersetTreeTupleToUserset.tupleset) + && Objects.equals(this.computed, usersetTreeTupleToUserset.computed); + } + + @Override + public int hashCode() { + return Objects.hash(tupleset, computed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsersetTreeTupleToUserset {\n"); + sb.append(" tupleset: ").append(toIndentedString(tupleset)).append("\n"); + sb.append(" computed: ").append(toIndentedString(computed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `tupleset` to the URL query string + if (getTupleset() != null) { + joiner.add(String.format( + "%stupleset%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getTupleset()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `computed` to the URL query string + if (getComputed() != null) { + for (int i = 0; i < getComputed().size(); i++) { + if (getComputed().get(i) != null) { + joiner.add(getComputed() + .get(i) + .toUrlQueryString(String.format( + "%scomputed%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/Usersets.java b/src/main/java/dev/openfga/sdk/api/model/Usersets.java new file mode 100644 index 0000000..9a6f391 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/Usersets.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Usersets + */ +@JsonPropertyOrder({Usersets.JSON_PROPERTY_CHILD}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class Usersets { + public static final String JSON_PROPERTY_CHILD = "child"; + private List child = new ArrayList<>(); + + public Usersets() {} + + public Usersets child(List child) { + this.child = child; + return this; + } + + public Usersets addChildItem(Userset childItem) { + if (this.child == null) { + this.child = new ArrayList<>(); + } + this.child.add(childItem); + return this; + } + + /** + * Get child + * @return child + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHILD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getChild() { + return child; + } + + @JsonProperty(JSON_PROPERTY_CHILD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setChild(List child) { + this.child = child; + } + + /** + * Return true if this Usersets object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Usersets usersets = (Usersets) o; + return Objects.equals(this.child, usersets.child); + } + + @Override + public int hashCode() { + return Objects.hash(child); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Usersets {\n"); + sb.append(" child: ").append(toIndentedString(child)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `child` to the URL query string + if (getChild() != null) { + for (int i = 0; i < getChild().size(); i++) { + if (getChild().get(i) != null) { + joiner.add(getChild() + .get(i) + .toUrlQueryString(String.format( + "%schild%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponse.java b/src/main/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponse.java new file mode 100644 index 0000000..7c5bc7e --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponse.java @@ -0,0 +1,182 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * ValidationErrorMessageResponse + */ +@JsonPropertyOrder({ + ValidationErrorMessageResponse.JSON_PROPERTY_CODE, + ValidationErrorMessageResponse.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class ValidationErrorMessageResponse { + public static final String JSON_PROPERTY_CODE = "code"; + private ErrorCode code = ErrorCode.NO_ERROR; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public ValidationErrorMessageResponse() {} + + public ValidationErrorMessageResponse code(ErrorCode code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ErrorCode getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(ErrorCode code) { + this.code = code; + } + + public ValidationErrorMessageResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + /** + * Return true if this ValidationErrorMessageResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ValidationErrorMessageResponse validationErrorMessageResponse = (ValidationErrorMessageResponse) o; + return Objects.equals(this.code, validationErrorMessageResponse.code) + && Objects.equals(this.message, validationErrorMessageResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ValidationErrorMessageResponse {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format( + "%scode%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format( + "%smessage%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/WriteAssertionsRequest.java b/src/main/java/dev/openfga/sdk/api/model/WriteAssertionsRequest.java new file mode 100644 index 0000000..0278b8f --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/WriteAssertionsRequest.java @@ -0,0 +1,157 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * WriteAssertionsRequest + */ +@JsonPropertyOrder({WriteAssertionsRequest.JSON_PROPERTY_ASSERTIONS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class WriteAssertionsRequest { + public static final String JSON_PROPERTY_ASSERTIONS = "assertions"; + private List assertions = new ArrayList<>(); + + public WriteAssertionsRequest() {} + + public WriteAssertionsRequest assertions(List assertions) { + this.assertions = assertions; + return this; + } + + public WriteAssertionsRequest addAssertionsItem(Assertion assertionsItem) { + if (this.assertions == null) { + this.assertions = new ArrayList<>(); + } + this.assertions.add(assertionsItem); + return this; + } + + /** + * Get assertions + * @return assertions + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ASSERTIONS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getAssertions() { + return assertions; + } + + @JsonProperty(JSON_PROPERTY_ASSERTIONS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setAssertions(List assertions) { + this.assertions = assertions; + } + + /** + * Return true if this WriteAssertions_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WriteAssertionsRequest writeAssertionsRequest = (WriteAssertionsRequest) o; + return Objects.equals(this.assertions, writeAssertionsRequest.assertions); + } + + @Override + public int hashCode() { + return Objects.hash(assertions); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WriteAssertionsRequest {\n"); + sb.append(" assertions: ").append(toIndentedString(assertions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `assertions` to the URL query string + if (getAssertions() != null) { + for (int i = 0; i < getAssertions().size(); i++) { + if (getAssertions().get(i) != null) { + joiner.add(getAssertions() + .get(i) + .toUrlQueryString(String.format( + "%sassertions%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequest.java b/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequest.java new file mode 100644 index 0000000..2f96481 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequest.java @@ -0,0 +1,201 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * WriteAuthorizationModelRequest + */ +@JsonPropertyOrder({ + WriteAuthorizationModelRequest.JSON_PROPERTY_TYPE_DEFINITIONS, + WriteAuthorizationModelRequest.JSON_PROPERTY_SCHEMA_VERSION +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class WriteAuthorizationModelRequest { + public static final String JSON_PROPERTY_TYPE_DEFINITIONS = "type_definitions"; + private List typeDefinitions = new ArrayList<>(); + + public static final String JSON_PROPERTY_SCHEMA_VERSION = "schema_version"; + private String schemaVersion; + + public WriteAuthorizationModelRequest() {} + + public WriteAuthorizationModelRequest typeDefinitions(List typeDefinitions) { + this.typeDefinitions = typeDefinitions; + return this; + } + + public WriteAuthorizationModelRequest addTypeDefinitionsItem(TypeDefinition typeDefinitionsItem) { + if (this.typeDefinitions == null) { + this.typeDefinitions = new ArrayList<>(); + } + this.typeDefinitions.add(typeDefinitionsItem); + return this; + } + + /** + * Get typeDefinitions + * @return typeDefinitions + **/ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE_DEFINITIONS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTypeDefinitions() { + return typeDefinitions; + } + + @JsonProperty(JSON_PROPERTY_TYPE_DEFINITIONS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTypeDefinitions(List typeDefinitions) { + this.typeDefinitions = typeDefinitions; + } + + public WriteAuthorizationModelRequest schemaVersion(String schemaVersion) { + this.schemaVersion = schemaVersion; + return this; + } + + /** + * Get schemaVersion + * @return schemaVersion + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCHEMA_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSchemaVersion() { + return schemaVersion; + } + + @JsonProperty(JSON_PROPERTY_SCHEMA_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSchemaVersion(String schemaVersion) { + this.schemaVersion = schemaVersion; + } + + /** + * Return true if this WriteAuthorizationModel_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WriteAuthorizationModelRequest writeAuthorizationModelRequest = (WriteAuthorizationModelRequest) o; + return Objects.equals(this.typeDefinitions, writeAuthorizationModelRequest.typeDefinitions) + && Objects.equals(this.schemaVersion, writeAuthorizationModelRequest.schemaVersion); + } + + @Override + public int hashCode() { + return Objects.hash(typeDefinitions, schemaVersion); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WriteAuthorizationModelRequest {\n"); + sb.append(" typeDefinitions: ") + .append(toIndentedString(typeDefinitions)) + .append("\n"); + sb.append(" schemaVersion: ").append(toIndentedString(schemaVersion)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type_definitions` to the URL query string + if (getTypeDefinitions() != null) { + for (int i = 0; i < getTypeDefinitions().size(); i++) { + if (getTypeDefinitions().get(i) != null) { + joiner.add(getTypeDefinitions() + .get(i) + .toUrlQueryString(String.format( + "%stype_definitions%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `schema_version` to the URL query string + if (getSchemaVersion() != null) { + joiner.add(String.format( + "%sschema_version%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getSchemaVersion()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponse.java b/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponse.java new file mode 100644 index 0000000..d7eb2a5 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponse.java @@ -0,0 +1,144 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * WriteAuthorizationModelResponse + */ +@JsonPropertyOrder({WriteAuthorizationModelResponse.JSON_PROPERTY_AUTHORIZATION_MODEL_ID}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class WriteAuthorizationModelResponse { + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public WriteAuthorizationModelResponse() {} + + public WriteAuthorizationModelResponse authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + /** + * Return true if this WriteAuthorizationModelResponse object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WriteAuthorizationModelResponse writeAuthorizationModelResponse = (WriteAuthorizationModelResponse) o; + return Objects.equals(this.authorizationModelId, writeAuthorizationModelResponse.authorizationModelId); + } + + @Override + public int hashCode() { + return Objects.hash(authorizationModelId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WriteAuthorizationModelResponse {\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/api/model/WriteRequest.java b/src/main/java/dev/openfga/sdk/api/model/WriteRequest.java new file mode 100644 index 0000000..4020f06 --- /dev/null +++ b/src/main/java/dev/openfga/sdk/api/model/WriteRequest.java @@ -0,0 +1,212 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * WriteRequest + */ +@JsonPropertyOrder({ + WriteRequest.JSON_PROPERTY_WRITES, + WriteRequest.JSON_PROPERTY_DELETES, + WriteRequest.JSON_PROPERTY_AUTHORIZATION_MODEL_ID +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2023-08-18T17:32:33.976511Z[Etc/UTC]") +public class WriteRequest { + public static final String JSON_PROPERTY_WRITES = "writes"; + private TupleKeys writes; + + public static final String JSON_PROPERTY_DELETES = "deletes"; + private TupleKeys deletes; + + public static final String JSON_PROPERTY_AUTHORIZATION_MODEL_ID = "authorization_model_id"; + private String authorizationModelId; + + public WriteRequest() {} + + public WriteRequest writes(TupleKeys writes) { + this.writes = writes; + return this; + } + + /** + * Get writes + * @return writes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_WRITES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleKeys getWrites() { + return writes; + } + + @JsonProperty(JSON_PROPERTY_WRITES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWrites(TupleKeys writes) { + this.writes = writes; + } + + public WriteRequest deletes(TupleKeys deletes) { + this.deletes = deletes; + return this; + } + + /** + * Get deletes + * @return deletes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DELETES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TupleKeys getDeletes() { + return deletes; + } + + @JsonProperty(JSON_PROPERTY_DELETES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeletes(TupleKeys deletes) { + this.deletes = deletes; + } + + public WriteRequest authorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + return this; + } + + /** + * Get authorizationModelId + * @return authorizationModelId + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAuthorizationModelId() { + return authorizationModelId; + } + + @JsonProperty(JSON_PROPERTY_AUTHORIZATION_MODEL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuthorizationModelId(String authorizationModelId) { + this.authorizationModelId = authorizationModelId; + } + + /** + * Return true if this Write_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WriteRequest writeRequest = (WriteRequest) o; + return Objects.equals(this.writes, writeRequest.writes) + && Objects.equals(this.deletes, writeRequest.deletes) + && Objects.equals(this.authorizationModelId, writeRequest.authorizationModelId); + } + + @Override + public int hashCode() { + return Objects.hash(writes, deletes, authorizationModelId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WriteRequest {\n"); + sb.append(" writes: ").append(toIndentedString(writes)).append("\n"); + sb.append(" deletes: ").append(toIndentedString(deletes)).append("\n"); + sb.append(" authorizationModelId: ") + .append(toIndentedString(authorizationModelId)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `writes` to the URL query string + if (getWrites() != null) { + joiner.add(getWrites().toUrlQueryString(prefix + "writes" + suffix)); + } + + // add `deletes` to the URL query string + if (getDeletes() != null) { + joiner.add(getDeletes().toUrlQueryString(prefix + "deletes" + suffix)); + } + + // add `authorization_model_id` to the URL query string + if (getAuthorizationModelId() != null) { + joiner.add(String.format( + "%sauthorization_model_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getAuthorizationModelId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/dev/openfga/sdk/errors/FgaInvalidParameterException.java b/src/main/java/dev/openfga/sdk/errors/FgaInvalidParameterException.java new file mode 100644 index 0000000..49ad99d --- /dev/null +++ b/src/main/java/dev/openfga/sdk/errors/FgaInvalidParameterException.java @@ -0,0 +1,15 @@ +package dev.openfga.sdk.errors; + +public class FgaInvalidParameterException extends Exception { + public FgaInvalidParameterException(String paramName, String functionName) { + super(message(paramName, functionName)); + } + + public FgaInvalidParameterException(String paramName, String functionName, Throwable cause) { + super(message(paramName, functionName), cause); + } + + private static String message(String paramName, String functionName) { + return String.format("Required parameter %s was invalid when calling %s.", paramName, functionName); + } +} diff --git a/src/main/java/dev/openfga/util/StringUtil.java b/src/main/java/dev/openfga/util/StringUtil.java new file mode 100644 index 0000000..4528525 --- /dev/null +++ b/src/main/java/dev/openfga/util/StringUtil.java @@ -0,0 +1,34 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.util; + +import java.util.function.Predicate; +import java.util.regex.Pattern; + +public class StringUtil { + private StringUtil() {} // Instantiation prevented for utility class. + + private static final Predicate NULL_OR_WS = + Pattern.compile("^\\s*$").asMatchPredicate(); + + /** + * Returns true when the String is null, empty or contains only whitespace + * characters. + * + * @param str The String being tested. + * @return true iff str is null, empty or contains only whitespace. + */ + public static boolean isNullOrWhitespace(String str) { + return str == null || NULL_OR_WS.test(str); + } +} diff --git a/src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java b/src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java new file mode 100644 index 0000000..601b29f --- /dev/null +++ b/src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java @@ -0,0 +1,331 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api; + +import static org.junit.jupiter.api.Assertions.*; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import dev.openfga.sdk.api.client.*; +import dev.openfga.sdk.api.model.*; +import java.net.http.HttpClient; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class OpenFgaApiIntegrationTest { + private static final ObjectMapper mapper = new ObjectMapper().findAndRegisterModules(); + private static final String DEFAULT_AUTH_MODEL = + "{\"schema_version\":\"1.1\",\"type_definitions\":[{\"type\":\"user\"},{\"type\":\"document\",\"relations\":{\"reader\":{\"this\":{}},\"writer\":{\"this\":{}},\"owner\":{\"this\":{}}},\"metadata\":{\"relations\":{\"reader\":{\"directly_related_user_types\":[{\"type\":\"user\"}]},\"writer\":{\"directly_related_user_types\":[{\"type\":\"user\"}]},\"owner\":{\"directly_related_user_types\":[{\"type\":\"user\"}]}}}}]}"; + private static final String DEFAULT_USER = "user:81684243-9356-4421-8fbf-a4f8d36aa31b"; + private static final String DEFAULT_DOC = "document:2021-budget"; + public static final TupleKey DEFAULT_TUPLE_KEY = + new TupleKey().user(DEFAULT_USER).relation("reader")._object(DEFAULT_DOC); + public static final List DEFAULT_TUPLE_KEYS = List.of(DEFAULT_TUPLE_KEY); + + private OpenFgaApi api; + + @BeforeEach + public void initializeApi() { + Configuration apiConfig = new Configuration("http://localhost:8080"); + ApiClient apiClient = new ApiClient(HttpClient.newBuilder(), mapper); + api = new OpenFgaApi(apiClient, apiConfig); + } + + @Test + public void createStore() throws Exception { + // Given + String storeName = thisTestName(); + CreateStoreRequest createStoreRequest = new CreateStoreRequest().name(storeName); + + // When + CreateStoreResponse response = api.createStore(createStoreRequest).get(); + + // Then + assertEquals("OpenFgaApiIntegrationTest.createStore", response.getName()); + } + + @Test + public void deleteStore() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + + // When + api.deleteStore(storeId); + + // Then + ListStoresResponse response = api.listStores(100, null).get(); + boolean itWasDeleted = response.getStores().stream().map(Store::getId).noneMatch(storeId::equals); + assertTrue(itWasDeleted, String.format("No stores should remain with the id %s.", storeId)); + } + + @Test + public void getStore() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + + // When + GetStoreResponse response = api.getStore(storeId).get(); + + // Then + assertEquals(storeName, response.getName()); + } + + @Test + public void listStores() throws Exception { + // Given + String testName = thisTestName(); + String store1 = testName + "-store1"; + String store2 = testName + "-store2"; + String store3 = testName + "-store3"; + List stores = List.of(store1, store2, store3); + for (String store : stores) { + createStore(store); + } + + // When + ListStoresResponse response = api.listStores(100, null).get(); + + // Then + for (String store : stores) { + boolean exists = response.getStores().stream().map(Store::getName).anyMatch(store::equals); + assertTrue(exists, String.format("Store %s should be in listStores response", store)); + } + } + + @Test + public void readAuthModel() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String authModelId = writeAuthModel(storeId); + + // When + ReadAuthorizationModelResponse response = + api.readAuthorizationModel(storeId, authModelId).get(); + + // Then + AuthorizationModel authModel = response.getAuthorizationModel(); + assertEquals(authModelId, authModel.getId()); + String typeDefsJson = mapper.writeValueAsString(authModel.getTypeDefinitions()); + assertEquals( + "[{\"type\":\"user\",\"relations\":{},\"metadata\":null},{\"type\":\"document\",\"relations\":{\"owner\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null},\"reader\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null},\"writer\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null}},\"metadata\":{\"relations\":{\"owner\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]},\"reader\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]},\"writer\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]}}}}]", + typeDefsJson); + } + + @Test + public void readAuthModels() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String authModelId = writeAuthModel(storeId); + + // When + ReadAuthorizationModelsResponse response = + api.readAuthorizationModels(storeId, 100, null).get(); + + // Then + response.getAuthorizationModels().stream() + .filter(authModel -> authModel.getId().equals(authModelId)) + .forEach(authModel -> { + assertEquals(authModelId, authModel.getId()); + try { + String typeDefsJson = mapper.writeValueAsString(authModel.getTypeDefinitions()); + + assertEquals( + "[{\"type\":\"user\",\"relations\":{},\"metadata\":null},{\"type\":\"document\",\"relations\":{\"owner\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null},\"reader\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null},\"writer\":{\"this\":{},\"computedUserset\":null,\"tupleToUserset\":null,\"union\":null,\"intersection\":null,\"difference\":null}},\"metadata\":{\"relations\":{\"owner\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]},\"reader\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]},\"writer\":{\"directly_related_user_types\":[{\"type\":\"user\",\"relation\":null,\"wildcard\":null}]}}}}]", + typeDefsJson); + } catch (JsonProcessingException ex) { + assertNull(ex); + } + }); + } + + @Test + public void writeAuthModel() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + WriteAuthorizationModelRequest request = + mapper.readValue(DEFAULT_AUTH_MODEL, WriteAuthorizationModelRequest.class); + + // When + WriteAuthorizationModelResponse response = + api.writeAuthorizationModel(storeId, request).get(); + + // Then + assertNotNull(response); + assertNotNull(response.getAuthorizationModelId()); + assertNotEquals("", response.getAuthorizationModelId()); + } + + @Test + public void write_and_read() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String _authModelId = writeAuthModel(storeId); + WriteRequest writeRequest = new WriteRequest().writes(new TupleKeys().tupleKeys(List.of(DEFAULT_TUPLE_KEY))); + ReadRequest readRequest = + new ReadRequest().tupleKey(new TupleKey().user(DEFAULT_USER)._object(DEFAULT_DOC)); + + // When + api.write(storeId, writeRequest); + ReadResponse response = api.read(storeId, readRequest).get(); + + // Then + TupleKey key = response.getTuples().get(0).getKey(); + assertEquals(DEFAULT_USER, key.getUser()); + assertEquals("reader", key.getRelation()); + assertEquals(DEFAULT_DOC, key.getObject()); + } + + @Test + public void write_and_check() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String _authModelId = writeAuthModel(storeId); + WriteRequest writeRequest = new WriteRequest().writes(new TupleKeys().tupleKeys(DEFAULT_TUPLE_KEYS)); + CheckRequest checkRequest = new CheckRequest() + .tupleKey(new TupleKey().user(DEFAULT_USER).relation("reader")._object(DEFAULT_DOC)); + + // When + api.write(storeId, writeRequest); + CheckResponse response = api.check(storeId, checkRequest).get(); + + // Then + assertTrue(response.getAllowed()); + } + + @Test + public void write_and_expand() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String _authModelId = writeAuthModel(storeId); + WriteRequest writeRequest = new WriteRequest().writes(new TupleKeys().tupleKeys(DEFAULT_TUPLE_KEYS)); + ExpandRequest expandRequest = + new ExpandRequest().tupleKey(new TupleKey()._object(DEFAULT_DOC).relation("reader")); + + // When + api.write(storeId, writeRequest); + ExpandResponse response = api.expand(storeId, expandRequest).get(); + + // Then + assertNotNull(response.getTree()); + String responseJson = mapper.writeValueAsString(response); + assertEquals( + "{\"tree\":{\"root\":{\"name\":\"document:2021-budget#reader\",\"leaf\":{\"users\":{\"users\":[\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"]},\"computed\":null,\"tupleToUserset\":null},\"difference\":null,\"union\":null,\"intersection\":null}}}", + responseJson); + } + + @Test + public void write_and_listObjects() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String _authModelId = writeAuthModel(storeId); + WriteRequest writeRequest = new WriteRequest().writes(new TupleKeys().tupleKeys(DEFAULT_TUPLE_KEYS)); + ListObjectsRequest listObjectsRequest = + new ListObjectsRequest().user(DEFAULT_USER).relation("reader").type("document"); + + // When + api.write(storeId, writeRequest); + ListObjectsResponse response = + api.listObjects(storeId, listObjectsRequest).get(); + + // Then + assertEquals(1, response.getObjects().size()); + assertEquals(DEFAULT_DOC, response.getObjects().get(0)); + } + + @Test + public void write_and_readChanges() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String _authModelId = writeAuthModel(storeId); + WriteRequest writeRequest = new WriteRequest().writes(new TupleKeys().tupleKeys(DEFAULT_TUPLE_KEYS)); + + // When + api.write(storeId, writeRequest); + ReadChangesResponse response = + api.readChanges(storeId, null, null, null).get(); + + // Then + assertEquals(1, response.getChanges().size()); + String firstTupleKeyJson = + mapper.writeValueAsString(response.getChanges().get(0).getTupleKey()); + assertEquals( + "{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"}", + firstTupleKeyJson); + } + + @Test + public void write_readAssertions() throws Exception { + // Given + String storeName = thisTestName(); + String storeId = createStore(storeName); + String authModelId = writeAuthModel(storeId); + WriteAssertionsRequest writeRequest = new WriteAssertionsRequest() + .assertions(List.of(new Assertion().tupleKey(DEFAULT_TUPLE_KEY).expectation(true))); + + // When + api.writeAssertions(storeId, authModelId, writeRequest); + ReadAssertionsResponse response = + api.readAssertions(storeId, authModelId).get(); + + // Then + String responseJson = mapper.writeValueAsString(response.getAssertions()); + assertEquals( + "[{\"tuple_key\":{\"object\":\"document:2021-budget\",\"relation\":\"reader\",\"user\":\"user:81684243-9356-4421-8fbf-a4f8d36aa31b\"},\"expectation\":true}]", + responseJson); + } + + /** + * Create a store for a given name. If tests fail here, troubleshoot with the no-arguments + * test method createStore(). + * @return The created Store ID + */ + private String createStore(String storeName) throws Exception { + CreateStoreResponse response = + api.createStore(new CreateStoreRequest().name(storeName)).get(); + return response.getId(); + } + + /** + * Add a default authorization model to a store. If tests fail here, troubleshoot with the + * no-arguments @Test writeAuthModel() method. + * @return The created Authorization Model ID + */ + private String writeAuthModel(String storeId) throws Exception { + WriteAuthorizationModelRequest request = + mapper.readValue(DEFAULT_AUTH_MODEL, WriteAuthorizationModelRequest.class); + WriteAuthorizationModelResponse response = + api.writeAuthorizationModel(storeId, request).get(); + return response.getAuthorizationModelId(); + } + + /** Get the name of the test that invokes this function. Returned in the form: "$class.$fn" */ + private String thisTestName() { + // Tracing the stack gives an array of: + // 0: getStackTrace(), 1: getThisFunctionName(), 2: , 3: ... + StackTraceElement callingFn = Thread.currentThread().getStackTrace()[2]; + String callingClass = callingFn.getClassName().replace("dev.openfga.sdk.api.", ""); + + return String.format("%s.%s", callingClass, callingFn.getMethodName()); + } +} diff --git a/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java b/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java new file mode 100644 index 0000000..64826fe --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java @@ -0,0 +1,1762 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api; + +import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pgssoft.httpclient.HttpClientMock; +import dev.openfga.sdk.api.client.*; +import dev.openfga.sdk.api.model.*; +import dev.openfga.sdk.errors.*; +import java.time.Duration; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * API tests for OpenFgaApi + */ +public class OpenFgaApiTest { + private static final String DEFAULT_STORE_ID = "01YCP46JKYM8FJCQ37NMBYHE5X"; + private static final String DEFAULT_STORE_NAME = "test_store"; + private static final String DEFAULT_AUTH_MODEL_ID = "01G5JAVJ41T49E9TT3SKVS7X1J"; + private static final String DEFAULT_USER = "user:81684243-9356-4421-8fbf-a4f8d36aa31b"; + private static final String DEFAULT_RELATION = "reader"; + private static final String DEFAULT_TYPE = "document"; + private static final String DEFAULT_OBJECT = "document:budget"; + private static final String DEFAULT_SCHEMA_VERSION = "1.1"; + public static final String EMPTY_RESPONSE_BODY = "{}"; + + private final ObjectMapper mapper = new ObjectMapper(); + private OpenFgaApi fga; + private Configuration mockConfiguration; + private ApiClient mockApiClient; + private HttpClientMock mockHttpClient; + + @BeforeEach + public void beforeEachTest() { + mockHttpClient = new HttpClientMock(); + + mockConfiguration = mock(Configuration.class); + when(mockConfiguration.getApiUrl()).thenReturn("https://localhost"); + when(mockConfiguration.getReadTimeout()).thenReturn(Duration.ofMillis(250)); + + mockApiClient = mock(ApiClient.class); + when(mockApiClient.getObjectMapper()).thenReturn(mapper); + when(mockApiClient.getHttpClient()).thenReturn(mockHttpClient); + + fga = new OpenFgaApi(mockApiClient, mockConfiguration); + } + + /** + * List all stores. + */ + @Test + public void listStoresTest() throws Exception { + // Given + String responseBody = + String.format("{\"stores\":[{\"id\":\"%s\",\"name\":\"%s\"}]}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); + mockHttpClient.onGet("https://localhost/stores").doReturn(200, responseBody); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ListStoresResponse response = + fga.listStores(pageSize, continuationToken).get(); + + // Then + mockHttpClient.verify().get("https://localhost/stores").called(1); + assertNotNull(response.getStores()); + assertEquals(1, response.getStores().size()); + assertEquals(DEFAULT_STORE_ID, response.getStores().get(0).getId()); + assertEquals(DEFAULT_STORE_NAME, response.getStores().get(0).getName()); + } + + @Test + public void listStores_400() { + // Given + mockHttpClient + .onGet("https://localhost/stores") + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listStores(pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void listStores_404() throws Exception { + // Given + mockHttpClient + .onGet("https://localhost/stores") + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listStores(pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void listStores_500() throws Exception { + // Given + mockHttpClient + .onGet("https://localhost/stores") + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listStores(pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Create a store. + */ + @Test + public void createStoreTest() throws Exception { + // Given + String expectedBody = String.format("{\"name\":\"%s\"}", DEFAULT_STORE_NAME); + String requestBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); + mockHttpClient + .onPost("https://localhost/stores") + .withBody(is(expectedBody)) + .doReturn(201, requestBody); + CreateStoreRequest request = new CreateStoreRequest().name(DEFAULT_STORE_NAME); + + // When + CreateStoreResponse response = fga.createStore(request).get(); + + // Then + mockHttpClient + .verify() + .post("https://localhost/stores") + .withBody(is(expectedBody)) + .called(1); + assertEquals(DEFAULT_STORE_ID, response.getId()); + assertEquals(DEFAULT_STORE_NAME, response.getName()); + } + + @Test + public void createStore_bodyRequired() { + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.createStore(null).get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling createStore", exception.getMessage()); + } + + @Test + public void createStore_400() throws Exception { + // Given + mockHttpClient + .onPost("https://localhost/stores") + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.createStore(new CreateStoreRequest()) + .get()); + + // Then + mockHttpClient.verify().post("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void createStore_404() throws Exception { + // Given + mockHttpClient + .onPost("https://localhost/stores") + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.createStore(new CreateStoreRequest()) + .get()); + + // Then + mockHttpClient.verify().post("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void createStore_500() throws Exception { + // Given + mockHttpClient + .onPost("https://localhost/stores") + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.createStore(new CreateStoreRequest()) + .get()); + + // Then + mockHttpClient.verify().post("https://localhost/stores").called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Get a store. + */ + @Test + public void getStoreTest() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + String responseBody = String.format("{\"id\":\"%s\",\"name\":\"%s\"}", DEFAULT_STORE_ID, DEFAULT_STORE_NAME); + mockHttpClient.onGet(getUrl).doReturn(200, responseBody); + + // When + GetStoreResponse response = fga.getStore(DEFAULT_STORE_ID).get(); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + assertEquals(DEFAULT_STORE_ID, response.getId()); + assertEquals(DEFAULT_STORE_NAME, response.getName()); + } + + @Test + public void getStore_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.getStore(null).get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling getStore", exception.getMessage()); + } + + @Test + public void getStore_400() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onGet(getUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.getStore(DEFAULT_STORE_ID).get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void getStore_404() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onGet(getUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.getStore(DEFAULT_STORE_ID).get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void getStore_500() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onGet(getUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.getStore(DEFAULT_STORE_ID).get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Delete a store. + */ + @Test + public void deleteStoreTest() throws Exception { + // Given + String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient.onDelete(deleteUrl).doReturn(204, EMPTY_RESPONSE_BODY); + + // When + fga.deleteStore(DEFAULT_STORE_ID); + + // Then + mockHttpClient.verify().delete(deleteUrl).called(1); + } + + @Test + public void deleteStore_storeIdRequired() { + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.deleteStore(null).get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling deleteStore", exception.getMessage()); + } + + @Test + public void deleteStore_400() throws Exception { + // Given + String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onDelete(deleteUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.deleteStore(DEFAULT_STORE_ID) + .get()); + + // Then + mockHttpClient.verify().delete(deleteUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void deleteStore_404() throws Exception { + // Given + String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onDelete(deleteUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.deleteStore(DEFAULT_STORE_ID) + .get()); + + // Then + mockHttpClient.verify().delete(deleteUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void deleteStore_500() throws Exception { + // Given + String deleteUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X"; + mockHttpClient + .onDelete(deleteUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.deleteStore(DEFAULT_STORE_ID) + .get()); + + // Then + mockHttpClient.verify().delete(deleteUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Return all the authorization models for a particular store. + */ + @Test + public void readAuthorizationModelsTest() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String responseBody = String.format( + "{\"authorization_models\":[{\"id\":\"%s\",\"schema_version\":\"%s\"}]}", + DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); + mockHttpClient.onGet(getUrl).doReturn(200, responseBody); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ReadAuthorizationModelsResponse response = fga.readAuthorizationModels( + DEFAULT_STORE_ID, pageSize, continuationToken) + .get(); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + assertNotNull(response.getAuthorizationModels()); + assertEquals(1, response.getAuthorizationModels().size()); + AuthorizationModel authModel = response.getAuthorizationModels().get(0); + assertEquals(DEFAULT_AUTH_MODEL_ID, authModel.getId()); + assertEquals(DEFAULT_SCHEMA_VERSION, authModel.getSchemaVersion()); + } + + @Test + public void readAuthorizationModels_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAuthorizationModels(null, null, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'storeId' when calling readAuthorizationModels", + exception.getMessage()); + } + + @Test + public void readAuthorizationModels_400() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onGet(getUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.readAuthorizationModels( + DEFAULT_STORE_ID, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void readAuthorizationModels_404() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onGet(getUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.readAuthorizationModels( + DEFAULT_STORE_ID, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void readAuthorizationModels_500() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onGet(getUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.readAuthorizationModels( + DEFAULT_STORE_ID, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Create a new authorization model. + */ + @Test + public void writeAuthorizationModelTest() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + String expectedBody = + "{\"type_definitions\":[{\"type\":\"document\",\"relations\":{},\"metadata\":null}],\"schema_version\":\"1.1\"}"; + String responseBody = String.format("{\"authorization_model_id\":\"%s\"}", DEFAULT_AUTH_MODEL_ID); + mockHttpClient.onPost(postUrl).withBody(is(expectedBody)).doReturn(201, responseBody); + WriteAuthorizationModelRequest request = new WriteAuthorizationModelRequest() + .schemaVersion(DEFAULT_SCHEMA_VERSION) + .typeDefinitions(List.of(new TypeDefinition().type(DEFAULT_TYPE))); + + // When + WriteAuthorizationModelResponse response = + fga.writeAuthorizationModel(DEFAULT_STORE_ID, request).get(); + + // Then + mockHttpClient.verify().post(postUrl).withBody(is(expectedBody)).called(1); + assertEquals(DEFAULT_AUTH_MODEL_ID, response.getAuthorizationModelId()); + } + + @Test + public void writeAuthorizationModel_storeIdRequired() { + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.writeAuthorizationModel(null, new WriteAuthorizationModelRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'storeId' when calling writeAuthorizationModel", + exception.getMessage()); + } + + @Test + public void writeAuthorizationModel_bodyRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.writeAuthorizationModel(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'body' when calling writeAuthorizationModel", exception.getMessage()); + } + + @Test + public void writeAuthorizationModel_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAuthorizationModel( + DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void writeAuthorizationModel_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAuthorizationModel( + DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void writeAuthorizationModel_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAuthorizationModel( + DEFAULT_STORE_ID, new WriteAuthorizationModelRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Return a particular version of an authorization model. + */ + @Test + public void readAuthorizationModelTest() throws Exception { + // Given + String getUrl = + "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + String getResponse = String.format( + "{\"authorization_model\":{\"id\":\"%s\",\"schema_version\":\"%s\"}}", + DEFAULT_AUTH_MODEL_ID, DEFAULT_SCHEMA_VERSION); + mockHttpClient.onGet(getUrl).doReturn(200, getResponse); + + // When + ReadAuthorizationModelResponse response = fga.readAuthorizationModel(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get(); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + assertNotNull(response.getAuthorizationModel()); + assertEquals(DEFAULT_AUTH_MODEL_ID, response.getAuthorizationModel().getId()); + assertEquals(DEFAULT_SCHEMA_VERSION, response.getAuthorizationModel().getSchemaVersion()); + } + + @Test + public void readAuthorizationModel_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAuthorizationModel(null, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'storeId' when calling readAuthorizationModel", exception.getMessage()); + } + + @Test + public void readAuthorizationModel_idRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAuthorizationModel(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'id' when calling readAuthorizationModel", exception.getMessage()); + } + + @Test + public void readAuthorizationModel_400() throws Exception { + // Given + String getUrl = + "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readAuthorizationModel(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void readAuthorizationModel_404() throws Exception { + // Given + String getUrl = + "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readAuthorizationModel(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void readAuthorizationModel_500() throws Exception { + // Given + String getUrl = + "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readAuthorizationModel(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Return a list of all the tuple changes. + */ + @Test + public void readChangesTest() throws Exception { + // Given + String getPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + String responseBody = String.format( + "{\"changes\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"}}]}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); + mockHttpClient.onGet(getPath).doReturn(200, responseBody); + String type = null; // Input is optional + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ReadChangesResponse response = fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + .get(); + + // Then + mockHttpClient.verify().get(getPath).called(1); + assertNotNull(response.getChanges()); + assertEquals(1, response.getChanges().size()); + TupleChange change = response.getChanges().get(0); + assertNotNull(change.getTupleKey()); + assertEquals(DEFAULT_OBJECT, change.getTupleKey().getObject()); + assertEquals(DEFAULT_RELATION, change.getTupleKey().getRelation()); + assertEquals(DEFAULT_USER, change.getTupleKey().getUser()); + } + + @Test + public void readChanges_storeIdRequired() throws Exception { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readChanges(null, null, null, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling readChanges", exception.getMessage()); + } + + @Test + public void readChanges_400() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + mockHttpClient + .onGet(getUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + String type = null; // Input is optional + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void readChanges_404() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + mockHttpClient + .onGet(getUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + String type = null; // Input is optional + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void readChanges_500() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes"; + mockHttpClient + .onGet(getUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + String type = null; // Input is optional + Integer pageSize = null; // Input is optional + String continuationToken = null; // Input is optional + + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.readChanges(DEFAULT_STORE_ID, type, pageSize, continuationToken) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Get tuples from the store that matches a query, without following userset rewrite rules. + */ + @Test + public void readTest() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + String expectedBody = String.format( + "{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"page_size\":null,\"continuation_token\":null}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); + String responseBody = String.format( + "{\"tuples\":[{\"key\":{\"user\":\"%s\",\"relation\":\"%s\",\"object\":\"%s\"}}]}", + DEFAULT_USER, DEFAULT_RELATION, DEFAULT_OBJECT); + mockHttpClient.onPost(postUrl).withBody(is(expectedBody)).doReturn(200, responseBody); + ReadRequest request = new ReadRequest() + .tupleKey(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)); + + // When + ReadResponse response = fga.read(DEFAULT_STORE_ID, request).get(); + + // Then + mockHttpClient.verify().post(postUrl).withBody(is(expectedBody)).called(1); + assertNotNull(response.getTuples()); + assertEquals(1, response.getTuples().size()); + TupleKey key = response.getTuples().get(0).getKey(); + assertNotNull(key); + assertEquals(DEFAULT_USER, key.getUser()); + assertEquals(DEFAULT_RELATION, key.getRelation()); + assertEquals(DEFAULT_OBJECT, key.getObject()); + } + + @Test + public void read_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.read(null, new ReadRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling read", exception.getMessage()); + } + + @Test + public void read_bodyRequired() { + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.read(DEFAULT_STORE_ID, null).get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling read", exception.getMessage()); + } + + @Test + public void read_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.read(DEFAULT_STORE_ID, new ReadRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void read_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.read(DEFAULT_STORE_ID, new ReadRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void read_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.read(DEFAULT_STORE_ID, new ReadRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Add or delete tuples from the store. + */ + @Test + public void writeTest_writes() throws Exception { + // Given + String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String expectedBody = String.format( + "{\"writes\":{\"tuple_keys\":[{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"}]},\"deletes\":null,\"authorization_model_id\":\"%s\"}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER, DEFAULT_AUTH_MODEL_ID); + mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); + WriteRequest request = new WriteRequest() + .authorizationModelId(DEFAULT_AUTH_MODEL_ID) + .writes(new TupleKeys() + .tupleKeys(List.of(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)))); + + // When + fga.write(DEFAULT_STORE_ID, request); + + // Then + mockHttpClient.verify().post(postPath).withBody(is(expectedBody)).called(1); + } + + /** + * Add or delete tuples from the store. + */ + @Test + public void writeTest_deletes() throws Exception { + // Given + String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + String expectedBody = String.format( + "{\"writes\":null,\"deletes\":{\"tuple_keys\":[{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"}]},\"authorization_model_id\":\"%s\"}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER, DEFAULT_AUTH_MODEL_ID); + mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); + WriteRequest request = new WriteRequest() + .authorizationModelId(DEFAULT_AUTH_MODEL_ID) + .deletes(new TupleKeys() + .tupleKeys(List.of(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)))); + + // When + fga.write(DEFAULT_STORE_ID, request); + + // Then + mockHttpClient.verify().post(postPath).withBody(is(expectedBody)).called(1); + } + + @Test + public void write_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.write(null, new WriteRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling write", exception.getMessage()); + } + + @Test + public void write_bodyRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.write(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling write", exception.getMessage()); + } + + @Test + public void write_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.write(DEFAULT_STORE_ID, new WriteRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void write_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.write(DEFAULT_STORE_ID, new WriteRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void write_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/write"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.write(DEFAULT_STORE_ID, new WriteRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Check whether a user is authorized to access an object. + */ + @Test + public void check() throws Exception { + // Given + String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + String expectedBody = String.format( + "{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"contextual_tuples\":{\"tuple_keys\":[]},\"authorization_model_id\":\"01G5JAVJ41T49E9TT3SKVS7X1J\",\"trace\":null}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); + mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, "{\"allowed\":true}"); + CheckRequest request = new CheckRequest() + .tupleKey(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)) + .contextualTuples(new ContextualTupleKeys()) + .authorizationModelId(DEFAULT_AUTH_MODEL_ID); + + // When + CheckResponse response = fga.check(DEFAULT_STORE_ID, request).get(); + + // Then + verify(mockConfiguration).getApiUrl(); + verify(mockConfiguration).getReadTimeout(); + mockHttpClient.verify().post(postPath).withBody(is(expectedBody)).called(1); + assertEquals(Boolean.TRUE, response.getAllowed()); + } + + @Test + public void check_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.check(null, new CheckRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling check", exception.getMessage()); + } + + @Test + public void check_bodyRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.check(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling check", exception.getMessage()); + } + + @Test + public void check_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.check(DEFAULT_STORE_ID, new CheckRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void check_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.check(DEFAULT_STORE_ID, new CheckRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void check_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.check(DEFAULT_STORE_ID, new CheckRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship. + */ + @Test + public void expandTest() throws Exception { + // Given + String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + String expectedBody = String.format( + "{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"authorization_model_id\":\"%s\"}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER, DEFAULT_AUTH_MODEL_ID); + String responseBody = String.format( + "{\"tree\":{\"root\":{\"union\":{\"nodes\":[{\"leaf\":{\"users\":{\"users\":[\"%s\"]}}}]}}}}", + DEFAULT_USER); + mockHttpClient.onPost(postPath).withBody(is(expectedBody)).doReturn(200, responseBody); + ExpandRequest request = new ExpandRequest() + .authorizationModelId(DEFAULT_AUTH_MODEL_ID) + .tupleKey(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)); + + // When + ExpandResponse response = fga.expand(DEFAULT_STORE_ID, request).get(); + + // Then + mockHttpClient.verify().post(postPath).withBody(is(expectedBody)).called(1); + assertNotNull(response.getTree()); + assertNotNull(response.getTree().getRoot()); + assertNotNull(response.getTree().getRoot().getUnion()); + assertNotNull(response.getTree().getRoot().getUnion().getNodes()); + assertEquals(1, response.getTree().getRoot().getUnion().getNodes().size()); + assertNotNull(response.getTree().getRoot().getUnion().getNodes().get(0)); + Node node = response.getTree().getRoot().getUnion().getNodes().get(0); + assertNotNull(node.getLeaf()); + assertNotNull(node.getLeaf().getUsers()); + assertNotNull(node.getLeaf().getUsers().getUsers()); + assertEquals(1, node.getLeaf().getUsers().getUsers().size()); + assertEquals(DEFAULT_USER, node.getLeaf().getUsers().getUsers().get(0)); + } + + @Test + public void expand_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.expand(null, new ExpandRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling expand", exception.getMessage()); + } + + @Test + public void expand_bodyRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.expand(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling expand", exception.getMessage()); + } + + @Test + public void expand_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.expand(DEFAULT_STORE_ID, new ExpandRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void expand_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.expand(DEFAULT_STORE_ID, new ExpandRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void expand_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.expand(DEFAULT_STORE_ID, new ExpandRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * List all objects of the given type that the user has a relation with. + */ + @Test + public void listObjectsTest() throws Exception { + // Given + String postPath = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + String expectedBody = String.format( + "{\"authorization_model_id\":\"%s\",\"type\":null,\"relation\":\"%s\",\"user\":\"%s\",\"contextual_tuples\":null}", + DEFAULT_AUTH_MODEL_ID, DEFAULT_RELATION, DEFAULT_USER); + mockHttpClient + .onPost(postPath) + .withBody(is(expectedBody)) + .doReturn(200, String.format("{\"objects\":[\"%s\"]}", DEFAULT_OBJECT)); + ListObjectsRequest request = new ListObjectsRequest() + .authorizationModelId(DEFAULT_AUTH_MODEL_ID) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER); + + // When + ListObjectsResponse response = + fga.listObjects(DEFAULT_STORE_ID, request).get(); + + // Then + mockHttpClient.verify().post(postPath).withBody(is(expectedBody)).called(1); + assertEquals(List.of(DEFAULT_OBJECT), response.getObjects()); + } + + @Test + public void listObjects_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listObjects(null, new ListObjectsRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling listObjects", exception.getMessage()); + } + + @Test + public void listObjects_bodyRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listObjects(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling listObjects", exception.getMessage()); + } + + @Test + public void listObjects_400() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + mockHttpClient + .onPost(postUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listObjects(DEFAULT_STORE_ID, new ListObjectsRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void listObjects_404() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + mockHttpClient + .onPost(postUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listObjects(DEFAULT_STORE_ID, new ListObjectsRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void listObjects_500() throws Exception { + // Given + String postUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects"; + mockHttpClient + .onPost(postUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.listObjects(DEFAULT_STORE_ID, new ListObjectsRequest()) + .get()); + + // Then + mockHttpClient.verify().post(postUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Read assertions for an authorization model ID. + */ + @Test + public void readAssertionsTest() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String responseBody = String.format( + "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); + mockHttpClient.onGet(getUrl).doReturn(200, responseBody); + + // When + ReadAssertionsResponse response = + fga.readAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID).get(); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + assertNotNull(response.getAssertions()); + assertEquals(1, response.getAssertions().size()); + Assertion assertion = response.getAssertions().get(0); + assertNotNull(assertion); + assertTrue(assertion.getExpectation()); + assertEquals(DEFAULT_OBJECT, assertion.getTupleKey().getObject()); + assertEquals(DEFAULT_RELATION, assertion.getTupleKey().getRelation()); + assertEquals(DEFAULT_USER, assertion.getTupleKey().getUser()); + } + + @Test + public void readAssertions_storeIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAssertions(null, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling readAssertions", exception.getMessage()); + } + + @Test + public void readAssertions_authModelIdRequired() { + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAssertions(DEFAULT_STORE_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'authorizationModelId' when calling readAssertions", + exception.getMessage()); + } + + @Test + public void readAssertions_400() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void readAssertions_404() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void readAssertions_500() throws Exception { + // Given + String getUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onGet(getUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = + assertThrows(ExecutionException.class, () -> fga.readAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID) + .get()); + + // Then + mockHttpClient.verify().get(getUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } + + /** + * Upsert assertions for an authorization model ID. + */ + @Test + public void writeAssertionsTest() throws Exception { + // Given + String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + String expectedBody = String.format( + "{\"assertions\":[{\"tuple_key\":{\"object\":\"%s\",\"relation\":\"%s\",\"user\":\"%s\"},\"expectation\":true}]}", + DEFAULT_OBJECT, DEFAULT_RELATION, DEFAULT_USER); + mockHttpClient.onPut(putUrl).withBody(is(expectedBody)).doReturn(200, EMPTY_RESPONSE_BODY); + WriteAssertionsRequest request = new WriteAssertionsRequest() + .assertions(List.of(new Assertion() + .tupleKey(new TupleKey() + ._object(DEFAULT_OBJECT) + .relation(DEFAULT_RELATION) + .user(DEFAULT_USER)) + .expectation(true))); + + // When + fga.writeAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, request); + + // Then + mockHttpClient.verify().put(putUrl).withBody(is(expectedBody)).called(1); + } + + @Test + public void writeAssertions_storeIdRequired() { + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAssertions( + null, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'storeId' when calling writeAssertions", exception.getMessage()); + } + + @Test + public void writeAssertions_authModelIdRequired() { + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAssertions( + DEFAULT_STORE_ID, null, new WriteAssertionsRequest()) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals( + "Missing the required parameter 'authorizationModelId' when calling writeAssertions", + exception.getMessage()); + } + + @Test + public void writeAssertions_bodyRequired() { + // When + ExecutionException execException = assertThrows( + ExecutionException.class, () -> fga.writeAssertions(DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, null) + .get()); + + // Then + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals("Missing the required parameter 'body' when calling writeAssertions", exception.getMessage()); + } + + @Test + public void writeAssertions_400() throws Exception { + // Given + String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onPut(putUrl) + .doReturn(400, "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAssertions( + DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) + .get()); + + // Then + mockHttpClient.verify().put(putUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(400, exception.getCode()); + assertEquals( + "{\"code\":\"validation_error\",\"message\":\"Generic validation error\"}", + exception.getResponseBody()); + } + + @Test + public void writeAssertions_404() throws Exception { + // Given + String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onPut(putUrl) + .doReturn(404, "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAssertions( + DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) + .get()); + + // Then + mockHttpClient.verify().put(putUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(404, exception.getCode()); + assertEquals( + "{\"code\":\"undefined_endpoint\",\"message\":\"Endpoint not enabled\"}", exception.getResponseBody()); + } + + @Test + public void writeAssertions_500() throws Exception { + // Given + String putUrl = "https://localhost/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J"; + mockHttpClient + .onPut(putUrl) + .doReturn(500, "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}"); + + // When + ExecutionException execException = assertThrows(ExecutionException.class, () -> fga.writeAssertions( + DEFAULT_STORE_ID, DEFAULT_AUTH_MODEL_ID, new WriteAssertionsRequest()) + .get()); + + // Then + mockHttpClient.verify().put(putUrl).called(1); + ApiException exception = assertInstanceOf(ApiException.class, execException.getCause()); + assertEquals(500, exception.getCode()); + assertEquals( + "{\"code\":\"internal_error\",\"message\":\"Internal Server Error\"}", exception.getResponseBody()); + } +} diff --git a/src/test/java/dev/openfga/sdk/api/client/ClientCredentialsTest.java b/src/test/java/dev/openfga/sdk/api/client/ClientCredentialsTest.java new file mode 100644 index 0000000..6ae5606 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/client/ClientCredentialsTest.java @@ -0,0 +1,112 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.client; + +import static org.junit.jupiter.api.Assertions.*; + +import dev.openfga.sdk.errors.FgaInvalidParameterException; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class ClientCredentialsTest { + private static final List INVALID_IDENTIFIERS = Arrays.asList(null, "", "\t\r\n"); + private static final String VALID_CLIENT_ID = "client"; + private static final String VALID_CLIENT_SECRET = "secret"; + private static final String VALID_API_TOKEN_ISSUER = "tokenissuer.fga.example"; + private static final String VALID_API_AUDIENCE = "audience"; + + @Test + public void assertValid_allValid() throws FgaInvalidParameterException { + // When + ClientCredentials creds = new ClientCredentials() + .clientId(VALID_CLIENT_ID) + .clientSecret(VALID_CLIENT_SECRET) + .apiTokenIssuer(VALID_API_TOKEN_ISSUER) + .apiAudience(VALID_API_AUDIENCE); + + // Then + assertEquals(VALID_CLIENT_ID, creds.getClientId()); + assertEquals(VALID_CLIENT_SECRET, creds.getClientSecret()); + assertEquals(VALID_API_TOKEN_ISSUER, creds.getApiTokenIssuer()); + assertEquals(VALID_API_AUDIENCE, creds.getApiAudience()); + } + + @Test + public void assertValid_invalidClientId() { + INVALID_IDENTIFIERS.stream() + // Given + .map(invalid -> new ClientCredentials() + .clientId(invalid) + .clientSecret(VALID_CLIENT_SECRET) + .apiTokenIssuer(VALID_API_TOKEN_ISSUER) + .apiAudience(VALID_API_AUDIENCE)) + // When + .map(creds -> assertThrows(FgaInvalidParameterException.class, creds::assertValid)) + // Then + .forEach(exception -> assertEquals( + "Required parameter clientId was invalid when calling ClientCredentials.", + exception.getMessage())); + } + + @Test + public void assertValid_invalidClientSecret() { + INVALID_IDENTIFIERS.stream() + // Given + .map(invalid -> new ClientCredentials() + .clientId(VALID_CLIENT_ID) + .clientSecret(invalid) + .apiTokenIssuer(VALID_API_TOKEN_ISSUER) + .apiAudience(VALID_API_AUDIENCE)) + // When + .map(creds -> assertThrows(FgaInvalidParameterException.class, creds::assertValid)) + // Then + .forEach(exception -> assertEquals( + "Required parameter clientSecret was invalid when calling ClientCredentials.", + exception.getMessage())); + } + + @Test + public void assertValid_invalidApiTokenIssuer() { + INVALID_IDENTIFIERS.stream() + // Given + .map(invalid -> new ClientCredentials() + .clientId(VALID_CLIENT_ID) + .clientSecret(VALID_CLIENT_SECRET) + .apiTokenIssuer(invalid) + .apiAudience(VALID_API_AUDIENCE)) + // When + .map(creds -> assertThrows(FgaInvalidParameterException.class, creds::assertValid)) + // Then + .forEach(exception -> assertEquals( + "Required parameter apiTokenIssuer was invalid when calling ClientCredentials.", + exception.getMessage())); + } + + @Test + public void assertValid_invalidApiAudience() { + INVALID_IDENTIFIERS.stream() + // Given + .map(invalid -> new ClientCredentials() + .clientId(VALID_CLIENT_ID) + .clientSecret(VALID_CLIENT_SECRET) + .apiTokenIssuer(VALID_API_TOKEN_ISSUER) + .apiAudience(invalid)) + // When + .map(creds -> assertThrows(FgaInvalidParameterException.class, creds::assertValid)) + // Then + .forEach(exception -> assertEquals( + "Required parameter apiAudience was invalid when calling ClientCredentials.", + exception.getMessage())); + } +} diff --git a/src/test/java/dev/openfga/sdk/api/client/ConfigurationTest.java b/src/test/java/dev/openfga/sdk/api/client/ConfigurationTest.java new file mode 100644 index 0000000..6b5c33c --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/client/ConfigurationTest.java @@ -0,0 +1,87 @@ +package dev.openfga.sdk.api.client; + +import static org.junit.jupiter.api.Assertions.*; + +import dev.openfga.sdk.errors.*; +import org.junit.jupiter.api.Test; + +class ConfigurationTest { + @Test + void apiUrl_nullDefaults() throws FgaInvalidParameterException { + // Given + String apiUrl = null; + var config = new Configuration(apiUrl); + + // When + config.assertValid(); + + // Then + assertEquals("http://localhost:8080", config.getApiUrl()); + } + + @Test + void apiUrl_emptyStringDefaults() throws FgaInvalidParameterException { + // Given + String apiUrl = ""; + var config = new Configuration(apiUrl); + + // When + config.assertValid(); + + // Then + assertEquals("http://localhost:8080", config.getApiUrl()); + } + + @Test + void apiUrl_whitespaceStringDefaults() throws FgaInvalidParameterException { + // Given + String apiUrl = " \t\r\n"; + var config = new Configuration(apiUrl); + + // When + config.assertValid(); + + // Then + assertEquals("http://localhost:8080", config.getApiUrl()); + } + + @Test + void apiUrl_stringNoProtocolFails() { + String apiUrl = "localhost:8080"; + FgaInvalidParameterException e = assertThrows(FgaInvalidParameterException.class, () -> { + var config = new Configuration(apiUrl); + config.assertValid(); + }); + assertEquals("Required parameter apiUrl was invalid when calling Configuration.", e.getMessage()); + } + + @Test + void apiUrl_stringInvalidProtocolFails() { + String apiUrl = "zzz://localhost:8080"; + FgaInvalidParameterException e = assertThrows(FgaInvalidParameterException.class, () -> { + var config = new Configuration(apiUrl); + config.assertValid(); + }); + assertEquals("Required parameter apiUrl was invalid when calling Configuration.", e.getMessage()); + } + + @Test + void apiUrl_stringNoHostFails() { + String apiUrl = "http://"; + FgaInvalidParameterException e = assertThrows(FgaInvalidParameterException.class, () -> { + var config = new Configuration(apiUrl); + config.assertValid(); + }); + assertEquals("Required parameter apiUrl was invalid when calling Configuration.", e.getMessage()); + } + + @Test + void apiUrl_stringBadPortFails() { + String apiUrl = "http://localshost:abcd"; + FgaInvalidParameterException e = assertThrows(FgaInvalidParameterException.class, () -> { + var config = new Configuration(apiUrl); + config.assertValid(); + }); + assertEquals("Required parameter apiUrl was invalid when calling Configuration.", e.getMessage()); + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/AnyTest.java b/src/test/java/dev/openfga/sdk/api/model/AnyTest.java new file mode 100644 index 0000000..c01467f --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/AnyTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Any + */ +public class AnyTest { + private final Any model = new Any(); + + /** + * Model tests for Any + */ + @Test + public void testAny() { + // TODO: test Any + } + + /** + * Test the property 'atType' + */ + @Test + public void atTypeTest() { + // TODO: test atType + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/AssertionTest.java b/src/test/java/dev/openfga/sdk/api/model/AssertionTest.java new file mode 100644 index 0000000..c2b1703 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/AssertionTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Assertion + */ +public class AssertionTest { + private final Assertion model = new Assertion(); + + /** + * Model tests for Assertion + */ + @Test + public void testAssertion() { + // TODO: test Assertion + } + + /** + * Test the property 'tupleKey' + */ + @Test + public void tupleKeyTest() { + // TODO: test tupleKey + } + + /** + * Test the property 'expectation' + */ + @Test + public void expectationTest() { + // TODO: test expectation + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/AuthorizationModelTest.java b/src/test/java/dev/openfga/sdk/api/model/AuthorizationModelTest.java new file mode 100644 index 0000000..1500a4e --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/AuthorizationModelTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for AuthorizationModel + */ +public class AuthorizationModelTest { + private final AuthorizationModel model = new AuthorizationModel(); + + /** + * Model tests for AuthorizationModel + */ + @Test + public void testAuthorizationModel() { + // TODO: test AuthorizationModel + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'schemaVersion' + */ + @Test + public void schemaVersionTest() { + // TODO: test schemaVersion + } + + /** + * Test the property 'typeDefinitions' + */ + @Test + public void typeDefinitionsTest() { + // TODO: test typeDefinitions + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/CheckRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/CheckRequestTest.java new file mode 100644 index 0000000..fec5bbd --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/CheckRequestTest.java @@ -0,0 +1,62 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for CheckRequest + */ +public class CheckRequestTest { + private final CheckRequest model = new CheckRequest(); + + /** + * Model tests for CheckRequest + */ + @Test + public void testCheckRequest() { + // TODO: test CheckRequest + } + + /** + * Test the property 'tupleKey' + */ + @Test + public void tupleKeyTest() { + // TODO: test tupleKey + } + + /** + * Test the property 'contextualTuples' + */ + @Test + public void contextualTuplesTest() { + // TODO: test contextualTuples + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } + + /** + * Test the property 'trace' + */ + @Test + public void traceTest() { + // TODO: test trace + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/CheckResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/CheckResponseTest.java new file mode 100644 index 0000000..4d02dfc --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/CheckResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for CheckResponse + */ +public class CheckResponseTest { + private final CheckResponse model = new CheckResponse(); + + /** + * Model tests for CheckResponse + */ + @Test + public void testCheckResponse() { + // TODO: test CheckResponse + } + + /** + * Test the property 'allowed' + */ + @Test + public void allowedTest() { + // TODO: test allowed + } + + /** + * Test the property 'resolution' + */ + @Test + public void resolutionTest() { + // TODO: test resolution + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ComputedTest.java b/src/test/java/dev/openfga/sdk/api/model/ComputedTest.java new file mode 100644 index 0000000..2bc4d98 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ComputedTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Computed + */ +public class ComputedTest { + private final Computed model = new Computed(); + + /** + * Model tests for Computed + */ + @Test + public void testComputed() { + // TODO: test Computed + } + + /** + * Test the property 'userset' + */ + @Test + public void usersetTest() { + // TODO: test userset + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ContextualTupleKeysTest.java b/src/test/java/dev/openfga/sdk/api/model/ContextualTupleKeysTest.java new file mode 100644 index 0000000..5b14e72 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ContextualTupleKeysTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ContextualTupleKeys + */ +public class ContextualTupleKeysTest { + private final ContextualTupleKeys model = new ContextualTupleKeys(); + + /** + * Model tests for ContextualTupleKeys + */ + @Test + public void testContextualTupleKeys() { + // TODO: test ContextualTupleKeys + } + + /** + * Test the property 'tupleKeys' + */ + @Test + public void tupleKeysTest() { + // TODO: test tupleKeys + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/CreateStoreRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/CreateStoreRequestTest.java new file mode 100644 index 0000000..4472a9b --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/CreateStoreRequestTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for CreateStoreRequest + */ +public class CreateStoreRequestTest { + private final CreateStoreRequest model = new CreateStoreRequest(); + + /** + * Model tests for CreateStoreRequest + */ + @Test + public void testCreateStoreRequest() { + // TODO: test CreateStoreRequest + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/CreateStoreResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/CreateStoreResponseTest.java new file mode 100644 index 0000000..143a3cd --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/CreateStoreResponseTest.java @@ -0,0 +1,62 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for CreateStoreResponse + */ +public class CreateStoreResponseTest { + private final CreateStoreResponse model = new CreateStoreResponse(); + + /** + * Model tests for CreateStoreResponse + */ + @Test + public void testCreateStoreResponse() { + // TODO: test CreateStoreResponse + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'createdAt' + */ + @Test + public void createdAtTest() { + // TODO: test createdAt + } + + /** + * Test the property 'updatedAt' + */ + @Test + public void updatedAtTest() { + // TODO: test updatedAt + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/DifferenceTest.java b/src/test/java/dev/openfga/sdk/api/model/DifferenceTest.java new file mode 100644 index 0000000..ca28ecd --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/DifferenceTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Difference + */ +public class DifferenceTest { + private final Difference model = new Difference(); + + /** + * Model tests for Difference + */ + @Test + public void testDifference() { + // TODO: test Difference + } + + /** + * Test the property 'base' + */ + @Test + public void baseTest() { + // TODO: test base + } + + /** + * Test the property 'subtract' + */ + @Test + public void subtractTest() { + // TODO: test subtract + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ErrorCodeTest.java b/src/test/java/dev/openfga/sdk/api/model/ErrorCodeTest.java new file mode 100644 index 0000000..56d0cde --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ErrorCodeTest.java @@ -0,0 +1,28 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ErrorCode + */ +public class ErrorCodeTest { + /** + * Model tests for ErrorCode + */ + @Test + public void testErrorCode() { + // TODO: test ErrorCode + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ExpandRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/ExpandRequestTest.java new file mode 100644 index 0000000..127a496 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ExpandRequestTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ExpandRequest + */ +public class ExpandRequestTest { + private final ExpandRequest model = new ExpandRequest(); + + /** + * Model tests for ExpandRequest + */ + @Test + public void testExpandRequest() { + // TODO: test ExpandRequest + } + + /** + * Test the property 'tupleKey' + */ + @Test + public void tupleKeyTest() { + // TODO: test tupleKey + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ExpandResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ExpandResponseTest.java new file mode 100644 index 0000000..24eeb39 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ExpandResponseTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ExpandResponse + */ +public class ExpandResponseTest { + private final ExpandResponse model = new ExpandResponse(); + + /** + * Model tests for ExpandResponse + */ + @Test + public void testExpandResponse() { + // TODO: test ExpandResponse + } + + /** + * Test the property 'tree' + */ + @Test + public void treeTest() { + // TODO: test tree + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/GetStoreResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/GetStoreResponseTest.java new file mode 100644 index 0000000..aad87d4 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/GetStoreResponseTest.java @@ -0,0 +1,62 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for GetStoreResponse + */ +public class GetStoreResponseTest { + private final GetStoreResponse model = new GetStoreResponse(); + + /** + * Model tests for GetStoreResponse + */ + @Test + public void testGetStoreResponse() { + // TODO: test GetStoreResponse + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'createdAt' + */ + @Test + public void createdAtTest() { + // TODO: test createdAt + } + + /** + * Test the property 'updatedAt' + */ + @Test + public void updatedAtTest() { + // TODO: test updatedAt + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/InternalErrorCodeTest.java b/src/test/java/dev/openfga/sdk/api/model/InternalErrorCodeTest.java new file mode 100644 index 0000000..0a74ca7 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/InternalErrorCodeTest.java @@ -0,0 +1,28 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for InternalErrorCode + */ +public class InternalErrorCodeTest { + /** + * Model tests for InternalErrorCode + */ + @Test + public void testInternalErrorCode() { + // TODO: test InternalErrorCode + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/InternalErrorMessageResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/InternalErrorMessageResponseTest.java new file mode 100644 index 0000000..a08a34d --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/InternalErrorMessageResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for InternalErrorMessageResponse + */ +public class InternalErrorMessageResponseTest { + private final InternalErrorMessageResponse model = new InternalErrorMessageResponse(); + + /** + * Model tests for InternalErrorMessageResponse + */ + @Test + public void testInternalErrorMessageResponse() { + // TODO: test InternalErrorMessageResponse + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/LeafTest.java b/src/test/java/dev/openfga/sdk/api/model/LeafTest.java new file mode 100644 index 0000000..5c2cb5c --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/LeafTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Leaf + */ +public class LeafTest { + private final Leaf model = new Leaf(); + + /** + * Model tests for Leaf + */ + @Test + public void testLeaf() { + // TODO: test Leaf + } + + /** + * Test the property 'users' + */ + @Test + public void usersTest() { + // TODO: test users + } + + /** + * Test the property 'computed' + */ + @Test + public void computedTest() { + // TODO: test computed + } + + /** + * Test the property 'tupleToUserset' + */ + @Test + public void tupleToUsersetTest() { + // TODO: test tupleToUserset + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ListObjectsRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/ListObjectsRequestTest.java new file mode 100644 index 0000000..a2f5337 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ListObjectsRequestTest.java @@ -0,0 +1,70 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ListObjectsRequest + */ +public class ListObjectsRequestTest { + private final ListObjectsRequest model = new ListObjectsRequest(); + + /** + * Model tests for ListObjectsRequest + */ + @Test + public void testListObjectsRequest() { + // TODO: test ListObjectsRequest + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'relation' + */ + @Test + public void relationTest() { + // TODO: test relation + } + + /** + * Test the property 'user' + */ + @Test + public void userTest() { + // TODO: test user + } + + /** + * Test the property 'contextualTuples' + */ + @Test + public void contextualTuplesTest() { + // TODO: test contextualTuples + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ListObjectsResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ListObjectsResponseTest.java new file mode 100644 index 0000000..67d15cd --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ListObjectsResponseTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ListObjectsResponse + */ +public class ListObjectsResponseTest { + private final ListObjectsResponse model = new ListObjectsResponse(); + + /** + * Model tests for ListObjectsResponse + */ + @Test + public void testListObjectsResponse() { + // TODO: test ListObjectsResponse + } + + /** + * Test the property 'objects' + */ + @Test + public void objectsTest() { + // TODO: test objects + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ListStoresResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ListStoresResponseTest.java new file mode 100644 index 0000000..1fb61eb --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ListStoresResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ListStoresResponse + */ +public class ListStoresResponseTest { + private final ListStoresResponse model = new ListStoresResponse(); + + /** + * Model tests for ListStoresResponse + */ + @Test + public void testListStoresResponse() { + // TODO: test ListStoresResponse + } + + /** + * Test the property 'stores' + */ + @Test + public void storesTest() { + // TODO: test stores + } + + /** + * Test the property 'continuationToken' + */ + @Test + public void continuationTokenTest() { + // TODO: test continuationToken + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/MetadataTest.java b/src/test/java/dev/openfga/sdk/api/model/MetadataTest.java new file mode 100644 index 0000000..b85bb35 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/MetadataTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Metadata + */ +public class MetadataTest { + private final Metadata model = new Metadata(); + + /** + * Model tests for Metadata + */ + @Test + public void testMetadata() { + // TODO: test Metadata + } + + /** + * Test the property 'relations' + */ + @Test + public void relationsTest() { + // TODO: test relations + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/NodeTest.java b/src/test/java/dev/openfga/sdk/api/model/NodeTest.java new file mode 100644 index 0000000..e7ca0e8 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/NodeTest.java @@ -0,0 +1,70 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Node + */ +public class NodeTest { + private final Node model = new Node(); + + /** + * Model tests for Node + */ + @Test + public void testNode() { + // TODO: test Node + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'leaf' + */ + @Test + public void leafTest() { + // TODO: test leaf + } + + /** + * Test the property 'difference' + */ + @Test + public void differenceTest() { + // TODO: test difference + } + + /** + * Test the property 'union' + */ + @Test + public void unionTest() { + // TODO: test union + } + + /** + * Test the property 'intersection' + */ + @Test + public void intersectionTest() { + // TODO: test intersection + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/NodesTest.java b/src/test/java/dev/openfga/sdk/api/model/NodesTest.java new file mode 100644 index 0000000..12c0331 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/NodesTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Nodes + */ +public class NodesTest { + private final Nodes model = new Nodes(); + + /** + * Model tests for Nodes + */ + @Test + public void testNodes() { + // TODO: test Nodes + } + + /** + * Test the property 'nodes' + */ + @Test + public void nodesTest() { + // TODO: test nodes + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/NotFoundErrorCodeTest.java b/src/test/java/dev/openfga/sdk/api/model/NotFoundErrorCodeTest.java new file mode 100644 index 0000000..89a6a20 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/NotFoundErrorCodeTest.java @@ -0,0 +1,28 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for NotFoundErrorCode + */ +public class NotFoundErrorCodeTest { + /** + * Model tests for NotFoundErrorCode + */ + @Test + public void testNotFoundErrorCode() { + // TODO: test NotFoundErrorCode + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ObjectRelationTest.java b/src/test/java/dev/openfga/sdk/api/model/ObjectRelationTest.java new file mode 100644 index 0000000..4250939 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ObjectRelationTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ObjectRelation + */ +public class ObjectRelationTest { + private final ObjectRelation model = new ObjectRelation(); + + /** + * Model tests for ObjectRelation + */ + @Test + public void testObjectRelation() { + // TODO: test ObjectRelation + } + + /** + * Test the property '_object' + */ + @Test + public void _objectTest() { + // TODO: test _object + } + + /** + * Test the property 'relation' + */ + @Test + public void relationTest() { + // TODO: test relation + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponseTest.java new file mode 100644 index 0000000..587ba31 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/PathUnknownErrorMessageResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for PathUnknownErrorMessageResponse + */ +public class PathUnknownErrorMessageResponseTest { + private final PathUnknownErrorMessageResponse model = new PathUnknownErrorMessageResponse(); + + /** + * Model tests for PathUnknownErrorMessageResponse + */ + @Test + public void testPathUnknownErrorMessageResponse() { + // TODO: test PathUnknownErrorMessageResponse + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadAssertionsResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadAssertionsResponseTest.java new file mode 100644 index 0000000..521492e --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadAssertionsResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadAssertionsResponse + */ +public class ReadAssertionsResponseTest { + private final ReadAssertionsResponse model = new ReadAssertionsResponse(); + + /** + * Model tests for ReadAssertionsResponse + */ + @Test + public void testReadAssertionsResponse() { + // TODO: test ReadAssertionsResponse + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } + + /** + * Test the property 'assertions' + */ + @Test + public void assertionsTest() { + // TODO: test assertions + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponseTest.java new file mode 100644 index 0000000..845a766 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelResponseTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadAuthorizationModelResponse + */ +public class ReadAuthorizationModelResponseTest { + private final ReadAuthorizationModelResponse model = new ReadAuthorizationModelResponse(); + + /** + * Model tests for ReadAuthorizationModelResponse + */ + @Test + public void testReadAuthorizationModelResponse() { + // TODO: test ReadAuthorizationModelResponse + } + + /** + * Test the property 'authorizationModel' + */ + @Test + public void authorizationModelTest() { + // TODO: test authorizationModel + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponseTest.java new file mode 100644 index 0000000..80d9821 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadAuthorizationModelsResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadAuthorizationModelsResponse + */ +public class ReadAuthorizationModelsResponseTest { + private final ReadAuthorizationModelsResponse model = new ReadAuthorizationModelsResponse(); + + /** + * Model tests for ReadAuthorizationModelsResponse + */ + @Test + public void testReadAuthorizationModelsResponse() { + // TODO: test ReadAuthorizationModelsResponse + } + + /** + * Test the property 'authorizationModels' + */ + @Test + public void authorizationModelsTest() { + // TODO: test authorizationModels + } + + /** + * Test the property 'continuationToken' + */ + @Test + public void continuationTokenTest() { + // TODO: test continuationToken + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadChangesResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadChangesResponseTest.java new file mode 100644 index 0000000..8b11f6c --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadChangesResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadChangesResponse + */ +public class ReadChangesResponseTest { + private final ReadChangesResponse model = new ReadChangesResponse(); + + /** + * Model tests for ReadChangesResponse + */ + @Test + public void testReadChangesResponse() { + // TODO: test ReadChangesResponse + } + + /** + * Test the property 'changes' + */ + @Test + public void changesTest() { + // TODO: test changes + } + + /** + * Test the property 'continuationToken' + */ + @Test + public void continuationTokenTest() { + // TODO: test continuationToken + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadRequestTest.java new file mode 100644 index 0000000..955310a --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadRequestTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadRequest + */ +public class ReadRequestTest { + private final ReadRequest model = new ReadRequest(); + + /** + * Model tests for ReadRequest + */ + @Test + public void testReadRequest() { + // TODO: test ReadRequest + } + + /** + * Test the property 'tupleKey' + */ + @Test + public void tupleKeyTest() { + // TODO: test tupleKey + } + + /** + * Test the property 'pageSize' + */ + @Test + public void pageSizeTest() { + // TODO: test pageSize + } + + /** + * Test the property 'continuationToken' + */ + @Test + public void continuationTokenTest() { + // TODO: test continuationToken + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ReadResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ReadResponseTest.java new file mode 100644 index 0000000..59fb83d --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ReadResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ReadResponse + */ +public class ReadResponseTest { + private final ReadResponse model = new ReadResponse(); + + /** + * Model tests for ReadResponse + */ + @Test + public void testReadResponse() { + // TODO: test ReadResponse + } + + /** + * Test the property 'tuples' + */ + @Test + public void tuplesTest() { + // TODO: test tuples + } + + /** + * Test the property 'continuationToken' + */ + @Test + public void continuationTokenTest() { + // TODO: test continuationToken + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/RelationMetadataTest.java b/src/test/java/dev/openfga/sdk/api/model/RelationMetadataTest.java new file mode 100644 index 0000000..82763ae --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/RelationMetadataTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for RelationMetadata + */ +public class RelationMetadataTest { + private final RelationMetadata model = new RelationMetadata(); + + /** + * Model tests for RelationMetadata + */ + @Test + public void testRelationMetadata() { + // TODO: test RelationMetadata + } + + /** + * Test the property 'directlyRelatedUserTypes' + */ + @Test + public void directlyRelatedUserTypesTest() { + // TODO: test directlyRelatedUserTypes + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/RelationReferenceTest.java b/src/test/java/dev/openfga/sdk/api/model/RelationReferenceTest.java new file mode 100644 index 0000000..a738757 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/RelationReferenceTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for RelationReference + */ +public class RelationReferenceTest { + private final RelationReference model = new RelationReference(); + + /** + * Model tests for RelationReference + */ + @Test + public void testRelationReference() { + // TODO: test RelationReference + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'relation' + */ + @Test + public void relationTest() { + // TODO: test relation + } + + /** + * Test the property 'wildcard' + */ + @Test + public void wildcardTest() { + // TODO: test wildcard + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/StatusTest.java b/src/test/java/dev/openfga/sdk/api/model/StatusTest.java new file mode 100644 index 0000000..0262f9f --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/StatusTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Status + */ +public class StatusTest { + private final Status model = new Status(); + + /** + * Model tests for Status + */ + @Test + public void testStatus() { + // TODO: test Status + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + + /** + * Test the property 'details' + */ + @Test + public void detailsTest() { + // TODO: test details + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/StoreTest.java b/src/test/java/dev/openfga/sdk/api/model/StoreTest.java new file mode 100644 index 0000000..2ed2f53 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/StoreTest.java @@ -0,0 +1,70 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Store + */ +public class StoreTest { + private final Store model = new Store(); + + /** + * Model tests for Store + */ + @Test + public void testStore() { + // TODO: test Store + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'createdAt' + */ + @Test + public void createdAtTest() { + // TODO: test createdAt + } + + /** + * Test the property 'updatedAt' + */ + @Test + public void updatedAtTest() { + // TODO: test updatedAt + } + + /** + * Test the property 'deletedAt' + */ + @Test + public void deletedAtTest() { + // TODO: test deletedAt + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleChangeTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleChangeTest.java new file mode 100644 index 0000000..43a626f --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleChangeTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TupleChange + */ +public class TupleChangeTest { + private final TupleChange model = new TupleChange(); + + /** + * Model tests for TupleChange + */ + @Test + public void testTupleChange() { + // TODO: test TupleChange + } + + /** + * Test the property 'tupleKey' + */ + @Test + public void tupleKeyTest() { + // TODO: test tupleKey + } + + /** + * Test the property 'operation' + */ + @Test + public void operationTest() { + // TODO: test operation + } + + /** + * Test the property 'timestamp' + */ + @Test + public void timestampTest() { + // TODO: test timestamp + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleKeyTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleKeyTest.java new file mode 100644 index 0000000..ef9e315 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleKeyTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TupleKey + */ +public class TupleKeyTest { + private final TupleKey model = new TupleKey(); + + /** + * Model tests for TupleKey + */ + @Test + public void testTupleKey() { + // TODO: test TupleKey + } + + /** + * Test the property '_object' + */ + @Test + public void _objectTest() { + // TODO: test _object + } + + /** + * Test the property 'relation' + */ + @Test + public void relationTest() { + // TODO: test relation + } + + /** + * Test the property 'user' + */ + @Test + public void userTest() { + // TODO: test user + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleKeysTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleKeysTest.java new file mode 100644 index 0000000..a57d57b --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleKeysTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TupleKeys + */ +public class TupleKeysTest { + private final TupleKeys model = new TupleKeys(); + + /** + * Model tests for TupleKeys + */ + @Test + public void testTupleKeys() { + // TODO: test TupleKeys + } + + /** + * Test the property 'tupleKeys' + */ + @Test + public void tupleKeysTest() { + // TODO: test tupleKeys + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleOperationTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleOperationTest.java new file mode 100644 index 0000000..4bc1458 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleOperationTest.java @@ -0,0 +1,28 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TupleOperation + */ +public class TupleOperationTest { + /** + * Model tests for TupleOperation + */ + @Test + public void testTupleOperation() { + // TODO: test TupleOperation + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleTest.java new file mode 100644 index 0000000..c56c98c --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Tuple + */ +public class TupleTest { + private final Tuple model = new Tuple(); + + /** + * Model tests for Tuple + */ + @Test + public void testTuple() { + // TODO: test Tuple + } + + /** + * Test the property 'key' + */ + @Test + public void keyTest() { + // TODO: test key + } + + /** + * Test the property 'timestamp' + */ + @Test + public void timestampTest() { + // TODO: test timestamp + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TupleToUsersetTest.java b/src/test/java/dev/openfga/sdk/api/model/TupleToUsersetTest.java new file mode 100644 index 0000000..00d0944 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TupleToUsersetTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TupleToUserset + */ +public class TupleToUsersetTest { + private final TupleToUserset model = new TupleToUserset(); + + /** + * Model tests for TupleToUserset + */ + @Test + public void testTupleToUserset() { + // TODO: test TupleToUserset + } + + /** + * Test the property 'tupleset' + */ + @Test + public void tuplesetTest() { + // TODO: test tupleset + } + + /** + * Test the property 'computedUserset' + */ + @Test + public void computedUsersetTest() { + // TODO: test computedUserset + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/TypeDefinitionTest.java b/src/test/java/dev/openfga/sdk/api/model/TypeDefinitionTest.java new file mode 100644 index 0000000..f0b4f6b --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/TypeDefinitionTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for TypeDefinition + */ +public class TypeDefinitionTest { + private final TypeDefinition model = new TypeDefinition(); + + /** + * Model tests for TypeDefinition + */ + @Test + public void testTypeDefinition() { + // TODO: test TypeDefinition + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'relations' + */ + @Test + public void relationsTest() { + // TODO: test relations + } + + /** + * Test the property 'metadata' + */ + @Test + public void metadataTest() { + // TODO: test metadata + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersTest.java new file mode 100644 index 0000000..a3fb034 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Users + */ +public class UsersTest { + private final Users model = new Users(); + + /** + * Model tests for Users + */ + @Test + public void testUsers() { + // TODO: test Users + } + + /** + * Test the property 'users' + */ + @Test + public void usersTest() { + // TODO: test users + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersetTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersetTest.java new file mode 100644 index 0000000..819e997 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersetTest.java @@ -0,0 +1,78 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Userset + */ +public class UsersetTest { + private final Userset model = new Userset(); + + /** + * Model tests for Userset + */ + @Test + public void testUserset() { + // TODO: test Userset + } + + /** + * Test the property '_this' + */ + @Test + public void _thisTest() { + // TODO: test _this + } + + /** + * Test the property 'computedUserset' + */ + @Test + public void computedUsersetTest() { + // TODO: test computedUserset + } + + /** + * Test the property 'tupleToUserset' + */ + @Test + public void tupleToUsersetTest() { + // TODO: test tupleToUserset + } + + /** + * Test the property 'union' + */ + @Test + public void unionTest() { + // TODO: test union + } + + /** + * Test the property 'intersection' + */ + @Test + public void intersectionTest() { + // TODO: test intersection + } + + /** + * Test the property 'difference' + */ + @Test + public void differenceTest() { + // TODO: test difference + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersetTreeDifferenceTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeDifferenceTest.java new file mode 100644 index 0000000..43a13ac --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeDifferenceTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for UsersetTreeDifference + */ +public class UsersetTreeDifferenceTest { + private final UsersetTreeDifference model = new UsersetTreeDifference(); + + /** + * Model tests for UsersetTreeDifference + */ + @Test + public void testUsersetTreeDifference() { + // TODO: test UsersetTreeDifference + } + + /** + * Test the property 'base' + */ + @Test + public void baseTest() { + // TODO: test base + } + + /** + * Test the property 'subtract' + */ + @Test + public void subtractTest() { + // TODO: test subtract + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTest.java new file mode 100644 index 0000000..9aea5c0 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for UsersetTree + */ +public class UsersetTreeTest { + private final UsersetTree model = new UsersetTree(); + + /** + * Model tests for UsersetTree + */ + @Test + public void testUsersetTree() { + // TODO: test UsersetTree + } + + /** + * Test the property 'root' + */ + @Test + public void rootTest() { + // TODO: test root + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUsersetTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUsersetTest.java new file mode 100644 index 0000000..d730491 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersetTreeTupleToUsersetTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for UsersetTreeTupleToUserset + */ +public class UsersetTreeTupleToUsersetTest { + private final UsersetTreeTupleToUserset model = new UsersetTreeTupleToUserset(); + + /** + * Model tests for UsersetTreeTupleToUserset + */ + @Test + public void testUsersetTreeTupleToUserset() { + // TODO: test UsersetTreeTupleToUserset + } + + /** + * Test the property 'tupleset' + */ + @Test + public void tuplesetTest() { + // TODO: test tupleset + } + + /** + * Test the property 'computed' + */ + @Test + public void computedTest() { + // TODO: test computed + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/UsersetsTest.java b/src/test/java/dev/openfga/sdk/api/model/UsersetsTest.java new file mode 100644 index 0000000..b9fa799 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/UsersetsTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for Usersets + */ +public class UsersetsTest { + private final Usersets model = new Usersets(); + + /** + * Model tests for Usersets + */ + @Test + public void testUsersets() { + // TODO: test Usersets + } + + /** + * Test the property 'child' + */ + @Test + public void childTest() { + // TODO: test child + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponseTest.java new file mode 100644 index 0000000..43f6bd1 --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/ValidationErrorMessageResponseTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ValidationErrorMessageResponse + */ +public class ValidationErrorMessageResponseTest { + private final ValidationErrorMessageResponse model = new ValidationErrorMessageResponse(); + + /** + * Model tests for ValidationErrorMessageResponse + */ + @Test + public void testValidationErrorMessageResponse() { + // TODO: test ValidationErrorMessageResponse + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/WriteAssertionsRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/WriteAssertionsRequestTest.java new file mode 100644 index 0000000..feb1e5c --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/WriteAssertionsRequestTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for WriteAssertionsRequest + */ +public class WriteAssertionsRequestTest { + private final WriteAssertionsRequest model = new WriteAssertionsRequest(); + + /** + * Model tests for WriteAssertionsRequest + */ + @Test + public void testWriteAssertionsRequest() { + // TODO: test WriteAssertionsRequest + } + + /** + * Test the property 'assertions' + */ + @Test + public void assertionsTest() { + // TODO: test assertions + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequestTest.java new file mode 100644 index 0000000..de5bbcd --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelRequestTest.java @@ -0,0 +1,46 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for WriteAuthorizationModelRequest + */ +public class WriteAuthorizationModelRequestTest { + private final WriteAuthorizationModelRequest model = new WriteAuthorizationModelRequest(); + + /** + * Model tests for WriteAuthorizationModelRequest + */ + @Test + public void testWriteAuthorizationModelRequest() { + // TODO: test WriteAuthorizationModelRequest + } + + /** + * Test the property 'typeDefinitions' + */ + @Test + public void typeDefinitionsTest() { + // TODO: test typeDefinitions + } + + /** + * Test the property 'schemaVersion' + */ + @Test + public void schemaVersionTest() { + // TODO: test schemaVersion + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponseTest.java b/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponseTest.java new file mode 100644 index 0000000..815f06f --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/WriteAuthorizationModelResponseTest.java @@ -0,0 +1,38 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for WriteAuthorizationModelResponse + */ +public class WriteAuthorizationModelResponseTest { + private final WriteAuthorizationModelResponse model = new WriteAuthorizationModelResponse(); + + /** + * Model tests for WriteAuthorizationModelResponse + */ + @Test + public void testWriteAuthorizationModelResponse() { + // TODO: test WriteAuthorizationModelResponse + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } +} diff --git a/src/test/java/dev/openfga/sdk/api/model/WriteRequestTest.java b/src/test/java/dev/openfga/sdk/api/model/WriteRequestTest.java new file mode 100644 index 0000000..85966ca --- /dev/null +++ b/src/test/java/dev/openfga/sdk/api/model/WriteRequestTest.java @@ -0,0 +1,54 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.sdk.api.model; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for WriteRequest + */ +public class WriteRequestTest { + private final WriteRequest model = new WriteRequest(); + + /** + * Model tests for WriteRequest + */ + @Test + public void testWriteRequest() { + // TODO: test WriteRequest + } + + /** + * Test the property 'writes' + */ + @Test + public void writesTest() { + // TODO: test writes + } + + /** + * Test the property 'deletes' + */ + @Test + public void deletesTest() { + // TODO: test deletes + } + + /** + * Test the property 'authorizationModelId' + */ + @Test + public void authorizationModelIdTest() { + // TODO: test authorizationModelId + } +} diff --git a/src/test/java/dev/openfga/util/StringUtilTest.java b/src/test/java/dev/openfga/util/StringUtilTest.java new file mode 100644 index 0000000..0a92d00 --- /dev/null +++ b/src/test/java/dev/openfga/util/StringUtilTest.java @@ -0,0 +1,50 @@ +/* + * OpenFGA + * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. + * + * The version of the OpenAPI document: 0.1 + * Contact: community@openfga.dev + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package dev.openfga.util; + +import static dev.openfga.util.StringUtil.isNullOrWhitespace; +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class StringUtilTest { + @Test + public void isNullOrWhitespace_someContent_false() { + assertFalse(isNullOrWhitespace("abc")); + } + + @Test + public void isNullOrWhitespace_null_true() { + assertTrue(isNullOrWhitespace(null)); + } + + @Test + public void isNullOrWhitespace_empty_true() { + assertTrue(isNullOrWhitespace("")); + } + + @Test + public void isNullOrWhitespace_singleSpace_true() { + assertTrue(isNullOrWhitespace(" ")); + } + + @Test + public void isNullOrWhitespace_multipleSpace_true() { + assertTrue(isNullOrWhitespace(" ")); + } + + @Test + public void isNullOrWhitespace_multipleOtherWhitespace_true() { + assertTrue(isNullOrWhitespace(" \t\r\n")); + } +}