Class NeptuneRdf4JSigV4Example
- java.lang.Object
-
- com.amazonaws.neptune.client.rdf4j.NeptuneRdf4JSigV4Example
-
public final class NeptuneRdf4JSigV4Example extends Object
Small example demonstrating how to use NeptuneSparqlRepository with SignatureV4 in combination with the RDF4J library (see http://rdf4j.org/). The example uses theNeptuneSparqlRepositoryclass contained in this package, which extends RDF4J's SparqlRepository class by IAM authentication.Before running this code, make sure you've got everything setup properly, in particular:
- Make sure that your AWS credentials are available in the provider chain, see DefaultAWSCredentialsProviderChain for more information.
- Start the main method by passing in your endpoint, e.g. "http://<my_neptune_host>:<my_neptune_port>".
The server will send a
"SELECT * WHERE { ?s ?p ?o } LIMIT 10"query against your endpoint.
- Author:
- schmdtm
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidevaluateAndPrintQueryResult(String queryString, org.eclipse.rdf4j.repository.Repository repo)Evaluate the query and print the query result.protected static voidexecuteSignedInsertRequest(String endpointUrl)Example for signed request.protected static voidexecuteSignedQueryRequest(String endpointUrl, String query)Example for signed request.protected static voidexecuteUnsignedQueryRequest(String endpointUrl)Example for unsigned request.static voidmain(String[] args)Main method.
-
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Main method. Expecting the endpoint as the first argument.- Parameters:
args- arguments- Throws:
Exception- in case there are problems
-
executeSignedQueryRequest
protected static void executeSignedQueryRequest(String endpointUrl, String query) throws com.amazonaws.neptune.auth.NeptuneSigV4SignerException
Example for signed request.- Parameters:
endpointUrl- of the endpoint to which to send the request- Throws:
com.amazonaws.neptune.auth.NeptuneSigV4SignerException- in case there's a problem signing the request
-
executeSignedInsertRequest
protected static void executeSignedInsertRequest(String endpointUrl) throws com.amazonaws.neptune.auth.NeptuneSigV4SignerException
Example for signed request.- Parameters:
endpointUrl- of the endpoint to which to send the request- Throws:
com.amazonaws.neptune.auth.NeptuneSigV4SignerException- in case there's a problem signing the request
-
executeUnsignedQueryRequest
protected static void executeUnsignedQueryRequest(String endpointUrl)
Example for unsigned request.- Parameters:
endpointUrl- of the endpoint to which to send the request
-
evaluateAndPrintQueryResult
protected static void evaluateAndPrintQueryResult(String queryString, org.eclipse.rdf4j.repository.Repository repo)
Evaluate the query and print the query result.- Parameters:
queryString- the query string to evaluaterepo- the repository over which to evaluate the query
-
-