├── .dockerignore ├── .github ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── deploy-gh-pages.yml │ ├── docker-build.yml │ ├── package.yml │ └── test.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── build.gradle ├── docs ├── data-formats.md ├── expressions.md ├── installation-and-config.md ├── operate.md └── package-directions.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew └── src ├── main ├── java │ └── com │ │ └── aerospike │ │ └── restclient │ │ ├── AerospikeRestGatewayApplication.java │ │ ├── RestClientErrorHandler.java │ │ ├── config │ │ ├── AerospikeClientConfig.java │ │ ├── ClientPolicyConfig.java │ │ ├── JSONMessageConverter.java │ │ ├── MsgPackConverter.java │ │ ├── OpenApiConfiguration.java │ │ ├── ServiceConfig.java │ │ ├── TLSPolicyConfig.java │ │ └── WebConfig.java │ │ ├── controllers │ │ ├── AdminController.java │ │ ├── BaseController.java │ │ ├── BatchController.java │ │ ├── ClusterController.java │ │ ├── DocumentApiController.java │ │ ├── ExecuteV1Controller.java │ │ ├── ExecuteV2Controller.java │ │ ├── InfoController.java │ │ ├── KeyValueController.java │ │ ├── OperateV1Controller.java │ │ ├── OperateV2Controller.java │ │ ├── QueryController.java │ │ ├── SIndexController.java │ │ ├── ScanController.java │ │ └── TruncateController.java │ │ ├── domain │ │ ├── RestClientError.java │ │ ├── RestClientIndex.java │ │ ├── RestClientKey.java │ │ ├── RestClientKeyRecord.java │ │ ├── RestClientOperation.java │ │ ├── RestClientPrivilege.java │ │ ├── RestClientRecord.java │ │ ├── RestClientRole.java │ │ ├── RestClientRoleQuota.java │ │ ├── RestClientUserModel.java │ │ ├── auth │ │ │ └── AuthDetails.java │ │ ├── batchmodels │ │ │ ├── BatchDelete.java │ │ │ ├── BatchDeletePolicy.java │ │ │ ├── BatchRead.java │ │ │ ├── BatchReadPolicy.java │ │ │ ├── BatchRecord.java │ │ │ ├── BatchRecordResponse.java │ │ │ ├── BatchResponseBody.java │ │ │ ├── BatchUDF.java │ │ │ ├── BatchUDFPolicy.java │ │ │ ├── BatchWrite.java │ │ │ └── BatchWritePolicy.java │ │ ├── ctxmodels │ │ │ ├── CTX.java │ │ │ ├── ListIndexCTX.java │ │ │ ├── ListIndexCreateCTX.java │ │ │ ├── ListRankCTX.java │ │ │ ├── ListValueCTX.java │ │ │ ├── MapIndexCTX.java │ │ │ ├── MapKeyCTX.java │ │ │ ├── MapKeyCreateCTX.java │ │ │ ├── MapRankCTX.java │ │ │ └── MapValueCTX.java │ │ ├── executemodels │ │ │ ├── ExecuteRequestBody.java │ │ │ ├── RestClientExecuteTask.java │ │ │ └── RestClientExecuteTaskStatus.java │ │ ├── geojsonmodels │ │ │ ├── AeroCircle.java │ │ │ ├── GeoJSON.java │ │ │ ├── LngLat.java │ │ │ ├── LngLatRad.java │ │ │ ├── Point.java │ │ │ └── Polygon.java │ │ ├── operationmodels │ │ │ ├── AddOperation.java │ │ │ ├── AppendOperation.java │ │ │ ├── BitAddOperation.java │ │ │ ├── BitAndOperation.java │ │ │ ├── BitCountOperation.java │ │ │ ├── BitGetIntOperation.java │ │ │ ├── BitGetOperation.java │ │ │ ├── BitInsertOperation.java │ │ │ ├── BitLScanOperation.java │ │ │ ├── BitLShiftOperation.java │ │ │ ├── BitNotOperation.java │ │ │ ├── BitOperation.java │ │ │ ├── BitOrOperation.java │ │ │ ├── BitRScanOperation.java │ │ │ ├── BitRShiftOperation.java │ │ │ ├── BitRemoveOperation.java │ │ │ ├── BitResizeOperation.java │ │ │ ├── BitSetIntOperation.java │ │ │ ├── BitSetOperation.java │ │ │ ├── BitSubtractOperation.java │ │ │ ├── BitXOrOperation.java │ │ │ ├── DeleteOperation.java │ │ │ ├── GetHeaderOperation.java │ │ │ ├── GetOperation.java │ │ │ ├── HLLAddOperation.java │ │ │ ├── HLLDescribeOperation.java │ │ │ ├── HLLFoldOperation.java │ │ │ ├── HLLGetCountOperation.java │ │ │ ├── HLLGetIntersectionCountOperation.java │ │ │ ├── HLLGetSimilarityOperation.java │ │ │ ├── HLLGetUnionCountOperation.java │ │ │ ├── HLLGetUnionOperation.java │ │ │ ├── HLLInitOperation.java │ │ │ ├── HLLOperation.java │ │ │ ├── HLLRefreshCountOperation.java │ │ │ ├── HLLSetUnionOperation.java │ │ │ ├── ListAppendItemsOperation.java │ │ │ ├── ListAppendOperation.java │ │ │ ├── ListClearOperation.java │ │ │ ├── ListCreateOperation.java │ │ │ ├── ListGetByIndexOperation.java │ │ │ ├── ListGetByIndexRangeOperation.java │ │ │ ├── ListGetByRankOperation.java │ │ │ ├── ListGetByRankRangeOperation.java │ │ │ ├── ListGetByValueListOperation.java │ │ │ ├── ListGetByValueOperation.java │ │ │ ├── ListGetByValueRangeOperation.java │ │ │ ├── ListGetByValueRelativeRankRangeOperation.java │ │ │ ├── ListGetOperation.java │ │ │ ├── ListGetRangeOperation.java │ │ │ ├── ListIncrementOperation.java │ │ │ ├── ListInsertItemsOperation.java │ │ │ ├── ListInsertOperation.java │ │ │ ├── ListOperation.java │ │ │ ├── ListPolicy.java │ │ │ ├── ListPopOperation.java │ │ │ ├── ListPopRangeOperation.java │ │ │ ├── ListRemoveByIndexOperation.java │ │ │ ├── ListRemoveByIndexRangeOperation.java │ │ │ ├── ListRemoveByRankOperation.java │ │ │ ├── ListRemoveByRankRangeOperation.java │ │ │ ├── ListRemoveByValueListOperation.java │ │ │ ├── ListRemoveByValueOperation.java │ │ │ ├── ListRemoveByValueRangeOperation.java │ │ │ ├── ListRemoveByValueRelativeRankRangeOperation.java │ │ │ ├── ListRemoveOperation.java │ │ │ ├── ListRemoveRangeOperation.java │ │ │ ├── ListReturnType.java │ │ │ ├── ListSetOperation.java │ │ │ ├── ListSetOrderOperation.java │ │ │ ├── ListSizeOperation.java │ │ │ ├── ListSortFlag.java │ │ │ ├── ListSortOperation.java │ │ │ ├── ListTrimOperation.java │ │ │ ├── ListWriteFlag.java │ │ │ ├── MapClearOperation.java │ │ │ ├── MapCreateOperation.java │ │ │ ├── MapGetByIndexOperation.java │ │ │ ├── MapGetByIndexRangeOperation.java │ │ │ ├── MapGetByKeyListOperation.java │ │ │ ├── MapGetByKeyOperation.java │ │ │ ├── MapGetByKeyRangeOperation.java │ │ │ ├── MapGetByKeyRelativeIndexRange.java │ │ │ ├── MapGetByRankOperation.java │ │ │ ├── MapGetByRankRangeOperation.java │ │ │ ├── MapGetByValueListOperation.java │ │ │ ├── MapGetByValueOperation.java │ │ │ ├── MapGetByValueRangeOperation.java │ │ │ ├── MapGetByValueRelativeRankRangeOperation.java │ │ │ ├── MapIncrementOperation.java │ │ │ ├── MapOperation.java │ │ │ ├── MapPolicy.java │ │ │ ├── MapPutItemsOperation.java │ │ │ ├── MapPutOperation.java │ │ │ ├── MapRemoveByIndexOperation.java │ │ │ ├── MapRemoveByIndexRangeOperation.java │ │ │ ├── MapRemoveByKeyOperation.java │ │ │ ├── MapRemoveByKeyRangeOperation.java │ │ │ ├── MapRemoveByKeyRelativeIndexRange.java │ │ │ ├── MapRemoveByRankOperation.java │ │ │ ├── MapRemoveByRankRangeOperation.java │ │ │ ├── MapRemoveByValueListOperation.java │ │ │ ├── MapRemoveByValueOperation.java │ │ │ ├── MapRemoveByValueRangeOperation.java │ │ │ ├── MapRemoveByValueRelativeRankRange.java │ │ │ ├── MapReturnType.java │ │ │ ├── MapSetPolicyOperation.java │ │ │ ├── MapSizeOperation.java │ │ │ ├── MapWriteFlag.java │ │ │ ├── OperateRequestBody.java │ │ │ ├── OperateResponseRecordBody.java │ │ │ ├── OperateResponseRecordsBody.java │ │ │ ├── Operation.java │ │ │ ├── OperationTypes.java │ │ │ ├── PrependOperation.java │ │ │ ├── PutOperation.java │ │ │ ├── ReadOperation.java │ │ │ └── TouchOperation.java │ │ ├── querymodels │ │ │ ├── QueryContainsLongFilter.java │ │ │ ├── QueryContainsStringFilter.java │ │ │ ├── QueryEqualLongFilter.java │ │ │ ├── QueryEqualsStringFilter.java │ │ │ ├── QueryFilter.java │ │ │ ├── QueryGeoContainsPointFilter.java │ │ │ ├── QueryGeoWithinPolygonFilter.java │ │ │ ├── QueryGeoWithinRadiusFilter.java │ │ │ ├── QueryRangeFilter.java │ │ │ ├── QueryRequestBody.java │ │ │ └── QueryResponseBody.java │ │ ├── scanmodels │ │ │ ├── Pagination.java │ │ │ └── RestClientScanResponse.java │ │ └── swaggermodels │ │ │ ├── RestClientClusterInfoResponse.java │ │ │ ├── RestClientNamespaceInfoResponse.java │ │ │ ├── RestClientNodeInfoResponse.java │ │ │ ├── RestClientSetInformation.java │ │ │ └── RestClientUserResponse.java │ │ ├── handlers │ │ ├── AdminHandler.java │ │ ├── BatchHandler.java │ │ ├── ClusterHandler.java │ │ ├── DocumentHandler.java │ │ ├── ExecuteHandler.java │ │ ├── IndexHandler.java │ │ ├── InfoHandler.java │ │ ├── OperateHandler.java │ │ ├── QueryHandler.java │ │ ├── RecordHandler.java │ │ ├── ScanHandler.java │ │ └── TruncateHandler.java │ │ ├── service │ │ ├── AerospikeAdminService.java │ │ ├── AerospikeAdminServiceV1.java │ │ ├── AerospikeBatchService.java │ │ ├── AerospikeBatchServiceV1.java │ │ ├── AerospikeClusterService.java │ │ ├── AerospikeClusterServiceV1.java │ │ ├── AerospikeDocumentService.java │ │ ├── AerospikeDocumentServiceV1.java │ │ ├── AerospikeExecuteService.java │ │ ├── AerospikeExecuteServiceV1.java │ │ ├── AerospikeInfoService.java │ │ ├── AerospikeInfoServiceV1.java │ │ ├── AerospikeOperateService.java │ │ ├── AerospikeOperateServiceV1.java │ │ ├── AerospikeQueryService.java │ │ ├── AerospikeQueryServiceV1.java │ │ ├── AerospikeRecordService.java │ │ ├── AerospikeRecordServiceV1.java │ │ ├── AerospikeSIndexService.java │ │ ├── AerospikeSIndexServiceV1.java │ │ ├── AerospikeScanService.java │ │ ├── AerospikeScanServiceV1.java │ │ ├── AerospikeTruncateService.java │ │ └── AerospikeTruncateServiceV1.java │ │ └── util │ │ ├── APIDescriptors.java │ │ ├── APIParamDescriptors.java │ │ ├── AerospikeAPIConstants.java │ │ ├── AerospikeClientPool.java │ │ ├── AerospikeOperation.java │ │ ├── HeaderHandler.java │ │ ├── InfoResponseParser.java │ │ ├── KeyBuilder.java │ │ ├── RequestBodyExamples.java │ │ ├── RequestParamHandler.java │ │ ├── ResponseExamples.java │ │ ├── RestClientErrors.java │ │ ├── TLSPolicyBuilder.java │ │ ├── annotations │ │ ├── ASRestClientBatchPolicyQueryParams.java │ │ ├── ASRestClientInfoPolicyQueryParams.java │ │ ├── ASRestClientOperateReadQueryParams.java │ │ ├── ASRestClientParams.java │ │ ├── ASRestClientPolicyQueryParams.java │ │ ├── ASRestClientQueryPolicyQueryParams.java │ │ ├── ASRestClientScanPolicyQueryParams.java │ │ ├── ASRestClientSchemas.java │ │ ├── ASRestClientStatementQueryParams.java │ │ ├── ASRestClientWritePolicyQueryParams.java │ │ ├── ASRestDocumentPolicyQueryParams.java │ │ ├── ASRestDocumentWritePolicyQueryParams.java │ │ └── DefaultRestClientAPIResponses.java │ │ ├── converters │ │ ├── BinConverter.java │ │ ├── DateConverter.java │ │ ├── OperationConverter.java │ │ ├── OperationsConverter.java │ │ ├── PolicyValueConverter.java │ │ ├── StatementConverter.java │ │ ├── exp │ │ │ ├── BaseExpFactory.java │ │ │ ├── BaseExpressionParser.java │ │ │ ├── ExpressionParser.java │ │ │ ├── FilterExpFactory.java │ │ │ ├── FilterExpParser.java │ │ │ └── Operator.java │ │ └── policyconverters │ │ │ ├── BatchPolicyConverter.java │ │ │ ├── InfoPolicyConverter.java │ │ │ ├── PolicyConverter.java │ │ │ ├── QueryPolicyConverter.java │ │ │ ├── ScanPolicyConverter.java │ │ │ └── WritePolicyConverter.java │ │ ├── deserializers │ │ ├── MsgPackBinParser.java │ │ ├── MsgPackOperationsParser.java │ │ ├── MsgPackParser.java │ │ └── ObjectDeserializer.java │ │ └── serializers │ │ ├── MsgPackGeoJSONSerializer.java │ │ └── MsgPackObjKeySerializer.java └── resources │ └── application.properties └── test └── java └── com └── aerospike └── restclient ├── ASTestMapper.java ├── ASTestUtils.java ├── AerospikeRestGatewayApplicationTests.java ├── AuthenticationTest.java ├── BatchCorrectTests.java ├── ClusterTests.java ├── ClusterUtils.java ├── ConfigRequireAuthTest.java ├── DocumentApiTests.java ├── ErrorReturnTest.java ├── ExceptionHTTPCodesTest.java ├── ExecuteV1Tests.java ├── ExecuteV2Tests.java ├── ExpressionParserTest.java ├── FilterExpressionTest.java ├── IASTestMapper.java ├── InfoResponseParserTests.java ├── InfoTests.java ├── KeyBuilderTest.java ├── MsgPackOperateTest.java ├── MsgPackOperationV1Performer.java ├── NestedCdtOperationsTest.java ├── OperateV1BitCorrectTests.java ├── OperateV1HLLCorrectTests.java ├── OperateV1ListCorrectTests.java ├── OperateV1MapCorrectTests.java ├── OperateV1TestCorrect.java ├── OperateV2BitCorrectTests.java ├── OperateV2CorrectTest.java ├── OperateV2HLLCorrectTests.java ├── OperateV2ListCorrectTests.java ├── OperateV2MapCorrectTests.java ├── OperationV1Performer.java ├── OperationV2Performer.java ├── QueryCorrectTest.java ├── QueryErrorTest.java ├── RecordDeleteCorrectTests.java ├── RecordDeleteErrorTests.java ├── RecordExistsTests.java ├── RecordGetCorrectTests.java ├── RecordGetErrorTests.java ├── RecordPatchCorrectTests.java ├── RecordPatchErrorTests.java ├── RecordPostCorrectTests.java ├── RecordPostErrorTests.java ├── RecordPutCorrectTests.java ├── RecordPutErrorTests.java ├── RoleTestsCorrect.java ├── RoleTestsError.java ├── ScanTest.java ├── SindexResponseParserTests.java ├── SindexTestsCorrect.java ├── SindexTestsError.java ├── TruncateTestsCorrect.java ├── TruncateTestsError.java ├── UserTestsCorrect.java ├── UserTestsError.java ├── controller ├── KVControllerGetRecordKeyTypeTests.java ├── KVControllerGetRecordTests.java ├── KVControllerV1DeleteRecordTests.java ├── KVControllerV1KeyTypeTests.java ├── KVControllerV1PutPostPatchTests.java └── KVControllerV1PutPostUpdateErrorTests.java ├── converters ├── BatchReadDeserializerTest.java ├── BinConverterTests.java ├── OperationConverterErrors.java ├── PolicyConverterTests.java ├── RequestParamHandlerTests.java ├── StatementConverterTest.java └── policyConverters │ ├── BasePolicyConverterTests.java │ ├── BatchPolicyConverterTests.java │ ├── InfoPolicyConverterTests.java │ ├── QueryPolicyConverterTest.java │ └── WritePolicyConverterTests.java ├── domain ├── RestClientKeyTest.java ├── RestClientOperationTest.java ├── RestClientRecordTest.java ├── batchmodels │ ├── RestClientBatchBodyTest.java │ ├── RestClientBatchDeletePolicyTest.java │ ├── RestClientBatchReadPolicyTest.java │ ├── RestClientBatchRecordResponseTest.java │ ├── RestClientBatchUDFPolicyTest.java │ └── RestClientBatchWritePolicyTest.java ├── ctxmodels │ └── RestClientCTXTest.java ├── geojsonmodels │ └── GeoJSONTest.java ├── operationmodels │ ├── BitAddOperationTest.java │ ├── BitSubtractOperationTest.java │ ├── HLLAddOperationTest.java │ ├── HLLInitOperationTest.java │ ├── ListAppendItemsOperationTest.java │ ├── ListAppendOperationTest.java │ ├── ListGetByIndexOperationTest.java │ ├── ListGetByIndexRangeOperationTest.java │ ├── ListGetByRankOperationTest.java │ ├── ListGetByRankRangeOperationTest.java │ ├── ListGetByValueListOperationTest.java │ ├── ListGetByValueOperationTest.java │ ├── ListGetByValueRangeOperationTest.java │ ├── ListGetByValueRelativeRankRangeOperationTest.java │ ├── ListPolicyTest.java │ ├── ListRemoveByIndexRangeOperationTest.java │ ├── ListRemoveByValueListOperationTest.java │ ├── ListRemoveByValueOperationTest.java │ ├── ListRemoveByValueRangeOperationTest.java │ ├── ListRemoveByValueRelativeRankRangeOperationTest.java │ ├── ListReturnTypeTest.java │ ├── ListSortFlagTest.java │ ├── ListSortOperationTest.java │ ├── ListWriteFlagTest.java │ ├── MapGetByValueRangeOperationTest.java │ ├── MapPolicyTest.java │ ├── MapRemoveByIndexOperationTest.java │ ├── MapRemoveByIndexRangeOperationTest.java │ ├── MapRemoveByKeyOperationTest.java │ ├── MapRemoveByKeyRangeOperationTest.java │ ├── MapRemoveByValueRelativeRankRangeTest.java │ ├── MapReturnTypeTest.java │ ├── MapSetPolicyOperationTest.java │ └── MapWriteFlagTest.java └── querymodels │ ├── QueryFilterTest.java │ ├── QueryRequestBodyTest.java │ └── QueryResponseBodyTest.java ├── msgpack ├── BasicMsgPackOperationsTest.java ├── BinParserTest.java ├── MsgPackParserTest.java ├── MsgpackCustomSerializerTest.java ├── MsgpackPostTests.java └── OperationParserTest.java └── udf └── record_example.lua /.dockerignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .github 3 | .gradle 4 | build 5 | target 6 | 7 | .idea 8 | .vscode 9 | 10 | *.md 11 | !README*.md 12 | README-secret.md -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gradle" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/docker-build.yml: -------------------------------------------------------------------------------- 1 | name: Build x86 Docker Image 2 | on: 3 | pull_request: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v4 13 | with: 14 | fetch-depth: 0 15 | - name: Build x86 Image 16 | run: 17 | make image -------------------------------------------------------------------------------- /.github/workflows/package.yml: -------------------------------------------------------------------------------- 1 | name: Package 2 | on: 3 | push: 4 | tags: 5 | - '*' 6 | branches: 7 | - build-automation 8 | pull_request: 9 | branches: 10 | - master 11 | workflow_call: 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | - name: Set up JDK 17 22 | uses: actions/setup-java@v4 23 | with: 24 | distribution: 'temurin' 25 | java-version: 17 26 | - name: Install npm 27 | run: sudo apt-get install npm && npm install -g swagger-cli 28 | - name: Cache Gradle packages 29 | uses: actions/cache@v3 30 | with: 31 | path: | 32 | ~/.gradle/caches 33 | ~/.gradle/wrapper 34 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 35 | restore-keys: | 36 | ${{ runner.os }}-gradle- 37 | - name: Build & Package 38 | run: make package 39 | - name: Upload artifact 40 | uses: actions/upload-artifact@v3 41 | with: 42 | path: target/aerospike-rest-gateway-*.tgz* 43 | name: aerospike-rest-gateway-pkg 44 | - name: Cleanup Gradle Cache 45 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. 46 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. 47 | run: | 48 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 49 | rm -f ~/.gradle/caches/modules-2/gc.properties -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: 17 19 | distribution: 'temurin' 20 | 21 | - name: Set up Aerospike Database 22 | uses: reugn/github-action-aerospike@v1 23 | with: 24 | server-version: 7.0.0.9 25 | 26 | - name: Cache Gradle packages 27 | uses: actions/cache@v3 28 | with: 29 | path: | 30 | ~/.gradle/caches 31 | ~/.gradle/wrapper 32 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 33 | restore-keys: | 34 | ${{ runner.os }}-gradle- 35 | 36 | - name: Build & Test with Gradle 37 | run: ./gradlew clean test --stacktrace --info 38 | 39 | - name: Cleanup Gradle Cache 40 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. 41 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. 42 | run: | 43 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 44 | rm -f ~/.gradle/caches/modules-2/gc.properties -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | .DS_Store 3 | /gradle/ 4 | /build/ 5 | .project 6 | /.settings/ 7 | gradlew 8 | gradlew.bat 9 | .classpath 10 | /.gradle/ 11 | .vscode/ 12 | .idea/ 13 | target/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:17-jdk AS build 2 | WORKDIR /workspace/app 3 | 4 | # Needed for arm64 support. Open gradle issue: https://github.com/gradle/gradle/issues/18212 5 | ENV JAVA_OPTS="-Djdk.lang.Process.launchMechanism=vfork" 6 | 7 | COPY . /workspace/app 8 | RUN apt-get -y update && apt-get -y install git 9 | RUN ./gradlew clean build -x test 10 | 11 | # Copy the non-plain jar into /build/dependency 12 | RUN mkdir -p build/dependency && cd build/dependency && jar -xf $(ls ../libs/*.jar | grep -v "plain.jar") 13 | 14 | FROM eclipse-temurin:17-jre 15 | VOLUME /tmp 16 | ARG DEPENDENCY=/workspace/app/build/dependency 17 | COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF 18 | COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib 19 | COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app 20 | EXPOSE 8080 21 | ENTRYPOINT ["java","-cp","app:app/lib/*","com.aerospike.restclient.AerospikeRestGatewayApplication"] 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | VERSION=$(shell git describe --tags) 3 | ARCHIVEDIR=aerospike-rest-gateway-$(VERSION) 4 | ARCHIVENAME=$(ARCHIVEDIR).tgz 5 | OPENAPI_SPEC=build/openapi.json 6 | 7 | .PHONY: package 8 | package: clean validatedocs build 9 | mkdir $(ARCHIVEDIR) 10 | mkdir target 11 | cp build/libs/*.jar $(ARCHIVEDIR) 12 | cp $(OPENAPI_SPEC) $(ARCHIVEDIR) 13 | tar -czvf target/$(ARCHIVENAME) $(ARCHIVEDIR) 14 | cd target; sha256sum $(ARCHIVENAME) > $(ARCHIVENAME).sha256 15 | 16 | .PHONY: build 17 | build: 18 | ./gradlew build -x test 19 | 20 | .PHONY: image 21 | image: 22 | docker build -t aerospike-rest-gateway . 23 | 24 | .PHONY: run 25 | run: 26 | ./gradlew bootRun 27 | 28 | .PHONY: clean 29 | clean: 30 | echo $(VERSION) 31 | rm -rf $(ARCHIVEDIR) 32 | rm -f $(ARCHIVENAME) 33 | rm -rf target/ 34 | ./gradlew clean 35 | 36 | .PHONY: validatedocs 37 | validatedocs: $(OPENAPI_SPEC) 38 | swagger-cli validate $(OPENAPI_SPEC) 39 | 40 | $(OPENAPI_SPEC): 41 | ./gradlew clean generateApiDocs 42 | -------------------------------------------------------------------------------- /docs/package-directions.md: -------------------------------------------------------------------------------- 1 | # Aerospike Rest Gateway package 2 | 3 | This package contains the following files 4 | 5 | * `openapi.json` The swagger specification for the Rest API. 6 | * `aerospike-rest-gateway##.jar` A `.jar` file to be deployed. 7 | * `aerospike-rest-gateway##-plain.jar` A plain `.jar` file. 8 | 9 | ## Installing and starting the Rest Gateway 10 | 11 | Follow the [installation and configuration directions](./installation-and-config.md) to install and start the rest 12 | client. 13 | 14 | ## First steps 15 | 16 | **Note** The following directions assume that the Rest Gateway is listening 17 | on `http://localhost:8080/`, 18 | if this is not the case, change the URLS accordingly. 19 | 20 | To get a quick introduction to the API and usage of the Rest Gateway we recommend visiting the Interactive Documentation 21 | which will be located at . This Interface shows all the 22 | API 23 | endpoints, and allows you to try them out from a browser. 24 | 25 | ## Further information 26 | 27 | For directions on the interchange formats supported by the Rest Gateway, see [Data Formats](./data-formats.md) . 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | jarBaseName=aerospike-rest-gateway 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aerospike/aerospike-rest-gateway/eb36fb58f939cb220bd0ac6072afc2e387dedd54/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/AerospikeRestGatewayApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.retry.annotation.EnableRetry; 22 | 23 | @SpringBootApplication 24 | @EnableRetry 25 | public class AerospikeRestGatewayApplication { 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(AerospikeRestGatewayApplication.class, args); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/config/JSONMessageConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.config; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | import com.fasterxml.jackson.core.JsonFactory; 21 | import com.fasterxml.jackson.databind.ObjectMapper; 22 | import com.fasterxml.jackson.databind.module.SimpleModule; 23 | import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; 24 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 25 | 26 | public class JSONMessageConverter extends MappingJackson2HttpMessageConverter { 27 | 28 | JSONMessageConverter() { 29 | super(getJSONObjectMapper()); 30 | } 31 | 32 | public static ObjectMapper getJSONObjectMapper() { 33 | ObjectMapper jsonMapper = new ObjectMapper(new JsonFactory()); 34 | SimpleModule recordModule = new SimpleModule(); 35 | jsonMapper.registerModule(recordModule); 36 | jsonMapper.registerModule(new ParameterNamesModule()); 37 | jsonMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); 38 | return jsonMapper; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/config/OpenApiConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.config; 18 | 19 | import io.swagger.v3.oas.models.OpenAPI; 20 | import io.swagger.v3.oas.models.info.Contact; 21 | import io.swagger.v3.oas.models.info.Info; 22 | import io.swagger.v3.oas.models.info.License; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.info.BuildProperties; 25 | import org.springframework.context.annotation.Bean; 26 | import org.springframework.context.annotation.Configuration; 27 | 28 | @Configuration 29 | public class OpenApiConfiguration { 30 | 31 | @Autowired 32 | private BuildProperties buildProperties; 33 | 34 | @Bean 35 | public OpenAPI customOpenAPI() { 36 | return new OpenAPI().info(apiInfo()); 37 | } 38 | 39 | private Info apiInfo() { 40 | return new Info().title("Aerospike REST Gateway") 41 | .description("REST Interface for Aerospike Database.") 42 | .version(buildProperties.getVersion()) 43 | .contact(apiContact()) 44 | .license(apiLicence()); 45 | } 46 | 47 | private License apiLicence() { 48 | return new License().name("Apache 2.0 License").url("http://www.apache.org/licenses/LICENSE-2.0"); 49 | } 50 | 51 | private Contact apiContact() { 52 | return new Contact().name("Aerospike, Inc.").url("https://www.aerospike.com"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/config/ServiceConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.config; 18 | 19 | import com.aerospike.client.AerospikeException; 20 | import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; 21 | import io.github.resilience4j.timelimiter.TimeLimiterConfig; 22 | import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JCircuitBreakerFactory; 23 | import org.springframework.cloud.client.circuitbreaker.Customizer; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.context.annotation.Configuration; 26 | 27 | import java.time.Duration; 28 | 29 | @Configuration 30 | public class ServiceConfig { 31 | 32 | @Bean 33 | public Customizer restClientCustomizer() { 34 | final TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() 35 | .timeoutDuration(Duration.ofSeconds(1)) 36 | .build(); 37 | final CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom() 38 | .failureRateThreshold(50) 39 | .waitDurationInOpenState(Duration.ofSeconds(2)) 40 | .slidingWindowSize(10) 41 | .recordException(e -> e instanceof AerospikeException.Connection) 42 | .build(); 43 | 44 | return factory -> factory.configure( 45 | builder -> builder.circuitBreakerConfig(circuitBreakerConfig).timeLimiterConfig(timeLimiterConfig), 46 | "rest-client"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/controllers/BaseController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.controllers; 18 | 19 | import io.swagger.v3.oas.annotations.Hidden; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | /* 24 | * A controller which allows for a 200 response from the base URL. 25 | */ 26 | @RestController 27 | @RequestMapping("") 28 | @Hidden 29 | public class BaseController { 30 | 31 | @RequestMapping(value = "") 32 | public void respond() { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/RestClientKeyRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain; 18 | 19 | import com.aerospike.client.Key; 20 | import com.aerospike.client.Record; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Map; 24 | import java.util.Objects; 25 | 26 | public class RestClientKeyRecord { 27 | 28 | public RestClientKeyRecord() { 29 | } 30 | 31 | public RestClientKeyRecord(Key key, Record rec) { 32 | if (Objects.nonNull(key) && Objects.nonNull(key.userKey)) { 33 | userKey = key.userKey.getObject(); 34 | } 35 | generation = rec.generation; 36 | ttl = rec.getTimeToLive(); 37 | bins = rec.bins; 38 | } 39 | 40 | @Schema( 41 | requiredMode = Schema.RequiredMode.REQUIRED, 42 | description = "The user key, it may be a string, integer, or URL safe Base64 encoded bytes.", 43 | example = "userKey" 44 | ) 45 | public Object userKey; 46 | 47 | @Schema(name = "generation", description = "The generation of the record.", example = "2") 48 | public int generation; 49 | 50 | @Schema(name = "ttl", description = "The time to live for the record, in seconds from now.", example = "1000") 51 | public int ttl; 52 | 53 | @Schema( 54 | name = "bins", 55 | description = "A mapping from binName to binValue", 56 | example = "{\"bin1\": \"val1\", \"pi\": \"3.14\"}" 57 | ) 58 | public Map bins; 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/RestClientRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain; 18 | 19 | import com.aerospike.client.Record; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Map; 24 | 25 | /* Record describing what we return as a record in JSON */ 26 | public class RestClientRecord { 27 | 28 | public RestClientRecord() { 29 | } 30 | 31 | public RestClientRecord(Record rec) { 32 | generation = rec.generation; 33 | ttl = rec.getTimeToLive(); 34 | bins = rec.bins; 35 | } 36 | 37 | @Schema(name = "generation", description = "The generation of the record.", example = "2") 38 | public int generation; 39 | 40 | @Schema(name = "ttl", description = "The time to live for the record, in seconds from now.", example = "1000") 41 | public int ttl; 42 | 43 | @JsonInclude(JsonInclude.Include.ALWAYS) 44 | @Schema( 45 | name = "bins", 46 | description = "A mapping from binName to binValue", 47 | example = "{\"bin1\": \"val1\", \"pi\": \"3.14\"}" 48 | ) 49 | public Map bins; 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/RestClientRoleQuota.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientRoleQuota { 22 | 23 | @Schema(description = "Maximum reads per second limit.") 24 | private int readQuota; 25 | 26 | @Schema(description = "Maximum writes per second limit.") 27 | private int writeQuota; 28 | 29 | public int getReadQuota() { 30 | return this.readQuota; 31 | } 32 | 33 | public void setReadQuota(int readQuota) { 34 | this.readQuota = readQuota; 35 | } 36 | 37 | public int getWriteQuota() { 38 | return this.writeQuota; 39 | } 40 | 41 | public void setWriteQuota(int writeQuota) { 42 | this.writeQuota = writeQuota; 43 | } 44 | 45 | public RestClientRoleQuota() { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/RestClientUserModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain; 18 | 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 21 | import jakarta.validation.constraints.NotNull; 22 | 23 | @JsonInclude(Include.NON_NULL) 24 | public class RestClientUserModel { 25 | 26 | @NotNull String username; 27 | @NotNull String password; 28 | @NotNull String[] roles; 29 | 30 | public String getUsername() { 31 | return this.username; 32 | } 33 | 34 | public String getPassword() { 35 | return this.password; 36 | } 37 | 38 | public String[] getRoles() { 39 | return this.roles; 40 | } 41 | 42 | public void setUsername(String userName) { 43 | this.username = userName; 44 | } 45 | 46 | public void setPassword(String password) { 47 | this.password = password; 48 | } 49 | 50 | public void setRoles(String[] roles) { 51 | this.roles = roles; 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/auth/AuthDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.auth; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class AuthDetails { 22 | 23 | @Schema(description = "Basic access authentication username.") 24 | private final String user; 25 | 26 | @Schema(description = "Basic access authentication password.") 27 | private final String password; 28 | 29 | public AuthDetails(String user, String password) { 30 | this.user = user; 31 | this.password = password; 32 | } 33 | 34 | public String getUser() { 35 | return user; 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return user + password; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/batchmodels/BatchRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.batchmodels; 18 | 19 | import com.aerospike.restclient.domain.RestClientKey; 20 | import com.aerospike.restclient.util.AerospikeAPIConstants; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import com.fasterxml.jackson.annotation.JsonSubTypes; 23 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 24 | import io.swagger.v3.oas.annotations.media.Schema; 25 | 26 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") 27 | @JsonSubTypes({ 28 | @JsonSubTypes.Type(value = BatchRead.class, name = AerospikeAPIConstants.BATCH_TYPE_READ), 29 | @JsonSubTypes.Type(value = BatchWrite.class, name = AerospikeAPIConstants.BATCH_TYPE_WRITE), 30 | @JsonSubTypes.Type(value = BatchDelete.class, name = AerospikeAPIConstants.BATCH_TYPE_DELETE), 31 | @JsonSubTypes.Type(value = BatchUDF.class, name = AerospikeAPIConstants.BATCH_TYPE_UDF), 32 | }) 33 | @Schema( 34 | description = "The batch operation base type.", 35 | oneOf = {BatchRead.class, BatchWrite.class, BatchDelete.class, BatchUDF.class} 36 | ) 37 | public abstract class BatchRecord { 38 | @Schema(description = "Key to a record.", requiredMode = Schema.RequiredMode.REQUIRED) 39 | @JsonProperty(required = true) 40 | public RestClientKey key; 41 | 42 | public abstract com.aerospike.client.BatchRecord toBatchRecord(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/batchmodels/BatchResponseBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.batchmodels; 18 | 19 | import java.util.List; 20 | 21 | public class BatchResponseBody { 22 | // TODO: Make the input and return type a map instead of a list for easier backwards compatibility changes 23 | public List batchRecords; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/ctxmodels/ListRankCTX.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.ctxmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | @Schema( 24 | description = "Lookup list by rank", 25 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/cdt/CTX.html") 26 | ) 27 | public class ListRankCTX extends CTX { 28 | @Schema( 29 | description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.LIST_RANK, 30 | allowableValues = {AerospikeAPIConstants.CTX.LIST_RANK}, 31 | requiredMode = Schema.RequiredMode.REQUIRED 32 | ) 33 | public final String type = AerospikeAPIConstants.CTX.LIST_RANK; 34 | 35 | @Schema( 36 | description = """ 37 | * 0 = smallest value 38 | * N = Nth smallest value 39 | * -1 = largest value""", requiredMode = Schema.RequiredMode.REQUIRED 40 | ) 41 | public Integer rank; 42 | 43 | ListRankCTX() { 44 | } 45 | 46 | public ListRankCTX(int rank) { 47 | this.rank = rank; 48 | } 49 | 50 | @Override 51 | public com.aerospike.client.cdt.CTX toCTX() { 52 | return com.aerospike.client.cdt.CTX.listRank(rank); 53 | } 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/ctxmodels/MapRankCTX.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.ctxmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | @Schema( 24 | name = "MapRankCTX", 25 | description = "Lookup map by rank.", 26 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/cdt/CTX.html") 27 | ) 28 | public class MapRankCTX extends CTX { 29 | @Schema( 30 | description = "The type of context this object represents. It is always " + AerospikeAPIConstants.CTX.MAP_RANK, 31 | allowableValues = {AerospikeAPIConstants.CTX.MAP_RANK}, 32 | requiredMode = Schema.RequiredMode.REQUIRED 33 | ) 34 | public final String type = AerospikeAPIConstants.CTX.MAP_RANK; 35 | 36 | @Schema( 37 | description = """ 38 | * 0 = smallest value 39 | * N = Nth smallest value 40 | * -1 = largest value""", requiredMode = Schema.RequiredMode.REQUIRED 41 | ) 42 | public Integer rank; 43 | 44 | MapRankCTX() { 45 | } 46 | 47 | @Override 48 | public com.aerospike.client.cdt.CTX toCTX() { 49 | return com.aerospike.client.cdt.CTX.mapRank(rank); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/executemodels/ExecuteRequestBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.executemodels; 18 | 19 | import com.aerospike.restclient.domain.operationmodels.Operation; 20 | 21 | import java.util.List; 22 | 23 | public class ExecuteRequestBody { 24 | public List opsList; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/executemodels/RestClientExecuteTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.executemodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientExecuteTask { 22 | 23 | @Schema(description = "The task ID value.") 24 | private final long taskId; 25 | 26 | @Schema(description = "The scan indicator.") 27 | private final boolean scan; 28 | 29 | public RestClientExecuteTask(long taskId, boolean scan) { 30 | this.taskId = taskId; 31 | this.scan = scan; 32 | } 33 | 34 | public RestClientExecuteTask() { 35 | this(-1L, true); 36 | } 37 | 38 | public long getTaskId() { 39 | return taskId; 40 | } 41 | 42 | public boolean getScan() { 43 | return scan; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/executemodels/RestClientExecuteTaskStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.executemodels; 18 | 19 | import com.aerospike.client.task.Task; 20 | import io.swagger.v3.oas.annotations.media.Schema; 21 | 22 | public class RestClientExecuteTaskStatus { 23 | 24 | @Schema(description = "The ExecuteTask object.") 25 | private final RestClientExecuteTask task; 26 | 27 | @Schema(description = "The ExecuteTask status.") 28 | private final String status; 29 | 30 | public RestClientExecuteTaskStatus(RestClientExecuteTask task, int statusCode) { 31 | this.task = task; 32 | this.status = translateStatusCode(statusCode); 33 | } 34 | 35 | public RestClientExecuteTaskStatus() { 36 | this(new RestClientExecuteTask(), -1); 37 | } 38 | 39 | private String translateStatusCode(int statusCode) { 40 | return switch (statusCode) { 41 | case Task.IN_PROGRESS -> "IN_PROGRESS"; 42 | case Task.COMPLETE -> "COMPLETE"; 43 | case Task.NOT_FOUND -> "NOT_FOUND"; 44 | default -> "UNKNOWN"; 45 | }; 46 | } 47 | 48 | public RestClientExecuteTask getTask() { 49 | return task; 50 | } 51 | 52 | public String getStatus() { 53 | return status; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/geojsonmodels/AeroCircle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.geojsonmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Objects; 24 | 25 | @Schema( 26 | description = "Aerospike's custom GeoJSON extension type to describe a circle.", 27 | externalDocs = @ExternalDocumentation(url = "https://docs.aerospike.com/server/guide/data-types/geospatial") 28 | ) 29 | public class AeroCircle extends GeoJSON { 30 | @Schema( 31 | description = "The type of geoJSON geometry this object represents. It is always " + AerospikeAPIConstants.GeoJSON.Types.AERO_CIRCLE, 32 | allowableValues = {AerospikeAPIConstants.GeoJSON.Types.AERO_CIRCLE}, 33 | requiredMode = Schema.RequiredMode.REQUIRED 34 | ) 35 | public final String type = AerospikeAPIConstants.GeoJSON.Types.AERO_CIRCLE; 36 | 37 | public LngLatRad coordinates; 38 | 39 | AeroCircle() { 40 | } 41 | 42 | @Override 43 | public boolean equals(Object o) { 44 | if (this == o) return true; 45 | if (o == null || getClass() != o.getClass()) return false; 46 | AeroCircle that = (AeroCircle) o; 47 | return Objects.equals(coordinates, that.coordinates); 48 | } 49 | 50 | @Override 51 | public int hashCode() { 52 | return Objects.hash(coordinates); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/geojsonmodels/LngLat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.geojsonmodels; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Objects; 24 | 25 | @JsonFormat(shape = JsonFormat.Shape.ARRAY) 26 | @JsonPropertyOrder({"longitude", "latitude"}) 27 | @Schema( 28 | requiredMode = Schema.RequiredMode.REQUIRED, 29 | description = "A 2 element array describing a position of the form [longitude, latitude]", 30 | example = "[37.421331, -122.098820]" 31 | ) 32 | public class LngLat { 33 | public double longitude; 34 | public double latitude; 35 | 36 | public LngLat() { 37 | } 38 | 39 | public LngLat(double longitude, double latitude) { 40 | this.longitude = longitude; 41 | this.latitude = latitude; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object o) { 46 | if (this == o) return true; 47 | if (o == null || getClass() != o.getClass()) return false; 48 | LngLat lngLat = (LngLat) o; 49 | return Double.compare(lngLat.longitude, longitude) == 0 && Double.compare(lngLat.latitude, latitude) == 0; 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return Objects.hash(longitude, latitude); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/geojsonmodels/LngLatRad.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.geojsonmodels; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Objects; 24 | 25 | @JsonFormat(shape = JsonFormat.Shape.ARRAY) 26 | @JsonPropertyOrder({"latLng", "radius"}) 27 | @Schema( 28 | requiredMode = Schema.RequiredMode.REQUIRED, 29 | description = "A 2 element array describing a circle of the form [[longitude, latitude], radius].", 30 | example = "[[37.421331, -122.098820], 3.14159]" 31 | ) 32 | public class LngLatRad { 33 | public LngLat latLng; 34 | public double radius; 35 | 36 | public LngLatRad() { 37 | } 38 | 39 | public LngLatRad(double longitude, double latitude, double radius) { 40 | this.latLng = new LngLat(longitude, latitude); 41 | this.radius = radius; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object o) { 46 | if (this == o) return true; 47 | if (o == null || getClass() != o.getClass()) return false; 48 | LngLatRad lngLatRad = (LngLatRad) o; 49 | return Double.compare(lngLatRad.radius, radius) == 0 && Objects.equals(latLng, lngLatRad.latLng); 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return Objects.hash(latLng, radius); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/geojsonmodels/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.geojsonmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | import java.util.Objects; 24 | 25 | @Schema( 26 | description = "GeoJSON Point geometry.", 27 | externalDocs = @ExternalDocumentation(url = "https://docs.aerospike.com/server/guide/data-types/geospatial") 28 | ) 29 | public class Point extends GeoJSON { 30 | @Schema( 31 | description = "The type of geoJSON geometry this object represents. It is always " + AerospikeAPIConstants.GeoJSON.Types.POINT, 32 | allowableValues = {AerospikeAPIConstants.GeoJSON.Types.POINT}, 33 | requiredMode = Schema.RequiredMode.REQUIRED 34 | ) 35 | public final String type = AerospikeAPIConstants.GeoJSON.Types.POINT; 36 | 37 | public LngLat coordinates; 38 | 39 | public Point() { 40 | } 41 | 42 | public Point(LngLat coordinates) { 43 | this.coordinates = coordinates; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if (this == o) return true; 49 | if (o == null || getClass() != o.getClass()) return false; 50 | Point point = (Point) o; 51 | return Objects.equals(coordinates, point.coordinates); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hash(coordinates); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/DeleteOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | @Schema( 24 | description = "Delete a record.", 25 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/Operation.html") 26 | ) 27 | public class DeleteOperation extends Operation { 28 | 29 | @Schema( 30 | description = "The type of operation. It is always " + OperationTypes.DELETE, 31 | requiredMode = Schema.RequiredMode.REQUIRED, 32 | allowableValues = {OperationTypes.DELETE} 33 | ) 34 | public final String type = OperationTypes.DELETE; 35 | 36 | @Override 37 | public com.aerospike.client.Operation toOperation() { 38 | return com.aerospike.client.Operation.delete(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/GetHeaderOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | @Schema( 24 | description = "Return metadata about a record.", 25 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/Operation.html") 26 | ) 27 | public class GetHeaderOperation extends Operation { 28 | 29 | @Schema( 30 | description = "The type of operation. It is always " + OperationTypes.GET_HEADER, 31 | requiredMode = Schema.RequiredMode.REQUIRED, 32 | allowableValues = {OperationTypes.GET_HEADER} 33 | ) 34 | public final String type = OperationTypes.GET_HEADER; 35 | 36 | @Override 37 | public com.aerospike.client.Operation toOperation() { 38 | return com.aerospike.client.Operation.getHeader(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/GetOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import com.fasterxml.jackson.annotation.JsonCreator; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 23 | import io.swagger.v3.oas.annotations.media.Schema; 24 | 25 | @Schema( 26 | description = "Return the contents of a record", 27 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/Operation.html") 28 | ) 29 | public class GetOperation extends Operation { 30 | 31 | @Schema( 32 | description = "The type of operation. It is always " + OperationTypes.GET, 33 | requiredMode = Schema.RequiredMode.REQUIRED, 34 | allowableValues = {OperationTypes.GET} 35 | ) 36 | public final String type = OperationTypes.GET; 37 | 38 | private final String binName; 39 | 40 | @JsonCreator 41 | public GetOperation(@JsonProperty(value = "binName") String binName) { 42 | this.binName = binName; 43 | } 44 | 45 | @Override 46 | public com.aerospike.client.Operation toOperation() { 47 | if (binName == null) { 48 | return com.aerospike.client.Operation.get(); 49 | } 50 | 51 | return com.aerospike.client.Operation.get(binName); 52 | } 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/ListPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.ListOrder; 20 | 21 | import java.util.List; 22 | 23 | public class ListPolicy { 24 | private ListOrder order; 25 | 26 | private List writeFlags; 27 | 28 | public ListPolicy() { 29 | } 30 | 31 | public ListOrder getOrder() { 32 | return order; 33 | } 34 | 35 | public void setOrder(ListOrder order) { 36 | this.order = order; 37 | } 38 | 39 | public List getWriteFlags() { 40 | return writeFlags; 41 | } 42 | 43 | public void setWriteFlags(List writeFlags) { 44 | this.writeFlags = writeFlags; 45 | } 46 | 47 | public com.aerospike.client.cdt.ListPolicy toListPolicy() { 48 | if (order == null && (writeFlags == null || writeFlags.isEmpty())) { 49 | return com.aerospike.client.cdt.ListPolicy.Default; 50 | } 51 | 52 | if (order == null) { 53 | order = ListOrder.UNORDERED; 54 | } 55 | 56 | int flags = 0; 57 | 58 | if (writeFlags != null) { 59 | flags = writeFlags.stream().reduce(0, (acc, flag) -> acc | flag.flag, Integer::sum); 60 | } 61 | 62 | return new com.aerospike.client.cdt.ListPolicy(order, flags); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/ListReturnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | public enum ListReturnType { 20 | COUNT, INDEX, EXISTS, NONE, RANK, REVERSE_INDEX, REVERSE_RANK, VALUE; 21 | 22 | public int toListReturnType(boolean inverted) { 23 | int invertedFlag = inverted ? com.aerospike.client.cdt.ListReturnType.INVERTED : 0; 24 | 25 | return switch (this) { 26 | case COUNT -> com.aerospike.client.cdt.ListReturnType.COUNT | invertedFlag; 27 | case INDEX -> com.aerospike.client.cdt.ListReturnType.INDEX | invertedFlag; 28 | case NONE -> com.aerospike.client.cdt.ListReturnType.NONE | invertedFlag; 29 | case RANK -> com.aerospike.client.cdt.ListReturnType.RANK | invertedFlag; 30 | case REVERSE_INDEX -> com.aerospike.client.cdt.ListReturnType.REVERSE_INDEX | invertedFlag; 31 | case REVERSE_RANK -> com.aerospike.client.cdt.ListReturnType.REVERSE_RANK | invertedFlag; 32 | case VALUE -> com.aerospike.client.cdt.ListReturnType.VALUE | invertedFlag; 33 | case EXISTS -> com.aerospike.client.cdt.ListReturnType.EXISTS | invertedFlag; 34 | }; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/ListSortFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.ListSortFlags; 20 | 21 | /* 22 | * Wraps constants in Aerospike client class ListSortFlags 23 | */ 24 | public enum ListSortFlag { 25 | /** 26 | * Default. Preserve duplicate values when sorting list. 27 | */ 28 | DEFAULT(ListSortFlags.DEFAULT), 29 | 30 | /** 31 | * Drop duplicate values when sorting list. 32 | */ 33 | DROP_DUPLICATES(ListSortFlags.DROP_DUPLICATES); 34 | 35 | public final int flag; 36 | 37 | ListSortFlag(int flag) { 38 | this.flag = flag; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/ListWriteFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.ListWriteFlags; 20 | 21 | /* 22 | * Wraps constants in Aerospike client class ListWriteFlags 23 | */ 24 | public enum ListWriteFlag { 25 | /** 26 | * Default. Allow duplicate values and insertions at any index. 27 | */ 28 | DEFAULT(ListWriteFlags.DEFAULT), 29 | 30 | /** 31 | * Only add unique values 32 | */ 33 | ADD_UNIQUE(ListWriteFlags.ADD_UNIQUE), 34 | 35 | /** 36 | * Enforce list boundaries when inserting. Do not allow values to be inserted at index outside current list boundaries. 37 | */ 38 | INSERT_BOUNDED(ListWriteFlags.INSERT_BOUNDED), 39 | 40 | /** 41 | * Do not raise error if a list item fails due to write flag constraints. 42 | */ 43 | NO_FAIL(ListWriteFlags.NO_FAIL), 44 | 45 | /** 46 | * Allow other valid list items to be committed if a list item fails due to write flag constraints. 47 | */ 48 | PARTIAL(ListWriteFlags.PARTIAL); 49 | 50 | public final int flag; 51 | 52 | ListWriteFlag(int flag) { 53 | this.flag = flag; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/MapPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.MapOrder; 20 | 21 | import java.util.List; 22 | 23 | public class MapPolicy { 24 | 25 | private MapOrder order; 26 | 27 | private List writeFlags; 28 | 29 | public MapPolicy() { 30 | } 31 | 32 | public MapOrder getOrder() { 33 | return order; 34 | } 35 | 36 | public void setOrder(MapOrder order) { 37 | this.order = order; 38 | } 39 | 40 | public List getWriteFlags() { 41 | return writeFlags; 42 | } 43 | 44 | public void setWriteFlags(List writeFlags) { 45 | this.writeFlags = writeFlags; 46 | } 47 | 48 | public com.aerospike.client.cdt.MapPolicy toMapPolicy() { 49 | if (order == null && (writeFlags == null || writeFlags.isEmpty())) { 50 | return com.aerospike.client.cdt.MapPolicy.Default; 51 | } 52 | 53 | if (order == null) { 54 | order = MapOrder.UNORDERED; 55 | } 56 | 57 | int flags = 0; 58 | 59 | if (writeFlags != null) { 60 | flags = writeFlags.stream().reduce(0, (acc, flag) -> acc | flag.flag, Integer::sum); 61 | } 62 | 63 | return new com.aerospike.client.cdt.MapPolicy(order, flags); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/MapReturnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | public enum MapReturnType { 20 | COUNT(com.aerospike.client.cdt.MapReturnType.COUNT), 21 | INDEX(com.aerospike.client.cdt.MapReturnType.INDEX), 22 | KEY(com.aerospike.client.cdt.MapReturnType.KEY), 23 | KEY_VALUE(com.aerospike.client.cdt.MapReturnType.KEY_VALUE), 24 | NONE(com.aerospike.client.cdt.MapReturnType.NONE), 25 | RANK(com.aerospike.client.cdt.MapReturnType.RANK), 26 | REVERSE_INDEX(com.aerospike.client.cdt.MapReturnType.REVERSE_INDEX), 27 | REVERSE_RANK(com.aerospike.client.cdt.MapReturnType.REVERSE_RANK), 28 | VALUE(com.aerospike.client.cdt.MapReturnType.VALUE), 29 | EXISTS(com.aerospike.client.cdt.MapReturnType.EXISTS), 30 | UNORDERED_MAP(com.aerospike.client.cdt.MapReturnType.UNORDERED_MAP), 31 | ORDERED_MAP(com.aerospike.client.cdt.MapReturnType.ORDERED_MAP); 32 | 33 | private final int returnType; 34 | 35 | MapReturnType(int returnType) { 36 | this.returnType = returnType; 37 | } 38 | 39 | public int toMapReturnType(boolean inverted) { 40 | int invertedFlag = inverted ? com.aerospike.client.cdt.MapReturnType.INVERTED : 0; 41 | return this.returnType | invertedFlag; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/MapWriteFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.MapWriteFlags; 20 | 21 | /* 22 | * Wraps constants in Aerospike client class MapWriteFlags 23 | */ 24 | public enum MapWriteFlag { 25 | /** 26 | * Default. Allow create or update. 27 | */ 28 | DEFAULT(MapWriteFlags.DEFAULT), 29 | 30 | /** 31 | * If the key already exists, the item will be denied. 32 | * If the key does not exist, a new item will be created. 33 | */ 34 | CREATE_ONLY(MapWriteFlags.CREATE_ONLY), 35 | 36 | /** 37 | * If the key already exists, the item will be overwritten. 38 | * If the key does not exist, the item will be denied. 39 | */ 40 | UPDATE_ONLY(MapWriteFlags.UPDATE_ONLY), 41 | 42 | /** 43 | * Do not raise error if a map item is denied due to write flag constraints. 44 | */ 45 | NO_FAIL(MapWriteFlags.NO_FAIL), 46 | 47 | /** 48 | * Allow other valid map items to be committed if a map item is denied due to 49 | * write flag constraints. 50 | */ 51 | PARTIAL(MapWriteFlags.PARTIAL); 52 | 53 | public final int flag; 54 | 55 | MapWriteFlag(int flag) { 56 | this.flag = flag; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/OperateRequestBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | import java.util.List; 22 | 23 | @Schema( 24 | description = "The body of an operate request.", 25 | example = "{ \"opsList\": [{\"type\": \"ADD\", \"binName\": \"intBin\", \"incr\": 2}, {\"type\": \"GET\", \"binName\": \"intBin\"}]}" 26 | ) 27 | public class OperateRequestBody { 28 | public List opsList; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/OperateResponseRecordBody.java: -------------------------------------------------------------------------------- 1 | package com.aerospike.restclient.domain.operationmodels; 2 | 3 | import com.aerospike.restclient.domain.RestClientRecord; 4 | 5 | public class OperateResponseRecordBody { 6 | private RestClientRecord record; 7 | 8 | public OperateResponseRecordBody(RestClientRecord record) { 9 | this.record = record; 10 | } 11 | 12 | public RestClientRecord getRecord() { 13 | return record; 14 | } 15 | 16 | public void setRecord(RestClientRecord record) { 17 | this.record = record; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/OperateResponseRecordsBody.java: -------------------------------------------------------------------------------- 1 | package com.aerospike.restclient.domain.operationmodels; 2 | 3 | import com.aerospike.restclient.domain.RestClientRecord; 4 | 5 | public class OperateResponseRecordsBody { 6 | private RestClientRecord[] records; 7 | 8 | public OperateResponseRecordsBody(RestClientRecord[] records) { 9 | this.records = records; 10 | } 11 | 12 | public RestClientRecord[] getRecords() { 13 | return records; 14 | } 15 | 16 | public void setRecords(RestClientRecord[] records) { 17 | this.records = records; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/ReadOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 22 | import io.swagger.v3.oas.annotations.media.Schema; 23 | 24 | @Schema( 25 | description = "Return the value of a specified `binName`.", 26 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/Operation.html") 27 | ) 28 | public class ReadOperation extends Operation { 29 | 30 | @Schema( 31 | description = "The type of operation. It is always " + OperationTypes.READ, 32 | requiredMode = Schema.RequiredMode.REQUIRED, 33 | allowableValues = {OperationTypes.READ} 34 | ) 35 | public final String type = OperationTypes.READ; 36 | 37 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED) 38 | private final String binName; 39 | 40 | public ReadOperation( 41 | @JsonProperty(value = "binName") 42 | @Schema(name = "binName", requiredMode = Schema.RequiredMode.REQUIRED) String binName 43 | ) { 44 | this.binName = binName; 45 | } 46 | 47 | @Override 48 | public com.aerospike.client.Operation toOperation() { 49 | return com.aerospike.client.Operation.get(binName); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/operationmodels/TouchOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | @Schema( 24 | description = "Reset a record’s TTL and increment its generation.", 25 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/Operation.html") 26 | ) 27 | public class TouchOperation extends Operation { 28 | 29 | @Schema( 30 | description = "The type of operation. It is always " + OperationTypes.TOUCH, 31 | requiredMode = Schema.RequiredMode.REQUIRED, 32 | allowableValues = {OperationTypes.TOUCH} 33 | ) 34 | public final String type = OperationTypes.TOUCH; 35 | 36 | @Override 37 | public com.aerospike.client.Operation toOperation() { 38 | return com.aerospike.client.Operation.touch(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/querymodels/QueryEqualLongFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.querymodels; 18 | 19 | import com.aerospike.client.cdt.CTX; 20 | import com.aerospike.client.query.Filter; 21 | import com.aerospike.restclient.util.AerospikeAPIConstants; 22 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 23 | import io.swagger.v3.oas.annotations.media.Schema; 24 | 25 | @Schema( 26 | description = "Filter for values that equal the provided value. Only allowed on bins which has a secondary index defined.", 27 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/query/Filter.html") 28 | ) 29 | public class QueryEqualLongFilter extends QueryFilter { 30 | 31 | @Schema( 32 | description = "The type of query filter this object represents. It is always " + AerospikeAPIConstants.QueryFilterTypes.EQUAL_LONG, 33 | requiredMode = Schema.RequiredMode.REQUIRED, 34 | allowableValues = {AerospikeAPIConstants.QueryFilterTypes.EQUAL_LONG} 35 | ) 36 | public final String type = AerospikeAPIConstants.QueryFilterTypes.EQUAL_LONG; 37 | 38 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED) 39 | public Long value; 40 | 41 | public QueryEqualLongFilter() { 42 | } 43 | 44 | @Override 45 | public Filter toFilter() { 46 | CTX[] asCTX = getCTXArray(); 47 | return Filter.equal(binName, value, asCTX); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/querymodels/QueryEqualsStringFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.querymodels; 18 | 19 | import com.aerospike.client.cdt.CTX; 20 | import com.aerospike.client.query.Filter; 21 | import com.aerospike.restclient.util.AerospikeAPIConstants; 22 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 23 | import io.swagger.v3.oas.annotations.media.Schema; 24 | 25 | @Schema( 26 | description = "Filter for values that equal the provided value. Only allowed on bins which has a secondary index defined.", 27 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/query/Filter.html") 28 | ) 29 | public class QueryEqualsStringFilter extends QueryFilter { 30 | @Schema( 31 | description = "The type of query filter this object represents. It is always " + AerospikeAPIConstants.QueryFilterTypes.EQUAL_STRING, 32 | requiredMode = Schema.RequiredMode.REQUIRED, 33 | allowableValues = {AerospikeAPIConstants.QueryFilterTypes.EQUAL_STRING} 34 | ) 35 | public final String type = AerospikeAPIConstants.QueryFilterTypes.EQUAL_STRING; 36 | 37 | @Schema(requiredMode = Schema.RequiredMode.REQUIRED) 38 | public String value; 39 | 40 | public QueryEqualsStringFilter() { 41 | } 42 | 43 | @Override 44 | public Filter toFilter() { 45 | CTX[] asCTX = getCTXArray(); 46 | return Filter.equal(binName, value, asCTX); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/querymodels/QueryRequestBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.querymodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | @Schema(description = "Body of Query request.") 22 | public class QueryRequestBody { 23 | @Schema( 24 | description = "QueryFilter. Only allowed on bin which has a secondary index defined." 25 | ) 26 | public QueryFilter filter; 27 | 28 | @Schema( 29 | description = "Pagination token returned from last query request used to retrieve the next page. Use \"getToken\" to retrieve this token." 30 | ) 31 | public String from; 32 | 33 | public QueryRequestBody() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/querymodels/QueryResponseBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.querymodels; 18 | 19 | import com.aerospike.restclient.domain.RestClientKeyRecord; 20 | import com.aerospike.restclient.domain.scanmodels.Pagination; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import io.swagger.v3.oas.annotations.media.Schema; 23 | 24 | import java.util.ArrayList; 25 | import java.util.Collections; 26 | import java.util.List; 27 | 28 | @Schema(description = "Body of query response.") 29 | public class QueryResponseBody { 30 | @Schema(description = "Records returned from query.", requiredMode = Schema.RequiredMode.REQUIRED) 31 | @JsonProperty(required = true) 32 | private final List records; 33 | 34 | @Schema(description = "Pagination details.") 35 | private final Pagination pagination; 36 | 37 | public QueryResponseBody(int initialCapacity) { 38 | records = Collections.synchronizedList(new ArrayList<>(initialCapacity)); 39 | pagination = new Pagination(); 40 | } 41 | 42 | public QueryResponseBody() { 43 | this(0); 44 | } 45 | 46 | public List getRecords() { 47 | return records; 48 | } 49 | 50 | public void addRecord(RestClientKeyRecord record) { 51 | records.add(record); 52 | } 53 | 54 | public int size() { 55 | return records.size(); 56 | } 57 | 58 | public Pagination getPagination() { 59 | return pagination; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/scanmodels/Pagination.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.scanmodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class Pagination { 22 | 23 | @Schema(description = "The next page token.") 24 | private String nextToken; 25 | 26 | @Schema(description = "The total number of records in page.") 27 | private long totalRecords; 28 | 29 | public Pagination() { 30 | } 31 | 32 | public String getNextToken() { 33 | return nextToken; 34 | } 35 | 36 | public void setNextToken(String token) { 37 | nextToken = token; 38 | } 39 | 40 | public long getTotalRecords() { 41 | return totalRecords; 42 | } 43 | 44 | public void setTotalRecords(long total) { 45 | totalRecords = total; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/scanmodels/RestClientScanResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.scanmodels; 18 | 19 | import com.aerospike.restclient.domain.RestClientKeyRecord; 20 | import io.swagger.v3.oas.annotations.media.Schema; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class RestClientScanResponse { 26 | 27 | @Schema(description = "List of records for current page.") 28 | private final List records; 29 | 30 | @Schema(description = "Pagination details.") 31 | private final Pagination pagination; 32 | 33 | public RestClientScanResponse(int initialCapacity) { 34 | records = new ArrayList<>(initialCapacity); 35 | pagination = new Pagination(); 36 | } 37 | 38 | public RestClientScanResponse() { 39 | this(0); 40 | } 41 | 42 | public List getRecords() { 43 | return records; 44 | } 45 | 46 | public void addRecord(RestClientKeyRecord record) { 47 | records.add(record); 48 | } 49 | 50 | public int size() { 51 | return records.size(); 52 | } 53 | 54 | public Pagination getPagination() { 55 | return pagination; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/swaggermodels/RestClientClusterInfoResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.swaggermodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | /* 22 | * A Model describing the return value from requests to the /v1/cluster endpoint. 23 | */ 24 | public class RestClientClusterInfoResponse { 25 | @Schema() 26 | public RestClientNodeInfoResponse[] nodes; 27 | 28 | @Schema() 29 | public RestClientNamespaceInfoResponse[] namespaces; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/swaggermodels/RestClientNamespaceInfoResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.swaggermodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientNamespaceInfoResponse { 22 | @Schema(example = "testNS") 23 | public String name; 24 | 25 | @Schema 26 | public RestClientSetInformation[] sets; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/swaggermodels/RestClientNodeInfoResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.swaggermodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientNodeInfoResponse { 22 | 23 | @Schema(example = "BB9DE9B1B270008") 24 | public String name; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/swaggermodels/RestClientSetInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.swaggermodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientSetInformation { 22 | 23 | @Schema(example = "100") 24 | public int objectCount; 25 | 26 | @Schema(example = "demo") 27 | public String name; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/domain/swaggermodels/RestClientUserResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.swaggermodels; 18 | 19 | import io.swagger.v3.oas.annotations.media.Schema; 20 | 21 | public class RestClientUserResponse { 22 | 23 | @Schema(example = "testUser") 24 | String name; 25 | 26 | @Schema(example = "[customRole1, customRole2]") 27 | String[] roles; 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public void setRoles(String[] roles) { 34 | this.roles = roles; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public String[] getRoles() { 42 | return roles; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/BatchHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.BatchRead; 21 | import com.aerospike.client.BatchRecord; 22 | import com.aerospike.client.policy.BatchPolicy; 23 | 24 | import java.util.List; 25 | 26 | public class BatchHandler { 27 | 28 | private final AerospikeClient client; 29 | 30 | public BatchHandler(AerospikeClient client) { 31 | this.client = client; 32 | } 33 | 34 | public void batchRecord(BatchPolicy policy, List batchRecords) { 35 | boolean allBatchRead = batchRecords.stream().allMatch(r -> r instanceof BatchRead); 36 | 37 | if (allBatchRead) { 38 | // Supported on old servers 39 | client.get(policy, batchRecords.stream().map(r -> (BatchRead) r).toList()); 40 | } else { 41 | client.operate(policy, batchRecords); 42 | } 43 | } 44 | 45 | public static BatchHandler create(AerospikeClient client) { 46 | return new BatchHandler(client); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/ClusterHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.cluster.Node; 21 | 22 | import java.util.ArrayList; 23 | import java.util.HashMap; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | public class ClusterHandler { 28 | 29 | private final AerospikeClient client; 30 | 31 | public ClusterHandler(AerospikeClient client) { 32 | this.client = client; 33 | } 34 | 35 | /* 36 | * Return list [{"name": "nodeName1"}, {"name":"nodeName2"}] 37 | */ 38 | public List> getNodeMaps() { 39 | List> nodeList = new ArrayList<>(); 40 | for (String nodeName : nodeNames()) { 41 | Map nodeMap = new HashMap<>(); 42 | nodeMap.put("name", nodeName); 43 | nodeList.add(nodeMap); 44 | } 45 | 46 | return nodeList; 47 | } 48 | 49 | private List nodeNames() { 50 | return client.getNodeNames(); 51 | } 52 | 53 | public Node[] getNodes() { 54 | return client.getNodes(); 55 | } 56 | 57 | public static ClusterHandler create(AerospikeClient client) { 58 | return new ClusterHandler(client); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/IndexHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.policy.Policy; 21 | import com.aerospike.client.query.IndexCollectionType; 22 | import com.aerospike.client.query.IndexType; 23 | 24 | public class IndexHandler { 25 | 26 | private final AerospikeClient client; 27 | 28 | public IndexHandler(AerospikeClient client) { 29 | this.client = client; 30 | } 31 | 32 | public void createIndex(Policy policy, String namespace, String setName, String indexName, String binName, 33 | IndexType indexType) { 34 | client.createIndex(policy, namespace, setName, indexName, binName, indexType); 35 | } 36 | 37 | public void createIndex(Policy policy, String namespace, String setName, String indexName, String binName, 38 | IndexType indexType, IndexCollectionType collectionType) { 39 | client.createIndex(policy, namespace, setName, indexName, binName, indexType, collectionType); 40 | } 41 | 42 | public void deleteIndex(Policy policy, String namespace, String setName, String indexName) { 43 | client.dropIndex(policy, namespace, setName, indexName); 44 | } 45 | 46 | public static IndexHandler create(AerospikeClient client) { 47 | return new IndexHandler(client); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/OperateHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.Record; 20 | import com.aerospike.client.*; 21 | import com.aerospike.client.policy.BatchPolicy; 22 | import com.aerospike.client.policy.WritePolicy; 23 | 24 | import java.util.List; 25 | 26 | public class OperateHandler { 27 | 28 | private final AerospikeClient client; 29 | 30 | public OperateHandler(AerospikeClient client) { 31 | this.client = client; 32 | } 33 | 34 | public Record operate(WritePolicy policy, Key key, Operation[] operations) { 35 | return client.operate(policy, key, operations); 36 | } 37 | 38 | public Record[] operate(BatchPolicy policy, Key[] key, Operation[] operations) { 39 | return client.get(policy, key, operations); 40 | } 41 | 42 | public List operate(BatchPolicy policy, List records) { 43 | client.operate(policy, records); 44 | return records; 45 | } 46 | 47 | public static OperateHandler create(AerospikeClient client) { 48 | return new OperateHandler(client); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/RecordHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.Bin; 21 | import com.aerospike.client.Key; 22 | import com.aerospike.client.Record; 23 | import com.aerospike.client.policy.Policy; 24 | import com.aerospike.client.policy.WritePolicy; 25 | 26 | public class RecordHandler { 27 | 28 | private final AerospikeClient client; 29 | 30 | public RecordHandler(AerospikeClient client) { 31 | this.client = client; 32 | } 33 | 34 | public boolean deleteRecord(WritePolicy policy, Key key) { 35 | return client.delete(policy, key); 36 | } 37 | 38 | public Record getRecord(Policy policy, Key key, String[] bins) { 39 | return client.get(policy, key, bins); 40 | } 41 | 42 | public Record getRecord(Policy policy, Key key) { 43 | return client.get(policy, key); 44 | } 45 | 46 | public void putRecord(WritePolicy policy, Key key, Bin... bins) { 47 | client.put(policy, key, bins); 48 | } 49 | 50 | public boolean existsRecord(Policy policy, Key key) { 51 | return client.exists(policy, key); 52 | } 53 | 54 | public static RecordHandler create(AerospikeClient client) { 55 | return new RecordHandler(client); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/handlers/TruncateHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.handlers; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.policy.InfoPolicy; 21 | 22 | import java.util.Calendar; 23 | 24 | public class TruncateHandler { 25 | 26 | private final AerospikeClient client; 27 | 28 | public TruncateHandler(AerospikeClient client) { 29 | this.client = client; 30 | } 31 | 32 | public void truncate(InfoPolicy policy, String ns, String set, Calendar beforeLastUpdate) { 33 | client.truncate(policy, ns, set, beforeLastUpdate); 34 | } 35 | 36 | public static TruncateHandler create(AerospikeClient client) { 37 | return new TruncateHandler(client); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeBatchService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.BatchPolicy; 20 | import com.aerospike.restclient.domain.auth.AuthDetails; 21 | import com.aerospike.restclient.domain.batchmodels.BatchRecord; 22 | import com.aerospike.restclient.domain.batchmodels.BatchResponseBody; 23 | 24 | import java.util.List; 25 | 26 | public interface AerospikeBatchService { 27 | BatchResponseBody batch(AuthDetails authDetails, List batchKeys, BatchPolicy policy); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeBatchServiceV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.BatchPolicy; 20 | import com.aerospike.restclient.domain.auth.AuthDetails; 21 | import com.aerospike.restclient.domain.batchmodels.BatchRecord; 22 | import com.aerospike.restclient.domain.batchmodels.BatchRecordResponse; 23 | import com.aerospike.restclient.domain.batchmodels.BatchResponseBody; 24 | import com.aerospike.restclient.handlers.BatchHandler; 25 | import com.aerospike.restclient.util.AerospikeClientPool; 26 | import org.springframework.beans.factory.annotation.Autowired; 27 | import org.springframework.stereotype.Service; 28 | 29 | import java.util.List; 30 | 31 | @Service 32 | public class AerospikeBatchServiceV1 implements AerospikeBatchService { 33 | 34 | @Autowired 35 | private AerospikeClientPool clientPool; 36 | 37 | @Override 38 | public BatchResponseBody batch(AuthDetails authDetails, List batchKeys, BatchPolicy policy) { 39 | BatchResponseBody resp = new BatchResponseBody(); 40 | List batchRecords = batchKeys.stream() 41 | .map(BatchRecord::toBatchRecord) 42 | .toList(); 43 | BatchHandler.create(clientPool.getClient(authDetails)).batchRecord(policy, batchRecords); 44 | resp.batchRecords = batchRecords.stream().map(BatchRecordResponse::new).toList(); 45 | return resp; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeClusterService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.restclient.domain.auth.AuthDetails; 20 | 21 | import java.util.Map; 22 | 23 | public interface AerospikeClusterService { 24 | 25 | Map getClusterInfo(AuthDetails authDetails); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeDocumentService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.Policy; 20 | import com.aerospike.client.policy.WritePolicy; 21 | import com.aerospike.restclient.domain.auth.AuthDetails; 22 | import com.aerospike.restclient.util.AerospikeAPIConstants; 23 | 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | public interface AerospikeDocumentService { 28 | 29 | Map getObject(AuthDetails authDetails, String namespace, String set, String key, List bins, 30 | String jsonPath, AerospikeAPIConstants.RecordKeyType keyType, Policy policy); 31 | 32 | void putObject(AuthDetails authDetails, String namespace, String set, String key, List bins, 33 | String jsonPath, Object jsonObject, AerospikeAPIConstants.RecordKeyType keyType, WritePolicy policy); 34 | 35 | void appendObject(AuthDetails authDetails, String namespace, String set, String key, List bins, 36 | String jsonPath, Object jsonObject, AerospikeAPIConstants.RecordKeyType keyType, 37 | WritePolicy policy); 38 | 39 | void deleteObject(AuthDetails authDetails, String namespace, String set, String key, List bins, 40 | String jsonPath, AerospikeAPIConstants.RecordKeyType keyType, WritePolicy policy); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeExecuteService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.WritePolicy; 20 | import com.aerospike.restclient.domain.RestClientOperation; 21 | import com.aerospike.restclient.domain.auth.AuthDetails; 22 | import com.aerospike.restclient.domain.executemodels.RestClientExecuteTask; 23 | import com.aerospike.restclient.domain.executemodels.RestClientExecuteTaskStatus; 24 | import com.aerospike.restclient.domain.operationmodels.Operation; 25 | 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | public interface AerospikeExecuteService { 30 | 31 | RestClientExecuteTask executeV1Scan(AuthDetails authDetails, String namespace, String set, 32 | List opsList, WritePolicy policy, 33 | Map requestParams); 34 | 35 | RestClientExecuteTask executeV2Scan(AuthDetails authDetails, String namespace, String set, List opsList, 36 | WritePolicy policy, Map requestParams); 37 | 38 | RestClientExecuteTaskStatus queryScanStatus(AuthDetails authDetails, String taskId); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeInfoService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.InfoPolicy; 20 | import com.aerospike.restclient.domain.auth.AuthDetails; 21 | 22 | import java.util.Map; 23 | 24 | public interface AerospikeInfoService { 25 | 26 | Map infoAny(AuthDetails authDetails, String[] requests, InfoPolicy policy); 27 | 28 | Map infoNodeName(AuthDetails authDetails, String nodeName, String[] requests, InfoPolicy policy); 29 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeInfoServiceV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.InfoPolicy; 20 | import com.aerospike.restclient.domain.auth.AuthDetails; 21 | import com.aerospike.restclient.handlers.InfoHandler; 22 | import com.aerospike.restclient.util.AerospikeClientPool; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Service; 25 | 26 | import java.util.Map; 27 | 28 | @Service 29 | public class AerospikeInfoServiceV1 implements AerospikeInfoService { 30 | 31 | @Autowired 32 | private AerospikeClientPool clientPool; 33 | 34 | @Override 35 | public Map infoAny(AuthDetails authDetails, String[] requests, InfoPolicy policy) { 36 | return InfoHandler.create(clientPool.getClient(authDetails)).multiInfoRequest(policy, requests); 37 | } 38 | 39 | @Override 40 | public Map infoNodeName(AuthDetails authDetails, String nodeName, String[] requests, 41 | InfoPolicy policy) { 42 | return InfoHandler.create(clientPool.getClient(authDetails)).multiInfoRequest(policy, nodeName, requests); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeQueryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.QueryPolicy; 20 | import com.aerospike.client.query.Statement; 21 | import com.aerospike.restclient.domain.auth.AuthDetails; 22 | import com.aerospike.restclient.domain.querymodels.QueryResponseBody; 23 | 24 | public interface AerospikeQueryService { 25 | 26 | QueryResponseBody query(AuthDetails authDetails, QueryPolicy policy, Statement stmt, boolean getToken, 27 | String fromToken); 28 | 29 | QueryResponseBody query(AuthDetails authDetails, QueryPolicy policy, Statement stmt, boolean getToken, 30 | String fromToken, int start, int count); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeRecordService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.Policy; 20 | import com.aerospike.client.policy.WritePolicy; 21 | import com.aerospike.restclient.domain.RestClientRecord; 22 | import com.aerospike.restclient.domain.auth.AuthDetails; 23 | import com.aerospike.restclient.util.AerospikeAPIConstants.RecordKeyType; 24 | 25 | import java.util.Map; 26 | 27 | public interface AerospikeRecordService { 28 | 29 | void storeRecord(AuthDetails authDetails, String namespace, String set, String key, Map binMap, 30 | RecordKeyType keyType, WritePolicy policy); 31 | 32 | RestClientRecord fetchRecord(AuthDetails authDetails, String namespace, String set, String key, String[] bins, 33 | RecordKeyType keyType, Policy policy); 34 | 35 | void deleteRecord(AuthDetails authDetails, String namespace, String set, String key, RecordKeyType keyType, 36 | WritePolicy policy); 37 | 38 | boolean recordExists(AuthDetails authDetails, String namespace, String set, String key, RecordKeyType keyType); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeSIndexService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.InfoPolicy; 20 | import com.aerospike.client.policy.Policy; 21 | import com.aerospike.restclient.domain.RestClientIndex; 22 | import com.aerospike.restclient.domain.auth.AuthDetails; 23 | 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | public interface AerospikeSIndexService { 28 | 29 | List getIndexList(AuthDetails authDetails, String namespace, InfoPolicy policy); 30 | 31 | void createIndex(AuthDetails authDetails, RestClientIndex indexModel, Policy policy); 32 | 33 | void dropIndex(AuthDetails authDetails, String namespace, String indexName, Policy policy); 34 | 35 | Map indexStats(AuthDetails authDetails, String namespace, String name, InfoPolicy policy); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeScanService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.client.policy.ScanPolicy; 20 | import com.aerospike.restclient.domain.auth.AuthDetails; 21 | import com.aerospike.restclient.domain.scanmodels.RestClientScanResponse; 22 | 23 | import java.util.Map; 24 | 25 | public interface AerospikeScanService { 26 | 27 | RestClientScanResponse scan(AuthDetails authDetails, String[] binNames, Map requestParams, 28 | ScanPolicy policy, String namespace, String set); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeTruncateService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.restclient.domain.auth.AuthDetails; 20 | 21 | public interface AerospikeTruncateService { 22 | 23 | void truncate(AuthDetails authDetails, String namespace, String set, String dateString); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/service/AerospikeTruncateServiceV1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.service; 18 | 19 | import com.aerospike.restclient.domain.auth.AuthDetails; 20 | import com.aerospike.restclient.handlers.TruncateHandler; 21 | import com.aerospike.restclient.util.AerospikeClientPool; 22 | import com.aerospike.restclient.util.converters.DateConverter; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Service; 25 | 26 | import java.util.Calendar; 27 | 28 | @Service 29 | public class AerospikeTruncateServiceV1 implements AerospikeTruncateService { 30 | 31 | @Autowired 32 | private AerospikeClientPool clientPool; 33 | 34 | @Override 35 | public void truncate(AuthDetails authDetails, String namespace, String set, String dateString) { 36 | Calendar calendar = DateConverter.iso8601StringToCalendar(dateString); 37 | TruncateHandler.create(clientPool.getClient(authDetails)).truncate(null, namespace, set, calendar); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/APIParamDescriptors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util; 18 | 19 | public class APIParamDescriptors { 20 | public static final String NAMESPACE_NOTES = "Namespace for the record; equivalent to database name."; 21 | public static final String SET_NOTES = "Set for the record; equivalent to database table."; 22 | public static final String USERKEY_NOTES = "Userkey for the record."; 23 | public static final String STORE_BINS_NOTES = "Bins to be stored in the record. This is a mapping from a string bin name to a value. " + "Value can be a String, integer, floating point number, list, map, bytearray, or GeoJSON value."; 24 | 25 | public static final String QUERY_PARTITION_BEGIN_NOTES = "Start partition id (0 - 4095)"; 26 | public static final String QUERY_PARTITION_COUNT_NOTES = "Number of partitions"; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/HeaderHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util; 18 | 19 | import com.aerospike.restclient.domain.auth.AuthDetails; 20 | 21 | import java.nio.charset.StandardCharsets; 22 | import java.util.Base64; 23 | 24 | public final class HeaderHandler { 25 | 26 | private HeaderHandler() { 27 | } 28 | 29 | public static AuthDetails extractAuthDetails(String basicAuth) { 30 | if (basicAuth == null || !basicAuth.toLowerCase().startsWith("basic")) { 31 | return null; 32 | } 33 | 34 | try { 35 | String base64Credentials = basicAuth.substring(5).trim(); 36 | byte[] credDecoded = Base64.getDecoder().decode(base64Credentials); 37 | String credentials = new String(credDecoded, StandardCharsets.UTF_8); 38 | // credentials = username:password 39 | final String[] details = credentials.split(":", 2); 40 | return new AuthDetails(details[0], details[1]); 41 | } catch (Exception e) { 42 | throw new RestClientErrors.UnauthorizedError(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/RequestBodyExamples.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util; 18 | 19 | public class RequestBodyExamples { 20 | 21 | // admin 22 | public static final String ROLES_NAME = "List of roles request body example"; 23 | public static final String ROLES_VALUE = "[\"read-write\", \"read-write-udf\"]"; 24 | 25 | // document api 26 | public static final String JSON_OBJECT_NAME = "JSON object request body example"; 27 | public static final String JSON_OBJECT_VALUE = "str3"; 28 | 29 | // info 30 | public static final String REQUESTS_INFO_NAME = "Array of info commands request body example"; 31 | public static final String REQUESTS_INFO_VALUE = "[\"build\", \"edition\"]"; 32 | 33 | // key value 34 | public static final String BINS_NAME = "Bins request body example"; 35 | public static final String BINS_VALUE = "{\"intBin\":5, \"strBin\":\"hello\", \"listBin\": [1,2,3], \"dictBin\": {\"one\": 1}, \"geoJsonBin\": {\"type\": \"Point\", \"coordinates\": [1.123, 4.156]}, \"byteArrayBin\": {\"type\": \"BYTE_ARRAY\", \"value\": \"YWVyb3NwaWtlCg==\"}}"; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/annotations/ASRestClientInfoPolicyQueryParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.annotations; 18 | 19 | import com.aerospike.restclient.util.APIDescriptors; 20 | import com.aerospike.restclient.util.AerospikeAPIConstants; 21 | import io.swagger.v3.oas.annotations.Parameter; 22 | import io.swagger.v3.oas.annotations.Parameters; 23 | import io.swagger.v3.oas.annotations.enums.ParameterIn; 24 | import io.swagger.v3.oas.annotations.media.Schema; 25 | 26 | import java.lang.annotation.Retention; 27 | import java.lang.annotation.RetentionPolicy; 28 | 29 | @Parameters( 30 | value = { 31 | @Parameter( 32 | name = AerospikeAPIConstants.TIMEOUT, 33 | description = APIDescriptors.INFO_POLICY_TIMEOUT, 34 | schema = @Schema(type = "integer"), 35 | in = ParameterIn.QUERY 36 | ) 37 | } 38 | ) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | public @interface ASRestClientInfoPolicyQueryParams { 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/annotations/ASRestClientSchemas.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.annotations; 18 | 19 | import com.aerospike.restclient.util.AerospikeAPIConstants; 20 | import io.swagger.v3.oas.annotations.ExternalDocumentation; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | 23 | public @interface ASRestClientSchemas { 24 | @Schema( 25 | description = "Secondary index collection type.", 26 | defaultValue = "DEFAULT", 27 | externalDocs = @ExternalDocumentation(url = "https://javadoc.io/doc/com.aerospike/aerospike-client/" + AerospikeAPIConstants.AS_CLIENT_VERSION + "/com/aerospike/client/query/IndexCollectionType.html") 28 | ) 29 | @interface IndexCollectionType { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/annotations/DefaultRestClientAPIResponses.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.annotations; 18 | 19 | import com.aerospike.restclient.domain.RestClientError; 20 | import io.swagger.v3.oas.annotations.media.Content; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | import io.swagger.v3.oas.annotations.responses.ApiResponse; 23 | import io.swagger.v3.oas.annotations.responses.ApiResponses; 24 | 25 | import java.lang.annotation.ElementType; 26 | import java.lang.annotation.Retention; 27 | import java.lang.annotation.RetentionPolicy; 28 | import java.lang.annotation.Target; 29 | 30 | @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.TYPE}) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @ApiResponses( 33 | { 34 | @ApiResponse( 35 | responseCode = "500", 36 | description = "REST Gateway encountered an error while processing the request.", 37 | content = @Content( 38 | schema = @Schema(implementation = RestClientError.class) 39 | ) 40 | ) 41 | } 42 | ) 43 | public @interface DefaultRestClientAPIResponses { 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/DateConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters; 18 | 19 | import com.aerospike.restclient.util.RestClientErrors.InvalidDateFormat; 20 | 21 | import java.time.ZonedDateTime; 22 | import java.time.format.DateTimeFormatter; 23 | import java.time.format.DateTimeParseException; 24 | import java.util.Calendar; 25 | import java.util.GregorianCalendar; 26 | 27 | public class DateConverter { 28 | public static Calendar iso8601StringToCalendar(String dateString) { 29 | Calendar calendar = null; 30 | if (dateString != null && !dateString.isEmpty()) { 31 | ZonedDateTime zdt; 32 | /* Parse a date like 2000 12 31 T 23 59 59 Z With the spaces omitted*/ 33 | DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; 34 | try { 35 | zdt = ZonedDateTime.parse(dateString, formatter); 36 | } catch (DateTimeParseException d) { 37 | throw new InvalidDateFormat(dateString); 38 | } 39 | calendar = GregorianCalendar.from(zdt); 40 | } 41 | 42 | return calendar; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/OperationsConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters; 18 | 19 | import com.aerospike.client.Operation; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * Deprecated. This class should only be used in /v1/operate and /v1/execute until removed. 26 | */ 27 | @Deprecated 28 | public class OperationsConverter { 29 | 30 | public static Operation[] mapListToOperationsArray(List> ops) { 31 | 32 | return ops.stream().map(OperationConverter::convertMapToOperation).toArray(Operation[]::new); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/exp/BaseExpFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters.exp; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import java.util.Optional; 22 | 23 | public abstract class BaseExpFactory { 24 | 25 | protected String stripQuotes(String str) { 26 | if (str.length() >= 2 && str.charAt(0) == '"' && str.charAt(str.length() - 1) == '"') { 27 | return str.substring(1, str.length() - 1); 28 | } 29 | return str; 30 | } 31 | 32 | protected List extractParameters(String params) { 33 | params = params.replaceAll("[()]", ""); 34 | List p = Arrays.asList(params.split(",")); 35 | return p.stream().map(String::trim).toList(); 36 | } 37 | 38 | protected Optional parseInt(String s) { 39 | int i; 40 | try { 41 | i = Integer.parseInt(s); 42 | } catch (Exception e) { 43 | return Optional.empty(); 44 | } 45 | return Optional.of(i); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/exp/BaseExpressionParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters.exp; 18 | 19 | import java.nio.charset.StandardCharsets; 20 | import java.util.*; 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | public abstract class BaseExpressionParser { 25 | 26 | protected static final Pattern pattern = Pattern.compile("(\\))|(\\()|([^\\s)(]+)", Pattern.CASE_INSENSITIVE); 27 | 28 | protected class NestedBlock { 29 | Stack simpleOperators; 30 | Stack logicOperators; 31 | Stack unaryLogicOperators; 32 | Stack operands; 33 | Stack filters; 34 | 35 | NestedBlock() { 36 | simpleOperators = new Stack<>(); 37 | logicOperators = new Stack<>(); 38 | unaryLogicOperators = new Stack<>(); 39 | operands = new Stack<>(); 40 | filters = new Stack<>(); 41 | } 42 | } 43 | 44 | protected boolean forAllEqual(Collection list) { 45 | return new HashSet<>(list).size() <= 1; 46 | } 47 | 48 | protected List parseExpressionString(String expression) { 49 | String decoded = new String(Base64.getUrlDecoder().decode(expression), StandardCharsets.UTF_8); 50 | Matcher matcher = pattern.matcher(decoded); 51 | List tokens = new ArrayList<>(); 52 | while (matcher.find()) { 53 | tokens.add(matcher.group()); 54 | } 55 | return tokens; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/exp/ExpressionParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters.exp; 18 | 19 | @FunctionalInterface 20 | public interface ExpressionParser { 21 | T parse(String expression); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/converters/policyconverters/InfoPolicyConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.converters.policyconverters; 18 | 19 | import com.aerospike.client.policy.InfoPolicy; 20 | import com.aerospike.restclient.util.AerospikeAPIConstants; 21 | import com.aerospike.restclient.util.converters.PolicyValueConverter; 22 | 23 | import java.util.Map; 24 | 25 | public class InfoPolicyConverter { 26 | 27 | public static InfoPolicy policyFromMap(Map policyMap) { 28 | InfoPolicy policy = new InfoPolicy(); 29 | if (policyMap.containsKey(AerospikeAPIConstants.TIMEOUT)) { 30 | policy.timeout = PolicyValueConverter.getIntValue(policyMap.get(AerospikeAPIConstants.TIMEOUT)); 31 | } 32 | return policy; 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/deserializers/ObjectDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.deserializers; 18 | 19 | import com.fasterxml.jackson.core.JsonParser; 20 | import com.fasterxml.jackson.core.ObjectCodec; 21 | import com.fasterxml.jackson.databind.DeserializationContext; 22 | import com.fasterxml.jackson.databind.JsonDeserializer; 23 | import com.fasterxml.jackson.databind.JsonNode; 24 | 25 | import java.io.IOException; 26 | 27 | // JSON Object Mapper by default deserializes doubles to BigDecimal. 28 | public class ObjectDeserializer extends JsonDeserializer { 29 | 30 | @Override 31 | public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { 32 | ObjectCodec codec = jsonParser.getCodec(); 33 | JsonNode jsonNode = codec.readTree(jsonParser); 34 | if (jsonNode.isBigDecimal()) { 35 | return jsonNode.asDouble(); 36 | } 37 | return codec.treeToValue(jsonNode, Object.class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/serializers/MsgPackGeoJSONSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.serializers; 18 | 19 | import com.aerospike.client.Value.GeoJSONValue; 20 | import com.aerospike.client.command.ParticleType; 21 | import com.fasterxml.jackson.core.JsonGenerator; 22 | import com.fasterxml.jackson.databind.SerializerProvider; 23 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 24 | import org.msgpack.jackson.dataformat.MessagePackExtensionType; 25 | import org.msgpack.jackson.dataformat.MessagePackGenerator; 26 | 27 | import java.io.IOException; 28 | 29 | public class MsgPackGeoJSONSerializer extends StdSerializer { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | public MsgPackGeoJSONSerializer() { 34 | this(null); 35 | } 36 | 37 | public MsgPackGeoJSONSerializer(Class t) { 38 | super(t); 39 | } 40 | 41 | /* 42 | We serialize aerospike GeoJSONValue values as a MessagePack extension of type 23. 43 | */ 44 | @Override 45 | public void serialize(GeoJSONValue geoVal, JsonGenerator gen, SerializerProvider provider) throws IOException { 46 | MessagePackExtensionType geoExt = new MessagePackExtensionType((byte) ParticleType.GEOJSON, 47 | geoVal.toString().getBytes()); 48 | ((MessagePackGenerator) gen).writeExtensionType(geoExt); 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/com/aerospike/restclient/util/serializers/MsgPackObjKeySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.util.serializers; 18 | 19 | import com.fasterxml.jackson.core.JsonGenerator; 20 | import com.fasterxml.jackson.databind.SerializerProvider; 21 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 22 | import org.msgpack.jackson.dataformat.MessagePackGenerator; 23 | import org.msgpack.jackson.dataformat.MessagePackSerializedString; 24 | 25 | import java.io.IOException; 26 | 27 | /* 28 | * When we are using MessagePack, we can have non string keys. This lets us write an arbitrary Object as a key 29 | * Instead of key.toString() 30 | */ 31 | public class MsgPackObjKeySerializer extends StdSerializer { 32 | 33 | public MsgPackObjKeySerializer() { 34 | this(null); 35 | } 36 | 37 | private static final long serialVersionUID = 1L; 38 | 39 | public MsgPackObjKeySerializer(Class object) { 40 | super(object); 41 | } 42 | 43 | @Override 44 | public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { 45 | ((MessagePackGenerator) gen).writeFieldName(new MessagePackSerializedString(value)); 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright 2022 Aerospike, Inc. 3 | # * 4 | # * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | # * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | # * 7 | # * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | # * use this file except in compliance with the License. You may obtain a copy of 9 | # * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | # * 11 | # * Unless required by applicable law or agreed to in writing, software 12 | # * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | # * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | # * License for the specific language governing permissions and limitations under 15 | # * the License. 16 | # */ 17 | # Disable error message from swagger UI about invalid default value. 18 | # Turn off Spring banner. 19 | # Aerospike host name. 20 | # aerospike.restclient.hostname=localhost 21 | # Aerospike host port. 22 | # aerospike.restclient.port=3000 23 | # Aerospike hosts to seed the cluster. 24 | # aerospike.restclient.hostlist=localhost:3000 25 | # Should client send boolean particle type for a boolean bin. If false, 26 | # an integer particle type (1 or 0) is sent instead. Must be false for server 27 | # versions less than 5.6 which do not support boolean bins. Can set to true for 28 | # server 5.6+. 29 | # aerospike.restclient.useBoolBin=false 30 | # Server HTTP port. 31 | # server.port=8080 32 | # Context path of the application. 33 | # server.servlet.context-path=/ 34 | # Whether response compression is enabled. 35 | # server.compression.enabled=false -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/ASTestMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient; 18 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; 20 | 21 | public class ASTestMapper implements IASTestMapper { 22 | private final ObjectMapper mapper; 23 | private final Class t; 24 | 25 | public ASTestMapper(ObjectMapper mapper, Class type) { 26 | this.mapper = mapper; 27 | t = type; 28 | } 29 | 30 | @Override 31 | public Object bytesToObject(byte[] bytes) throws Exception { 32 | return mapper.readValue(bytes, t); 33 | } 34 | 35 | @Override 36 | public byte[] objectToBytes(Object object) throws Exception { 37 | return mapper.writeValueAsBytes(object); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/AerospikeRestGatewayApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest 26 | public class AerospikeRestGatewayApplicationTests { 27 | 28 | @Test 29 | public void contextLoads() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/ClusterUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient; 18 | 19 | import com.aerospike.client.AerospikeClient; 20 | import com.aerospike.client.AerospikeException; 21 | import com.aerospike.client.Info; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | public final class ClusterUtils { 26 | 27 | private static final Logger logger = LoggerFactory.getLogger(ClusterUtils.class); 28 | 29 | private ClusterUtils() { 30 | } 31 | 32 | public static boolean isEnterpriseEdition(AerospikeClient client) { 33 | String infoEdition = Info.request(null, client.getCluster().getRandomNode(), "edition"); 34 | return infoEdition.contains("Enterprise"); 35 | } 36 | 37 | public static boolean isSecurityEnabled(AerospikeClient client) { 38 | if (isEnterpriseEdition(client)) { 39 | try { 40 | client.queryRoles(null); 41 | return true; 42 | } catch (AerospikeException e) { 43 | logger.info("Aerospike Server Enterprise Edition security disabled"); 44 | } 45 | } 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/ConfigRequireAuthTest.java: -------------------------------------------------------------------------------- 1 | package com.aerospike.restclient; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest(properties = "aerospike.restclient.requireAuthentication=true") 10 | public class ConfigRequireAuthTest { 11 | @Test 12 | public void startUpTest() { 13 | // Tests that the application will startup even without an default AerospikeClient instantiated. 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/IASTestMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient; 18 | 19 | public interface IASTestMapper { 20 | Object bytesToObject(byte[] bytes) throws Exception; 21 | 22 | byte[] objectToBytes(Object object) throws Exception; 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/converters/policyConverters/InfoPolicyConverterTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.converters.policyConverters; 18 | 19 | import com.aerospike.client.policy.InfoPolicy; 20 | import com.aerospike.restclient.util.AerospikeAPIConstants; 21 | import com.aerospike.restclient.util.converters.policyconverters.InfoPolicyConverter; 22 | import org.junit.Assert; 23 | import org.junit.Before; 24 | import org.junit.Test; 25 | 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | 29 | public class InfoPolicyConverterTests { 30 | 31 | Map policyMap; 32 | 33 | @Before 34 | public void setup() { 35 | policyMap = new HashMap(); 36 | } 37 | 38 | @Test 39 | public void testTimeout() { 40 | policyMap.put(AerospikeAPIConstants.TIMEOUT, "333"); 41 | InfoPolicy policy = InfoPolicyConverter.policyFromMap(policyMap); 42 | Assert.assertEquals(policy.timeout, 333); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/RestClientRecordTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain; 18 | 19 | import com.aerospike.client.Record; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | 26 | public class RestClientRecordTest { 27 | 28 | @Test 29 | public void testNoArgConstructor() { 30 | new RestClientRecord(); 31 | } 32 | 33 | @Test 34 | public void testNullBins() { 35 | Record record = new Record(null, 2, 1000); 36 | RestClientRecord rcRecord = new RestClientRecord(record); 37 | 38 | Assert.assertNull(rcRecord.bins); 39 | Assert.assertEquals(rcRecord.generation, 2); 40 | Assert.assertEquals(rcRecord.ttl, record.getTimeToLive()); 41 | } 42 | 43 | @Test 44 | public void testWithBins() { 45 | Map bins = new HashMap<>(); 46 | bins.put("bin1", 5l); 47 | bins.put("bin2", "hello"); 48 | Record record = new Record(bins, 2, 1000); 49 | RestClientRecord rcRecord = new RestClientRecord(record); 50 | 51 | Assert.assertEquals(rcRecord.bins, bins); 52 | Assert.assertEquals(rcRecord.generation, 2); 53 | Assert.assertEquals(rcRecord.ttl, record.getTimeToLive()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/BitAddOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.operation.BitOverflowAction; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | public class BitAddOperationTest { 24 | 25 | @Test 26 | public void isSigned() { 27 | BitAddOperation op = new BitAddOperation("bit", 0, 0, 1); 28 | Assert.assertFalse(op.isSigned()); 29 | op.setSigned(true); 30 | Assert.assertTrue(op.isSigned()); 31 | } 32 | 33 | @Test 34 | public void setAction() { 35 | BitAddOperation op = new BitAddOperation("bit", 0, 0, 1); 36 | Assert.assertEquals(BitOverflowAction.FAIL, op.getAction()); 37 | op.setAction(BitOverflowAction.SATURATE); 38 | Assert.assertEquals(BitOverflowAction.SATURATE, op.getAction()); 39 | } 40 | } -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/BitSubtractOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.operation.BitOverflowAction; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | public class BitSubtractOperationTest { 24 | 25 | @Test 26 | public void isSigned() { 27 | BitSubtractOperation op = new BitSubtractOperation("bit", 0, 0, 1); 28 | Assert.assertFalse(op.isSigned()); 29 | op.setSigned(true); 30 | Assert.assertTrue(op.isSigned()); 31 | } 32 | 33 | @Test 34 | public void getAction() { 35 | BitSubtractOperation op = new BitSubtractOperation("bit", 0, 0, 1); 36 | Assert.assertEquals(BitOverflowAction.FAIL, op.getAction()); 37 | op.setAction(BitOverflowAction.SATURATE); 38 | Assert.assertEquals(BitOverflowAction.SATURATE, op.getAction()); 39 | } 40 | } -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/HLLAddOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class HLLAddOperationTest { 23 | 24 | @Test 25 | public void getIndexBitCount() { 26 | HLLAddOperation op = new HLLAddOperation("op", null); 27 | Assert.assertNull(op.getIndexBitCount()); 28 | op.setIndexBitCount(2); 29 | Assert.assertEquals(Integer.valueOf(2), op.getIndexBitCount()); 30 | } 31 | 32 | @Test 33 | public void getMinHashBitCount() { 34 | HLLAddOperation op = new HLLAddOperation("op", null); 35 | Assert.assertNull(op.getMinHashBitCount()); 36 | op.setMinHashBitCount(2); 37 | Assert.assertEquals(Integer.valueOf(2), op.getMinHashBitCount()); 38 | } 39 | } -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/HLLInitOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class HLLInitOperationTest { 23 | 24 | @Test 25 | public void getMinHashBitCount() { 26 | HLLInitOperation op = new HLLInitOperation("bin", 0); 27 | Assert.assertNull(op.getMinHashBitCount()); 28 | op.setMinHashBitCount(8); 29 | Assert.assertEquals(Integer.valueOf(8), op.getMinHashBitCount()); 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListAppendItemsOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class ListAppendItemsOperationTest { 26 | 27 | @Test 28 | public void getMinHashBitCount() { 29 | ListAppendItemsOperation op = new ListAppendItemsOperation("bin", new ArrayList<>()); 30 | Assert.assertNull(op.getListPolicy()); 31 | ListPolicy policy = new ListPolicy(); 32 | List flags = new ArrayList<>(); 33 | flags.add(ListWriteFlag.ADD_UNIQUE); 34 | policy.setWriteFlags(flags); 35 | op.setListPolicy(policy); 36 | Assert.assertEquals(policy, op.getListPolicy()); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListAppendOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class ListAppendOperationTest { 26 | 27 | @Test 28 | public void getMinHashBitCount() { 29 | ListAppendOperation op = new ListAppendOperation("bin", new ArrayList<>()); 30 | Assert.assertNull(op.getListPolicy()); 31 | ListPolicy policy = new ListPolicy(); 32 | List flags = new ArrayList<>(); 33 | flags.add(ListWriteFlag.ADD_UNIQUE); 34 | policy.setWriteFlags(flags); 35 | op.setListPolicy(policy); 36 | Assert.assertEquals(policy, op.getListPolicy()); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByIndexOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByIndexOperationTest { 23 | 24 | @Test 25 | public void isInverted() { 26 | ListGetByIndexOperation op = new ListGetByIndexOperation("bin", 1, ListReturnType.RANK); 27 | Assert.assertFalse(op.isInverted()); 28 | op.setInverted(true); 29 | Assert.assertTrue(op.isInverted()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByIndexRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByIndexRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | ListGetByIndexRangeOperation op = new ListGetByIndexRangeOperation("bin", 1, ListReturnType.RANK); 27 | Assert.assertNull(op.getCount()); 28 | op.setCount(6); 29 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 30 | } 31 | 32 | @Test 33 | public void isInverted() { 34 | ListGetByIndexRangeOperation op = new ListGetByIndexRangeOperation("bin", 1, ListReturnType.RANK); 35 | Assert.assertFalse(op.isInverted()); 36 | op.setInverted(true); 37 | Assert.assertTrue(op.isInverted()); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByRankOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByRankOperationTest { 23 | 24 | @Test 25 | public void isInverted() { 26 | ListGetByRankOperation op = new ListGetByRankOperation("bin", 1, ListReturnType.RANK); 27 | Assert.assertFalse(op.isInverted()); 28 | op.setInverted(true); 29 | Assert.assertTrue(op.isInverted()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByRankRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByRankRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | ListGetByRankRangeOperation op = new ListGetByRankRangeOperation("bin", 1, ListReturnType.RANK); 27 | Assert.assertNull(op.getCount()); 28 | op.setCount(6); 29 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 30 | } 31 | 32 | @Test 33 | public void isInverted() { 34 | ListGetByRankRangeOperation op = new ListGetByRankRangeOperation("bin", 1, ListReturnType.RANK); 35 | Assert.assertFalse(op.isInverted()); 36 | op.setInverted(true); 37 | Assert.assertTrue(op.isInverted()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByValueListOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.ArrayList; 23 | 24 | public class ListGetByValueListOperationTest { 25 | @Test 26 | public void isInverted() { 27 | ListGetByValueListOperation op = new ListGetByValueListOperation("bin", ListReturnType.RANK, new ArrayList<>()); 28 | Assert.assertFalse(op.isInverted()); 29 | op.setInverted(true); 30 | Assert.assertTrue(op.isInverted()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByValueOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByValueOperationTest { 23 | @Test 24 | public void isInverted() { 25 | ListGetByValueOperation op = new ListGetByValueOperation("bin", 1, ListReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByValueRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByValueRangeOperationTest { 23 | @Test 24 | public void isInverted() { 25 | ListGetByValueRangeOperation op = new ListGetByValueRangeOperation("bin", ListReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | 31 | @Test 32 | public void getValueBegin() { 33 | ListGetByValueRangeOperation op = new ListGetByValueRangeOperation("bin", ListReturnType.RANK); 34 | Assert.assertNull(op.getValueBegin()); 35 | op.setValueBegin(true); 36 | Assert.assertTrue((Boolean) op.getValueBegin()); 37 | } 38 | 39 | @Test 40 | public void getValueEnd() { 41 | ListGetByValueRangeOperation op = new ListGetByValueRangeOperation("bin", ListReturnType.RANK); 42 | Assert.assertNull(op.getValueEnd()); 43 | op.setValueEnd(true); 44 | Assert.assertTrue((Boolean) op.getValueEnd()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListGetByValueRelativeRankRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListGetByValueRelativeRankRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | ListGetByValueRelativeRankRangeOperation op = new ListGetByValueRelativeRankRangeOperation("bin", 1, 2, 27 | ListReturnType.RANK); 28 | Assert.assertNull(op.getCount()); 29 | op.setCount(6); 30 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 31 | } 32 | 33 | @Test 34 | public void isInverted() { 35 | ListGetByValueRelativeRankRangeOperation op = new ListGetByValueRelativeRankRangeOperation("bin", 1, 2, 36 | ListReturnType.RANK); 37 | Assert.assertFalse(op.isInverted()); 38 | op.setInverted(true); 39 | Assert.assertTrue(op.isInverted()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListRemoveByIndexRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListRemoveByIndexRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | ListGetByIndexRangeOperation op = new ListGetByIndexRangeOperation("bin", 1, ListReturnType.RANK); 27 | Assert.assertNull(op.getCount()); 28 | op.setCount(6); 29 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 30 | } 31 | 32 | @Test 33 | public void isInverted() { 34 | ListGetByIndexRangeOperation op = new ListGetByIndexRangeOperation("bin", 1, ListReturnType.RANK); 35 | Assert.assertFalse(op.isInverted()); 36 | op.setInverted(true); 37 | Assert.assertTrue(op.isInverted()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListRemoveByValueListOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.ArrayList; 23 | 24 | public class ListRemoveByValueListOperationTest { 25 | @Test 26 | public void isInverted() { 27 | ListGetByValueListOperation op = new ListGetByValueListOperation("bin", ListReturnType.RANK, new ArrayList<>()); 28 | Assert.assertFalse(op.isInverted()); 29 | op.setInverted(true); 30 | Assert.assertTrue(op.isInverted()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListRemoveByValueOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListRemoveByValueOperationTest { 23 | @Test 24 | public void isInverted() { 25 | ListGetByValueOperation op = new ListGetByValueOperation("bin", 1, ListReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListRemoveByValueRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListRemoveByValueRangeOperationTest { 23 | @Test 24 | public void isInverted() { 25 | ListRemoveByValueRangeOperation op = new ListRemoveByValueRangeOperation("bin", ListReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | 31 | @Test 32 | public void getValueBegin() { 33 | ListRemoveByValueRangeOperation op = new ListRemoveByValueRangeOperation("bin", ListReturnType.RANK); 34 | Assert.assertNull(op.getValueBegin()); 35 | op.setValueBegin(true); 36 | Assert.assertTrue((Boolean) op.getValueBegin()); 37 | } 38 | 39 | @Test 40 | public void getValueEnd() { 41 | ListRemoveByValueRangeOperation op = new ListRemoveByValueRangeOperation("bin", ListReturnType.RANK); 42 | Assert.assertNull(op.getValueEnd()); 43 | op.setValueEnd(true); 44 | Assert.assertTrue((Boolean) op.getValueEnd()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListRemoveByValueRelativeRankRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class ListRemoveByValueRelativeRankRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | ListGetByValueRelativeRankRangeOperation op = new ListGetByValueRelativeRankRangeOperation("bin", 1, 2, 27 | ListReturnType.RANK); 28 | Assert.assertNull(op.getCount()); 29 | op.setCount(6); 30 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 31 | } 32 | 33 | @Test 34 | public void isInverted() { 35 | ListGetByValueRelativeRankRangeOperation op = new ListGetByValueRelativeRankRangeOperation("bin", 1, 2, 36 | ListReturnType.RANK); 37 | Assert.assertFalse(op.isInverted()); 38 | op.setInverted(true); 39 | Assert.assertTrue(op.isInverted()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListSortFlagTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.ListSortFlags; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.Parameterized; 24 | 25 | @RunWith(Parameterized.class) 26 | public class ListSortFlagTest { 27 | 28 | @Parameterized.Parameters 29 | public static Object[][] getParams() { 30 | return new Object[][]{ 31 | new Object[]{ListSortFlag.DEFAULT, ListSortFlags.DEFAULT}, 32 | new Object[]{ListSortFlag.DROP_DUPLICATES, ListSortFlags.DROP_DUPLICATES}, 33 | }; 34 | } 35 | 36 | ListSortFlag enum_; 37 | int flag; 38 | 39 | public ListSortFlagTest(ListSortFlag enum_, int flag) { 40 | this.enum_ = enum_; 41 | this.flag = flag; 42 | } 43 | 44 | @Test 45 | public void toListSortFlagTest() { 46 | Assert.assertEquals(enum_.flag, flag); 47 | } 48 | } -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListSortOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | public class ListSortOperationTest { 26 | 27 | @Test 28 | public void getSortFlags() { 29 | ListSortOperation op = new ListSortOperation("bin"); 30 | Assert.assertNull(op.getSortFlags()); 31 | List flags = new ArrayList<>(); 32 | flags.add(ListSortFlag.DROP_DUPLICATES); 33 | op.setSortFlags(flags); 34 | Assert.assertEquals(flags, op.getSortFlags()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/ListWriteFlagTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.ListWriteFlags; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.Parameterized; 24 | 25 | @RunWith(Parameterized.class) 26 | public class ListWriteFlagTest { 27 | 28 | @Parameterized.Parameters 29 | public static Object[][] getParams() { 30 | return new Object[][]{ 31 | new Object[]{ListWriteFlag.DEFAULT, ListWriteFlags.DEFAULT}, 32 | new Object[]{ListWriteFlag.ADD_UNIQUE, ListWriteFlags.ADD_UNIQUE}, 33 | new Object[]{ListWriteFlag.INSERT_BOUNDED, ListWriteFlags.INSERT_BOUNDED}, 34 | new Object[]{ListWriteFlag.NO_FAIL, ListWriteFlags.NO_FAIL}, 35 | new Object[]{ListWriteFlag.PARTIAL, ListWriteFlags.PARTIAL}, 36 | }; 37 | } 38 | 39 | ListWriteFlag enum_; 40 | int flag; 41 | 42 | public ListWriteFlagTest(ListWriteFlag enum_, int flag) { 43 | this.enum_ = enum_; 44 | this.flag = flag; 45 | } 46 | 47 | @Test 48 | public void testFlag() { 49 | Assert.assertEquals(enum_.flag, flag); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapGetByValueRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapGetByValueRangeOperationTest { 23 | @Test 24 | public void isInverted() { 25 | MapGetByValueRangeOperation op = new MapGetByValueRangeOperation("bin", MapReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | 31 | @Test 32 | public void getValueBegin() { 33 | MapGetByValueRangeOperation op = new MapGetByValueRangeOperation("bin", MapReturnType.RANK); 34 | Assert.assertNull(op.getValueBegin()); 35 | op.setValueBegin(true); 36 | Assert.assertTrue((Boolean) op.getValueBegin()); 37 | } 38 | 39 | @Test 40 | public void getValueEnd() { 41 | MapGetByValueRangeOperation op = new MapGetByValueRangeOperation("bin", MapReturnType.RANK); 42 | Assert.assertNull(op.getValueEnd()); 43 | op.setValueEnd(true); 44 | Assert.assertTrue((Boolean) op.getValueEnd()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapRemoveByIndexOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapRemoveByIndexOperationTest { 23 | @Test 24 | public void isInverted() { 25 | MapRemoveByIndexOperation op = new MapRemoveByIndexOperation("bin", 1, MapReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapRemoveByIndexRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapRemoveByIndexRangeOperationTest { 23 | 24 | @Test 25 | public void getCount() { 26 | MapRemoveByIndexRangeOperation op = new MapRemoveByIndexRangeOperation("bin", 1, MapReturnType.RANK); 27 | Assert.assertNull(op.getCount()); 28 | op.setCount(6); 29 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 30 | } 31 | 32 | @Test 33 | public void isInverted() { 34 | MapRemoveByIndexRangeOperation op = new MapRemoveByIndexRangeOperation("bin", 1, MapReturnType.RANK); 35 | Assert.assertFalse(op.isInverted()); 36 | op.setInverted(true); 37 | Assert.assertTrue(op.isInverted()); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapRemoveByKeyOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapRemoveByKeyOperationTest { 23 | @Test 24 | public void isInverted() { 25 | MapRemoveByKeyOperation op = new MapRemoveByKeyOperation("bin", "key", MapReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapRemoveByKeyRangeOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapRemoveByKeyRangeOperationTest { 23 | @Test 24 | public void isInverted() { 25 | MapRemoveByKeyRangeOperation op = new MapRemoveByKeyRangeOperation("bin", MapReturnType.RANK); 26 | Assert.assertFalse(op.isInverted()); 27 | op.setInverted(true); 28 | Assert.assertTrue(op.isInverted()); 29 | } 30 | 31 | @Test 32 | public void getKeyBegin() { 33 | MapRemoveByKeyRangeOperation op = new MapRemoveByKeyRangeOperation("bin", MapReturnType.RANK); 34 | Assert.assertNull(op.getKeyBegin()); 35 | op.setKeyBegin(true); 36 | Assert.assertTrue((Boolean) op.getKeyBegin()); 37 | } 38 | 39 | @Test 40 | public void getKeyEnd() { 41 | MapRemoveByKeyRangeOperation op = new MapRemoveByKeyRangeOperation("bin", MapReturnType.RANK); 42 | Assert.assertNull(op.getKeyEnd()); 43 | op.setKeyEnd(true); 44 | Assert.assertTrue((Boolean) op.getKeyEnd()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapRemoveByValueRelativeRankRangeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class MapRemoveByValueRelativeRankRangeTest { 23 | 24 | @Test 25 | public void getCount() { 26 | MapRemoveByValueRelativeRankRange op = new MapRemoveByValueRelativeRankRange("bin", 1, 1, MapReturnType.RANK); 27 | Assert.assertNull(op.getCount()); 28 | op.setCount(6); 29 | Assert.assertEquals(Integer.valueOf(6), op.getCount()); 30 | } 31 | 32 | @Test 33 | public void isInverted() { 34 | MapRemoveByValueRelativeRankRange op = new MapRemoveByValueRelativeRankRange("bin", 1, 1, MapReturnType.RANK); 35 | Assert.assertFalse(op.isInverted()); 36 | op.setInverted(true); 37 | Assert.assertTrue(op.isInverted()); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapSetPolicyOperationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.Operation; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | public class MapSetPolicyOperationTest { 24 | @Test 25 | public void toOperationPolicyIsNull() { 26 | MapSetPolicyOperation op = new MapSetPolicyOperation("bin", null); 27 | Operation asOp = op.toOperation(); 28 | 29 | Assert.assertEquals(Operation.Type.MAP_MODIFY, asOp.type); 30 | Assert.assertEquals("bin", asOp.binName); 31 | } 32 | 33 | @Test 34 | public void toOperationWithPolicy() { 35 | MapSetPolicyOperation op = new MapSetPolicyOperation("bin", new MapPolicy()); 36 | Operation asOp = op.toOperation(); 37 | 38 | Assert.assertEquals(Operation.Type.MAP_MODIFY, asOp.type); 39 | Assert.assertEquals("bin", asOp.binName); 40 | } 41 | } -------------------------------------------------------------------------------- /src/test/java/com/aerospike/restclient/domain/operationmodels/MapWriteFlagTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Aerospike, Inc. 3 | * 4 | * Portions may be licensed to Aerospike, Inc. under one or more contributor 5 | * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | * use this file except in compliance with the License. You may obtain a copy of 9 | * the License at http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package com.aerospike.restclient.domain.operationmodels; 18 | 19 | import com.aerospike.client.cdt.MapWriteFlags; 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.Parameterized; 24 | 25 | @RunWith(Parameterized.class) 26 | public class MapWriteFlagTest { 27 | 28 | @Parameterized.Parameters 29 | public static Object[][] getParams() { 30 | return new Object[][]{ 31 | new Object[]{MapWriteFlag.DEFAULT, MapWriteFlags.DEFAULT}, 32 | new Object[]{MapWriteFlag.CREATE_ONLY, MapWriteFlags.CREATE_ONLY}, 33 | new Object[]{MapWriteFlag.UPDATE_ONLY, MapWriteFlags.UPDATE_ONLY}, 34 | new Object[]{MapWriteFlag.NO_FAIL, MapWriteFlags.NO_FAIL}, 35 | new Object[]{MapWriteFlag.PARTIAL, MapWriteFlags.PARTIAL}, 36 | }; 37 | } 38 | 39 | MapWriteFlag enum_; 40 | int flag; 41 | 42 | public MapWriteFlagTest(MapWriteFlag enum_, int flag) { 43 | this.enum_ = enum_; 44 | this.flag = flag; 45 | } 46 | 47 | @Test 48 | public void testFlag() { 49 | Assert.assertEquals(enum_.flag, flag); 50 | } 51 | } 52 | --------------------------------------------------------------------------------