@@ -54,13 +54,18 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
5454
5555from nitric.api.const import MAX_SUB_COLLECTION_DEPTH
5656from nitric.api.exception import exception_from_grpc_error
57- from proto.nitric.document.v1 import (
57+ from nitric. proto.nitric.document.v1 import (
5858 DocumentServiceStub,
5959 Collection as CollectionMessage,
6060 Key as KeyMessage,
6161 Expression as ExpressionMessage,
6262 ExpressionValue,
6363 Document as DocumentMessage,
64+ DocumentSetRequest,
65+ DocumentGetRequest,
66+ DocumentDeleteRequest,
67+ DocumentQueryStreamRequest,
68+ DocumentQueryRequest,
6469)
6570
6671from nitric.utils import new_default_channel, _dict_from_struct, _struct_from_dict
@@ -102,7 +107,9 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
102107 async def get(self) -> Document:
103108 """Retrieve the contents of this document, if it exists."""
104109 try:
105- response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
110+ response = await self._documents._stub.get(
111+ document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
112+ )
106113 return _document_from_wire(documents=self._documents, message=response.document)
107114 except GRPCError as grpc_err:
108115 raise exception_from_grpc_error(grpc_err)
@@ -115,8 +122,10 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
115122 """
116123 try:
117124 await self._documents._stub.set(
118- key=_doc_ref_to_wire(self),
119- content=_struct_from_dict(content),
125+ document_set_request=DocumentSetRequest(
126+ key=_doc_ref_to_wire(self),
127+ content=_struct_from_dict(content),
128+ )
120129 )
121130 except GRPCError as grpc_err:
122131 raise exception_from_grpc_error(grpc_err)
@@ -125,7 +134,9 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
125134 """Delete this document, if it exists."""
126135 try:
127136 await self._documents._stub.delete(
128- key=_doc_ref_to_wire(self),
137+ document_delete_request=DocumentDeleteRequest(
138+ key=_doc_ref_to_wire(self),
139+ )
129140 )
130141 except GRPCError as grpc_err:
131142 raise exception_from_grpc_error(grpc_err)
@@ -525,9 +536,11 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
525536
526537 try:
527538 async for result in self._documents._stub.query_stream(
528- collection=_collection_to_wire(self._collection),
529- expressions=self._expressions_to_wire(),
530- limit=self._limit,
539+ document_query_stream_request=DocumentQueryStreamRequest(
540+ collection=_collection_to_wire(self._collection),
541+ expressions=self._expressions_to_wire(),
542+ limit=self._limit,
543+ )
531544 ):
532545 yield _document_from_wire(documents=self._documents, message=result.document)
533546 except GRPCError as grpc_err:
@@ -541,10 +554,12 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
541554 """
542555 try:
543556 results = await self._documents._stub.query(
544- collection=_collection_to_wire(self._collection),
545- expressions=self._expressions_to_wire(),
546- limit=self._limit,
547- paging_token=self._paging_token,
557+ document_query_request=DocumentQueryRequest(
558+ collection=_collection_to_wire(self._collection),
559+ expressions=self._expressions_to_wire(),
560+ limit=self._limit,
561+ paging_token=self._paging_token,
562+ )
548563 )
549564
550565 return QueryResultsPage(
@@ -674,7 +689,8 @@ <h3>Ancestors</h3>
674689< summary >
675690< span > Expand source code</ span >
676691</ summary >
677- < pre > < code class ="python "> class CollectionGroupRef:
692+ < pre > < code class ="python "> @dataclass(frozen=True, order=True)
693+ class CollectionGroupRef:
678694 """A reference to a collection group."""
679695
680696 _documents: Documents
@@ -738,7 +754,7 @@ <h3>Class variables</h3>
738754< dd >
739755< div class ="desc "> </ div >
740756</ dd >
741- < dt id ="nitric.api.documents.CollectionGroupRef.parent "> < code class ="name "> var < span class ="ident "> parent</ span > : Union [< a title ="nitric.api.documents.CollectionRef " href ="#nitric.api.documents.CollectionRef "> CollectionRef</ a > , NoneType ]</ code > </ dt >
757+ < dt id ="nitric.api.documents.CollectionGroupRef.parent "> < code class ="name "> var < span class ="ident "> parent</ span > : Optional [< a title ="nitric.api.documents.CollectionRef " href ="#nitric.api.documents.CollectionRef "> CollectionRef</ a > ]</ code > </ dt >
742758< dd >
743759< div class ="desc "> </ div >
744760</ dd >
@@ -861,7 +877,8 @@ <h3>Methods</h3>
861877< summary >
862878< span > Expand source code</ span >
863879</ summary >
864- < pre > < code class ="python "> class CollectionRef:
880+ < pre > < code class ="python "> @dataclass(frozen=True, order=True)
881+ class CollectionRef:
865882 """A reference to a collection of documents."""
866883
867884 _documents: Documents
@@ -921,7 +938,7 @@ <h3>Class variables</h3>
921938< dd >
922939< div class ="desc "> </ div >
923940</ dd >
924- < dt id ="nitric.api.documents.CollectionRef.parent "> < code class ="name "> var < span class ="ident "> parent</ span > : Union [< a title ="nitric.api.documents.DocumentRef " href ="#nitric.api.documents.DocumentRef "> DocumentRef</ a > , NoneType ]</ code > </ dt >
941+ < dt id ="nitric.api.documents.CollectionRef.parent "> < code class ="name "> var < span class ="ident "> parent</ span > : Optional [< a title ="nitric.api.documents.DocumentRef " href ="#nitric.api.documents.DocumentRef "> DocumentRef</ a > ]</ code > </ dt >
925942< dd >
926943< div class ="desc "> </ div >
927944</ dd >
@@ -1040,7 +1057,8 @@ <h3>Methods</h3>
10401057< summary >
10411058< span > Expand source code</ span >
10421059</ summary >
1043- < pre > < code class ="python "> class Document:
1060+ < pre > < code class ="python "> @dataclass(frozen=True, order=True)
1061+ class Document:
10441062 """Represents a document and any associated metadata."""
10451063
10461064 _ref: DocumentRef
@@ -1121,7 +1139,8 @@ <h3>Instance variables</h3>
11211139< summary >
11221140< span > Expand source code</ span >
11231141</ summary >
1124- < pre > < code class ="python "> class DocumentRef:
1142+ < pre > < code class ="python "> @dataclass(frozen=True, order=True)
1143+ class DocumentRef:
11251144 """A reference to a document in a collection."""
11261145
11271146 _documents: Documents
@@ -1148,7 +1167,9 @@ <h3>Instance variables</h3>
11481167 async def get(self) -> Document:
11491168 """Retrieve the contents of this document, if it exists."""
11501169 try:
1151- response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
1170+ response = await self._documents._stub.get(
1171+ document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
1172+ )
11521173 return _document_from_wire(documents=self._documents, message=response.document)
11531174 except GRPCError as grpc_err:
11541175 raise exception_from_grpc_error(grpc_err)
@@ -1161,8 +1182,10 @@ <h3>Instance variables</h3>
11611182 """
11621183 try:
11631184 await self._documents._stub.set(
1164- key=_doc_ref_to_wire(self),
1165- content=_struct_from_dict(content),
1185+ document_set_request=DocumentSetRequest(
1186+ key=_doc_ref_to_wire(self),
1187+ content=_struct_from_dict(content),
1188+ )
11661189 )
11671190 except GRPCError as grpc_err:
11681191 raise exception_from_grpc_error(grpc_err)
@@ -1171,7 +1194,9 @@ <h3>Instance variables</h3>
11711194 """Delete this document, if it exists."""
11721195 try:
11731196 await self._documents._stub.delete(
1174- key=_doc_ref_to_wire(self),
1197+ document_delete_request=DocumentDeleteRequest(
1198+ key=_doc_ref_to_wire(self),
1199+ )
11751200 )
11761201 except GRPCError as grpc_err:
11771202 raise exception_from_grpc_error(grpc_err)</ code > </ pre >
@@ -1232,7 +1257,9 @@ <h3>Methods</h3>
12321257 """Delete this document, if it exists."""
12331258 try:
12341259 await self._documents._stub.delete(
1235- key=_doc_ref_to_wire(self),
1260+ document_delete_request=DocumentDeleteRequest(
1261+ key=_doc_ref_to_wire(self),
1262+ )
12361263 )
12371264 except GRPCError as grpc_err:
12381265 raise exception_from_grpc_error(grpc_err)</ code > </ pre >
@@ -1250,7 +1277,9 @@ <h3>Methods</h3>
12501277< pre > < code class ="python "> async def get(self) -> Document:
12511278 """Retrieve the contents of this document, if it exists."""
12521279 try:
1253- response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
1280+ response = await self._documents._stub.get(
1281+ document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
1282+ )
12541283 return _document_from_wire(documents=self._documents, message=response.document)
12551284 except GRPCError as grpc_err:
12561285 raise exception_from_grpc_error(grpc_err)</ code > </ pre >
@@ -1274,8 +1303,10 @@ <h3>Methods</h3>
12741303 """
12751304 try:
12761305 await self._documents._stub.set(
1277- key=_doc_ref_to_wire(self),
1278- content=_struct_from_dict(content),
1306+ document_set_request=DocumentSetRequest(
1307+ key=_doc_ref_to_wire(self),
1308+ content=_struct_from_dict(content),
1309+ )
12791310 )
12801311 except GRPCError as grpc_err:
12811312 raise exception_from_grpc_error(grpc_err)</ code > </ pre >
@@ -1345,7 +1376,8 @@ <h3>Methods</h3>
13451376< summary >
13461377< span > Expand source code</ span >
13471378</ summary >
1348- < pre > < code class ="python "> class Expression:
1379+ < pre > < code class ="python "> @dataclass(order=True)
1380+ class Expression:
13491381 """Query expressions, representing a boolean operation used for query filters."""
13501382
13511383 operand: str
@@ -1566,9 +1598,11 @@ <h3>Class variables</h3>
15661598
15671599 try:
15681600 async for result in self._documents._stub.query_stream(
1569- collection=_collection_to_wire(self._collection),
1570- expressions=self._expressions_to_wire(),
1571- limit=self._limit,
1601+ document_query_stream_request=DocumentQueryStreamRequest(
1602+ collection=_collection_to_wire(self._collection),
1603+ expressions=self._expressions_to_wire(),
1604+ limit=self._limit,
1605+ )
15721606 ):
15731607 yield _document_from_wire(documents=self._documents, message=result.document)
15741608 except GRPCError as grpc_err:
@@ -1582,10 +1616,12 @@ <h3>Class variables</h3>
15821616 """
15831617 try:
15841618 results = await self._documents._stub.query(
1585- collection=_collection_to_wire(self._collection),
1586- expressions=self._expressions_to_wire(),
1587- limit=self._limit,
1588- paging_token=self._paging_token,
1619+ document_query_request=DocumentQueryRequest(
1620+ collection=_collection_to_wire(self._collection),
1621+ expressions=self._expressions_to_wire(),
1622+ limit=self._limit,
1623+ paging_token=self._paging_token,
1624+ )
15891625 )
15901626
15911627 return QueryResultsPage(
@@ -1642,10 +1678,12 @@ <h3>Methods</h3>
16421678 """
16431679 try:
16441680 results = await self._documents._stub.query(
1645- collection=_collection_to_wire(self._collection),
1646- expressions=self._expressions_to_wire(),
1647- limit=self._limit,
1648- paging_token=self._paging_token,
1681+ document_query_request=DocumentQueryRequest(
1682+ collection=_collection_to_wire(self._collection),
1683+ expressions=self._expressions_to_wire(),
1684+ limit=self._limit,
1685+ paging_token=self._paging_token,
1686+ )
16491687 )
16501688
16511689 return QueryResultsPage(
@@ -1712,9 +1750,11 @@ <h3>Methods</h3>
17121750
17131751 try:
17141752 async for result in self._documents._stub.query_stream(
1715- collection=_collection_to_wire(self._collection),
1716- expressions=self._expressions_to_wire(),
1717- limit=self._limit,
1753+ document_query_stream_request=DocumentQueryStreamRequest(
1754+ collection=_collection_to_wire(self._collection),
1755+ expressions=self._expressions_to_wire(),
1756+ limit=self._limit,
1757+ )
17181758 ):
17191759 yield _document_from_wire(documents=self._documents, message=result.document)
17201760 except GRPCError as grpc_err:
@@ -1799,7 +1839,8 @@ <h2 id="examples">Examples</h2>
17991839< summary >
18001840< span > Expand source code</ span >
18011841</ summary >
1802- < pre > < code class ="python "> class QueryResultsPage:
1842+ < pre > < code class ="python "> @dataclass(frozen=True, order=True)
1843+ class QueryResultsPage:
18031844 """Represents a page of results from a query."""
18041845
18051846 paging_token: any = field(default_factory=lambda: None)
0 commit comments