Goal:
This article explains the steps on how to test MapR Data Access Gateway.Env:
MapR 6.1 (secured)Solution:
1. Python OJAI client
Follow the documentation https://mapr.com/docs/61/MapR-DB/JSON_DB/UsingPythonOJAIClient.html to install python library "maprdb-python-client".Below is a sample python program named "test.py" to scan the column "_id" of maprdb table "/tmp/test":
from mapr.ojai.storage.ConnectionFactory import ConnectionFactory connection_str = "v1.poc.com:5678?auth=basic;user=mapr;password=mapr;" \ "ssl=true;" \ "sslCA=./ssl_truststore.pem;" \ "sslTargetNameOverride=v1.poc.com" connection = ConnectionFactory.get_connection(connection_str=connection_str) store = connection.get_store('/tmp/test') query = {"$select": ["_id"]} options = { 'ojai.mapr.query.result-as-document': True } query_result = store.find(query, options=options) for doc in query_result: print(doc.as_dictionary()) connection.close()
Note: make sure a valid ssl_truststore.pem is located here.
Run it:
$ python test.py {'_id': '0002'}
2. REST OJAI API
Refer to documentation https://mapr.com/docs/61/MapR-DB/JSON_DB/UsingMapRDBJSONRESTAPI.htmlBelow examples are using basic authentication.
2.a insecure mode(-k)
curl -X GET -k \ 'https://v1.poc.com:8243/api/v2/table/%2Ftmp%2Ftest%2F' \ -u mapr:mapr
2.b using SSL certificates
curl --cacert ./ssl_truststore.pem -X GET \ 'https://v1.poc.com:8243/api/v2/table/%2Ftmp%2Ftest%2F' \ -u mapr:mapr
Troubleshooting:
If there is any issue with SSL/TLS/Certificates, use below commands to troubleshoot.From Data Access Gateway node:
keytool -list -keystore /opt/mapr/conf/ssl_keystore -v keytool -list -v -keystore /opt/mapr/conf/ssl_keystore.p12 -storetype PKCS12 keytool -list -keystore /opt/mapr/conf/ssl_truststore -vFrom the client node:
openssl s_client -connect v1.poc.com:5678 -CAfile /path/on/client/node/ssl_truststore.pem -showcerts
No comments:
Post a Comment