diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a35c2aa --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gradle" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml new file mode 100644 index 0000000..3ba65c0 --- /dev/null +++ b/.github/workflows/gradle-publish.yml @@ -0,0 +1,60 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle + +name: Release +on: + push: + branches: + - main + - rc + - beta + - alpha + - "*.x" + +jobs: + get-next-version: + uses: lenra-io/github-actions/.github/workflows/get-version.yml@main + + release: + needs: [get-next-version] + if: ${{ needs.get-next-version.outputs.will-release == 'true' }} + uses: lenra-io/github-actions/.github/workflows/release.yml@main + + publish: + name: publish + needs: [get-next-version] + if: ${{ needs.get-next-version.outputs.will-release == 'true' }} + runs-on: ubuntu-latest + env: + VERSION: ${{ needs.get-next-version.outputs.version }} + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - run: sed -E "s/^(version\s*=\s*)(.+)\$/\1${{ env.VERSION }}/" -i gradle.properties + + - name: Build with Gradle + run: ./gradlew build + + - name: Publish to GitHub Packages + run: ./gradlew publish + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index c4ae299..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,30 +0,0 @@ -# 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 Lenra server internal API - 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/.gitignore b/.gitignore index a530464..327f1e9 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ hs_err_pid* target .gradle build + +/api/ diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 872e5bc..9794fd8 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -5,8 +5,10 @@ api/openapi.yaml build.gradle build.sbt docs/DataApi.md -docs/DataDocument.md +docs/DataOptions.md docs/FindDocumentsRequest.md +docs/InsertManyDocuments200Response.md +docs/InsertManyDocumentsRequest.md docs/UpdateManyDocumentsRequest.md git_push.sh gradle.properties @@ -35,6 +37,11 @@ src/main/java/io/lenra/api/internal/auth/HttpBasicAuth.java src/main/java/io/lenra/api/internal/auth/HttpBearerAuth.java src/main/java/io/lenra/api/internal/client/DataApi.java src/main/java/io/lenra/api/internal/client/model/AbstractOpenApiSchema.java -src/main/java/io/lenra/api/internal/client/model/DataDocument.java +src/main/java/io/lenra/api/internal/client/model/DataOptions.java src/main/java/io/lenra/api/internal/client/model/FindDocumentsRequest.java +src/main/java/io/lenra/api/internal/client/model/InsertManyDocuments200Response.java +src/main/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequest.java src/main/java/io/lenra/api/internal/client/model/UpdateManyDocumentsRequest.java +src/test/java/io/lenra/api/internal/client/model/DataOptionsTest.java +src/test/java/io/lenra/api/internal/client/model/InsertManyDocuments200ResponseTest.java +src/test/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequestTest.java diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 40e3636..c9e125b 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.1.0-SNAPSHOT \ No newline at end of file +7.4.0-SNAPSHOT diff --git a/README.md b/README.md index 8e8b775..0f04c0b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # lenra-internal-api-client +```bash +# Load API +## With wget +wget https://github.com/lenra-io/api/releases/latest/download/load-api.sh -O - -q | bash +## With curl +curl -fsSL https://github.com/lenra-io/api/releases/latest/download/load-api.sh | bash +``` + +Generate + ```bash docker run --rm -v ${PWD}:/local --workdir /local openapitools/openapi-generator-cli batch /local/gen-conf/java.yml ``` diff --git a/api/api-version.txt b/api/api-version.txt deleted file mode 100644 index 6d7de6e..0000000 --- a/api/api-version.txt +++ /dev/null @@ -1 +0,0 @@ -1.0.2 diff --git a/api/api.tar.gz b/api/api.tar.gz deleted file mode 100644 index da5c019..0000000 Binary files a/api/api.tar.gz and /dev/null differ diff --git a/api/internal-api.yml b/api/internal-api.yml deleted file mode 100644 index 068fd69..0000000 --- a/api/internal-api.yml +++ /dev/null @@ -1,316 +0,0 @@ -openapi: 3.1.0 -info: - title: Lenra server internal API - description: The API usable by the Lenra applications - license: - name: MIT - url: https://opensource.org/licenses/MIT - version: 0.0.0 - contact: - name: Lenra - url: https://www.lenra.io/contact.html -servers: - - url: http://localhost:4001 - description: Devtool -tags: - - name: Data - description: Data management API -components: - securitySchemes: - bearerAuth: - type: http - scheme: bearer - schemas: - data.document: - title: Document - description: A document in MongoDB database - type: object - properties: - _id: - type: string - description: The document identifier - additionalProperties: true - data.query: - title: Query - description: Mongo data query - type: object - properties: {} - additionalProperties: true - data.result.find: - title: FindResult - description: Find query result. - type: object - additionalProperties: {} - data.update: - title: Query - description: Mongo data query - type: object - additionalProperties: true -security: - - bearerAuth: - - api - - transaction -paths: - /app-api/v1-api/v1/data/colls/{coll}: - delete: - tags: - - Data - summary: Deletes a collection from database - operationId: deleteCollection - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - responses: - "200": - description: Collection deleted - /app-api/v1/data/colls/{coll}/docs: - get: - tags: - - Data - summary: Gets documents from database - operationId: getDocuments - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - responses: - "200": - description: Documents found - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/data.document" - post: - tags: - - Data - summary: Creates a document in database - operationId: createDocument - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - requestBody: - description: The document to create - required: true - content: - application/json: - schema: - type: object - responses: - "200": - description: Document created - content: - application/json: - schema: - $ref: "#/components/schemas/data.document" - /app-api/v1/data/colls/{coll}/docs/{id}: - get: - tags: - - Data - summary: Gets a document from database - operationId: getDocumentById - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - - name: id - in: path - description: The document identifier - required: true - schema: - type: string - responses: - "200": - description: Document created - content: - application/json: - schema: - $ref: "#/components/schemas/data.document" - put: - tags: - - Data - summary: Updates a document in database - operationId: updateDocumentById - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - - name: id - in: path - description: The document identifier - required: true - schema: - type: string - requestBody: - description: The document to update - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/data.document" - responses: - "200": - description: Document updated - content: - application/json: - schema: - $ref: "#/components/schemas/data.document" - delete: - tags: - - Data - summary: Deletes a document from database - operationId: deleteDocumentById - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - - name: id - in: path - description: The document identifier - required: true - schema: - type: string - responses: - "200": - description: Document deleted - content: - application/json: - schema: - $ref: "#/components/schemas/data.document" - /app-api/v1/data/colls/{coll}/find: - post: - tags: - - Data - summary: Finds documents in database - operationId: findDocuments - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - requestBody: - description: The query to find documents - required: true - content: - application/json: - schema: - type: object - properties: - query: - $ref: "#/components/schemas/data.query" - projection: - type: object - nullable: true - additionalProperties: true - required: - - query - additionalProperties: false - responses: - "200": - description: Documents found - content: - application/json: - schema: - $ref: "#/components/schemas/data.result.find" - /app-api/v1/data/colls/{coll}/updateMany: - post: - tags: - - Data - summary: Updates many documents in database - operationId: updateManyDocuments - parameters: - - name: coll - in: path - description: The document collection name - required: true - schema: - type: string - requestBody: - description: The query to find documents - required: true - content: - application/json: - schema: - type: object - properties: - filter: - $ref: "#/components/schemas/data.query" - nullable: false - update: - $ref: "#/components/schemas/data.update" - nullable: false - required: - - filter - - update - additionalProperties: false - responses: - "200": - description: Documents updated - content: - application/json: - schema: - type: object - /app-api/v1/data/transaction: - post: - tags: - - Data - summary: Creates a transaction - operationId: createTransaction - security: - - bearerAuth: - - api - responses: - "200": - description: Transaction created - content: - application/json: - schema: - description: The transaction token - type: string - /app-api/v1/data/transaction/commit: - post: - tags: - - Data - summary: Commits a transaction - operationId: commitTransaction - security: - - bearerAuth: - - transaction - responses: - "200": - description: Transaction commited - /app-api/v1/data/transaction/abort: - post: - tags: - - Data - summary: Aborts a transaction - operationId: abortTransaction - security: - - bearerAuth: - - transaction - responses: - "200": - description: Transaction aborted diff --git a/api/openapi.yaml b/api/openapi.yaml deleted file mode 100644 index 2eee8f6..0000000 --- a/api/openapi.yaml +++ /dev/null @@ -1,365 +0,0 @@ -openapi: 3.1.0 -info: - contact: - name: Lenra - url: https://www.lenra.io/contact.html - description: The API usable by the Lenra applications - license: - name: MIT - url: https://opensource.org/licenses/MIT - title: Lenra server internal API - version: 0.0.0 -servers: -- description: Devtool - url: http://localhost:4001 -security: -- bearerAuth: - - api - - transaction -tags: -- description: Data management API - name: Data -paths: - /app-api/v1-api/v1/data/colls/{coll}: - delete: - operationId: deleteCollection - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - responses: - "200": - description: Collection deleted - summary: Deletes a collection from database - tags: - - Data - x-accepts: application/json - /app-api/v1/data/colls/{coll}/docs: - get: - operationId: getDocuments - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - items: - $ref: '#/components/schemas/data.document' - type: array - description: Documents found - summary: Gets documents from database - tags: - - Data - x-accepts: application/json - post: - operationId: createDocument - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - type: object - description: The document to create - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/data.document' - description: Document created - summary: Creates a document in database - tags: - - Data - x-content-type: application/json - x-accepts: application/json - /app-api/v1/data/colls/{coll}/docs/{id}: - delete: - operationId: deleteDocumentById - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - - description: The document identifier - explode: false - in: path - name: id - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/data.document' - description: Document deleted - summary: Deletes a document from database - tags: - - Data - x-accepts: application/json - get: - operationId: getDocumentById - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - - description: The document identifier - explode: false - in: path - name: id - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/data.document' - description: Document created - summary: Gets a document from database - tags: - - Data - x-accepts: application/json - put: - operationId: updateDocumentById - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - - description: The document identifier - explode: false - in: path - name: id - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/data.document' - description: The document to update - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/data.document' - description: Document updated - summary: Updates a document in database - tags: - - Data - x-content-type: application/json - x-accepts: application/json - /app-api/v1/data/colls/{coll}/find: - post: - operationId: findDocuments - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/findDocuments_request' - description: The query to find documents - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/data.result.find' - description: Documents found - summary: Finds documents in database - tags: - - Data - x-content-type: application/json - x-accepts: application/json - /app-api/v1/data/colls/{coll}/updateMany: - post: - operationId: updateManyDocuments - parameters: - - description: The document collection name - explode: false - in: path - name: coll - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/updateManyDocuments_request' - description: The query to find documents - required: true - responses: - "200": - content: - application/json: - schema: - type: object - description: Documents updated - summary: Updates many documents in database - tags: - - Data - x-content-type: application/json - x-accepts: application/json - /app-api/v1/data/transaction: - post: - operationId: createTransaction - responses: - "200": - content: - application/json: - schema: - description: The transaction token - type: string - description: Transaction created - security: - - bearerAuth: - - api - summary: Creates a transaction - tags: - - Data - x-accepts: application/json - /app-api/v1/data/transaction/commit: - post: - operationId: commitTransaction - responses: - "200": - description: Transaction commited - security: - - bearerAuth: - - transaction - summary: Commits a transaction - tags: - - Data - x-accepts: application/json - /app-api/v1/data/transaction/abort: - post: - operationId: abortTransaction - responses: - "200": - description: Transaction aborted - security: - - bearerAuth: - - transaction - summary: Aborts a transaction - tags: - - Data - x-accepts: application/json -components: - schemas: - data.document: - additionalProperties: true - description: A document in MongoDB database - example: - _id: _id - properties: - _id: - description: The document identifier - type: string - title: Document - data.query: - additionalProperties: true - description: Mongo data query - properties: {} - title: Query - type: object - data.result.find: - additionalProperties: true - description: Find query result. - title: FindResult - type: object - data.update: - additionalProperties: true - description: Mongo data query - title: Query - type: object - findDocuments_request: - additionalProperties: {} - properties: - query: - additionalProperties: true - description: Mongo data query - properties: {} - title: Query - type: object - projection: - additionalProperties: {} - nullable: true - required: - - query - updateManyDocuments_request: - additionalProperties: {} - properties: - filter: - additionalProperties: true - description: Mongo data query - properties: {} - title: Query - type: object - update: - additionalProperties: true - description: Mongo data query - title: Query - type: object - required: - - filter - - update - securitySchemes: - bearerAuth: - scheme: bearer - type: http - diff --git a/build.gradle b/build.gradle index c8ae406..75bce10 100644 --- a/build.gradle +++ b/build.gradle @@ -2,17 +2,15 @@ apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'java' apply plugin: 'com.diffplug.spotless' +apply plugin: 'maven-publish' group = 'io.lenra' -version = '1.0.0' buildscript { repositories { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' } } @@ -20,85 +18,29 @@ buildscript { repositories { mavenCentral() } -sourceSets { - main.java.srcDirs = ['src/main/java'] -} - -if(hasProperty('target') && target == 'android') { - - apply plugin: 'com.android.library' - apply plugin: 'com.github.dcendents.android-maven' - android { - compileSdkVersion 25 - buildToolsVersion '25.0.2' - defaultConfig { - minSdkVersion 14 - targetSdkVersion 25 - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.aar')) { - def fileName = "${project.name}-${variant.baseName}-${version}.aar" - output.outputFile = new File(outputFile.parent, fileName) - } +publishing { + repositories { + maven { + credentials { + username "${System.env.NEXUS_USERNAME}" + password "${System.env.NEXUS_PASSWORD}" } - } - - dependencies { - provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" - } - } - - afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDirectory - task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") - task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task) + if(project.version.endsWith('-SNAPSHOT')) + url "https://oss.sonatype.org/content/repositories/snapshots" + else + url "https://oss.sonatype.org/service/local/staging/deploy/maven2" } } - - task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' - } - - artifacts { - archives sourcesJar - } - -} else { - - apply plugin: 'java' - apply plugin: 'maven-publish' - - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - publishing { - publications { - maven(MavenPublication) { - artifactId = 'lenra-internal-api-client' - from components.java - } + publications { + maven(MavenPublication) { + artifactId = 'lenra-internal-api-client' + from components.java } } - - task execute(type:JavaExec) { - main = System.getProperty('mainClass') - classpath = sourceSets.main.runtimeClasspath - } } ext { diff --git a/docs/DataApi.md b/docs/DataApi.md index 5b8382c..ad20718 100644 --- a/docs/DataApi.md +++ b/docs/DataApi.md @@ -6,13 +6,14 @@ All URIs are relative to *http://localhost:4001* |------------- | ------------- | -------------| | [**abortTransaction**](DataApi.md#abortTransaction) | **POST** /app-api/v1/data/transaction/abort | Aborts a transaction | | [**commitTransaction**](DataApi.md#commitTransaction) | **POST** /app-api/v1/data/transaction/commit | Commits a transaction | -| [**createDocument**](DataApi.md#createDocument) | **POST** /app-api/v1/data/colls/{coll}/docs | Creates a document in database | +| [**createDocument**](DataApi.md#createDocument) | **POST** /app-api/v1/data/colls/{coll}/docs | Creates one document in database | | [**createTransaction**](DataApi.md#createTransaction) | **POST** /app-api/v1/data/transaction | Creates a transaction | | [**deleteCollection**](DataApi.md#deleteCollection) | **DELETE** /app-api/v1-api/v1/data/colls/{coll} | Deletes a collection from database | | [**deleteDocumentById**](DataApi.md#deleteDocumentById) | **DELETE** /app-api/v1/data/colls/{coll}/docs/{id} | Deletes a document from database | | [**findDocuments**](DataApi.md#findDocuments) | **POST** /app-api/v1/data/colls/{coll}/find | Finds documents in database | | [**getDocumentById**](DataApi.md#getDocumentById) | **GET** /app-api/v1/data/colls/{coll}/docs/{id} | Gets a document from database | | [**getDocuments**](DataApi.md#getDocuments) | **GET** /app-api/v1/data/colls/{coll}/docs | Gets documents from database | +| [**insertManyDocuments**](DataApi.md#insertManyDocuments) | **POST** /app-api/v1/data/colls/{coll}/insertMany | Inserts many documents in database | | [**updateDocumentById**](DataApi.md#updateDocumentById) | **PUT** /app-api/v1/data/colls/{coll}/docs/{id} | Updates a document in database | | [**updateManyDocuments**](DataApi.md#updateManyDocuments) | **POST** /app-api/v1/data/colls/{coll}/updateMany | Updates many documents in database | @@ -139,9 +140,9 @@ null (empty response body) # **createDocument** -> DataDocument createDocument(coll, body) +> Map<String, Object> createDocument(coll, body) -Creates a document in database +Creates one document in database ### Example ```java @@ -166,7 +167,7 @@ public class Example { String coll = "coll_example"; // String | The document collection name Object body = null; // Object | The document to create try { - DataDocument result = apiInstance.createDocument(coll, body); + Map result = apiInstance.createDocument(coll, body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#createDocument"); @@ -188,7 +189,7 @@ public class Example { ### Return type -[**DataDocument**](DataDocument.md) +**Map<String, Object>** ### Authorization @@ -331,7 +332,7 @@ null (empty response body) # **deleteDocumentById** -> DataDocument deleteDocumentById(coll, id) +> Map<String, Object> deleteDocumentById(coll, id) Deletes a document from database @@ -358,7 +359,7 @@ public class Example { String coll = "coll_example"; // String | The document collection name String id = "id_example"; // String | The document identifier try { - DataDocument result = apiInstance.deleteDocumentById(coll, id); + Map result = apiInstance.deleteDocumentById(coll, id); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#deleteDocumentById"); @@ -380,7 +381,7 @@ public class Example { ### Return type -[**DataDocument**](DataDocument.md) +**Map<String, Object>** ### Authorization @@ -398,7 +399,7 @@ public class Example { # **findDocuments** -> Map<String, Object> findDocuments(coll, findDocumentsRequest) +> List<Map<String, Object>> findDocuments(coll, findDocumentsRequest) Finds documents in database @@ -425,7 +426,7 @@ public class Example { String coll = "coll_example"; // String | The document collection name FindDocumentsRequest findDocumentsRequest = new FindDocumentsRequest(); // FindDocumentsRequest | The query to find documents try { - Map result = apiInstance.findDocuments(coll, findDocumentsRequest); + List> result = apiInstance.findDocuments(coll, findDocumentsRequest); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#findDocuments"); @@ -447,7 +448,7 @@ public class Example { ### Return type -**Map<String, Object>** +[**List<Map<String, Object>>**](Map.md) ### Authorization @@ -465,7 +466,7 @@ public class Example { # **getDocumentById** -> DataDocument getDocumentById(coll, id) +> Map<String, Object> getDocumentById(coll, id) Gets a document from database @@ -492,7 +493,7 @@ public class Example { String coll = "coll_example"; // String | The document collection name String id = "id_example"; // String | The document identifier try { - DataDocument result = apiInstance.getDocumentById(coll, id); + Map result = apiInstance.getDocumentById(coll, id); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#getDocumentById"); @@ -514,7 +515,7 @@ public class Example { ### Return type -[**DataDocument**](DataDocument.md) +**Map<String, Object>** ### Authorization @@ -532,7 +533,7 @@ public class Example { # **getDocuments** -> List<DataDocument> getDocuments(coll) +> List<Map<String, Object>> getDocuments(coll) Gets documents from database @@ -558,7 +559,7 @@ public class Example { DataApi apiInstance = new DataApi(defaultClient); String coll = "coll_example"; // String | The document collection name try { - List result = apiInstance.getDocuments(coll); + List> result = apiInstance.getDocuments(coll); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#getDocuments"); @@ -579,7 +580,7 @@ public class Example { ### Return type -[**List<DataDocument>**](DataDocument.md) +[**List<Map<String, Object>>**](Map.md) ### Authorization @@ -595,9 +596,76 @@ public class Example { |-------------|-------------|------------------| | **200** | Documents found | - | + +# **insertManyDocuments** +> InsertManyDocuments200Response insertManyDocuments(coll, insertManyDocumentsRequest) + +Inserts many documents in database + +### Example +```java +// Import classes: +import io.lenra.api.internal.ApiClient; +import io.lenra.api.internal.ApiException; +import io.lenra.api.internal.Configuration; +import io.lenra.api.internal.auth.*; +import io.lenra.api.internal.models.*; +import io.lenra.api.internal.client.DataApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:4001"); + + // Configure HTTP bearer authorization: bearerAuth + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); + bearerAuth.setBearerToken("BEARER TOKEN"); + + DataApi apiInstance = new DataApi(defaultClient); + String coll = "coll_example"; // String | The documents collection name + InsertManyDocumentsRequest insertManyDocumentsRequest = new InsertManyDocumentsRequest(); // InsertManyDocumentsRequest | The documents to create + try { + InsertManyDocuments200Response result = apiInstance.insertManyDocuments(coll, insertManyDocumentsRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DataApi#insertManyDocuments"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **coll** | **String**| The documents collection name | | +| **insertManyDocumentsRequest** | [**InsertManyDocumentsRequest**](InsertManyDocumentsRequest.md)| The documents to create | | + +### Return type + +[**InsertManyDocuments200Response**](InsertManyDocuments200Response.md) + +### Authorization + +[bearerAuth](../README.md#bearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Documents inserted | - | + # **updateDocumentById** -> DataDocument updateDocumentById(coll, id, dataDocument) +> Map<String, Object> updateDocumentById(coll, id, requestBody) Updates a document in database @@ -623,9 +691,9 @@ public class Example { DataApi apiInstance = new DataApi(defaultClient); String coll = "coll_example"; // String | The document collection name String id = "id_example"; // String | The document identifier - DataDocument dataDocument = new DataDocument(); // DataDocument | The document to update + Map requestBody = null; // Map | The document to update try { - DataDocument result = apiInstance.updateDocumentById(coll, id, dataDocument); + Map result = apiInstance.updateDocumentById(coll, id, requestBody); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling DataApi#updateDocumentById"); @@ -644,11 +712,11 @@ public class Example { |------------- | ------------- | ------------- | -------------| | **coll** | **String**| The document collection name | | | **id** | **String**| The document identifier | | -| **dataDocument** | [**DataDocument**](DataDocument.md)| The document to update | | +| **requestBody** | [**Map<String, Object>**](Object.md)| The document to update | | ### Return type -[**DataDocument**](DataDocument.md) +**Map<String, Object>** ### Authorization diff --git a/docs/DataOptions.md b/docs/DataOptions.md new file mode 100644 index 0000000..39d9d35 --- /dev/null +++ b/docs/DataOptions.md @@ -0,0 +1,16 @@ + + +# DataOptions + +Mongo data query options + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**limit** | **Object** | | [optional] | +|**skip** | **Object** | | [optional] | +|**sort** | **Object** | | [optional] | + + + diff --git a/docs/FindDocumentsRequest.md b/docs/FindDocumentsRequest.md index 96a6190..38d09c3 100644 --- a/docs/FindDocumentsRequest.md +++ b/docs/FindDocumentsRequest.md @@ -7,8 +7,9 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**query** | **Map<String, Object>** | Mongo data query | | +|**query** | | Mongo data query | | |**projection** | | | [optional] | +|**options** | [**DataOptions**](DataOptions.md) | | [optional] | diff --git a/docs/InsertManyDocuments200Response.md b/docs/InsertManyDocuments200Response.md new file mode 100644 index 0000000..c0fa2af --- /dev/null +++ b/docs/InsertManyDocuments200Response.md @@ -0,0 +1,13 @@ + + +# InsertManyDocuments200Response + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**insertedIds** | **List<String>** | | | + + + diff --git a/docs/InsertManyDocumentsRequest.md b/docs/InsertManyDocumentsRequest.md new file mode 100644 index 0000000..a0e2206 --- /dev/null +++ b/docs/InsertManyDocumentsRequest.md @@ -0,0 +1,13 @@ + + +# InsertManyDocumentsRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**documents** | **Object** | | | + + + diff --git a/docs/UpdateManyDocumentsRequest.md b/docs/UpdateManyDocumentsRequest.md index 0caa0db..18359b9 100644 --- a/docs/UpdateManyDocumentsRequest.md +++ b/docs/UpdateManyDocumentsRequest.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**filter** | **Map<String, Object>** | Mongo data query | | -|**update** | **Map<String, Object>** | Mongo data query | | +|**filter** | | Mongo data query | | +|**update** | | Mongo data query | | diff --git a/gradle.properties b/gradle.properties index a340857..0f94f07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1 @@ -# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). -# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. -# -# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties -# For example, uncomment below to build for Android -#target = android +version = 0.0.0-SNAPSHOT \ No newline at end of file diff --git a/lenra-api.version.txt b/lenra-api.version.txt index e6d5cb8..c9929e3 100644 --- a/lenra-api.version.txt +++ b/lenra-api.version.txt @@ -1 +1 @@ -1.0.2 \ No newline at end of file +1.4.2 \ No newline at end of file diff --git a/src/main/java/io/lenra/api/internal/ApiClient.java b/src/main/java/io/lenra/api/internal/ApiClient.java index 21241f3..6508270 100644 --- a/src/main/java/io/lenra/api/internal/ApiClient.java +++ b/src/main/java/io/lenra/api/internal/ApiClient.java @@ -47,6 +47,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -384,14 +385,23 @@ public Authentication getAuthentication(String authName) { return authentications.get(authName); } - /** - * Helper method to set access token for the first Bearer authentication. - * @param bearerToken Bearer token - */ + /** + * Helper method to set access token for the first Bearer authentication. + * @param bearerToken Bearer token + */ public void setBearerToken(String bearerToken) { + setBearerToken(() -> bearerToken); + } + + /** + * Helper method to set the supplier of access tokens for Bearer authentication. + * + * @param tokenSupplier The supplier of bearer tokens + */ + public void setBearerToken(Supplier tokenSupplier) { for (Authentication auth : authentications.values()) { if (auth instanceof HttpBearerAuth) { - ((HttpBearerAuth) auth).setBearerToken(bearerToken); + ((HttpBearerAuth) auth).setBearerToken(tokenSupplier); return; } } diff --git a/src/main/java/io/lenra/api/internal/ApiException.java b/src/main/java/io/lenra/api/internal/ApiException.java index eab4aca..b8ebe19 100644 --- a/src/main/java/io/lenra/api/internal/ApiException.java +++ b/src/main/java/io/lenra/api/internal/ApiException.java @@ -21,8 +21,10 @@ *

