Skip to content

Commit 3515712

Browse files
doc: Update generated source code (#101)
Generated SDK source code using: - Generator version 3.30.0 - Specification version 1.0.0-dev0.0.36 - Automation (cloudant-sdks) version 93ee781
1 parent 7a440c7 commit 3515712

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

README.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ try:
406406
doc_id=example_doc_id
407407
).get_result()
408408

409+
# Note: for response byte stream use:
410+
# document_as_byte_stream = client.get_document_as_stream(
411+
# db=example_db_name,
412+
# doc_id=example_doc_id
413+
# ).get_result()
414+
409415
# Add Bob Smith's address to the document
410416
document["address"] = "19 Front Street, Darlington, DL5 1TY"
411417

@@ -419,6 +425,12 @@ try:
419425
document=document
420426
).get_result()
421427

428+
# Note: for request byte stream use:
429+
# update_document_response = client.post_document(
430+
# db=example_db_name,
431+
# document=document_as_byte_stream
432+
# ).get_result()
433+
422434
# Keep track with the revision number of the document object:
423435
document["_rev"] = update_document_response["rev"]
424436
print(f'You have updated the document:\n' +
@@ -513,13 +525,32 @@ For sample code on handling errors, see
513525
### Raw IO
514526

515527
For endpoints that read or write document content it is possible to bypass
516-
usage of the built-in models and send or receive a bytes response.
517-
For examples of using byte streams, see the API reference documentation
518-
("Example request as a stream" section).
528+
usage of the built-in object with byte streams.
529+
530+
Depending on the specific SDK operation it may be possible to:
531+
* accept a user-provided byte stream to send to the server as a request body
532+
* return a byte stream of the server response body to the user
533+
534+
Request byte stream can be supplied for arguments that accept the `BinaryIO` type.
535+
For these cases you can pass this byte stream directly to the HTTP request body.
536+
537+
Response byte stream is supported in functions with the suffix of `_as_stream`.
538+
The returned byte stream allows the response body to be consumed
539+
without triggering JSON unmarshalling that is typically performed by the SDK.
540+
541+
The [update document](#3-update-your-previously-created-document) section
542+
contains examples for both request and response byte stream cases.
543+
544+
The API reference contains further examples of using byte streams.
545+
They are titled "Example request as stream" and are initially collapsed.
546+
Expand them to see examples of:
547+
548+
- Byte requests:
549+
- [Bulk modify multiple documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=python#postbulkdocs)
519550

520-
- [Bulk modify multiple documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=python#postbulkdocs)
521-
- [Query a list of all documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=python#postalldocs)
522-
- [Query the database document changes feed](https://cloud.ibm.com/apidocs/cloudant?code=python#postchanges)
551+
- Byte responses:
552+
- [Query a list of all documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=python#postalldocs)
553+
- [Query the database document changes feed](https://cloud.ibm.com/apidocs/cloudant?code=python#postchanges)
523554

524555
### Further resources
525556

0 commit comments

Comments
 (0)