@@ -514,7 +514,13 @@ def retrieve_content(
514
514
response = self ._do_request ("POST" , f"{ self ._RESOURCE_PATH } /content" , accept = "text/plain" , json = identifier )
515
515
return response .content
516
516
517
- def retrieve_content_buffer (self , id : int , buffer : BinaryIO ) -> None :
517
+ def retrieve_content_buffer (
518
+ self ,
519
+ buffer : BinaryIO ,
520
+ id : int | None = None ,
521
+ external_id : str | None = None ,
522
+ instance_id : NodeId | None = None ,
523
+ ) -> None :
518
524
"""`Retrieve document content into buffer <https://developer.cognite.com/api#tag/Documents/operation/documentsContent>`_
519
525
520
526
Returns extracted textual information for the given document.
@@ -526,8 +532,10 @@ def retrieve_content_buffer(self, id: int, buffer: BinaryIO) -> None:
526
532
527
533
528
534
Args:
529
- id (int): The server-generated ID for the document you want to retrieve the content of.
530
535
buffer (BinaryIO): The document content is streamed directly into the buffer. This is useful for retrieving large documents.
536
+ id (int | None): The server-generated ID for the document you want to retrieve the content of.
537
+ external_id (str | None): External ID
538
+ instance_id (NodeId | None): Instance ID
531
539
532
540
Examples:
533
541
@@ -539,8 +547,10 @@ def retrieve_content_buffer(self, id: int, buffer: BinaryIO) -> None:
539
547
>>> with Path("my_file.txt").open("wb") as buffer:
540
548
... client.documents.retrieve_content_buffer(id=123, buffer=buffer)
541
549
"""
550
+ identifiers = IdentifierSequence .load (ids = id , external_ids = external_id , instance_ids = instance_id ).as_singleton ()
551
+ identifier = identifiers .as_dicts ()[0 ]
542
552
with self ._do_request (
543
- "POST" , f"{ self ._RESOURCE_PATH } /content" , stream = True , accept = "text/plain" , json = { "id" : id }
553
+ "POST" , f"{ self ._RESOURCE_PATH } /content" , stream = True , accept = "text/plain" , json = identifier
544
554
) as response :
545
555
for chunk in response .iter_content (chunk_size = 2 ** 21 ):
546
556
if chunk : # filter out keep-alive new chunks
0 commit comments