From 7e7aacf307ed8b37b2ed049e98fdab0256db9c38 Mon Sep 17 00:00:00 2001 From: Dequan Chen Date: Tue, 27 Mar 2018 11:20:33 -0500 Subject: [PATCH] Add Endpoints of Check-And-PUT and Check-And-Delete HBase Rest Documentation for JIRA - HBASE-7129 --- src/main/asciidoc/_chapters/external_apis.adoc | 100 +++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/main/asciidoc/_chapters/external_apis.adoc b/src/main/asciidoc/_chapters/external_apis.adoc index ffb6ee6cbf..886cc38287 100644 --- a/src/main/asciidoc/_chapters/external_apis.adoc +++ b/src/main/asciidoc/_chapters/external_apis.adoc @@ -353,6 +353,106 @@ curl -vi -X PUT \ "example.com:8000/users/fakerow" |=== + + +.Endpoints for `Check-And-Put` Operations +[options="header", cols="2m,m,3d,6l"] +|=== +|Endpoint +|HTTP Verb +|Description +|Example + +|/_table_/_row_key_/?check=put +|PUT +|Conditional Put - Change the current version value of a cell: Compare the current or latest version value (`current-version-value`) of a cell with the `check-value`, and if `current-version-value` == `check-value`, write new data (the `new-value`) into the cell as the current or latest version. The row, column qualifier, and value must each be Base-64 encoded. To encode a string, use the base64 command-line utility. To decode the string, use base64 -d. The payload is in the --data argument, with check column qualifier and value at the end or right after the new column qualifier and value of the same row key. You can also save the data to be inserted to a file and pass it to the `-d` parameter with syntax like `-d @filename.txt`. +|curl -vi -X PUT \ + -H "Accept: text/xml" \ + -H "Content-Type: text/xml" \ + -d 'T2xkR3V5TmV3R3V5' \ + "http://example.com:8000/users/row1/?check=put" + +curl -vi -X PUT \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"Row":[{"key":"cm93MQ==","Cell":[{"column":"Y2ZhOmFsaWFz","$":"T2xkR3V5"},{"column":"Y2ZhOmFsaWFz", "$":"TmV3R3V5"}] }]}' \ + "http://example.com:8000/users/row1/?check=put" +|=== + +.Endpoints for `Check-And-Delete` Operations +[options="header", cols="2m,m,3d,6l"] +|=== +|Endpoint +|HTTP Verb +|Description +|Example + +|/_table_/_row_key_/?check=delete +|DELETE +|Conditional Deleting a Row: Compare the value of any version of a cell (`any-version-value`) with the `check-value`, and if `any-version-value` == `check-value`, delete the row specified by the `row_key` inside the requesting URL.The row, column qualifier, and value for checking in the payload must each be Base-64 encoded. To encode a string, use the base64 command-line utility. To decode the string, use base64 -d. The payload is in the --data argument. You can also save the data to be checked to a file and pass it to the `-d` parameter with syntax like `-d @filename.txt`. +|curl -vi -X DELETE \ + -H "Accept: text/xml" \ + -H "Content-Type: text/xml" \ + -d 'TmV3R3V5' \ + "http://example.com:8000/users/row1/?check=delete" + +curl -vi -X DELETE \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"Row":[{"key":"cm93MQ==","Cell":[{"column":"Y2ZhOmFsaWFz","$":"TmV3R3V5"}]}]}' \ + "http://example.com:8000/users/row1/?check=delete" + +|/_table_/_row_key_ +/_column_family_ +/?check=delete +|DELETE +|Conditional Deleting a Column Family of a Row: Compare the value of any version of a cell (`any-version-value`) with the `check-value`, and if `any-version-value` == `check-value`, delete the column family of a row specified by the `row_key/column_family` inside the requesting URL. Anything else is the same as those in `Conditional Deleting a Row`. +|curl -vi -X DELETE \ + -H "Accept: text/xml" \ + -H "Content-Type: text/xml" \ + -d 'TmV3R3V5' \ + "http://example.com:8000/users/row1/cfa/?check=delete" + +curl -vi -X DELETE \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"Row":[{"key":"cm93MQ==","Cell":[{"column":"Y2ZhOmFsaWFz","$":"TmV3R3V5"}]}]}' \ + "http://example.com:8000/users/row1/cfa/?check=delete" + +|/_table_/_row_key_ +/_column:qualifier_ +/?check=delete +|DELETE +|Conditional Deleting All Versions of a Column of a Row: Compare the value of any version of a cell (`any-version-value`) with the `check-value`, and if `any-version-value` == `check-value`, delete the column of a row specified by the `row_key/column:qualifier` inside the requesting URL. The `column:qualifier` in the requesting URL is the `column_family:column_name`. Anything else is the same as those in `Conditional Deleting a Row`. +|curl -vi -X DELETE \ + -H "Accept: text/xml" \ + -H "Content-Type: text/xml" \ + -d 'TmV3R3V5' \ + "http://example.com:8000/users/row1/cfa:alias/?check=delete" + +curl -vi -X DELETE \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"Row":[{"key":"cm93MQ==","Cell":[{"column":"Y2ZhOmFsaWFz","$":"TmV3R3V5"}]}]}' \ + "http://example.com:8000/users/row1/cfa:alias/?check=delete" + +|/_table_/_row_key_ +/_column:qualifier_ +/_version_id_/?check=delete +|DELETE +|Conditional Deleting a Single Version of a Column of a Row: Compare the value of any version of a cell (`any-version-value`) with the `check-value`, and if `any-version-value` == `check-value`, delete the version of a column of a row specified by the `row_key/column:qualifier/version_id` inside the requesting URL. The `column:qualifier` in the requesting URL is the `column_family:column_name`. The `version_id` in the requesting URL is a number, which equals to `the timestamp of the targeted version + 1`. Anything else is the same as those in `Conditional Deleting a Row`. +|curl -vi -X DELETE \ + -H "Accept: text/xml" \ + -H "Content-Type: text/xml" \ + -d 'TmV3R3V5' \ + "http://example.com:8000/users/row1/cfa:alias/1519423552160/?check=delete" + +curl -vi -X DELETE \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{"Row":[{"key":"cm93MQ==","Cell":[{"column":"Y2ZhOmFsaWFz","$":"TmV3R3V5"}]}]}' \ + "http://example.com:8000/users/row1/cfa:alias/1519423552160/?check=delete" +|=== [[xml_schema]] === REST XML Schema -- 2.13.1.windows.2