ApiException class.

*/ @SuppressWarnings("serial") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + private int code = 0; private Map> responseHeaders = null; private String responseBody = null; diff --git a/src/main/java/io/lenra/api/internal/Configuration.java b/src/main/java/io/lenra/api/internal/Configuration.java index 90e1803..354f447 100644 --- a/src/main/java/io/lenra/api/internal/Configuration.java +++ b/src/main/java/io/lenra/api/internal/Configuration.java @@ -13,7 +13,7 @@ package io.lenra.api.internal; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class Configuration { public static final String VERSION = "1.0.0"; diff --git a/src/main/java/io/lenra/api/internal/JSON.java b/src/main/java/io/lenra/api/internal/JSON.java index 060c126..8d2c810 100644 --- a/src/main/java/io/lenra/api/internal/JSON.java +++ b/src/main/java/io/lenra/api/internal/JSON.java @@ -13,11 +13,11 @@ package io.lenra.api.internal; +import com.fasterxml.jackson.databind.util.StdDateFormat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonParseException; import com.google.gson.TypeAdapter; -import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.google.gson.JsonElement; @@ -31,14 +31,16 @@ import java.lang.reflect.Type; import java.text.DateFormat; import java.text.ParseException; -import java.text.ParsePosition; import java.time.LocalDate; import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.HashMap; +import java.util.TimeZone; /* * A JSON utility class @@ -55,6 +57,11 @@ public class JSON { private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + private static final StdDateFormat sdf = new StdDateFormat() + .withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) + .withColonInTimeZone(true); + private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + @SuppressWarnings("unchecked") public static GsonBuilder createGson() { GsonFireBuilder fireBuilder = new GsonFireBuilder() @@ -86,15 +93,17 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri return clazz; } - { + static { GsonBuilder gsonBuilder = createGson(); gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.DataDocument.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.DataOptions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.FindDocumentsRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.InsertManyDocuments200Response.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.InsertManyDocumentsRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lenra.api.internal.client.model.UpdateManyDocumentsRequest.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); } @@ -328,7 +337,7 @@ public java.sql.Date read(JsonReader in) throws IOException { if (dateFormat != null) { return new java.sql.Date(dateFormat.parse(date).getTime()); } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + return new java.sql.Date(sdf.parse(date).getTime()); } catch (ParseException e) { throw new JsonParseException(e); } @@ -338,7 +347,7 @@ public java.sql.Date read(JsonReader in) throws IOException { /** * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. + * If the dateFormat is null, DateTimeFormatter will be used. */ public static class DateTypeAdapter extends TypeAdapter { @@ -363,7 +372,7 @@ public void write(JsonWriter out, Date date) throws IOException { if (dateFormat != null) { value = dateFormat.format(date); } else { - value = ISO8601Utils.format(date, true); + value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf); } out.value(value); } @@ -382,7 +391,7 @@ public Date read(JsonReader in) throws IOException { if (dateFormat != null) { return dateFormat.parse(date); } - return ISO8601Utils.parse(date, new ParsePosition(0)); + return sdf.parse(date); } catch (ParseException e) { throw new JsonParseException(e); } diff --git a/src/main/java/io/lenra/api/internal/Pair.java b/src/main/java/io/lenra/api/internal/Pair.java index cf63cdc..4c11e7c 100644 --- a/src/main/java/io/lenra/api/internal/Pair.java +++ b/src/main/java/io/lenra/api/internal/Pair.java @@ -13,7 +13,7 @@ package io.lenra.api.internal; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class Pair { private String name = ""; private String value = ""; diff --git a/src/main/java/io/lenra/api/internal/StringUtil.java b/src/main/java/io/lenra/api/internal/StringUtil.java index 735b576..d3fb7ef 100644 --- a/src/main/java/io/lenra/api/internal/StringUtil.java +++ b/src/main/java/io/lenra/api/internal/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/src/main/java/io/lenra/api/internal/auth/ApiKeyAuth.java b/src/main/java/io/lenra/api/internal/auth/ApiKeyAuth.java index 24eacca..a536544 100644 --- a/src/main/java/io/lenra/api/internal/auth/ApiKeyAuth.java +++ b/src/main/java/io/lenra/api/internal/auth/ApiKeyAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/src/main/java/io/lenra/api/internal/auth/HttpBearerAuth.java b/src/main/java/io/lenra/api/internal/auth/HttpBearerAuth.java index 3623ce2..e2dec0f 100644 --- a/src/main/java/io/lenra/api/internal/auth/HttpBearerAuth.java +++ b/src/main/java/io/lenra/api/internal/auth/HttpBearerAuth.java @@ -17,13 +17,15 @@ import io.lenra.api.internal.Pair; import java.net.URI; -import java.util.Map; import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class HttpBearerAuth implements Authentication { private final String scheme; - private String bearerToken; + private Supplier tokenSupplier; public HttpBearerAuth(String scheme) { this.scheme = scheme; @@ -35,7 +37,7 @@ public HttpBearerAuth(String scheme) { * @return The bearer token */ public String getBearerToken() { - return bearerToken; + return tokenSupplier.get(); } /** @@ -44,12 +46,22 @@ public String getBearerToken() { * @param bearerToken The bearer token to send in the Authorization header */ public void setBearerToken(String bearerToken) { - this.bearerToken = bearerToken; + this.tokenSupplier = () -> bearerToken; + } + + /** + * Sets the supplier of tokens, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param tokenSupplier The supplier of bearer tokens to send in the Authorization header + */ + public void setBearerToken(Supplier tokenSupplier) { + this.tokenSupplier = tokenSupplier; } @Override public void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException { + String bearerToken = Optional.ofNullable(tokenSupplier).map(Supplier::get).orElse(null); if (bearerToken == null) { return; } diff --git a/src/main/java/io/lenra/api/internal/client/DataApi.java b/src/main/java/io/lenra/api/internal/client/DataApi.java index 5724396..4890674 100644 --- a/src/main/java/io/lenra/api/internal/client/DataApi.java +++ b/src/main/java/io/lenra/api/internal/client/DataApi.java @@ -27,8 +27,9 @@ import java.io.IOException; -import io.lenra.api.internal.client.model.DataDocument; import io.lenra.api.internal.client.model.FindDocumentsRequest; +import io.lenra.api.internal.client.model.InsertManyDocuments200Response; +import io.lenra.api.internal.client.model.InsertManyDocumentsRequest; import io.lenra.api.internal.client.model.UpdateManyDocumentsRequest; import java.lang.reflect.Type; @@ -366,11 +367,11 @@ private okhttp3.Call createDocumentValidateBeforeCall(String coll, Object body, } /** - * Creates a document in database + * Creates one document in database * * @param coll The document collection name (required) * @param body The document to create (required) - * @return DataDocument + * @return Map<String, Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -378,17 +379,17 @@ private okhttp3.Call createDocumentValidateBeforeCall(String coll, Object body,
200 Document created -
*/ - public DataDocument createDocument(String coll, Object body) throws ApiException { - ApiResponse localVarResp = createDocumentWithHttpInfo(coll, body); + public Map createDocument(String coll, Object body) throws ApiException { + ApiResponse> localVarResp = createDocumentWithHttpInfo(coll, body); return localVarResp.getData(); } /** - * Creates a document in database + * Creates one document in database * * @param coll The document collection name (required) * @param body The document to create (required) - * @return ApiResponse<DataDocument> + * @return ApiResponse<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -396,14 +397,14 @@ public DataDocument createDocument(String coll, Object body) throws ApiException
200 Document created -
*/ - public ApiResponse createDocumentWithHttpInfo(String coll, Object body) throws ApiException { + public ApiResponse> createDocumentWithHttpInfo(String coll, Object body) throws ApiException { okhttp3.Call localVarCall = createDocumentValidateBeforeCall(coll, body, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } /** - * Creates a document in database (asynchronously) + * Creates one document in database (asynchronously) * * @param coll The document collection name (required) * @param body The document to create (required) @@ -416,10 +417,10 @@ public ApiResponse createDocumentWithHttpInfo(String coll, Object 200 Document created - */ - public okhttp3.Call createDocumentAsync(String coll, Object body, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createDocumentAsync(String coll, Object body, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = createDocumentValidateBeforeCall(coll, body, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -734,7 +735,7 @@ private okhttp3.Call deleteDocumentByIdValidateBeforeCall(String coll, String id * * @param coll The document collection name (required) * @param id The document identifier (required) - * @return DataDocument + * @return Map<String, Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -742,8 +743,8 @@ private okhttp3.Call deleteDocumentByIdValidateBeforeCall(String coll, String id
200 Document deleted -
*/ - public DataDocument deleteDocumentById(String coll, String id) throws ApiException { - ApiResponse localVarResp = deleteDocumentByIdWithHttpInfo(coll, id); + public Map deleteDocumentById(String coll, String id) throws ApiException { + ApiResponse> localVarResp = deleteDocumentByIdWithHttpInfo(coll, id); return localVarResp.getData(); } @@ -752,7 +753,7 @@ public DataDocument deleteDocumentById(String coll, String id) throws ApiExcepti * * @param coll The document collection name (required) * @param id The document identifier (required) - * @return ApiResponse<DataDocument> + * @return ApiResponse<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -760,9 +761,9 @@ public DataDocument deleteDocumentById(String coll, String id) throws ApiExcepti
200 Document deleted -
*/ - public ApiResponse deleteDocumentByIdWithHttpInfo(String coll, String id) throws ApiException { + public ApiResponse> deleteDocumentByIdWithHttpInfo(String coll, String id) throws ApiException { okhttp3.Call localVarCall = deleteDocumentByIdValidateBeforeCall(coll, id, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -780,10 +781,10 @@ public ApiResponse deleteDocumentByIdWithHttpInfo(String coll, Str 200 Document deleted - */ - public okhttp3.Call deleteDocumentByIdAsync(String coll, String id, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteDocumentByIdAsync(String coll, String id, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = deleteDocumentByIdValidateBeforeCall(coll, id, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -867,7 +868,7 @@ private okhttp3.Call findDocumentsValidateBeforeCall(String coll, FindDocumentsR * * @param coll The document collection name (required) * @param findDocumentsRequest The query to find documents (required) - * @return Map<String, Object> + * @return List<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -875,8 +876,8 @@ private okhttp3.Call findDocumentsValidateBeforeCall(String coll, FindDocumentsR
200 Documents found -
*/ - public Map findDocuments(String coll, FindDocumentsRequest findDocumentsRequest) throws ApiException { - ApiResponse> localVarResp = findDocumentsWithHttpInfo(coll, findDocumentsRequest); + public List> findDocuments(String coll, FindDocumentsRequest findDocumentsRequest) throws ApiException { + ApiResponse>> localVarResp = findDocumentsWithHttpInfo(coll, findDocumentsRequest); return localVarResp.getData(); } @@ -885,7 +886,7 @@ public Map findDocuments(String coll, FindDocumentsRequest findD * * @param coll The document collection name (required) * @param findDocumentsRequest The query to find documents (required) - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<List<Map<String, Object>>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -893,9 +894,9 @@ public Map findDocuments(String coll, FindDocumentsRequest findD
200 Documents found -
*/ - public ApiResponse> findDocumentsWithHttpInfo(String coll, FindDocumentsRequest findDocumentsRequest) throws ApiException { + public ApiResponse>> findDocumentsWithHttpInfo(String coll, FindDocumentsRequest findDocumentsRequest) throws ApiException { okhttp3.Call localVarCall = findDocumentsValidateBeforeCall(coll, findDocumentsRequest, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -913,10 +914,10 @@ public ApiResponse> findDocumentsWithHttpInfo(String coll, F 200 Documents found - */ - public okhttp3.Call findDocumentsAsync(String coll, FindDocumentsRequest findDocumentsRequest, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call findDocumentsAsync(String coll, FindDocumentsRequest findDocumentsRequest, final ApiCallback>> _callback) throws ApiException { okhttp3.Call localVarCall = findDocumentsValidateBeforeCall(coll, findDocumentsRequest, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -1000,7 +1001,7 @@ private okhttp3.Call getDocumentByIdValidateBeforeCall(String coll, String id, f * * @param coll The document collection name (required) * @param id The document identifier (required) - * @return DataDocument + * @return Map<String, Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1008,8 +1009,8 @@ private okhttp3.Call getDocumentByIdValidateBeforeCall(String coll, String id, f
200 Document created -
*/ - public DataDocument getDocumentById(String coll, String id) throws ApiException { - ApiResponse localVarResp = getDocumentByIdWithHttpInfo(coll, id); + public Map getDocumentById(String coll, String id) throws ApiException { + ApiResponse> localVarResp = getDocumentByIdWithHttpInfo(coll, id); return localVarResp.getData(); } @@ -1018,7 +1019,7 @@ public DataDocument getDocumentById(String coll, String id) throws ApiException * * @param coll The document collection name (required) * @param id The document identifier (required) - * @return ApiResponse<DataDocument> + * @return ApiResponse<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1026,9 +1027,9 @@ public DataDocument getDocumentById(String coll, String id) throws ApiException
200 Document created -
*/ - public ApiResponse getDocumentByIdWithHttpInfo(String coll, String id) throws ApiException { + public ApiResponse> getDocumentByIdWithHttpInfo(String coll, String id) throws ApiException { okhttp3.Call localVarCall = getDocumentByIdValidateBeforeCall(coll, id, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1046,10 +1047,10 @@ public ApiResponse getDocumentByIdWithHttpInfo(String coll, String 200 Document created - */ - public okhttp3.Call getDocumentByIdAsync(String coll, String id, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getDocumentByIdAsync(String coll, String id, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = getDocumentByIdValidateBeforeCall(coll, id, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -1125,7 +1126,7 @@ private okhttp3.Call getDocumentsValidateBeforeCall(String coll, final ApiCallba * Gets documents from database * * @param coll The document collection name (required) - * @return List<DataDocument> + * @return List<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1133,8 +1134,8 @@ private okhttp3.Call getDocumentsValidateBeforeCall(String coll, final ApiCallba
200 Documents found -
*/ - public List getDocuments(String coll) throws ApiException { - ApiResponse> localVarResp = getDocumentsWithHttpInfo(coll); + public List> getDocuments(String coll) throws ApiException { + ApiResponse>> localVarResp = getDocumentsWithHttpInfo(coll); return localVarResp.getData(); } @@ -1142,7 +1143,7 @@ public List getDocuments(String coll) throws ApiException { * Gets documents from database * * @param coll The document collection name (required) - * @return ApiResponse<List<DataDocument>> + * @return ApiResponse<List<Map<String, Object>>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1150,9 +1151,9 @@ public List getDocuments(String coll) throws ApiException {
200 Documents found -
*/ - public ApiResponse> getDocumentsWithHttpInfo(String coll) throws ApiException { + public ApiResponse>> getDocumentsWithHttpInfo(String coll) throws ApiException { okhttp3.Call localVarCall = getDocumentsValidateBeforeCall(coll, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1169,10 +1170,143 @@ public ApiResponse> getDocumentsWithHttpInfo(String coll) thr 200 Documents found - */ - public okhttp3.Call getDocumentsAsync(String coll, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call getDocumentsAsync(String coll, final ApiCallback>> _callback) throws ApiException { okhttp3.Call localVarCall = getDocumentsValidateBeforeCall(coll, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>>(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for insertManyDocuments + * @param coll The documents collection name (required) + * @param insertManyDocumentsRequest The documents to create (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Documents inserted -
+ */ + public okhttp3.Call insertManyDocumentsCall(String coll, InsertManyDocumentsRequest insertManyDocumentsRequest, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = insertManyDocumentsRequest; + + // create path and map variables + String localVarPath = "/app-api/v1/data/colls/{coll}/insertMany" + .replace("{" + "coll" + "}", localVarApiClient.escapeString(coll.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "bearerAuth" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call insertManyDocumentsValidateBeforeCall(String coll, InsertManyDocumentsRequest insertManyDocumentsRequest, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'coll' is set + if (coll == null) { + throw new ApiException("Missing the required parameter 'coll' when calling insertManyDocuments(Async)"); + } + + // verify the required parameter 'insertManyDocumentsRequest' is set + if (insertManyDocumentsRequest == null) { + throw new ApiException("Missing the required parameter 'insertManyDocumentsRequest' when calling insertManyDocuments(Async)"); + } + + return insertManyDocumentsCall(coll, insertManyDocumentsRequest, _callback); + + } + + /** + * Inserts many documents in database + * + * @param coll The documents collection name (required) + * @param insertManyDocumentsRequest The documents to create (required) + * @return InsertManyDocuments200Response + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Documents inserted -
+ */ + public InsertManyDocuments200Response insertManyDocuments(String coll, InsertManyDocumentsRequest insertManyDocumentsRequest) throws ApiException { + ApiResponse localVarResp = insertManyDocumentsWithHttpInfo(coll, insertManyDocumentsRequest); + return localVarResp.getData(); + } + + /** + * Inserts many documents in database + * + * @param coll The documents collection name (required) + * @param insertManyDocumentsRequest The documents to create (required) + * @return ApiResponse<InsertManyDocuments200Response> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Documents inserted -
+ */ + public ApiResponse insertManyDocumentsWithHttpInfo(String coll, InsertManyDocumentsRequest insertManyDocumentsRequest) throws ApiException { + okhttp3.Call localVarCall = insertManyDocumentsValidateBeforeCall(coll, insertManyDocumentsRequest, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Inserts many documents in database (asynchronously) + * + * @param coll The documents collection name (required) + * @param insertManyDocumentsRequest The documents to create (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Documents inserted -
+ */ + public okhttp3.Call insertManyDocumentsAsync(String coll, InsertManyDocumentsRequest insertManyDocumentsRequest, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = insertManyDocumentsValidateBeforeCall(coll, insertManyDocumentsRequest, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -1180,7 +1314,7 @@ public okhttp3.Call getDocumentsAsync(String coll, final ApiCallback 200 Document updated - */ - public okhttp3.Call updateDocumentByIdCall(String coll, String id, DataDocument dataDocument, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateDocumentByIdCall(String coll, String id, Map requestBody, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1204,7 +1338,7 @@ public okhttp3.Call updateDocumentByIdCall(String coll, String id, DataDocument basePath = null; } - Object localVarPostBody = dataDocument; + Object localVarPostBody = requestBody; // create path and map variables String localVarPath = "/app-api/v1/data/colls/{coll}/docs/{id}" @@ -1238,7 +1372,7 @@ public okhttp3.Call updateDocumentByIdCall(String coll, String id, DataDocument } @SuppressWarnings("rawtypes") - private okhttp3.Call updateDocumentByIdValidateBeforeCall(String coll, String id, DataDocument dataDocument, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updateDocumentByIdValidateBeforeCall(String coll, String id, Map requestBody, final ApiCallback _callback) throws ApiException { // verify the required parameter 'coll' is set if (coll == null) { throw new ApiException("Missing the required parameter 'coll' when calling updateDocumentById(Async)"); @@ -1249,12 +1383,12 @@ private okhttp3.Call updateDocumentByIdValidateBeforeCall(String coll, String id throw new ApiException("Missing the required parameter 'id' when calling updateDocumentById(Async)"); } - // verify the required parameter 'dataDocument' is set - if (dataDocument == null) { - throw new ApiException("Missing the required parameter 'dataDocument' when calling updateDocumentById(Async)"); + // verify the required parameter 'requestBody' is set + if (requestBody == null) { + throw new ApiException("Missing the required parameter 'requestBody' when calling updateDocumentById(Async)"); } - return updateDocumentByIdCall(coll, id, dataDocument, _callback); + return updateDocumentByIdCall(coll, id, requestBody, _callback); } @@ -1263,8 +1397,8 @@ private okhttp3.Call updateDocumentByIdValidateBeforeCall(String coll, String id * * @param coll The document collection name (required) * @param id The document identifier (required) - * @param dataDocument The document to update (required) - * @return DataDocument + * @param requestBody The document to update (required) + * @return Map<String, Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1272,8 +1406,8 @@ private okhttp3.Call updateDocumentByIdValidateBeforeCall(String coll, String id
200 Document updated -
*/ - public DataDocument updateDocumentById(String coll, String id, DataDocument dataDocument) throws ApiException { - ApiResponse localVarResp = updateDocumentByIdWithHttpInfo(coll, id, dataDocument); + public Map updateDocumentById(String coll, String id, Map requestBody) throws ApiException { + ApiResponse> localVarResp = updateDocumentByIdWithHttpInfo(coll, id, requestBody); return localVarResp.getData(); } @@ -1282,8 +1416,8 @@ public DataDocument updateDocumentById(String coll, String id, DataDocument data * * @param coll The document collection name (required) * @param id The document identifier (required) - * @param dataDocument The document to update (required) - * @return ApiResponse<DataDocument> + * @param requestBody The document to update (required) + * @return ApiResponse<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -1291,9 +1425,9 @@ public DataDocument updateDocumentById(String coll, String id, DataDocument data
200 Document updated -
*/ - public ApiResponse updateDocumentByIdWithHttpInfo(String coll, String id, DataDocument dataDocument) throws ApiException { - okhttp3.Call localVarCall = updateDocumentByIdValidateBeforeCall(coll, id, dataDocument, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse> updateDocumentByIdWithHttpInfo(String coll, String id, Map requestBody) throws ApiException { + okhttp3.Call localVarCall = updateDocumentByIdValidateBeforeCall(coll, id, requestBody, null); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -1302,7 +1436,7 @@ public ApiResponse updateDocumentByIdWithHttpInfo(String coll, Str * * @param coll The document collection name (required) * @param id The document identifier (required) - * @param dataDocument The document to update (required) + * @param requestBody The document to update (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -1312,10 +1446,10 @@ public ApiResponse updateDocumentByIdWithHttpInfo(String coll, Str 200 Document updated - */ - public okhttp3.Call updateDocumentByIdAsync(String coll, String id, DataDocument dataDocument, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateDocumentByIdAsync(String coll, String id, Map requestBody, final ApiCallback> _callback) throws ApiException { - okhttp3.Call localVarCall = updateDocumentByIdValidateBeforeCall(coll, id, dataDocument, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = updateDocumentByIdValidateBeforeCall(coll, id, requestBody, _callback); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/io/lenra/api/internal/client/model/AbstractOpenApiSchema.java b/src/main/java/io/lenra/api/internal/client/model/AbstractOpenApiSchema.java index 2df534b..a73c26f 100644 --- a/src/main/java/io/lenra/api/internal/client/model/AbstractOpenApiSchema.java +++ b/src/main/java/io/lenra/api/internal/client/model/AbstractOpenApiSchema.java @@ -18,12 +18,10 @@ import java.lang.reflect.Type; import java.util.Map; -//import com.fasterxml.jackson.annotation.JsonValue; - /** * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public abstract class AbstractOpenApiSchema { // store the actual instance of the schema/object diff --git a/src/main/java/io/lenra/api/internal/client/model/DataOptions.java b/src/main/java/io/lenra/api/internal/client/model/DataOptions.java new file mode 100644 index 0000000..e676b1d --- /dev/null +++ b/src/main/java/io/lenra/api/internal/client/model/DataOptions.java @@ -0,0 +1,348 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.lenra.api.internal.JSON; + +/** + * Mongo data query options + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") +public class DataOptions { + public static final String SERIALIZED_NAME_LIMIT = "limit"; + @SerializedName(SERIALIZED_NAME_LIMIT) + private Object limit = null; + + public static final String SERIALIZED_NAME_SKIP = "skip"; + @SerializedName(SERIALIZED_NAME_SKIP) + private Object skip = null; + + public static final String SERIALIZED_NAME_SORT = "sort"; + @SerializedName(SERIALIZED_NAME_SORT) + private Object sort = null; + + public DataOptions() { + } + + public DataOptions limit(Object limit) { + this.limit = limit; + return this; + } + + /** + * Get limit + * @return limit + **/ + @javax.annotation.Nullable + public Object getLimit() { + return limit; + } + + public void setLimit(Object limit) { + this.limit = limit; + } + + + public DataOptions skip(Object skip) { + this.skip = skip; + return this; + } + + /** + * Get skip + * @return skip + **/ + @javax.annotation.Nullable + public Object getSkip() { + return skip; + } + + public void setSkip(Object skip) { + this.skip = skip; + } + + + public DataOptions sort(Object sort) { + this.sort = sort; + return this; + } + + /** + * Get sort + * @return sort + **/ + @javax.annotation.Nullable + public Object getSort() { + return sort; + } + + public void setSort(Object sort) { + this.sort = sort; + } + + /** + * 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 name of the property + * @param value value of the property + * @return the DataOptions instance itself + */ + public DataOptions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataOptions dataOptions = (DataOptions) o; + return Objects.equals(this.limit, dataOptions.limit) && + Objects.equals(this.skip, dataOptions.skip) && + Objects.equals(this.sort, dataOptions.sort)&& + Objects.equals(this.additionalProperties, dataOptions.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(limit, skip, sort, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataOptions {\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" skip: ").append(toIndentedString(skip)).append("\n"); + sb.append(" sort: ").append(toIndentedString(sort)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("limit"); + openapiFields.add("skip"); + openapiFields.add("sort"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to DataOptions + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DataOptions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DataOptions is not found in the empty JSON string", DataOptions.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DataOptions.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DataOptions' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DataOptions.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DataOptions value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DataOptions read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DataOptions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DataOptions given an JSON string + * + * @param jsonString JSON string + * @return An instance of DataOptions + * @throws IOException if the JSON string is invalid with respect to DataOptions + */ + public static DataOptions fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DataOptions.class); + } + + /** + * Convert an instance of DataOptions to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/io/lenra/api/internal/client/model/FindDocumentsRequest.java b/src/main/java/io/lenra/api/internal/client/model/FindDocumentsRequest.java index 591cbed..25c080f 100644 --- a/src/main/java/io/lenra/api/internal/client/model/FindDocumentsRequest.java +++ b/src/main/java/io/lenra/api/internal/client/model/FindDocumentsRequest.java @@ -19,11 +19,11 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.lenra.api.internal.client.model.DataOptions; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -52,7 +52,7 @@ /** * FindDocumentsRequest */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class FindDocumentsRequest { public static final String SERIALIZED_NAME_QUERY = "query"; @SerializedName(SERIALIZED_NAME_QUERY) @@ -60,25 +60,20 @@ public class FindDocumentsRequest { public static final String SERIALIZED_NAME_PROJECTION = "projection"; @SerializedName(SERIALIZED_NAME_PROJECTION) - private Map projection; + private Map projection = new HashMap<>(); + + public static final String SERIALIZED_NAME_OPTIONS = "options"; + @SerializedName(SERIALIZED_NAME_OPTIONS) + private DataOptions options; public FindDocumentsRequest() { } public FindDocumentsRequest query(Map query) { - this.query = query; return this; } - public FindDocumentsRequest putQueryItem(String key, Object queryItem) { - if (this.query == null) { - this.query = new HashMap<>(); - } - this.query.put(key, queryItem); - return this; - } - /** * Mongo data query * @return query @@ -88,14 +83,12 @@ public Map getQuery() { return query; } - public void setQuery(Map query) { this.query = query; } public FindDocumentsRequest projection(Map projection) { - this.projection = projection; return this; } @@ -109,11 +102,29 @@ public Map getProjection() { return projection; } - public void setProjection(Map projection) { this.projection = projection; } + + public FindDocumentsRequest options(DataOptions options) { + this.options = options; + return this; + } + + /** + * Get options + * @return options + **/ + @javax.annotation.Nullable + public DataOptions getOptions() { + return options; + } + + public void setOptions(DataOptions options) { + this.options = options; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -170,24 +181,14 @@ public boolean equals(Object o) { } FindDocumentsRequest findDocumentsRequest = (FindDocumentsRequest) o; return Objects.equals(this.query, findDocumentsRequest.query) && - Objects.equals(this.projection, findDocumentsRequest.projection)&& + Objects.equals(this.projection, findDocumentsRequest.projection) && + Objects.equals(this.options, findDocumentsRequest.options)&& Objects.equals(this.additionalProperties, findDocumentsRequest.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - @Override public int hashCode() { - return Objects.hash(query, projection, additionalProperties); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + return Objects.hash(query, projection, options, additionalProperties); } @Override @@ -196,6 +197,7 @@ public String toString() { sb.append("class FindDocumentsRequest {\n"); sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb.append(" projection: ").append(toIndentedString(projection)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -221,6 +223,7 @@ private String toIndentedString(Object o) { openapiFields = new HashSet(); openapiFields.add("query"); openapiFields.add("projection"); + openapiFields.add("options"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -247,6 +250,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `options` + if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { + DataOptions.validateJsonElement(jsonObj.get("options")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -277,7 +284,12 @@ else if (entry.getValue() instanceof Boolean) else if (entry.getValue() instanceof Character) obj.addProperty(entry.getKey(), (Character) entry.getValue()); else { - obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } } } } diff --git a/src/main/java/io/lenra/api/internal/client/model/InsertManyDocuments200Response.java b/src/main/java/io/lenra/api/internal/client/model/InsertManyDocuments200Response.java new file mode 100644 index 0000000..a9117e4 --- /dev/null +++ b/src/main/java/io/lenra/api/internal/client/model/InsertManyDocuments200Response.java @@ -0,0 +1,227 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.lenra.api.internal.JSON; + +/** + * InsertManyDocuments200Response + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") +public class InsertManyDocuments200Response { + public static final String SERIALIZED_NAME_INSERTED_IDS = "insertedIds"; + @SerializedName(SERIALIZED_NAME_INSERTED_IDS) + private List insertedIds = new ArrayList<>(); + + public InsertManyDocuments200Response() { + } + + public InsertManyDocuments200Response insertedIds(List insertedIds) { + this.insertedIds = insertedIds; + return this; + } + + public InsertManyDocuments200Response addInsertedIdsItem(String insertedIdsItem) { + if (this.insertedIds == null) { + this.insertedIds = new ArrayList<>(); + } + this.insertedIds.add(insertedIdsItem); + return this; + } + + /** + * Get insertedIds + * @return insertedIds + **/ + @javax.annotation.Nonnull + public List getInsertedIds() { + return insertedIds; + } + + public void setInsertedIds(List insertedIds) { + this.insertedIds = insertedIds; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InsertManyDocuments200Response insertManyDocuments200Response = (InsertManyDocuments200Response) o; + return Objects.equals(this.insertedIds, insertManyDocuments200Response.insertedIds); + } + + @Override + public int hashCode() { + return Objects.hash(insertedIds); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InsertManyDocuments200Response {\n"); + sb.append(" insertedIds: ").append(toIndentedString(insertedIds)).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 static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("insertedIds"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("insertedIds"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to InsertManyDocuments200Response + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!InsertManyDocuments200Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in InsertManyDocuments200Response is not found in the empty JSON string", InsertManyDocuments200Response.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!InsertManyDocuments200Response.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `InsertManyDocuments200Response` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : InsertManyDocuments200Response.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the required json array is present + if (jsonObj.get("insertedIds") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("insertedIds").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `insertedIds` to be an array in the JSON string but got `%s`", jsonObj.get("insertedIds").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!InsertManyDocuments200Response.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'InsertManyDocuments200Response' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(InsertManyDocuments200Response.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, InsertManyDocuments200Response value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public InsertManyDocuments200Response read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of InsertManyDocuments200Response given an JSON string + * + * @param jsonString JSON string + * @return An instance of InsertManyDocuments200Response + * @throws IOException if the JSON string is invalid with respect to InsertManyDocuments200Response + */ + public static InsertManyDocuments200Response fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, InsertManyDocuments200Response.class); + } + + /** + * Convert an instance of InsertManyDocuments200Response to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequest.java b/src/main/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequest.java new file mode 100644 index 0000000..5bf4529 --- /dev/null +++ b/src/main/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequest.java @@ -0,0 +1,292 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.lenra.api.internal.JSON; + +/** + * InsertManyDocumentsRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") +public class InsertManyDocumentsRequest { + public static final String SERIALIZED_NAME_DOCUMENTS = "documents"; + @SerializedName(SERIALIZED_NAME_DOCUMENTS) + private Object documents = null; + + public InsertManyDocumentsRequest() { + } + + public InsertManyDocumentsRequest documents(Object documents) { + this.documents = documents; + return this; + } + + /** + * Get documents + * @return documents + **/ + @javax.annotation.Nullable + public Object getDocuments() { + return documents; + } + + public void setDocuments(Object documents) { + this.documents = documents; + } + + /** + * 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 name of the property + * @param value value of the property + * @return the InsertManyDocumentsRequest instance itself + */ + public InsertManyDocumentsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InsertManyDocumentsRequest insertManyDocumentsRequest = (InsertManyDocumentsRequest) o; + return Objects.equals(this.documents, insertManyDocumentsRequest.documents)&& + Objects.equals(this.additionalProperties, insertManyDocumentsRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(documents, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InsertManyDocumentsRequest {\n"); + sb.append(" documents: ").append(toIndentedString(documents)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("documents"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("documents"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to InsertManyDocumentsRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!InsertManyDocumentsRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in InsertManyDocumentsRequest is not found in the empty JSON string", InsertManyDocumentsRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : InsertManyDocumentsRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!InsertManyDocumentsRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'InsertManyDocumentsRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(InsertManyDocumentsRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, InsertManyDocumentsRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public InsertManyDocumentsRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + InsertManyDocumentsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of InsertManyDocumentsRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of InsertManyDocumentsRequest + * @throws IOException if the JSON string is invalid with respect to InsertManyDocumentsRequest + */ + public static InsertManyDocumentsRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, InsertManyDocumentsRequest.class); + } + + /** + * Convert an instance of InsertManyDocumentsRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/io/lenra/api/internal/client/model/UpdateManyDocumentsRequest.java b/src/main/java/io/lenra/api/internal/client/model/UpdateManyDocumentsRequest.java index 1882ec4..79b929b 100644 --- a/src/main/java/io/lenra/api/internal/client/model/UpdateManyDocumentsRequest.java +++ b/src/main/java/io/lenra/api/internal/client/model/UpdateManyDocumentsRequest.java @@ -51,7 +51,7 @@ /** * UpdateManyDocumentsRequest */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-12-20T13:50:13.979349Z[Etc/UTC]") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-03-05T16:58:04.750750451Z[Etc/UTC]") public class UpdateManyDocumentsRequest { public static final String SERIALIZED_NAME_FILTER = "filter"; @SerializedName(SERIALIZED_NAME_FILTER) @@ -65,19 +65,10 @@ public UpdateManyDocumentsRequest() { } public UpdateManyDocumentsRequest filter(Map filter) { - this.filter = filter; return this; } - public UpdateManyDocumentsRequest putFilterItem(String key, Object filterItem) { - if (this.filter == null) { - this.filter = new HashMap<>(); - } - this.filter.put(key, filterItem); - return this; - } - /** * Mongo data query * @return filter @@ -87,26 +78,16 @@ public Map getFilter() { return filter; } - public void setFilter(Map filter) { this.filter = filter; } public UpdateManyDocumentsRequest update(Map update) { - this.update = update; return this; } - public UpdateManyDocumentsRequest putUpdateItem(String key, Object updateItem) { - if (this.update == null) { - this.update = new HashMap<>(); - } - this.update.put(key, updateItem); - return this; - } - /** * Mongo data query * @return update @@ -116,7 +97,6 @@ public Map getUpdate() { return update; } - public void setUpdate(Map update) { this.update = update; } @@ -274,7 +254,12 @@ else if (entry.getValue() instanceof Boolean) else if (entry.getValue() instanceof Character) obj.addProperty(entry.getKey(), (Character) entry.getValue()); else { - obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } } } } diff --git a/src/test/java/io/lenra/api/internal/client/model/DataOptionsTest.java b/src/test/java/io/lenra/api/internal/client/model/DataOptionsTest.java new file mode 100644 index 0000000..ba918f8 --- /dev/null +++ b/src/test/java/io/lenra/api/internal/client/model/DataOptionsTest.java @@ -0,0 +1,65 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for DataOptions + */ +public class DataOptionsTest { + private final DataOptions model = new DataOptions(); + + /** + * Model tests for DataOptions + */ + @Test + public void testDataOptions() { + // TODO: test DataOptions + } + + /** + * Test the property 'limit' + */ + @Test + public void limitTest() { + // TODO: test limit + } + + /** + * Test the property 'skip' + */ + @Test + public void skipTest() { + // TODO: test skip + } + + /** + * Test the property 'sort' + */ + @Test + public void sortTest() { + // TODO: test sort + } + +} diff --git a/src/test/java/io/lenra/api/internal/client/model/InsertManyDocuments200ResponseTest.java b/src/test/java/io/lenra/api/internal/client/model/InsertManyDocuments200ResponseTest.java new file mode 100644 index 0000000..dc1460f --- /dev/null +++ b/src/test/java/io/lenra/api/internal/client/model/InsertManyDocuments200ResponseTest.java @@ -0,0 +1,50 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for InsertManyDocuments200Response + */ +public class InsertManyDocuments200ResponseTest { + private final InsertManyDocuments200Response model = new InsertManyDocuments200Response(); + + /** + * Model tests for InsertManyDocuments200Response + */ + @Test + public void testInsertManyDocuments200Response() { + // TODO: test InsertManyDocuments200Response + } + + /** + * Test the property 'insertedIds' + */ + @Test + public void insertedIdsTest() { + // TODO: test insertedIds + } + +} diff --git a/src/test/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequestTest.java b/src/test/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequestTest.java new file mode 100644 index 0000000..92450a9 --- /dev/null +++ b/src/test/java/io/lenra/api/internal/client/model/InsertManyDocumentsRequestTest.java @@ -0,0 +1,48 @@ +/* + * Lenra server internal API + * The API usable by the Lenra applications + * + * The version of the OpenAPI document: 0.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lenra.api.internal.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for InsertManyDocumentsRequest + */ +public class InsertManyDocumentsRequestTest { + private final InsertManyDocumentsRequest model = new InsertManyDocumentsRequest(); + + /** + * Model tests for InsertManyDocumentsRequest + */ + @Test + public void testInsertManyDocumentsRequest() { + // TODO: test InsertManyDocumentsRequest + } + + /** + * Test the property 'documents' + */ + @Test + public void documentsTest() { + // TODO: test documents + } + +}