diff --git a/docs/modules/n1ql-rest-query/examples/exformdata.sh b/docs/modules/n1ql-rest-query/examples/exformdata.sh new file mode 100644 index 00000000..d850e646 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exformdata.sh @@ -0,0 +1,3 @@ +curl -v $BASEURL/_p/query/query/service \ + -d 'statement=SELECT name FROM `travel-sample`.inventory.hotel LIMIT 1' \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exn1qlerror.json b/docs/modules/n1ql-rest-query/examples/exn1qlerror.json new file mode 100644 index 00000000..fe4d4b6e --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exn1qlerror.json @@ -0,0 +1,18 @@ +{ + "requestID": "27087759-07af-431d-a3d7-29080f870e56", + "errors": [ + { + "code": 3000, + "msg": "syntax error - line 1, column 7, near 'SLECT', at: name" + } + ], + "status": "fatal", + "metrics": { + "elapsedTime": "1.478631ms", + "executionTime": "1.393274ms", + "resultCount": 0, + "resultSize": 0, + "serviceLoad": 12, + "errorCount": 1 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exnamed.json b/docs/modules/n1ql-rest-query/examples/exnamed.json new file mode 100644 index 00000000..0389aef5 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exnamed.json @@ -0,0 +1,25 @@ +{ + "requestID": "81aceab8-7f7a-4d00-b741-00385740329a", + "signature": { + "airline": "json" + }, + "results": [ + { + "airline": "B6" + }, + { + "airline": "EK" + }, + { + "airline": "SV" + } + ], + "status": "success", + "metrics": { + "elapsedTime": "72.886709ms", + "executionTime": "72.765333ms", + "resultCount": 3, + "resultSize": 48, + "serviceLoad": 12 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exnamed.sh b/docs/modules/n1ql-rest-query/examples/exnamed.sh new file mode 100644 index 00000000..35527eb3 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exnamed.sh @@ -0,0 +1,5 @@ +curl -v $BASEURL/_p/query/query/service \ + -d 'statement=SELECT airline FROM `travel-sample`.inventory.route + WHERE sourceairport = $aval AND distance > $dval + & $aval="LAX" & $dval=13000' \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exnotfound.json b/docs/modules/n1ql-rest-query/examples/exnotfound.json new file mode 100644 index 00000000..882dd6f3 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exnotfound.json @@ -0,0 +1,18 @@ +{ + "requestID": "d30b805f-6c1e-44ec-9aec-35ff711a6e88", + "errors": [ + { + "code": 12003, + "msg": "Keyspace not found in CB datastore: default:travel-sample.inventory.motel" + } + ], + "status": "fatal", + "metrics": { + "elapsedTime": "3.096786ms", + "executionTime": "2.468282ms", + "resultCount": 0, + "resultSize": 0, + "serviceLoad": 12, + "errorCount": 1 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exnumbered.json b/docs/modules/n1ql-rest-query/examples/exnumbered.json new file mode 100644 index 00000000..3cb9994e --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exnumbered.json @@ -0,0 +1,25 @@ +{ + "requestID": "6e242629-ebf5-4a58-8db4-62d94974519f", + "signature": { + "airline": "json" + }, + "results": [ + { + "airline": "B6" + }, + { + "airline": "EK" + }, + { + "airline": "SV" + } + ], + "status": "success", + "metrics": { + "elapsedTime": "86.962678ms", + "executionTime": "84.35715ms", + "resultCount": 3, + "resultSize": 48, + "serviceLoad": 12 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exnumbered.sh b/docs/modules/n1ql-rest-query/examples/exnumbered.sh new file mode 100644 index 00000000..c9888c99 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exnumbered.sh @@ -0,0 +1,5 @@ +curl -v $BASEURL/_p/query/query/service \ + -d 'statement=SELECT airline FROM `travel-sample`.inventory.route + WHERE sourceairport = $1 AND distance > $2 + & args=["LAX", 13000]' \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/expositional.json b/docs/modules/n1ql-rest-query/examples/expositional.json new file mode 100644 index 00000000..fc48bf3d --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/expositional.json @@ -0,0 +1,25 @@ +{ + "requestID": "6d77dc41-3cab-4e00-9c54-f60fcc2e0fab", + "signature": { + "airline": "json" + }, + "results": [ + { + "airline": "B6" + }, + { + "airline": "EK" + }, + { + "airline": "SV" + } + ], + "status": "success", + "metrics": { + "elapsedTime": "86.226474ms", + "executionTime": "86.072996ms", + "resultCount": 3, + "resultSize": 48, + "serviceLoad": 12 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/expositional.sh b/docs/modules/n1ql-rest-query/examples/expositional.sh new file mode 100644 index 00000000..4c73f573 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/expositional.sh @@ -0,0 +1,5 @@ +curl -v $BASEURL/_p/query/query/service \ + -d 'statement=SELECT airline FROM `travel-sample`.inventory.route + WHERE sourceairport = ? AND distance > ? + & args=["LAX", 13000]' \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exreadonly.sh b/docs/modules/n1ql-rest-query/examples/exreadonly.sh new file mode 100644 index 00000000..445658bf --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exreadonly.sh @@ -0,0 +1,2 @@ +curl -v $BASEURL/_p/query/query/service?statement=SELECT%20name%20FROM%20%60travel-sample%60.inventory.hotel%20LIMIT%201%3B \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exrequesterror.json b/docs/modules/n1ql-rest-query/examples/exrequesterror.json new file mode 100644 index 00000000..86072621 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exrequesterror.json @@ -0,0 +1,18 @@ +{ + "requestID": "424c0a6d-b851-4feb-892c-0d9a106f2e13", + "errors": [ + { + "code": 1050, + "msg": "No statement or prepared value" + } + ], + "status": "fatal", + "metrics": { + "elapsedTime": "1.124637ms", + "executionTime": "1.094663ms", + "resultCount": 0, + "resultSize": 0, + "serviceLoad": 0, + "errorCount": 1 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exserviceerror.json b/docs/modules/n1ql-rest-query/examples/exserviceerror.json new file mode 100644 index 00000000..3048677a --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exserviceerror.json @@ -0,0 +1,19 @@ +{ + "requestID": "5c0a6a81-2fc8-4a33-a035-ed7fb1512710", + "errors": [ + { + "code": "", + "msg": "Request queue full" + } + ], + "status": "errors", + "metrics": { + "elapsedTime": "134.7944us", + "executionTime": "130.5518us", + "resultCount": 0, + "resultSize": 0, + "mutationCount": 0, + "errorCount": 1, + "warningCount": 0 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exsuccessful.json b/docs/modules/n1ql-rest-query/examples/exsuccessful.json new file mode 100644 index 00000000..d48a72aa --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exsuccessful.json @@ -0,0 +1,19 @@ +{ + "requestID": "615e0b26-dd61-4a1a-bda9-22333193b982", + "signature": { + "name": "json" + }, + "results": [ + { + "name": "Medway Youth Hostel" + } + ], + "status": "success", + "metrics": { + "elapsedTime": "5.232754ms", + "executionTime": "5.160022ms", + "resultCount": 1, + "resultSize": 30, + "serviceLoad": 12 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exsuccessful.sh b/docs/modules/n1ql-rest-query/examples/exsuccessful.sh new file mode 100644 index 00000000..35fc5cd1 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exsuccessful.sh @@ -0,0 +1,4 @@ +curl -v $BASEURL/_p/query/query/service \ + -H 'Content-Type: application/json' \ + -d '{ "statement": "SELECT name FROM `travel-sample`.inventory.hotel LIMIT 1;" }' \ + -u $USER:$PASSWORD \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exwildcard.json b/docs/modules/n1ql-rest-query/examples/exwildcard.json new file mode 100644 index 00000000..49f72659 --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exwildcard.json @@ -0,0 +1,22 @@ +{ + "requestID": "716f5e7b-557a-44a6-a372-9a98611c5b5e", + "signature": { + "id": "json" + }, + "results": [ + { + "id": "hotel_10025" + }, + { + "id": "hotel_10026" + } + ], + "status": "success", + "metrics": { + "elapsedTime": "64.11756ms", + "executionTime": "63.993854ms", + "resultCount": 2, + "resultSize": 40, + "serviceLoad": 12 + } +} \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/examples/exwildcard.sh b/docs/modules/n1ql-rest-query/examples/exwildcard.sh new file mode 100644 index 00000000..669c1f0c --- /dev/null +++ b/docs/modules/n1ql-rest-query/examples/exwildcard.sh @@ -0,0 +1,6 @@ +curl -v $BASEURL/_p/query/query/service \ + -u $USER:$PASSWORD \ + -d 'statement=SELECT meta().id + FROM `travel-sample`.inventory.hotel + WHERE meta().id LIKE $pattern + & $pattern="hotel_1002%25"' \ No newline at end of file diff --git a/docs/modules/n1ql-rest-query/pages/index.adoc b/docs/modules/n1ql-rest-query/pages/index.adoc index ca29a3b4..f908df3c 100644 --- a/docs/modules/n1ql-rest-query/pages/index.adoc +++ b/docs/modules/n1ql-rest-query/pages/index.adoc @@ -270,9 +270,11 @@ a| <> | 400 a| [markdown] -- -Bad Request. The request cannot be processed for one of the following reasons: the statement contains a SQL++ syntax error; the request has a missing or unrecognized HTTP parameter; the request is badly formatted — for example, the request body contains a JSON syntax error. +Bad Request. The request cannot be processed for one of the following reasons: the statement contains a SQL++ syntax error; the request has a missing or unrecognized HTTP parameter; the request is badly formatted — for example, the request body contains a JSON syntax error. -- -a| +a| <> + + | 401 a| [markdown] -- @@ -290,7 +292,9 @@ a| [markdown] -- Not found. The statement in the request references an invalid namespace or keyspace. -- -a| +a| <> + + | 405 a| [markdown] -- @@ -326,7 +330,9 @@ a| [markdown] -- Service unavailable. There is an issue (that is possibly temporary) preventing the request being processed; the request queue is full or the data store is not accessible. -- -a| +a| <> + + |=== @@ -524,9 +530,11 @@ a| <> | 400 a| [markdown] -- -Bad Request. The request cannot be processed for one of the following reasons: the statement contains a SQL++ syntax error; the request has a missing or unrecognized HTTP parameter; the request is badly formatted — for example, the request body contains a JSON syntax error. +Bad Request. The request cannot be processed for one of the following reasons: the statement contains a SQL++ syntax error; the request has a missing or unrecognized HTTP parameter; the request is badly formatted — for example, the request body contains a JSON syntax error. -- -a| +a| <> + + | 401 a| [markdown] -- @@ -544,7 +552,9 @@ a| [markdown] -- Not found. The statement in the request references an invalid namespace or keyspace. -- -a| +a| <> + + | 405 a| [markdown] -- @@ -580,7 +590,9 @@ a| [markdown] -- Service unavailable. There is an issue (that is possibly temporary) preventing the request being processed; the request queue is full or the data store is not accessible. -- -a| +a| <> + + |=== diff --git a/src/query-service/swagger/query-service.yaml b/src/query-service/swagger/query-service.yaml index ae1b8ca5..ffa8ee34 100644 --- a/src/query-service/swagger/query-service.yaml +++ b/src/query-service/swagger/query-service.yaml @@ -48,6 +48,27 @@ paths: application/x-www-form-urlencoded: schema: $ref: "#/components/schemas/Request" + x-codeSamples: + - lang: Shell + label: JSON + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exsuccessful.sh' + - lang: Shell + label: Form Data + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exformdata.sh' + - lang: Shell + label: Named Parameters + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exnamed.sh' + - lang: Shell + label: Numbered Parameters + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exnumbered.sh' + - lang: Shell + label: Unnumbered Parameters + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/expositional.sh' security: - Header: [] - Parameter: [] @@ -95,6 +116,11 @@ paths: The format for URL-encoded parameters is consistent with the syntax for variables according to RFC 6570. schema: $ref: "#/components/schemas/Request" + x-codeSamples: + - lang: Shell + label: Read-Only + source: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exreadonly.sh' security: - Header: [] - Parameter: [] @@ -138,17 +164,29 @@ components: application/json: schema: $ref: "#/components/schemas/Response" + example: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exsuccessful.json' BadRequest: description: |- Bad Request. The request cannot be processed for one of the following reasons: - the statement contains a SQL++ syntax error; - the request has a missing or unrecognized HTTP parameter; - the request is badly formatted — for example, the request body contains a JSON syntax error. + content: + application/json: + schema: + $ref: "#/components/schemas/Response" + examples: + n1qlerror: + summary: SQL++ Error + value: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exn1qlerror.json' + requesterror: + summary: Request Error + value: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exrequesterror.json' Unauthorized: description: > @@ -165,6 +203,12 @@ components: description: > Not found. The statement in the request references an invalid namespace or keyspace. + content: + application/json: + schema: + $ref: "#/components/schemas/Response" + example: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exnotfound.json' MethodNotAllowed: description: > @@ -196,6 +240,12 @@ components: description: > Service unavailable. There is an issue (that is possibly temporary) preventing the request being processed; the request queue is full or the data store is not accessible. + content: + application/json: + schema: + $ref: "#/components/schemas/Response" + example: + $ref: '../../../docs/modules/n1ql-rest-query/examples/exserviceerror.json' schemas: Request: @@ -1010,6 +1060,7 @@ components: [queryUseReplica]: #queryUseReplica additionalProperties: x-desc-name: identifier + x-additionalPropertiesName: $identifier description: | Supplies the value for a named parameter in the statement. Applicable if the statement or prepared statement contains 1 or more named parameters.