Skip to content

Commit

Permalink
Merge pull request #4 from aerospike/1.0.2-candidate
Browse files Browse the repository at this point in the history
1.0.2 candidate
  • Loading branch information
aerospikerobertmarks authored Apr 30, 2019
2 parents 8dd2c9e + c45c601 commit 0ca89c0
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 21 deletions.
15 changes: 4 additions & 11 deletions .build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
name: aerospike-client-rest

dependency:
- url: [email protected]:citrusleaf/aerospike-client-java
dir: client/java
ref: master

container:
- base:
- docker.qe.aerospike.com/build/aerospike-client-java:openjdk-8
- docker.qe.aerospike.com/build/aerospike-client-rest:openjdk-8

build:
- name: build
script:
- cd client/java
- mvn install
- cd ../..
- export aerospikeUseLocal=1
- ./gradlew bootwar
- source ~/.bashrc
- make package
artifact:
- build/libs/*.war
- ./target/*.tgz

31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

VERSION=$(shell grep appVersion gradle.properties | cut -d '=' -f 2)
ARCHIVEDIR=as-rest-client-$(VERSION)
ARCHIVENAME=$(ARCHIVEDIR).tgz

.PHONY: package
package: clean war validatedocs
mkdir $(ARCHIVEDIR)
mkdir target
cp build/libs/*.war $(ARCHIVEDIR)
cp docs/swagger.json $(ARCHIVEDIR)
tar -czvf target/$(ARCHIVENAME) $(ARCHIVEDIR)

.PHONY: war
war:
./gradlew bootWar

.PHONY: clean
clean:
echo $(VERSION)
rm -rf $(ARCHIVEDIR)
rm -f $(ARCHIVENAME)
rm -rf target/
./gradlew clean

.PHONY: validatedocs
validatedocs:
ls -lat /root/.nvm/versions/node/v10.15.3/bin/swagger-tools
env
swagger-tools validate docs/swagger.json
swagger-cli validate docs/swagger.json
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# aerospike-client-rest

The Aerospike Rest client provides a server which translates Restful API requests into messages to an Aerospike Cluster.
The Aerospike REST client provides a server which translates Restful API requests into messages to an Aerospike Cluster.

It can be used as a bridge between applications written in languages without an existing Aerospike Client library, or as a pluggable component in a pre-existing architecture.

## Installation

For instructions on installing the Rest Client from a `.war` file see [Installation and Configuration](./docs/installation-and-config.md) .
For instructions on installing the REST Client from a `.war` file see [Installation and Configuration](./docs/installation-and-config.md) .

## Building

Expand All @@ -32,12 +32,12 @@ See [Installation and Configuration](./docs/installation-and-config.md) for conf

### Formats

The Aerospike Rest client allows communication utilizing `JSON` and `MessagePack` formats. For more information about how to specify the format, and recommended usages of each, see [Data Formats](./docs/data-formats.md)
The Aerospike REST client allows communication utilizing `JSON` and `MessagePack` formats. For more information about how to specify the format, and recommended usages of each, see [Data Formats](./docs/data-formats.md)

### Interactive UI and Swagger Specification

After installing and starting the Rest client, you can try out the API using an interactive frontend powered by Swagger UI. The interactive documentation is located at: `http://<API_ENDPOINT>:8080/swagger-ui.html`
After installing and starting the REST client, you can try out the API using an interactive frontend powered by Swagger UI. The interactive documentation is located at: `http://<API_ENDPOINT>:8080/swagger-ui.html`

The Swagger `.JSON` specification of the API is available at: `http://<API_ENDPOINT>:8080/v2/api-docs` .

So if the Rest Client is running on localhost these URLs would be `http://localhost:8080/swagger-ui.html` and `http://localhost:8080/v2/api-docs`.
So if the REST Client is running on localhost these URLs would be `http://localhost:8080/swagger-ui.html` and `http://localhost:8080/v2/api-docs`.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.aerospike'
version = '1.0.1'
sourceCompatibility = 1.8

bootWar {
archiveName "as-rest-client##${version}.war"
archiveName "${warBaseName}##${appVersion}.war"
}
test {
testLogging {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appVersion=1.0.2
warBaseName=as-rest-client
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

import com.aerospike.client.Key;
import com.aerospike.client.Operation;
import com.aerospike.client.Record;
import com.aerospike.client.policy.WritePolicy;
import com.aerospike.restclient.domain.RestClientOperation;
import com.aerospike.restclient.domain.RestClientRecord;
import com.aerospike.restclient.handlers.OperateHandler;
import com.aerospike.restclient.util.AerospikeAPIConstants.RecordKeyType;
import com.aerospike.restclient.util.KeyBuilder;
import com.aerospike.restclient.util.RestClientErrors;
import com.aerospike.restclient.util.converters.OperationsConverter;

@Service
Expand All @@ -49,8 +51,11 @@ public RestClientRecord operate(String namespace, String set, String key, List<M

Operation[] operations = OperationsConverter.mapListToOperationsArray(opsMaps);
Key opKey = KeyBuilder.buildKey(namespace, set, key, keyType);

return new RestClientRecord(handler.operate(policy, opKey, operations));
Record fetchedRecord = handler.operate(policy, opKey, operations);
if (fetchedRecord == null) {
throw new RestClientErrors.RecordNotFoundError();
}
return new RestClientRecord(fetchedRecord);
}

@Override
Expand All @@ -60,7 +65,11 @@ public RestClientRecord operateRCOps(String namespace, String set, String key, L

Operation[] operations = OperationsConverter.mapListToOperationsArray(opsMapsList);
Key opKey = KeyBuilder.buildKey(namespace, set, key, keyType);
return new RestClientRecord(handler.operate(policy, opKey, operations));
Record fetchedRecord = handler.operate(policy, opKey, operations);
if (fetchedRecord == null) {
throw new RestClientErrors.RecordNotFoundError();
}
return new RestClientRecord(fetchedRecord);

}
}
16 changes: 16 additions & 0 deletions src/test/java/com/aerospike/restclient/OperateTestCorrect.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.aerospike.restclient.util.AerospikeAPIConstants.OPERATION_FIELD;
import static com.aerospike.restclient.util.AerospikeAPIConstants.OPERATION_VALUES_FIELD;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import java.util.ArrayList;
import java.util.Base64;
Expand Down Expand Up @@ -337,4 +338,19 @@ public void testTouchOpWithDigestKey() throws Exception {
record = client.get(null, testKey);
Assert.assertEquals(oldGeneration + 1, record.generation);
}

@Test
public void testGetOpNonExistentRecord() throws Exception {
// Key that does not exist
String fakeEndpoint = ASTestUtils.buildEndpoint("operate", "test", "junit12345", "operate");
List<Map<String, Object>> opList = new ArrayList<Map<String, Object>>();
Map<String, Object> opMap = new HashMap<String, Object>();
Map<String, Object> opValues = new HashMap<String, Object>();
opMap.put(OPERATION_FIELD, AerospikeAPIConstants.OPERATION_GET);
opMap.put(OPERATION_VALUES_FIELD, opValues);

opList.add(opMap);
String jsString = objectMapper.writeValueAsString(opList);
ASTestUtils.performOperationAndExpect(mockMVC, fakeEndpoint, jsString, status().isNotFound());
}
}

0 comments on commit 0ca89c0

Please sign in to comment.