Skip to content

Instantly share code, notes, and snippets.

@NihalJain
Last active October 21, 2024 07:17
Show Gist options
  • Save NihalJain/7db91823bd140e41953a88eb3df56eae to your computer and use it in GitHub Desktop.
Save NihalJain/7db91823bd140e41953a88eb3df56eae to your computer and use it in GitHub Desktop.
A sample HBase REST client which does basic CRUD.
{
"info": {
"_postman_id": "8515f733-bf9c-4135-aaf8-f406d9c92d74",
"name": "HBase Rest Sample Client",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get all Namespaces",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/namespaces",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"namespaces"
]
}
},
"response": []
},
{
"name": "Create a Table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true,
"content-type": true
}
},
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TableSchema name=\"users\">\n <ColumnSchema name=\"cf\" />\n</TableSchema>"
},
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/schema",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"schema"
]
}
},
"response": []
},
{
"name": "Get a table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/schema",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"schema"
]
}
},
"response": []
},
{
"name": "Get all table regions",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/regions",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"regions"
]
}
},
"response": []
},
{
"name": "Put a row into table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true,
"accept": true
}
},
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<CellSet>\n <Row key=\"cjA=\">\n <Cell column=\"Y2Y6\">dmFsdWU1Cg==</Cell>\n </Row>\n</CellSet>"
},
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/r0",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"r0"
]
}
},
"response": []
},
{
"name": "Get a row from table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/r0",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"r0"
]
}
},
"response": []
},
{
"name": "Get a scanner for table",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"postman.setGlobalVariable(\"scanner_id\", pm.response.headers.get(\"Location\").split('\\/')[5]);",
"",
"pm.test(\"Status code is 201!\", function () {",
" pm.response.to.have.status(201);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "<Scanner batch=\"1\"/>"
},
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/scanner",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"scanner"
]
}
},
"response": []
},
{
"name": "Traverse a scanner id for table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});",
""
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/scanner/{{scanner_id}}",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"scanner",
"{{scanner_id}}"
]
}
},
"response": []
},
{
"name": "Traverse a scanner id for table Again",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 204!\", function () {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/scanner/{{scanner_id}}",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"scanner",
"{{scanner_id}}"
]
}
},
"response": []
},
{
"name": "Delete a scanner id for table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "DELETE",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/scanner/{{scanner_id}}",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"scanner",
"{{scanner_id}}"
]
}
},
"response": []
},
{
"name": "Traverse a scanner id for table : FAIL",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404!\", function () {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true
}
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/scanner/{{scanner_id}}",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"scanner",
"{{scanner_id}}"
]
}
},
"response": []
},
{
"name": "Delete a Table",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200!\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"accept": true,
"content-type": true
}
},
"request": {
"method": "DELETE",
"header": [
{
"key": "Accept",
"value": "text/xml",
"type": "text"
},
{
"key": "Content-Type",
"value": "text/xml",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TableSchema name=\"users\">\n <ColumnSchema name=\"cf\" />\n</TableSchema>"
},
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/schema",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"schema"
]
}
},
"response": []
},
{
"name": "Get a table FAIL",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404!\", function () {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{hostname}}:{{rest_port}}/{{table_name}}/schema",
"protocol": "http",
"host": [
"{{hostname}}"
],
"port": "{{rest_port}}",
"path": [
"{{table_name}}",
"schema"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"id": "864d1520-1cfd-4da2-823b-6939504bb05d",
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"id": "54de6c16-883b-4858-b25b-ca6b48ca8479",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"id": "26ac0806-e7e0-45f6-8da3-f30f13dff492",
"key": "table_name",
"value": "testRest",
"type": "string"
},
{
"id": "82a3055c-b7bf-43d2-9d02-89e332ccc1a1",
"key": "hostname",
"value": "localhost",
"type": "string"
},
{
"id": "625c6388-7e1e-4aff-9893-2a26b4239a7f",
"key": "rest_port",
"value": "8080",
"type": "string"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment