From c90631c11b83d425413a92e2bcc5dd3e9ab1f796 Mon Sep 17 00:00:00 2001 From: Ryan Cartwright Date: Wed, 29 Mar 2023 09:09:03 +1100 Subject: [PATCH 1/4] add support for open telemetry --- docs/nitric/api/documents.html | 125 +- docs/nitric/api/events.html | 79 +- docs/nitric/api/exception.html | 60 + docs/nitric/api/index.html | 76 +- docs/nitric/api/queues.html | 98 +- docs/nitric/api/secrets.html | 81 +- docs/nitric/api/storage.html | 294 +- docs/nitric/application.html | 310 ++ docs/nitric/config/default_settings.html | 6 +- docs/nitric/faas.html | 870 +++- docs/nitric/index.html | 15 + docs/nitric/proto/index.html | 93 + docs/nitric/proto/nitric/document/index.html | 88 + .../proto/nitric/document/v1/index.html | 1529 ++++++ docs/nitric/proto/nitric/error/index.html | 88 + docs/nitric/proto/nitric/error/v1/index.html | 227 + docs/nitric/proto/nitric/event/index.html | 88 + docs/nitric/proto/nitric/event/v1/index.html | 751 +++ docs/nitric/proto/nitric/faas/index.html | 88 + docs/nitric/proto/nitric/faas/v1/index.html | 1431 ++++++ docs/nitric/proto/nitric/index.html | 100 + docs/nitric/proto/nitric/queue/index.html | 88 + docs/nitric/proto/nitric/queue/v1/index.html | 1141 +++++ docs/nitric/proto/nitric/resource/index.html | 88 + .../proto/nitric/resource/v1/index.html | 1359 ++++++ docs/nitric/proto/nitric/secret/index.html | 88 + docs/nitric/proto/nitric/secret/v1/index.html | 683 +++ docs/nitric/proto/nitric/storage/index.html | 88 + .../nitric/proto/nitric/storage/v1/index.html | 1358 ++++++ docs/nitric/proto/validate/index.html | 4135 +++++++++++++++++ docs/nitric/resources/apis.html | 1356 ++++++ docs/nitric/resources/base.html | 354 ++ docs/nitric/resources/buckets.html | 336 ++ docs/nitric/resources/collections.html | 330 ++ docs/nitric/resources/index.html | 1600 +++++++ docs/nitric/resources/queues.html | 331 ++ docs/nitric/resources/schedules.html | 301 ++ docs/nitric/resources/secrets.html | 330 ++ docs/nitric/resources/topics.html | 352 ++ nitric/application.py | 51 + nitric/faas.py | 33 +- nitric/proto/__init__.py | 18 + nitric/proto/nitric/document/__init__.py | 18 + nitric/proto/nitric/document/v1/__init__.py | 19 + nitric/proto/nitric/error/__init__.py | 18 + nitric/proto/nitric/error/v1/__init__.py | 19 + nitric/proto/nitric/event/__init__.py | 18 + nitric/proto/nitric/event/v1/__init__.py | 19 + nitric/proto/nitric/faas/__init__.py | 18 + nitric/proto/nitric/faas/v1/__init__.py | 19 + nitric/proto/nitric/queue/__init__.py | 18 + nitric/proto/nitric/queue/v1/__init__.py | 19 + nitric/proto/nitric/resource/__init__.py | 18 + nitric/proto/nitric/resource/v1/__init__.py | 19 + nitric/proto/nitric/secret/__init__.py | 18 + nitric/proto/nitric/secret/v1/__init__.py | 19 + nitric/proto/nitric/storage/__init__.py | 18 + nitric/proto/nitric/storage/v1/__init__.py | 19 + nitric/proto/validate/__init__.py | 19 + setup.py | 7 +- 60 files changed, 20887 insertions(+), 352 deletions(-) create mode 100644 docs/nitric/application.html create mode 100644 docs/nitric/proto/index.html create mode 100644 docs/nitric/proto/nitric/document/index.html create mode 100644 docs/nitric/proto/nitric/document/v1/index.html create mode 100644 docs/nitric/proto/nitric/error/index.html create mode 100644 docs/nitric/proto/nitric/error/v1/index.html create mode 100644 docs/nitric/proto/nitric/event/index.html create mode 100644 docs/nitric/proto/nitric/event/v1/index.html create mode 100644 docs/nitric/proto/nitric/faas/index.html create mode 100644 docs/nitric/proto/nitric/faas/v1/index.html create mode 100644 docs/nitric/proto/nitric/index.html create mode 100644 docs/nitric/proto/nitric/queue/index.html create mode 100644 docs/nitric/proto/nitric/queue/v1/index.html create mode 100644 docs/nitric/proto/nitric/resource/index.html create mode 100644 docs/nitric/proto/nitric/resource/v1/index.html create mode 100644 docs/nitric/proto/nitric/secret/index.html create mode 100644 docs/nitric/proto/nitric/secret/v1/index.html create mode 100644 docs/nitric/proto/nitric/storage/index.html create mode 100644 docs/nitric/proto/nitric/storage/v1/index.html create mode 100644 docs/nitric/proto/validate/index.html create mode 100644 docs/nitric/resources/apis.html create mode 100644 docs/nitric/resources/base.html create mode 100644 docs/nitric/resources/buckets.html create mode 100644 docs/nitric/resources/collections.html create mode 100644 docs/nitric/resources/index.html create mode 100644 docs/nitric/resources/queues.html create mode 100644 docs/nitric/resources/schedules.html create mode 100644 docs/nitric/resources/secrets.html create mode 100644 docs/nitric/resources/topics.html diff --git a/docs/nitric/api/documents.html b/docs/nitric/api/documents.html index 467ccf3..cba7aa9 100644 --- a/docs/nitric/api/documents.html +++ b/docs/nitric/api/documents.html @@ -54,13 +54,18 @@

Module nitric.api.documents

from nitric.api.const import MAX_SUB_COLLECTION_DEPTH from nitric.api.exception import exception_from_grpc_error -from proto.nitric.document.v1 import ( +from nitric.proto.nitric.document.v1 import ( DocumentServiceStub, Collection as CollectionMessage, Key as KeyMessage, Expression as ExpressionMessage, ExpressionValue, Document as DocumentMessage, + DocumentSetRequest, + DocumentGetRequest, + DocumentDeleteRequest, + DocumentQueryStreamRequest, + DocumentQueryRequest, ) from nitric.utils import new_default_channel, _dict_from_struct, _struct_from_dict @@ -102,7 +107,9 @@

Module nitric.api.documents

async def get(self) -> Document: """Retrieve the contents of this document, if it exists.""" try: - response = await self._documents._stub.get(key=_doc_ref_to_wire(self)) + response = await self._documents._stub.get( + document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self)) + ) return _document_from_wire(documents=self._documents, message=response.document) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -115,8 +122,10 @@

Module nitric.api.documents

""" try: await self._documents._stub.set( - key=_doc_ref_to_wire(self), - content=_struct_from_dict(content), + document_set_request=DocumentSetRequest( + key=_doc_ref_to_wire(self), + content=_struct_from_dict(content), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -125,7 +134,9 @@

Module nitric.api.documents

"""Delete this document, if it exists.""" try: await self._documents._stub.delete( - key=_doc_ref_to_wire(self), + document_delete_request=DocumentDeleteRequest( + key=_doc_ref_to_wire(self), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -525,9 +536,11 @@

Module nitric.api.documents

try: async for result in self._documents._stub.query_stream( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, + document_query_stream_request=DocumentQueryStreamRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + ) ): yield _document_from_wire(documents=self._documents, message=result.document) except GRPCError as grpc_err: @@ -541,10 +554,12 @@

Module nitric.api.documents

""" try: results = await self._documents._stub.query( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, - paging_token=self._paging_token, + document_query_request=DocumentQueryRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + paging_token=self._paging_token, + ) ) return QueryResultsPage( @@ -674,7 +689,8 @@

Ancestors

Expand source code -
class CollectionGroupRef:
+
@dataclass(frozen=True, order=True)
+class CollectionGroupRef:
     """A reference to a collection group."""
 
     _documents: Documents
@@ -738,7 +754,7 @@ 

Class variables

-
var parent : Union[CollectionRef, NoneType]
+
var parent : Optional[CollectionRef]
@@ -861,7 +877,8 @@

Methods

Expand source code -
class CollectionRef:
+
@dataclass(frozen=True, order=True)
+class CollectionRef:
     """A reference to a collection of documents."""
 
     _documents: Documents
@@ -921,7 +938,7 @@ 

Class variables

-
var parent : Union[DocumentRef, NoneType]
+
var parent : Optional[DocumentRef]
@@ -1040,7 +1057,8 @@

Methods

Expand source code -
class Document:
+
@dataclass(frozen=True, order=True)
+class Document:
     """Represents a document and any associated metadata."""
 
     _ref: DocumentRef
@@ -1121,7 +1139,8 @@ 

Instance variables

Expand source code -
class DocumentRef:
+
@dataclass(frozen=True, order=True)
+class DocumentRef:
     """A reference to a document in a collection."""
 
     _documents: Documents
@@ -1148,7 +1167,9 @@ 

Instance variables

async def get(self) -> Document: """Retrieve the contents of this document, if it exists.""" try: - response = await self._documents._stub.get(key=_doc_ref_to_wire(self)) + response = await self._documents._stub.get( + document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self)) + ) return _document_from_wire(documents=self._documents, message=response.document) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -1161,8 +1182,10 @@

Instance variables

""" try: await self._documents._stub.set( - key=_doc_ref_to_wire(self), - content=_struct_from_dict(content), + document_set_request=DocumentSetRequest( + key=_doc_ref_to_wire(self), + content=_struct_from_dict(content), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -1171,7 +1194,9 @@

Instance variables

"""Delete this document, if it exists.""" try: await self._documents._stub.delete( - key=_doc_ref_to_wire(self), + document_delete_request=DocumentDeleteRequest( + key=_doc_ref_to_wire(self), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
@@ -1232,7 +1257,9 @@

Methods

"""Delete this document, if it exists.""" try: await self._documents._stub.delete( - key=_doc_ref_to_wire(self), + document_delete_request=DocumentDeleteRequest( + key=_doc_ref_to_wire(self), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
@@ -1250,7 +1277,9 @@

Methods

async def get(self) -> Document:
     """Retrieve the contents of this document, if it exists."""
     try:
-        response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
+        response = await self._documents._stub.get(
+            document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
+        )
         return _document_from_wire(documents=self._documents, message=response.document)
     except GRPCError as grpc_err:
         raise exception_from_grpc_error(grpc_err)
@@ -1274,8 +1303,10 @@

Methods

""" try: await self._documents._stub.set( - key=_doc_ref_to_wire(self), - content=_struct_from_dict(content), + document_set_request=DocumentSetRequest( + key=_doc_ref_to_wire(self), + content=_struct_from_dict(content), + ) ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
@@ -1345,7 +1376,8 @@

Methods

Expand source code -
class Expression:
+
@dataclass(order=True)
+class Expression:
     """Query expressions, representing a boolean operation used for query filters."""
 
     operand: str
@@ -1566,9 +1598,11 @@ 

Class variables

try: async for result in self._documents._stub.query_stream( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, + document_query_stream_request=DocumentQueryStreamRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + ) ): yield _document_from_wire(documents=self._documents, message=result.document) except GRPCError as grpc_err: @@ -1582,10 +1616,12 @@

Class variables

""" try: results = await self._documents._stub.query( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, - paging_token=self._paging_token, + document_query_request=DocumentQueryRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + paging_token=self._paging_token, + ) ) return QueryResultsPage( @@ -1642,10 +1678,12 @@

Methods

""" try: results = await self._documents._stub.query( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, - paging_token=self._paging_token, + document_query_request=DocumentQueryRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + paging_token=self._paging_token, + ) ) return QueryResultsPage( @@ -1712,9 +1750,11 @@

Methods

try: async for result in self._documents._stub.query_stream( - collection=_collection_to_wire(self._collection), - expressions=self._expressions_to_wire(), - limit=self._limit, + document_query_stream_request=DocumentQueryStreamRequest( + collection=_collection_to_wire(self._collection), + expressions=self._expressions_to_wire(), + limit=self._limit, + ) ): yield _document_from_wire(documents=self._documents, message=result.document) except GRPCError as grpc_err: @@ -1799,7 +1839,8 @@

Examples

Expand source code -
class QueryResultsPage:
+
@dataclass(frozen=True, order=True)
+class QueryResultsPage:
     """Represents a page of results from a query."""
 
     paging_token: any = field(default_factory=lambda: None)
diff --git a/docs/nitric/api/events.html b/docs/nitric/api/events.html
index d14ac05..aaca3c8 100644
--- a/docs/nitric/api/events.html
+++ b/docs/nitric/api/events.html
@@ -52,7 +52,13 @@ 

Module nitric.api.events

from nitric.api.exception import exception_from_grpc_error from nitric.utils import new_default_channel, _struct_from_dict -from proto.nitric.event.v1 import EventServiceStub, NitricEvent, TopicServiceStub +from nitric.proto.nitric.event.v1 import ( + EventServiceStub, + NitricEvent, + TopicServiceStub, + EventPublishRequest, + TopicListRequest, +) from dataclasses import dataclass, field @@ -74,7 +80,7 @@

Module nitric.api.events

@dataclass(frozen=True, order=True) -class Topic(object): +class TopicRef(object): """A reference to a topic on an event service, used to perform operations on that topic.""" _events: Events @@ -94,11 +100,12 @@

Module nitric.api.events

event = Event() if isinstance(event, dict): - # TODO: handle events that are just a payload - event = Event(**event) + event = Event(payload=event) try: - response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event)) + response = await self._events._stub.publish( + event_publish_request=EventPublishRequest(topic=self.name, event=_event_to_wire(event)) + ) return Event(**{**event.__dict__.copy(), **{"id": response.id}}) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -122,17 +129,17 @@

Module nitric.api.events

if self.channel is not None: self.channel.close() - async def topics(self) -> List[Topic]: + async def topics(self) -> List[TopicRef]: """Get a list of topics available for publishing or subscription.""" try: - response = await self._topic_stub.list() + response = await self._topic_stub.list(topic_list_request=TopicListRequest()) return [self.topic(topic.name) for topic in response.topics] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) - def topic(self, name: str) -> Topic: + def topic(self, name: str) -> TopicRef: """Return a reference to a topic.""" - return Topic(_events=self, name=name)
+ return TopicRef(_events=self, name=name)
@@ -154,7 +161,8 @@

Classes

Expand source code -
class Event(object):
+
@dataclass(frozen=True, order=True)
+class Event(object):
     """Eventing client, providing access to Topic and Event references and operations on those entities."""
 
     payload: dict = field(default_factory=dict)
@@ -206,22 +214,22 @@ 

Class variables

if self.channel is not None: self.channel.close() - async def topics(self) -> List[Topic]: + async def topics(self) -> List[TopicRef]: """Get a list of topics available for publishing or subscription.""" try: - response = await self._topic_stub.list() + response = await self._topic_stub.list(topic_list_request=TopicListRequest()) return [self.topic(topic.name) for topic in response.topics] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) - def topic(self, name: str) -> Topic: + def topic(self, name: str) -> TopicRef: """Return a reference to a topic.""" - return Topic(_events=self, name=name)
+ return TopicRef(_events=self, name=name)

Methods

-def topic(self, name: str) ‑> Topic +def topic(self, name: str) ‑> TopicRef

Return a reference to a topic.

@@ -229,13 +237,13 @@

Methods

Expand source code -
def topic(self, name: str) -> Topic:
+
def topic(self, name: str) -> TopicRef:
     """Return a reference to a topic."""
-    return Topic(_events=self, name=name)
+ return TopicRef(_events=self, name=name)
-async def topics(self) ‑> List[Topic] +async def topics(self) ‑> List[TopicRef]

Get a list of topics available for publishing or subscription.

@@ -243,10 +251,10 @@

Methods

Expand source code -
async def topics(self) -> List[Topic]:
+
async def topics(self) -> List[TopicRef]:
     """Get a list of topics available for publishing or subscription."""
     try:
-        response = await self._topic_stub.list()
+        response = await self._topic_stub.list(topic_list_request=TopicListRequest())
         return [self.topic(topic.name) for topic in response.topics]
     except GRPCError as grpc_err:
         raise exception_from_grpc_error(grpc_err)
@@ -254,8 +262,8 @@

Methods

-
-class Topic +
+class TopicRef (_events: Events, name: str)
@@ -264,7 +272,8 @@

Methods

Expand source code -
class Topic(object):
+
@dataclass(frozen=True, order=True)
+class TopicRef(object):
     """A reference to a topic on an event service, used to perform operations on that topic."""
 
     _events: Events
@@ -284,25 +293,26 @@ 

Methods

event = Event() if isinstance(event, dict): - # TODO: handle events that are just a payload - event = Event(**event) + event = Event(payload=event) try: - response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event)) + response = await self._events._stub.publish( + event_publish_request=EventPublishRequest(topic=self.name, event=_event_to_wire(event)) + ) return Event(**{**event.__dict__.copy(), **{"id": response.id}}) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)

Class variables

-
var name : str
+
var name : str

Methods

-
+
async def publish(self, event: Union[Event, dict] = None) ‑> Event
@@ -327,11 +337,12 @@

Methods

event = Event() if isinstance(event, dict): - # TODO: handle events that are just a payload - event = Event(**event) + event = Event(payload=event) try: - response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event)) + response = await self._events._stub.publish( + event_publish_request=EventPublishRequest(topic=self.name, event=_event_to_wire(event)) + ) return Event(**{**event.__dict__.copy(), **{"id": response.id}}) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
@@ -371,10 +382,10 @@

E
  • -

    Topic

    +

    TopicRef

  • diff --git a/docs/nitric/api/exception.html b/docs/nitric/api/exception.html index 9dfa6ec..adb743f 100644 --- a/docs/nitric/api/exception.html +++ b/docs/nitric/api/exception.html @@ -170,6 +170,18 @@

    Module nitric.api.exception

    pass +class NitricResourceException(Exception): + """Illegal nitric resource creation.""" + + pass + + +class NitricUnavailableException(Exception): + """Unable to connect to a nitric server.""" + + pass + + def exception_from_grpc_error(error: GRPCError): """Translate a gRPC error to a nitric api exception.""" return exception_from_grpc_code(error.status.value, error.message) @@ -445,6 +457,27 @@

    Ancestors

  • builtins.BaseException
  • +
    +class NitricResourceException +(*args, **kwargs) +
    +
    +

    Illegal nitric resource creation.

    +
    + +Expand source code + +
    class NitricResourceException(Exception):
    +    """Illegal nitric resource creation."""
    +
    +    pass
    +
    +

    Ancestors

    +
      +
    • builtins.Exception
    • +
    • builtins.BaseException
    • +
    +
    class NitricServiceException (*args, **kwargs) @@ -485,6 +518,27 @@

    Subclasses

  • UnknownException
  • +
    +class NitricUnavailableException +(*args, **kwargs) +
    +
    +

    Unable to connect to a nitric server.

    +
    + +Expand source code + +
    class NitricUnavailableException(Exception):
    +    """Unable to connect to a nitric server."""
    +
    +    pass
    +
    +

    Ancestors

    +
      +
    • builtins.Exception
    • +
    • builtins.BaseException
    • +
    +
    class NotFoundException (*args, **kwargs) @@ -723,9 +777,15 @@

    InvalidArgumentException

  • +

    NitricResourceException

    +
  • +
  • NitricServiceException

  • +

    NitricUnavailableException

    +
  • +
  • NotFoundException

  • diff --git a/docs/nitric/api/index.html b/docs/nitric/api/index.html index 5922a66..311470b 100644 --- a/docs/nitric/api/index.html +++ b/docs/nitric/api/index.html @@ -46,7 +46,7 @@

    Module nitric.api

    # limitations under the License. # """Nitric API SDK.""" -from nitric.api.events import Events, Event, Topic +from nitric.api.events import Events, Event, TopicRef from nitric.api.queues import Queues, Task, FailedTask from nitric.api.storage import Storage from nitric.api.documents import Documents @@ -60,7 +60,7 @@

    Module nitric.api

    "Event", "Task", "FailedTask", - "Topic", + "TopicRef", "Secrets", ]
  • @@ -167,7 +167,8 @@

    Methods

    Expand source code -
    class Event(object):
    +
    @dataclass(frozen=True, order=True)
    +class Event(object):
         """Eventing client, providing access to Topic and Event references and operations on those entities."""
     
         payload: dict = field(default_factory=dict)
    @@ -219,22 +220,22 @@ 

    Class variables

    if self.channel is not None: self.channel.close() - async def topics(self) -> List[Topic]: + async def topics(self) -> List[TopicRef]: """Get a list of topics available for publishing or subscription.""" try: - response = await self._topic_stub.list() + response = await self._topic_stub.list(topic_list_request=TopicListRequest()) return [self.topic(topic.name) for topic in response.topics] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) - def topic(self, name: str) -> Topic: + def topic(self, name: str) -> TopicRef: """Return a reference to a topic.""" - return Topic(_events=self, name=name)
    + return TopicRef(_events=self, name=name)

    Methods

    -def topic(self, name: str) ‑> Topic +def topic(self, name: str) ‑> TopicRef

    Return a reference to a topic.

    @@ -242,13 +243,13 @@

    Methods

    Expand source code -
    def topic(self, name: str) -> Topic:
    +
    def topic(self, name: str) -> TopicRef:
         """Return a reference to a topic."""
    -    return Topic(_events=self, name=name)
    + return TopicRef(_events=self, name=name)
    -async def topics(self) ‑> List[Topic] +async def topics(self) ‑> List[TopicRef]

    Get a list of topics available for publishing or subscription.

    @@ -256,10 +257,10 @@

    Methods

    Expand source code -
    async def topics(self) -> List[Topic]:
    +
    async def topics(self) -> List[TopicRef]:
         """Get a list of topics available for publishing or subscription."""
         try:
    -        response = await self._topic_stub.list()
    +        response = await self._topic_stub.list(topic_list_request=TopicListRequest())
             return [self.topic(topic.name) for topic in response.topics]
         except GRPCError as grpc_err:
             raise exception_from_grpc_error(grpc_err)
    @@ -277,7 +278,8 @@

    Methods

    Expand source code -
    class FailedTask(Task):
    +
    @dataclass(frozen=True, order=True)
    +class FailedTask(Task):
         """Represents a failed queue publish."""
     
         message: str = field(default="")
    @@ -319,7 +321,7 @@

    Class variables

    def queue(self, name: str): """Return a reference to a queue from the connected queue service.""" - return Queue(_queueing=self, name=name)
    + return QueueRef(_queueing=self, name=name)

    Methods

    @@ -334,7 +336,7 @@

    Methods

    def queue(self, name: str):
         """Return a reference to a queue from the connected queue service."""
    -    return Queue(_queueing=self, name=name)
    + return QueueRef(_queueing=self, name=name)
    @@ -369,7 +371,7 @@

    Methods

    def secret(self, name: str): """Return a reference to a secret container from the connected secrets management service.""" - return SecretContainer(_secrets=self, name=name)
    + return SecretContainerRef(_secrets=self, name=name)

    Methods

    @@ -384,7 +386,7 @@

    Methods

    def secret(self, name: str):
         """Return a reference to a secret container from the connected secrets management service."""
    -    return SecretContainer(_secrets=self, name=name)
    + return SecretContainerRef(_secrets=self, name=name)
    @@ -419,7 +421,7 @@

    Methods

    def bucket(self, name: str): """Return a reference to a bucket from the connected storage service.""" - return Bucket(_storage=self, name=name)
    + return BucketRef(_storage=self, name=name)

    Methods

    @@ -434,7 +436,7 @@

    Methods

    def bucket(self, name: str):
         """Return a reference to a bucket from the connected storage service."""
    -    return Bucket(_storage=self, name=name)
    + return BucketRef(_storage=self, name=name)
    @@ -449,7 +451,8 @@

    Methods

    Expand source code -
    class Task(object):
    +
    @dataclass(frozen=True, order=True)
    +class Task(object):
         """A task to be sent to a Queue."""
     
         id: str = field(default=None)
    @@ -476,8 +479,8 @@ 

    Class variables

    -
    -class Topic +
    +class TopicRef (_events: Events, name: str)
    @@ -486,7 +489,8 @@

    Class variables

    Expand source code -
    class Topic(object):
    +
    @dataclass(frozen=True, order=True)
    +class TopicRef(object):
         """A reference to a topic on an event service, used to perform operations on that topic."""
     
         _events: Events
    @@ -506,25 +510,26 @@ 

    Class variables

    event = Event() if isinstance(event, dict): - # TODO: handle events that are just a payload - event = Event(**event) + event = Event(payload=event) try: - response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event)) + response = await self._events._stub.publish( + event_publish_request=EventPublishRequest(topic=self.name, event=_event_to_wire(event)) + ) return Event(**{**event.__dict__.copy(), **{"id": response.id}}) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)

    Class variables

    -
    var name : str
    +
    var name : str

    Methods

    -
    +
    async def publish(self, event: Union[Event, dict] = None) ‑> Event
    @@ -549,11 +554,12 @@

    Methods

    event = Event() if isinstance(event, dict): - # TODO: handle events that are just a payload - event = Event(**event) + event = Event(payload=event) try: - response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event)) + response = await self._events._stub.publish( + event_publish_request=EventPublishRequest(topic=self.name, event=_event_to_wire(event)) + ) return Event(**{**event.__dict__.copy(), **{"id": response.id}}) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
    @@ -642,10 +648,10 @@

    Task

  • -

    Topic

    +

    TopicRef

  • diff --git a/docs/nitric/api/queues.html b/docs/nitric/api/queues.html index 6bf18f4..05867b7 100644 --- a/docs/nitric/api/queues.html +++ b/docs/nitric/api/queues.html @@ -52,7 +52,15 @@

    Module nitric.api.queues

    from nitric.api.exception import FailedPreconditionException, exception_from_grpc_error, InvalidArgumentException from nitric.utils import new_default_channel, _struct_from_dict, _dict_from_struct -from proto.nitric.queue.v1 import QueueServiceStub, NitricTask, FailedTask as WireFailedTask +from nitric.proto.nitric.queue.v1 import ( + QueueServiceStub, + NitricTask, + FailedTask as WireFailedTask, + QueueCompleteRequest, + QueueSendRequest, + QueueSendBatchRequest, + QueueReceiveRequest, +) from dataclasses import dataclass, field @@ -74,7 +82,7 @@

    Module nitric.api.queues

    payload: dict = field(default_factory=dict) lease_id: str = field(default=None) _queueing: Queues = field(default=None) - _queue: Queue = field(default=None) + _queue: QueueRef = field(default=None) async def complete(self): """ @@ -87,7 +95,9 @@

    Module nitric.api.queues

    "Task is missing internal client or lease id, was it returned from " "queue.receive?" ) try: - await self._queueing._queue_stub.complete(queue=self._queue.name, lease_id=self.lease_id) + await self._queueing._queue_stub.complete( + queue_complete_request=QueueCompleteRequest(queue=self._queue.name, lease_id=self.lease_id) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -113,7 +123,7 @@

    Module nitric.api.queues

    ) -def _wire_to_received_task(task: NitricTask, queueing: Queues = None, queue: Queue = None) -> ReceivedTask: +def _wire_to_received_task(task: NitricTask, queueing: Queues = None, queue: QueueRef = None) -> ReceivedTask: """ Convert a Nitric Queue Task (protobuf) to a Nitric Task (python SDK). @@ -148,7 +158,7 @@

    Module nitric.api.queues

    @dataclass(frozen=True, order=True) -class Queue(object): +class QueueRef(object): """A reference to a queue from a queue service, used to perform operations on that queue.""" _queueing: Queues @@ -177,7 +187,9 @@

    Module nitric.api.queues

    task = Task(**task) try: - await self._queueing._queue_stub.send(queue=self.name, task=_task_to_wire(task)) + await self._queueing._queue_stub.send( + queue_send_request=QueueSendRequest(queue=self.name, task=_task_to_wire(task)) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -195,7 +207,9 @@

    Module nitric.api.queues

    wire_tasks = [_task_to_wire(Task(**task) if isinstance(task, dict) else task) for task in tasks] try: - response = await self._queueing._queue_stub.send_batch(queue=self.name, tasks=wire_tasks) + response = await self._queueing._queue_stub.send_batch( + queue_send_batch_request=QueueSendBatchRequest(queue=self.name, tasks=wire_tasks) + ) return [_wire_to_failed_task(failed_task) for failed_task in response.failed_tasks] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -218,7 +232,9 @@

    Module nitric.api.queues

    limit = 1 try: - response = await self._queueing._queue_stub.receive(queue=self.name, depth=limit) + response = await self._queueing._queue_stub.receive( + queue_receive_request=QueueReceiveRequest(queue=self.name, depth=limit) + ) # Map the response protobuf response items to Python SDK Nitric Tasks return [_wire_to_received_task(task=task, queueing=self._queueing, queue=self) for task in response.tasks] except GRPCError as grpc_err: @@ -240,7 +256,7 @@

    Module nitric.api.queues

    def queue(self, name: str): """Return a reference to a queue from the connected queue service.""" - return Queue(_queueing=self, name=name)
    + return QueueRef(_queueing=self, name=name)
    @@ -262,7 +278,8 @@

    Classes

    Expand source code -
    class FailedTask(Task):
    +
    @dataclass(frozen=True, order=True)
    +class FailedTask(Task):
         """Represents a failed queue publish."""
     
         message: str = field(default="")
    @@ -279,8 +296,8 @@

    Class variables

    -
    -class Queue +
    +class QueueRef (_queueing: Queues, name: str)
    @@ -289,7 +306,8 @@

    Class variables

    Expand source code -
    class Queue(object):
    +
    @dataclass(frozen=True, order=True)
    +class QueueRef(object):
         """A reference to a queue from a queue service, used to perform operations on that queue."""
     
         _queueing: Queues
    @@ -318,7 +336,9 @@ 

    Class variables

    task = Task(**task) try: - await self._queueing._queue_stub.send(queue=self.name, task=_task_to_wire(task)) + await self._queueing._queue_stub.send( + queue_send_request=QueueSendRequest(queue=self.name, task=_task_to_wire(task)) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -336,7 +356,9 @@

    Class variables

    wire_tasks = [_task_to_wire(Task(**task) if isinstance(task, dict) else task) for task in tasks] try: - response = await self._queueing._queue_stub.send_batch(queue=self.name, tasks=wire_tasks) + response = await self._queueing._queue_stub.send_batch( + queue_send_batch_request=QueueSendBatchRequest(queue=self.name, tasks=wire_tasks) + ) return [_wire_to_failed_task(failed_task) for failed_task in response.failed_tasks] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -359,7 +381,9 @@

    Class variables

    limit = 1 try: - response = await self._queueing._queue_stub.receive(queue=self.name, depth=limit) + response = await self._queueing._queue_stub.receive( + queue_receive_request=QueueReceiveRequest(queue=self.name, depth=limit) + ) # Map the response protobuf response items to Python SDK Nitric Tasks return [_wire_to_received_task(task=task, queueing=self._queueing, queue=self) for task in response.tasks] except GRPCError as grpc_err: @@ -367,14 +391,14 @@

    Class variables

    Class variables

    -
    var name : str
    +
    var name : str

    Methods

    -
    +
    async def receive(self, limit: int = None) ‑> List[Task]
    @@ -407,14 +431,16 @@

    Methods

    limit = 1 try: - response = await self._queueing._queue_stub.receive(queue=self.name, depth=limit) + response = await self._queueing._queue_stub.receive( + queue_receive_request=QueueReceiveRequest(queue=self.name, depth=limit) + ) # Map the response protobuf response items to Python SDK Nitric Tasks return [_wire_to_received_task(task=task, queueing=self._queueing, queue=self) for task in response.tasks] except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
    -
    +
    async def send(self, tasks: Union[Task, dict, List[Union[Task, dict]]] = None) ‑> Union[Task, List[Union[TaskFailedTask]]]
    @@ -449,7 +475,9 @@

    Methods

    task = Task(**task) try: - await self._queueing._queue_stub.send(queue=self.name, task=_task_to_wire(task)) + await self._queueing._queue_stub.send( + queue_send_request=QueueSendRequest(queue=self.name, task=_task_to_wire(task)) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
    @@ -481,7 +509,7 @@

    Methods

    def queue(self, name: str): """Return a reference to a queue from the connected queue service.""" - return Queue(_queueing=self, name=name)
    + return QueueRef(_queueing=self, name=name)

    Methods

    @@ -496,7 +524,7 @@

    Methods

    def queue(self, name: str):
         """Return a reference to a queue from the connected queue service."""
    -    return Queue(_queueing=self, name=name)
    + return QueueRef(_queueing=self, name=name)
    @@ -511,7 +539,8 @@

    Methods

    Expand source code -
    class ReceivedTask(object):
    +
    @dataclass(frozen=True, order=True)
    +class ReceivedTask(object):
         """A reference to a task received from a Queue, with a lease."""
     
         id: str = field(default=None)
    @@ -519,7 +548,7 @@ 

    Methods

    payload: dict = field(default_factory=dict) lease_id: str = field(default=None) _queueing: Queues = field(default=None) - _queue: Queue = field(default=None) + _queue: QueueRef = field(default=None) async def complete(self): """ @@ -532,7 +561,9 @@

    Methods

    "Task is missing internal client or lease id, was it returned from " "queue.receive?" ) try: - await self._queueing._queue_stub.complete(queue=self._queue.name, lease_id=self.lease_id) + await self._queueing._queue_stub.complete( + queue_complete_request=QueueCompleteRequest(queue=self._queue.name, lease_id=self.lease_id) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
    @@ -578,7 +609,9 @@

    Methods

    "Task is missing internal client or lease id, was it returned from " "queue.receive?" ) try: - await self._queueing._queue_stub.complete(queue=self._queue.name, lease_id=self.lease_id) + await self._queueing._queue_stub.complete( + queue_complete_request=QueueCompleteRequest(queue=self._queue.name, lease_id=self.lease_id) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
    @@ -595,7 +628,8 @@

    Methods

    Expand source code -
    class Task(object):
    +
    @dataclass(frozen=True, order=True)
    +class Task(object):
         """A task to be sent to a Queue."""
     
         id: str = field(default=None)
    @@ -645,11 +679,11 @@ 

    Queue

    +

    QueueRef

  • diff --git a/docs/nitric/api/secrets.html b/docs/nitric/api/secrets.html index fb0f5aa..4391e42 100644 --- a/docs/nitric/api/secrets.html +++ b/docs/nitric/api/secrets.html @@ -52,7 +52,13 @@

    Module nitric.api.secrets

    from nitric.api.exception import exception_from_grpc_error from nitric.utils import new_default_channel -from proto.nitric.secret.v1 import SecretServiceStub, Secret as SecretMessage, SecretVersion as VersionMessage +from nitric.proto.nitric.secret.v1 import ( + SecretServiceStub, + Secret as SecretMessage, + SecretVersion as VersionMessage, + SecretPutRequest, + SecretAccessRequest, +) class Secrets(object): @@ -74,15 +80,15 @@

    Module nitric.api.secrets

    def secret(self, name: str): """Return a reference to a secret container from the connected secrets management service.""" - return SecretContainer(_secrets=self, name=name) + return SecretContainerRef(_secrets=self, name=name) -def _secret_to_wire(secret: SecretContainer) -> SecretMessage: +def _secret_to_wire(secret: SecretContainerRef) -> SecretMessage: return SecretMessage(name=secret.name) @dataclass(frozen=True) -class SecretContainer(object): +class SecretContainerRef(object): """A reference to a secret container, used to store and retrieve secret versions.""" _secrets: Secrets @@ -100,7 +106,9 @@

    Module nitric.api.secrets

    secret_message = _secret_to_wire(self) try: - response = await self._secrets._secrets_stub.put(secret=secret_message, value=value) + response = await self._secrets._secrets_stub.put( + secret_put_request=SecretPutRequest(secret=secret_message, value=value) + ) return self.version(version=response.secret_version.version) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -132,14 +140,16 @@

    Module nitric.api.secrets

    """A reference to a version of a secret, used to access the value of the version.""" _secrets: Secrets - secret: SecretContainer + secret: SecretContainerRef id: str async def access(self) -> SecretValue: """Return the value stored against this version of the secret.""" version_message = _secret_version_to_wire(self) try: - response = await self._secrets._secrets_stub.access(secret_version=version_message) + response = await self._secrets._secrets_stub.access( + secret_access_request=SecretAccessRequest(secret_version=version_message) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -187,8 +197,8 @@

    Module nitric.api.secrets

    Classes

    -
    -class SecretContainer +
    +class SecretContainerRef (_secrets: Secrets, name: str)
    @@ -197,7 +207,8 @@

    Classes

    Expand source code -
    class SecretContainer(object):
    +
    @dataclass(frozen=True)
    +class SecretContainerRef(object):
         """A reference to a secret container, used to store and retrieve secret versions."""
     
         _secrets: Secrets
    @@ -215,7 +226,9 @@ 

    Classes

    secret_message = _secret_to_wire(self) try: - response = await self._secrets._secrets_stub.put(secret=secret_message, value=value) + response = await self._secrets._secrets_stub.put( + secret_put_request=SecretPutRequest(secret=secret_message, value=value) + ) return self.version(version=response.secret_version.version) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -239,14 +252,14 @@

    Classes

    Class variables

    -
    var name : str
    +
    var name : str

    Methods

    -
    +
    def latest(self)
    @@ -267,7 +280,7 @@

    Methods

    return self.version("latest")
    -
    +
    async def put(self, value: Union[str, bytes]) ‑> SecretVersion
    @@ -289,13 +302,15 @@

    Methods

    secret_message = _secret_to_wire(self) try: - response = await self._secrets._secrets_stub.put(secret=secret_message, value=value) + response = await self._secrets._secrets_stub.put( + secret_put_request=SecretPutRequest(secret=secret_message, value=value) + ) return self.version(version=response.secret_version.version) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
  • -
    +
    def version(self, version: str)
    @@ -326,7 +341,8 @@

    Methods

    Expand source code -
    class SecretValue(object):
    +
    @dataclass(frozen=True)
    +class SecretValue(object):
         """Represents the value of a secret, tied to a specific version."""
     
         # The version containing this value. Never 'latest', always a specific version.
    @@ -392,7 +408,7 @@ 

    Methods

    class SecretVersion -(_secrets: Secrets, secret: SecretContainer, id: str) +(_secrets: Secrets, secret: SecretContainerRef, id: str)

    A reference to a version of a secret, used to access the value of the version.

    @@ -400,18 +416,21 @@

    Methods

    Expand source code -
    class SecretVersion(object):
    +
    @dataclass(frozen=True)
    +class SecretVersion(object):
         """A reference to a version of a secret, used to access the value of the version."""
     
         _secrets: Secrets
    -    secret: SecretContainer
    +    secret: SecretContainerRef
         id: str
     
         async def access(self) -> SecretValue:
             """Return the value stored against this version of the secret."""
             version_message = _secret_version_to_wire(self)
             try:
    -            response = await self._secrets._secrets_stub.access(secret_version=version_message)
    +            response = await self._secrets._secrets_stub.access(
    +                secret_access_request=SecretAccessRequest(secret_version=version_message)
    +            )
             except GRPCError as grpc_err:
                 raise exception_from_grpc_error(grpc_err)
     
    @@ -432,7 +451,7 @@ 

    Class variables

    -
    var secretSecretContainer
    +
    var secretSecretContainerRef
    @@ -452,7 +471,9 @@

    Methods

    """Return the value stored against this version of the secret.""" version_message = _secret_version_to_wire(self) try: - response = await self._secrets._secrets_stub.access(secret_version=version_message) + response = await self._secrets._secrets_stub.access( + secret_access_request=SecretAccessRequest(secret_version=version_message) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -500,7 +521,7 @@

    Methods

    def secret(self, name: str): """Return a reference to a secret container from the connected secrets management service.""" - return SecretContainer(_secrets=self, name=name)
    + return SecretContainerRef(_secrets=self, name=name)

    Methods

    @@ -515,7 +536,7 @@

    Methods

    def secret(self, name: str):
         """Return a reference to a secret container from the connected secrets management service."""
    -    return SecretContainer(_secrets=self, name=name)
    + return SecretContainerRef(_secrets=self, name=name)
    @@ -537,12 +558,12 @@

    Index

  • Classes

    • -

      SecretContainer

      +

      SecretContainerRef

    • diff --git a/docs/nitric/api/storage.html b/docs/nitric/api/storage.html index 8a0ec2d..9ad109b 100644 --- a/docs/nitric/api/storage.html +++ b/docs/nitric/api/storage.html @@ -47,10 +47,18 @@

      Module nitric.api.storage

      from dataclasses import dataclass from grpclib import GRPCError - -from nitric.api.exception import exception_from_grpc_error +from nitric.api.exception import exception_from_grpc_error, InvalidArgumentException from nitric.utils import new_default_channel -from proto.nitric.storage.v1 import StorageServiceStub +from nitric.proto.nitric.storage.v1 import ( + StorageServiceStub, + StoragePreSignUrlRequestOperation, + StorageWriteRequest, + StorageReadRequest, + StorageDeleteRequest, + StoragePreSignUrlRequest, + StorageListFilesRequest, +) +from enum import Enum class Storage(object): @@ -72,11 +80,11 @@

      Module nitric.api.storage

      def bucket(self, name: str): """Return a reference to a bucket from the connected storage service.""" - return Bucket(_storage=self, name=name) + return BucketRef(_storage=self, name=name) @dataclass(frozen=True, order=True) -class Bucket(object): +class BucketRef(object): """A reference to a bucket in a storage service, used to the perform operations on that bucket.""" _storage: Storage @@ -86,6 +94,29 @@

      Module nitric.api.storage

      """Return a reference to a file in this bucket.""" return File(_storage=self._storage, _bucket=self.name, key=key) + async def files(self): + """Return a list of files in this bucket.""" + resp = await self._storage._storage_stub.list_files( + storage_list_files_request=StorageListFilesRequest(bucket_name=self.name) + ) + return [self.file(f.key) for f in resp.files] + + +class FileMode(Enum): + """Definition of available operation modes for file signed URLs.""" + + READ = 0 + WRITE = 1 + + def to_request_operation(self) -> StoragePreSignUrlRequestOperation: + """Convert FileMode to a StoragePreSignUrlRequestOperation.""" + if self == FileMode.READ: + return StoragePreSignUrlRequestOperation.READ + elif self == FileMode.WRITE: + return StoragePreSignUrlRequestOperation.WRITE + else: + raise InvalidArgumentException("Invalid FileMode") + @dataclass(frozen=True, order=True) class File(object): @@ -102,14 +133,18 @@

      Module nitric.api.storage

      Will create the file if it doesn't already exist. """ try: - await self._storage._storage_stub.write(bucket_name=self._bucket, key=self.key, body=body) + await self._storage._storage_stub.write( + storage_write_request=StorageWriteRequest(bucket_name=self._bucket, key=self.key, body=body) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) async def read(self) -> bytes: """Read this files contents from the bucket.""" try: - response = await self._storage._storage_stub.read(bucket_name=self._bucket, key=self.key) + response = await self._storage._storage_stub.read( + storage_read_request=StorageReadRequest(bucket_name=self._bucket, key=self.key) + ) return response.body except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -117,7 +152,29 @@

      Module nitric.api.storage

      async def delete(self): """Delete this file from the bucket.""" try: - await self._storage._storage_stub.delete(bucket_name=self._bucket, key=self.key) + await self._storage._storage_stub.delete( + storage_delete_request=StorageDeleteRequest(bucket_name=self._bucket, key=self.key) + ) + except GRPCError as grpc_err: + raise exception_from_grpc_error(grpc_err) + + async def upload_url(self, expiry: int = 600): + """Get a temporary writable URL to this file.""" + await self.sign_url(mode=FileMode.WRITE, expiry=expiry) + + async def download_url(self, expiry: int = 600): + """Get a temporary readable URL to this file.""" + await self.sign_url(mode=FileMode.READ, expiry=expiry) + + async def sign_url(self, mode: FileMode = FileMode.READ, expiry: int = 3600): + """Generate a signed URL for reading or writing to a file.""" + try: + response = await self._storage._storage_stub.pre_sign_url( + storage_pre_sign_url_request=StoragePreSignUrlRequest( + bucket_name=self._bucket, key=self.key, operation=mode.to_request_operation(), expiry=expiry + ) + ) + return response.url except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
      @@ -131,8 +188,8 @@

      Module nitric.api.storage

      Classes

      -
      -class Bucket +
      +class BucketRef (_storage: Storage, name: str)
      @@ -141,7 +198,8 @@

      Classes

      Expand source code -
      class Bucket(object):
      +
      @dataclass(frozen=True, order=True)
      +class BucketRef(object):
           """A reference to a bucket in a storage service, used to the perform operations on that bucket."""
       
           _storage: Storage
      @@ -149,18 +207,25 @@ 

      Classes

      def file(self, key: str): """Return a reference to a file in this bucket.""" - return File(_storage=self._storage, _bucket=self.name, key=key)
      + return File(_storage=self._storage, _bucket=self.name, key=key) + + async def files(self): + """Return a list of files in this bucket.""" + resp = await self._storage._storage_stub.list_files( + storage_list_files_request=StorageListFilesRequest(bucket_name=self.name) + ) + return [self.file(f.key) for f in resp.files]

      Class variables

      -
      var name : str
      +
      var name : str

      Methods

      -
      +
      def file(self, key: str)
      @@ -174,6 +239,23 @@

      Methods

      return File(_storage=self._storage, _bucket=self.name, key=key)
      +
      +async def files(self) +
      +
      +

      Return a list of files in this bucket.

      +
      + +Expand source code + +
      async def files(self):
      +    """Return a list of files in this bucket."""
      +    resp = await self._storage._storage_stub.list_files(
      +        storage_list_files_request=StorageListFilesRequest(bucket_name=self.name)
      +    )
      +    return [self.file(f.key) for f in resp.files]
      +
      +
      @@ -186,7 +268,8 @@

      Methods

      Expand source code -
      class File(object):
      +
      @dataclass(frozen=True, order=True)
      +class File(object):
           """A reference to a file in a bucket, used to perform operations on that file."""
       
           _storage: Storage
      @@ -200,14 +283,18 @@ 

      Methods

      Will create the file if it doesn't already exist. """ try: - await self._storage._storage_stub.write(bucket_name=self._bucket, key=self.key, body=body) + await self._storage._storage_stub.write( + storage_write_request=StorageWriteRequest(bucket_name=self._bucket, key=self.key, body=body) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) async def read(self) -> bytes: """Read this files contents from the bucket.""" try: - response = await self._storage._storage_stub.read(bucket_name=self._bucket, key=self.key) + response = await self._storage._storage_stub.read( + storage_read_request=StorageReadRequest(bucket_name=self._bucket, key=self.key) + ) return response.body except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err) @@ -215,7 +302,29 @@

      Methods

      async def delete(self): """Delete this file from the bucket.""" try: - await self._storage._storage_stub.delete(bucket_name=self._bucket, key=self.key) + await self._storage._storage_stub.delete( + storage_delete_request=StorageDeleteRequest(bucket_name=self._bucket, key=self.key) + ) + except GRPCError as grpc_err: + raise exception_from_grpc_error(grpc_err) + + async def upload_url(self, expiry: int = 600): + """Get a temporary writable URL to this file.""" + await self.sign_url(mode=FileMode.WRITE, expiry=expiry) + + async def download_url(self, expiry: int = 600): + """Get a temporary readable URL to this file.""" + await self.sign_url(mode=FileMode.READ, expiry=expiry) + + async def sign_url(self, mode: FileMode = FileMode.READ, expiry: int = 3600): + """Generate a signed URL for reading or writing to a file.""" + try: + response = await self._storage._storage_stub.pre_sign_url( + storage_pre_sign_url_request=StoragePreSignUrlRequest( + bucket_name=self._bucket, key=self.key, operation=mode.to_request_operation(), expiry=expiry + ) + ) + return response.url except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
      @@ -240,11 +349,27 @@

      Methods

      async def delete(self):
           """Delete this file from the bucket."""
           try:
      -        await self._storage._storage_stub.delete(bucket_name=self._bucket, key=self.key)
      +        await self._storage._storage_stub.delete(
      +            storage_delete_request=StorageDeleteRequest(bucket_name=self._bucket, key=self.key)
      +        )
           except GRPCError as grpc_err:
               raise exception_from_grpc_error(grpc_err)
      +
      +async def download_url(self, expiry: int = 600) +
      +
      +

      Get a temporary readable URL to this file.

      +
      + +Expand source code + +
      async def download_url(self, expiry: int = 600):
      +    """Get a temporary readable URL to this file."""
      +    await self.sign_url(mode=FileMode.READ, expiry=expiry)
      +
      +
      async def read(self) ‑> bytes
      @@ -257,12 +382,50 @@

      Methods

      async def read(self) -> bytes:
           """Read this files contents from the bucket."""
           try:
      -        response = await self._storage._storage_stub.read(bucket_name=self._bucket, key=self.key)
      +        response = await self._storage._storage_stub.read(
      +            storage_read_request=StorageReadRequest(bucket_name=self._bucket, key=self.key)
      +        )
               return response.body
           except GRPCError as grpc_err:
               raise exception_from_grpc_error(grpc_err)
      +
      +async def sign_url(self, mode: FileMode = FileMode.READ, expiry: int = 3600) +
      +
      +

      Generate a signed URL for reading or writing to a file.

      +
      + +Expand source code + +
      async def sign_url(self, mode: FileMode = FileMode.READ, expiry: int = 3600):
      +    """Generate a signed URL for reading or writing to a file."""
      +    try:
      +        response = await self._storage._storage_stub.pre_sign_url(
      +            storage_pre_sign_url_request=StoragePreSignUrlRequest(
      +                bucket_name=self._bucket, key=self.key, operation=mode.to_request_operation(), expiry=expiry
      +            )
      +        )
      +        return response.url
      +    except GRPCError as grpc_err:
      +        raise exception_from_grpc_error(grpc_err)
      +
      +
      +
      +async def upload_url(self, expiry: int = 600) +
      +
      +

      Get a temporary writable URL to this file.

      +
      + +Expand source code + +
      async def upload_url(self, expiry: int = 600):
      +    """Get a temporary writable URL to this file."""
      +    await self.sign_url(mode=FileMode.WRITE, expiry=expiry)
      +
      +
      async def write(self, body: bytes)
      @@ -280,13 +443,78 @@

      Methods

      Will create the file if it doesn't already exist. """ try: - await self._storage._storage_stub.write(bucket_name=self._bucket, key=self.key, body=body) + await self._storage._storage_stub.write( + storage_write_request=StorageWriteRequest(bucket_name=self._bucket, key=self.key, body=body) + ) except GRPCError as grpc_err: raise exception_from_grpc_error(grpc_err)
      +
      +class FileMode +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
      +
      +

      Definition of available operation modes for file signed URLs.

      +
      + +Expand source code + +
      class FileMode(Enum):
      +    """Definition of available operation modes for file signed URLs."""
      +
      +    READ = 0
      +    WRITE = 1
      +
      +    def to_request_operation(self) -> StoragePreSignUrlRequestOperation:
      +        """Convert FileMode to a StoragePreSignUrlRequestOperation."""
      +        if self == FileMode.READ:
      +            return StoragePreSignUrlRequestOperation.READ
      +        elif self == FileMode.WRITE:
      +            return StoragePreSignUrlRequestOperation.WRITE
      +        else:
      +            raise InvalidArgumentException("Invalid FileMode")
      +
      +

      Ancestors

      +
        +
      • enum.Enum
      • +
      +

      Class variables

      +
      +
      var READ
      +
      +
      +
      +
      var WRITE
      +
      +
      +
      +
      +

      Methods

      +
      +
      +def to_request_operation(self) ‑> StoragePreSignUrlRequestOperation +
      +
      +

      Convert FileMode to a StoragePreSignUrlRequestOperation.

      +
      + +Expand source code + +
      def to_request_operation(self) -> StoragePreSignUrlRequestOperation:
      +    """Convert FileMode to a StoragePreSignUrlRequestOperation."""
      +    if self == FileMode.READ:
      +        return StoragePreSignUrlRequestOperation.READ
      +    elif self == FileMode.WRITE:
      +        return StoragePreSignUrlRequestOperation.WRITE
      +    else:
      +        raise InvalidArgumentException("Invalid FileMode")
      +
      +
      +
      +
      class Storage
      @@ -317,7 +545,7 @@

      Methods

      def bucket(self, name: str): """Return a reference to a bucket from the connected storage service.""" - return Bucket(_storage=self, name=name)
      + return BucketRef(_storage=self, name=name)

      Methods

      @@ -332,7 +560,7 @@

      Methods

      def bucket(self, name: str):
           """Return a reference to a bucket from the connected storage service."""
      -    return Bucket(_storage=self, name=name)
      + return BucketRef(_storage=self, name=name)
      @@ -354,22 +582,34 @@

      Index

    • Classes

      • -

        Bucket

        +

        BucketRef

      • File

        -
          +
        • +

          FileMode

          + +
        • +
        • Storage

          • bucket
          • diff --git a/docs/nitric/application.html b/docs/nitric/application.html new file mode 100644 index 0000000..6953e02 --- /dev/null +++ b/docs/nitric/application.html @@ -0,0 +1,310 @@ + + + + + + +nitric.application API documentation + + + + + + + + + + + +
            +
            +
            +

            Module nitric.application

            +
            +
            +
            + +Expand source code + +
            #
            +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
            +#
            +# This file is part of Nitric Python 3 SDK.
            +# See https://github.com/nitrictech/python-sdk for further info.
            +#
            +# Licensed under the Apache License, Version 2.0 (the "License");
            +# you may not use this file except in compliance with the License.
            +# You may obtain a copy of the License at
            +#
            +#     http://www.apache.org/licenses/LICENSE-2.0
            +#
            +# Unless required by applicable law or agreed to in writing, software
            +# distributed under the License is distributed on an "AS IS" BASIS,
            +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
            +# See the License for the specific language governing permissions and
            +# limitations under the License.
            +#
            +import asyncio
            +import os
            +
            +from opentelemetry import trace
            +from opentelemetry.sdk.trace import TracerProvider, sampling
            +from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
            +from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
            +from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
            +
            +from nitric.faas import FunctionServer
            +from nitric.api.exception import NitricUnavailableException
            +
            +# from nitric.resources.base import BaseResource
            +from typing import Dict, List, Type, Any, TypeVar
            +
            +
            +BT = TypeVar("BT")
            +
            +
            +class Nitric:
            +    """Represents a nitric app."""
            +
            +    _workers: List[FunctionServer] = []
            +    _cache: Dict[str, Dict[str, Any]] = {
            +        "api": {},
            +        "bucket": {},
            +        "topic": {},
            +        "secret": {},
            +        "queue": {},
            +        "collection": {},
            +    }
            +
            +    @classmethod
            +    def _register_worker(cls, srv: FunctionServer):
            +        """Register a worker for this application."""
            +        cls._workers.append(srv)
            +
            +    @classmethod
            +    def _create_resource(cls, resource: Type[BT], name: str, *args, **kwargs) -> BT:
            +        try:
            +            resource_type = resource.__name__.lower()
            +            if cls._cache.get(resource_type).get(name) is None:
            +                cls._cache[resource_type][name] = resource.make(name, *args, **kwargs)
            +
            +            return cls._cache[resource_type][name]
            +        except ConnectionRefusedError:
            +            raise NitricUnavailableException(
            +                'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
            +            )
            +
            +    @classmethod
            +    def _create_tracer(cls) -> TracerProvider:
            +        local_run = os.environ.OTELCOL_BIN is not None
            +        samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT        
            +
            +        # If its a local run use a console exporter, otherwise export using OTEL Protocol
            +        exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True)
            +        if local_run:
            +            exporter = ConsoleSpanExporter()
            +        
            +        provider = TracerProvider(
            +            active_span_processor=BatchSpanProcessor(exporter),
            +            sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100)
            +        )
            +        trace.set_tracer_provider(provider)
            +
            +        grpc_client_instrumentor = GrpcInstrumentorClient()
            +        grpc_client_instrumentor.instrument()
            +
            +        return provider
            +
            +    @classmethod
            +    def run(cls):
            +        """
            +        Start the nitric application.
            +
            +        This will execute in an existing event loop if there is one, otherwise it will attempt to create its own.
            +        """
            +        provider = cls._create_tracer()
            +        try:            
            +            try:
            +                loop = asyncio.get_running_loop()
            +            except RuntimeError:
            +                loop = asyncio.get_event_loop()
            +
            +            loop.run_until_complete(asyncio.gather(*[wkr.start() for wkr in cls._workers]))
            +        except KeyboardInterrupt:
            +            print("\nexiting")
            +        except ConnectionRefusedError:
            +            raise NitricUnavailableException(
            +                'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
            +            )
            +        finally:
            +            if provider is not None:
            +                provider.force_flush()
            +
            +
            +
            +
            +
            +
            +
            +
            +
            +

            Classes

            +
            +
            +class Nitric +
            +
            +

            Represents a nitric app.

            +
            + +Expand source code + +
            class Nitric:
            +    """Represents a nitric app."""
            +
            +    _workers: List[FunctionServer] = []
            +    _cache: Dict[str, Dict[str, Any]] = {
            +        "api": {},
            +        "bucket": {},
            +        "topic": {},
            +        "secret": {},
            +        "queue": {},
            +        "collection": {},
            +    }
            +
            +    @classmethod
            +    def _register_worker(cls, srv: FunctionServer):
            +        """Register a worker for this application."""
            +        cls._workers.append(srv)
            +
            +    @classmethod
            +    def _create_resource(cls, resource: Type[BT], name: str, *args, **kwargs) -> BT:
            +        try:
            +            resource_type = resource.__name__.lower()
            +            if cls._cache.get(resource_type).get(name) is None:
            +                cls._cache[resource_type][name] = resource.make(name, *args, **kwargs)
            +
            +            return cls._cache[resource_type][name]
            +        except ConnectionRefusedError:
            +            raise NitricUnavailableException(
            +                'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
            +            )
            +
            +    @classmethod
            +    def _create_tracer(cls) -> TracerProvider:
            +        local_run = os.environ.OTELCOL_BIN is not None
            +        samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT        
            +
            +        # If its a local run use a console exporter, otherwise export using OTEL Protocol
            +        exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True)
            +        if local_run:
            +            exporter = ConsoleSpanExporter()
            +        
            +        provider = TracerProvider(
            +            active_span_processor=BatchSpanProcessor(exporter),
            +            sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100)
            +        )
            +        trace.set_tracer_provider(provider)
            +
            +        grpc_client_instrumentor = GrpcInstrumentorClient()
            +        grpc_client_instrumentor.instrument()
            +
            +        return provider
            +
            +    @classmethod
            +    def run(cls):
            +        """
            +        Start the nitric application.
            +
            +        This will execute in an existing event loop if there is one, otherwise it will attempt to create its own.
            +        """
            +        provider = cls._create_tracer()
            +        try:            
            +            try:
            +                loop = asyncio.get_running_loop()
            +            except RuntimeError:
            +                loop = asyncio.get_event_loop()
            +
            +            loop.run_until_complete(asyncio.gather(*[wkr.start() for wkr in cls._workers]))
            +        except KeyboardInterrupt:
            +            print("\nexiting")
            +        except ConnectionRefusedError:
            +            raise NitricUnavailableException(
            +                'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
            +            )
            +        finally:
            +            if provider is not None:
            +                provider.force_flush()
            +
            +

            Static methods

            +
            +
            +def run() +
            +
            +

            Start the nitric application.

            +

            This will execute in an existing event loop if there is one, otherwise it will attempt to create its own.

            +
            + +Expand source code + +
            @classmethod
            +def run(cls):
            +    """
            +    Start the nitric application.
            +
            +    This will execute in an existing event loop if there is one, otherwise it will attempt to create its own.
            +    """
            +    provider = cls._create_tracer()
            +    try:            
            +        try:
            +            loop = asyncio.get_running_loop()
            +        except RuntimeError:
            +            loop = asyncio.get_event_loop()
            +
            +        loop.run_until_complete(asyncio.gather(*[wkr.start() for wkr in cls._workers]))
            +    except KeyboardInterrupt:
            +        print("\nexiting")
            +    except ConnectionRefusedError:
            +        raise NitricUnavailableException(
            +            'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
            +        )
            +    finally:
            +        if provider is not None:
            +            provider.force_flush()
            +
            +
            +
            +
            +
            +
            +
            + +
            + + + \ No newline at end of file diff --git a/docs/nitric/config/default_settings.html b/docs/nitric/config/default_settings.html index 2626ea4..38e8475 100644 --- a/docs/nitric/config/default_settings.html +++ b/docs/nitric/config/default_settings.html @@ -44,13 +44,11 @@

            Module nitric.config.default_settings

            # See the License for the specific language governing permissions and # limitations under the License. # +import os # Provides a set of default settings that env vars can replace - # Nitric Membrane Service Address -SERVICE_BIND = "127.0.0.1:50051" -# Child Process (User Code) Host Address -CHILD_ADDRESS = "127.0.0.1:8080" +SERVICE_BIND = os.environ.get('SERVICE_ADDRESS', '127.0.0.1:50051');
    • diff --git a/docs/nitric/faas.html b/docs/nitric/faas.html index d236c18..ed1be85 100644 --- a/docs/nitric/faas.html +++ b/docs/nitric/faas.html @@ -26,29 +26,70 @@

      Module nitric.faas

      Expand source code -
      from __future__ import annotations
      +
      #
      +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
      +#
      +# This file is part of Nitric Python 3 SDK.
      +# See https://github.com/nitrictech/python-sdk for further info.
      +#
      +# Licensed under the Apache License, Version 2.0 (the "License");
      +# you may not use this file except in compliance with the License.
      +# You may obtain a copy of the License at
      +#
      +#     http://www.apache.org/licenses/LICENSE-2.0
      +#
      +# Unless required by applicable law or agreed to in writing, software
      +# distributed under the License is distributed on an "AS IS" BASIS,
      +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      +# See the License for the specific language governing permissions and
      +# limitations under the License.
      +#
      +from __future__ import annotations
      +from enum import Enum
       
       import functools
       import json
       import traceback
      -from typing import Dict, Union, List, TypeVar, Callable, Coroutine, Any
      +from typing import Dict, Union, List, TypeVar, Callable, Coroutine, Any, Optional
      +from opentelemetry import context, propagate
       
       import betterproto
       from betterproto.grpc.util.async_channel import AsyncChannel
       from nitric.utils import new_default_channel
      -from proto.nitric.faas.v1 import (
      +from nitric.proto.nitric.faas.v1 import (
           FaasServiceStub,
           InitRequest,
           ClientMessage,
           TriggerRequest,
           TriggerResponse,
      +    HeaderValue,
           HttpResponseContext,
           TopicResponseContext,
      +    ScheduleWorker,
      +    ApiWorker,
      +    SubscriptionWorker,
      +    ScheduleRate,
       )
      +import grpclib
       import asyncio
       from abc import ABC
       
       Record = Dict[str, Union[str, List[str]]]
      +PROPAGATOR = propagate.get_global_textmap()
      +
      +
      +class HttpMethod(Enum):
      +    """Valid query expression operators."""
      +
      +    GET = "GET"
      +    POST = "POST"
      +    PUT = "PUT"
      +    DELETE = "DELETE"
      +    PATCH = "PATCH"
      +    OPTIONS = "OPTIONS"
      +
      +    def __str__(self):
      +        return str(self.value)
       
       
       class Request(ABC):
      @@ -98,12 +139,13 @@ 

      Module nitric.faas

      """ if ctx.http(): ctx = ctx.http() + headers = {k: HeaderValue(value=v) for (k, v) in ctx.res.headers.items()} + headers_old = {k: v[0] for (k, v) in ctx.res.headers.items()} + data = ctx.res.body if ctx.res.body else bytes() + return TriggerResponse( - data=ctx.res.body, - http=HttpResponseContext( - status=ctx.res.status, - headers=ctx.res.headers, - ), + data=data, + http=HttpResponseContext(status=ctx.res.status, headers=headers, headers_old=headers_old), ) elif ctx.event(): ctx = ctx.event() @@ -122,13 +164,34 @@

      Module nitric.faas

      class HttpRequest(Request): """Represents a translated Http Request forwarded from the Nitric Membrane.""" - def __init__(self, data: bytes, method: str, path: str, query: Record, headers: Record): + def __init__( + self, + data: bytes, + method: str, + path: str, + params: Dict[str, str], + query: Record, + headers: Record, + trace_context: Dict[str, str], + ): """Construct a new HttpRequest.""" super().__init__(data) self.method = method self.path = path + self.params = params self.query = query self.headers = headers + self.trace_context = trace_context + + @property + def json(self) -> Optional[Any]: + """Get the body of the request as JSON, returns None if request body is not JSON.""" + try: + return json.loads(self.body) + except json.JSONDecodeError: + return None + except TypeError: + return None @property def body(self): @@ -137,13 +200,28 @@

      Module nitric.faas

      class HttpResponse(Response): - """Represents an Http Response to be generated by the Nitric Membrane in response to an Http Request Trigger.""" + """Represents an HTTP Response to be generated by the Nitric Membrane in response to an HTTP Request Trigger.""" def __init__(self, status: int = 200, headers: Record = None, body: bytes = None): """Construct a new HttpResponse.""" self.status = status self.headers = headers if headers else {} - self.body = body if body else bytes() + self._body = body if body else bytes() + + @property + def body(self): + """Return the HTTP response body.""" + return self._body + + @body.setter + def body(self, value: Union[str, bytes, Any]): + if isinstance(value, str): + self._body = value.encode("utf-8") + elif isinstance(value, bytes): + self._body = value + else: + self._body = json.dumps(value).encode("utf-8") + self.headers["Content-Type"] = ["application/json"] class HttpContext(TriggerContext): @@ -163,31 +241,36 @@

      Module nitric.faas

      def from_grpc_trigger_request(trigger_request: TriggerRequest) -> HttpContext: """Construct a new HttpContext from an Http trigger from the Nitric Membrane.""" if len(trigger_request.http.headers.keys()) > 0: - headers = {k: v[0].value for (k, v) in trigger_request.http.headers.items()} + headers = {k: v.value for (k, v) in trigger_request.http.headers.items()} else: headers = trigger_request.http.headers_old + if len(trigger_request.http.query_params.keys()) > 0: + query = {k: v.value for (k, v) in trigger_request.http.query_params.items()} + else: + query = trigger_request.http.query_params_old + return HttpContext( request=HttpRequest( data=trigger_request.data, method=trigger_request.http.method, - query=trigger_request.http.query_params, + query=query, path=trigger_request.http.path, + params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, + trace_context=trigger_request.trace_context, ) ) -# ====== Events ====== - - class EventRequest(Request): """Represents a translated Event, from a Subscribed Topic, forwarded from the Nitric Membrane.""" - def __init__(self, data: bytes, topic: str): + def __init__(self, data: bytes, topic: str, trace_context: Dict[str, str]): """Construct a new EventRequest.""" super().__init__(data) self.topic = topic + self.trace_context = trace_context @property def payload(self) -> bytes: @@ -219,7 +302,13 @@

      Module nitric.faas

      @staticmethod def from_grpc_trigger_request(trigger_request: TriggerRequest): """Construct a new EventContext from an Event trigger from the Nitric Membrane.""" - return EventContext(request=EventRequest(data=trigger_request.data, topic=trigger_request.topic.topic)) + return EventContext( + request=EventRequest( + data=trigger_request.data, + topic=trigger_request.topic.topic, + trace_context=trigger_request.trace_context, + ) + ) # async def face(inpp: int) -> str: @@ -231,11 +320,11 @@

      Module nitric.faas

      C = TypeVar("C", TriggerContext, HttpContext, EventContext) Middleware = Callable Handler = Coroutine[Any, Any, C] -HttpHandler = Coroutine[Any, Any, HttpContext] -EventHandler = Coroutine[Any, Any, EventContext] +HttpHandler = Coroutine[Any, Any, Optional[HttpContext]] +EventHandler = Coroutine[Any, Any, Optional[EventContext]] Middleware = Callable[[C, Middleware], Handler] -# HttpMiddleware = Middleware[[HttpContext, Middleware], HttpHandler] -# EventMiddleware = Middleware[[EventContext, Middleware], EventHandler] +HttpMiddleware = Callable[[HttpContext, HttpHandler], HttpHandler] +EventMiddleware = Callable[[EventContext, EventHandler], EventHandler] def compose_middleware(*middlewares: Union[Middleware, List[Middleware]]) -> Middleware: @@ -245,16 +334,33 @@

      Module nitric.faas

      The resulting middleware will effectively be a chain of the provided middleware, where each calls the next in the chain when they're successful. """ + middlewares = list(middlewares) if len(middlewares) == 1 and not isinstance(middlewares[0], list): return middlewares[0] middlewares = [compose_middleware(m) if isinstance(m, list) else m for m in middlewares] async def handler(ctx, next_middleware=lambda ctx: ctx): - middleware_chain = functools.reduce( - lambda acc_next, cur: lambda context: cur(context, acc_next), reversed(middlewares + (next_middleware,)) - ) - return middleware_chain(ctx) + def reduce_chain(acc_next, cur): + async def chained_middleware(context): + # Count the positional arguments to determine if the function is a handler or middleware. + all_args = cur.__code__.co_argcount + kwargs = len(cur.__defaults__) if cur.__defaults__ is not None else 0 + pos_args = all_args - kwargs + if pos_args == 2: + # Call the middleware with next and return the result + return ( + (await cur(context, acc_next)) if asyncio.iscoroutinefunction(cur) else cur(context, acc_next) + ) + else: + # Call the handler with ctx only, then call the remainder of the middleware chain + result = (await cur(context)) if asyncio.iscoroutinefunction(cur) else cur(context) + return (await acc_next(result)) if asyncio.iscoroutinefunction(acc_next) else acc_next(result) + + return chained_middleware + + middleware_chain = functools.reduce(reduce_chain, reversed(middlewares + [next_middleware])) + return await middleware_chain(ctx) return handler @@ -273,14 +379,86 @@

      Module nitric.faas

      raise Exception(f"Unknown trigger type: {context_type}, unable to generate expected response") +class ApiWorkerOptions: + """Options for API workers.""" + + def __init__(self, api: str, route: str, methods: List[Union[str, HttpMethod]], opts: MethodOptions): + """Construct a new options object.""" + self.api = api + self.route = route + self.methods = [str(method) for method in methods] + self.opts = opts + + +class RateWorkerOptions: + """Options for rate workers.""" + + description: str + rate: int + frequency: Frequency + + def __init__(self, description: str, rate: int, frequency: Frequency): + """Construct a new options object.""" + self.description = description + self.rate = rate + self.frequency = frequency + + +class SubscriptionWorkerOptions: + """Options for subscription workers.""" + + def __init__(self, topic: str): + """Construct a new options object.""" + self.topic = topic + + +class Frequency(Enum): + """Valid schedule frequencies.""" + + seconds = "seconds" + minutes = "minutes" + hours = "hours" + days = "days" + + @staticmethod + def from_str(value: str) -> Frequency: + """Convert a string frequency value to a Frequency.""" + return Frequency[value.strip().lower()] + + @staticmethod + def as_str_list() -> List[str]: + """Return all frequency values as a list of strings.""" + return [str(frequency.value) for frequency in Frequency] + + +class MethodOptions: + """Represents options when defining a method handler.""" + + security: dict[str, List[str]] + + def __init__(self, security: dict[str, List[str]] = None): + """Construct a new HTTP method options object.""" + self.security = security + + +class FaasWorkerOptions: + """Empty worker options for generic function handlers.""" + + pass + + +FaasClientOptions = Union[ApiWorkerOptions, RateWorkerOptions, SubscriptionWorkerOptions, FaasWorkerOptions] + + class FunctionServer: """A Function as a Service server, which acts as a faas handler for the Nitric Membrane.""" - def __init__(self): + def __init__(self, opts: FaasClientOptions): """Construct a new function server.""" self.__http_handler = None self.__event_handler = None self._any_handler = None + self._opts = opts def http(self, *handlers: Union[Middleware, List[Middleware]]) -> FunctionServer: """ @@ -300,14 +478,13 @@

      Module nitric.faas

      self.__event_handler = compose_middleware(*handlers) return self - def start(self, *handlers: Union[Middleware, List[Middleware]]): + async def start(self, *handlers: Union[Middleware, List[Middleware]]): """Start the function server using the provided trigger handlers.""" self._any_handler = compose_middleware(*handlers) if len(handlers) > 0 else None - # TODO: implement the server if not self._any_handler and not self._http_handler and not self._event_handler: raise Exception("At least one handler function must be provided.") - asyncio.run(self.run()) + await self._run() @property def _http_handler(self): @@ -317,14 +494,31 @@

      Module nitric.faas

      def _event_handler(self): return self.__event_handler if self.__event_handler else self._any_handler - async def run(self): + async def _run(self): """Register a new FaaS worker with the Membrane, using the provided function as the handler.""" channel = new_default_channel() client = FaasServiceStub(channel) request_channel = AsyncChannel(close=True) # We can start be sending all the requests we already have try: - await request_channel.send(ClientMessage(init_request=InitRequest())) + init_request = InitRequest() + # Construct init request based on API worker options + if isinstance(self._opts, ApiWorkerOptions): + init_request = InitRequest( + api=ApiWorker(api=self._opts.api, path=self._opts.route, methods=self._opts.methods) + ) + elif isinstance(self._opts, RateWorkerOptions): + # TODO: Populate rate + init_request = InitRequest( + schedule=ScheduleWorker( + key=self._opts.description, rate=ScheduleRate(rate=f"{self._opts.rate} {self._opts.frequency}") + ) + ) + elif isinstance(self._opts, SubscriptionWorkerOptions): + init_request = InitRequest(subscription=SubscriptionWorker(topic=self._opts.topic)) + + # let the membrane server know we're ready to start + await request_channel.send(ClientMessage(init_request=init_request)) async for srv_msg in client.trigger_stream(request_channel): # The response iterator will remain active until the connection is closed msg_type, val = betterproto.which_one_of(srv_msg, "content") @@ -338,13 +532,21 @@

      Module nitric.faas

      ctx = _ctx_from_grpc_trigger_request(srv_msg.trigger_request) try: + if len(ctx.req.trace_context) > 0: + context.attach(PROPAGATOR().extract(ctx.req.trace_context)) + if ctx.http(): func = self._http_handler elif ctx.event(): func = self._event_handler else: func = self._any_handler + response_ctx = (await func(ctx)) if asyncio.iscoroutinefunction(func) else func(ctx) + + if response_ctx is None: + response_ctx = ctx + # Send function response back to server await request_channel.send( ClientMessage( @@ -364,6 +566,11 @@

      Module nitric.faas

      continue if request_channel.done(): break + except grpclib.exceptions.StreamTerminatedError: + print("stream from Membrane closed, closing client stream") + except asyncio.CancelledError: + # Membrane has closed stream after init + print("stream from Membrane closed, closing client stream") except ConnectionRefusedError as cre: traceback.print_exc() raise ConnectionRefusedError("Failed to register function with Membrane") from cre @@ -371,7 +578,6 @@

      Module nitric.faas

      traceback.print_exc() raise Exception("An unexpected error occurred.") from e finally: - print("stream from Membrane closed, closing client stream") # The channel must be closed to complete the gRPC connection request_channel.close() channel.close() @@ -386,7 +592,7 @@

      Module nitric.faas

      When multiple handlers are provided, they will be called in order. """ - return FunctionServer().http(*handlers) + return FunctionServer(opts=[]).http(*handlers) def event(*handlers: Union[Middleware, List[Middleware]]) -> FunctionServer: @@ -395,14 +601,14 @@

      Module nitric.faas

      When multiple handlers are provided, they will be called in order. """ - return FunctionServer().event(*handlers) + return FunctionServer(opts=[]).event(*handlers) def start(*handlers: Union[Middleware, List[Middleware]]): """Create a new Function Server and start it using the provided trigger handlers.""" if len(handlers) < 1: raise Exception("At least one handler must be provided.") - return FunctionServer().start(*handlers)
      + return FunctionServer(opts=[]).start(*handlers)
      @@ -430,16 +636,33 @@

      Functions

      The resulting middleware will effectively be a chain of the provided middleware, where each calls the next in the chain when they're successful. """ + middlewares = list(middlewares) if len(middlewares) == 1 and not isinstance(middlewares[0], list): return middlewares[0] middlewares = [compose_middleware(m) if isinstance(m, list) else m for m in middlewares] async def handler(ctx, next_middleware=lambda ctx: ctx): - middleware_chain = functools.reduce( - lambda acc_next, cur: lambda context: cur(context, acc_next), reversed(middlewares + (next_middleware,)) - ) - return middleware_chain(ctx) + def reduce_chain(acc_next, cur): + async def chained_middleware(context): + # Count the positional arguments to determine if the function is a handler or middleware. + all_args = cur.__code__.co_argcount + kwargs = len(cur.__defaults__) if cur.__defaults__ is not None else 0 + pos_args = all_args - kwargs + if pos_args == 2: + # Call the middleware with next and return the result + return ( + (await cur(context, acc_next)) if asyncio.iscoroutinefunction(cur) else cur(context, acc_next) + ) + else: + # Call the handler with ctx only, then call the remainder of the middleware chain + result = (await cur(context)) if asyncio.iscoroutinefunction(cur) else cur(context) + return (await acc_next(result)) if asyncio.iscoroutinefunction(acc_next) else acc_next(result) + + return chained_middleware + + middleware_chain = functools.reduce(reduce_chain, reversed(middlewares + [next_middleware])) + return await middleware_chain(ctx) return handler @@ -460,7 +683,7 @@

      Functions

      When multiple handlers are provided, they will be called in order. """ - return FunctionServer().event(*handlers) + return FunctionServer(opts=[]).event(*handlers)
      @@ -479,7 +702,7 @@

      Functions

      When multiple handlers are provided, they will be called in order. """ - return FunctionServer().http(*handlers)
      + return FunctionServer(opts=[]).http(*handlers)
      @@ -495,7 +718,7 @@

      Functions

      """Create a new Function Server and start it using the provided trigger handlers.""" if len(handlers) < 1: raise Exception("At least one handler must be provided.") - return FunctionServer().start(*handlers)
      + return FunctionServer(opts=[]).start(*handlers) @@ -503,6 +726,28 @@

      Functions

      Classes

      +
      +class ApiWorkerOptions +(api: str, route: str, methods: List[Union[str, HttpMethod]], opts: MethodOptions) +
      +
      +

      Options for API workers.

      +

      Construct a new options object.

      +
      + +Expand source code + +
      class ApiWorkerOptions:
      +    """Options for API workers."""
      +
      +    def __init__(self, api: str, route: str, methods: List[Union[str, HttpMethod]], opts: MethodOptions):
      +        """Construct a new options object."""
      +        self.api = api
      +        self.route = route
      +        self.methods = [str(method) for method in methods]
      +        self.opts = opts
      +
      +
      class EventContext (request: EventRequest, response: EventResponse = None) @@ -530,7 +775,13 @@

      Classes

      @staticmethod def from_grpc_trigger_request(trigger_request: TriggerRequest): """Construct a new EventContext from an Event trigger from the Nitric Membrane.""" - return EventContext(request=EventRequest(data=trigger_request.data, topic=trigger_request.topic.topic))
      + return EventContext( + request=EventRequest( + data=trigger_request.data, + topic=trigger_request.topic.topic, + trace_context=trigger_request.trace_context, + ) + )

      Ancestors

        @@ -551,7 +802,13 @@

        Static methods

        @staticmethod
         def from_grpc_trigger_request(trigger_request: TriggerRequest):
             """Construct a new EventContext from an Event trigger from the Nitric Membrane."""
        -    return EventContext(request=EventRequest(data=trigger_request.data, topic=trigger_request.topic.topic))
        + return EventContext( + request=EventRequest( + data=trigger_request.data, + topic=trigger_request.topic.topic, + trace_context=trigger_request.trace_context, + ) + )
      @@ -583,7 +840,7 @@

      Inherited members

      class EventRequest -(data: bytes, topic: str) +(data: bytes, topic: str, trace_context: Dict[str, str])

      Represents a translated Event, from a Subscribed Topic, forwarded from the Nitric Membrane.

      @@ -595,10 +852,11 @@

      Inherited members

      class EventRequest(Request):
           """Represents a translated Event, from a Subscribed Topic, forwarded from the Nitric Membrane."""
       
      -    def __init__(self, data: bytes, topic: str):
      +    def __init__(self, data: bytes, topic: str, trace_context: Dict[str, str]):
               """Construct a new EventRequest."""
               super().__init__(data)
               self.topic = topic
      +        self.trace_context = trace_context
       
           @property
           def payload(self) -> bytes:
      @@ -651,8 +909,109 @@ 

      Ancestors

    • abc.ABC
    +
    +class FaasWorkerOptions +
    +
    +

    Empty worker options for generic function handlers.

    +
    + +Expand source code + +
    class FaasWorkerOptions:
    +    """Empty worker options for generic function handlers."""
    +
    +    pass
    +
    +
    +
    +class Frequency +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
    +
    +

    Valid schedule frequencies.

    +
    + +Expand source code + +
    class Frequency(Enum):
    +    """Valid schedule frequencies."""
    +
    +    seconds = "seconds"
    +    minutes = "minutes"
    +    hours = "hours"
    +    days = "days"
    +
    +    @staticmethod
    +    def from_str(value: str) -> Frequency:
    +        """Convert a string frequency value to a Frequency."""
    +        return Frequency[value.strip().lower()]
    +
    +    @staticmethod
    +    def as_str_list() -> List[str]:
    +        """Return all frequency values as a list of strings."""
    +        return [str(frequency.value) for frequency in Frequency]
    +
    +

    Ancestors

    +
      +
    • enum.Enum
    • +
    +

    Class variables

    +
    +
    var days
    +
    +
    +
    +
    var hours
    +
    +
    +
    +
    var minutes
    +
    +
    +
    +
    var seconds
    +
    +
    +
    +
    +

    Static methods

    +
    +
    +def as_str_list() ‑> List[str] +
    +
    +

    Return all frequency values as a list of strings.

    +
    + +Expand source code + +
    @staticmethod
    +def as_str_list() -> List[str]:
    +    """Return all frequency values as a list of strings."""
    +    return [str(frequency.value) for frequency in Frequency]
    +
    +
    +
    +def from_str(value: str) ‑> Frequency +
    +
    +

    Convert a string frequency value to a Frequency.

    +
    + +Expand source code + +
    @staticmethod
    +def from_str(value: str) -> Frequency:
    +    """Convert a string frequency value to a Frequency."""
    +    return Frequency[value.strip().lower()]
    +
    +
    +
    +
    class FunctionServer +(opts: FaasClientOptions)

    A Function as a Service server, which acts as a faas handler for the Nitric Membrane.

    @@ -664,11 +1023,12 @@

    Ancestors

    class FunctionServer:
         """A Function as a Service server, which acts as a faas handler for the Nitric Membrane."""
     
    -    def __init__(self):
    +    def __init__(self, opts: FaasClientOptions):
             """Construct a new function server."""
             self.__http_handler = None
             self.__event_handler = None
             self._any_handler = None
    +        self._opts = opts
     
         def http(self, *handlers: Union[Middleware, List[Middleware]]) -> FunctionServer:
             """
    @@ -688,14 +1048,13 @@ 

    Ancestors

    self.__event_handler = compose_middleware(*handlers) return self - def start(self, *handlers: Union[Middleware, List[Middleware]]): + async def start(self, *handlers: Union[Middleware, List[Middleware]]): """Start the function server using the provided trigger handlers.""" self._any_handler = compose_middleware(*handlers) if len(handlers) > 0 else None - # TODO: implement the server if not self._any_handler and not self._http_handler and not self._event_handler: raise Exception("At least one handler function must be provided.") - asyncio.run(self.run()) + await self._run() @property def _http_handler(self): @@ -705,14 +1064,31 @@

    Ancestors

    def _event_handler(self): return self.__event_handler if self.__event_handler else self._any_handler - async def run(self): + async def _run(self): """Register a new FaaS worker with the Membrane, using the provided function as the handler.""" channel = new_default_channel() client = FaasServiceStub(channel) request_channel = AsyncChannel(close=True) # We can start be sending all the requests we already have try: - await request_channel.send(ClientMessage(init_request=InitRequest())) + init_request = InitRequest() + # Construct init request based on API worker options + if isinstance(self._opts, ApiWorkerOptions): + init_request = InitRequest( + api=ApiWorker(api=self._opts.api, path=self._opts.route, methods=self._opts.methods) + ) + elif isinstance(self._opts, RateWorkerOptions): + # TODO: Populate rate + init_request = InitRequest( + schedule=ScheduleWorker( + key=self._opts.description, rate=ScheduleRate(rate=f"{self._opts.rate} {self._opts.frequency}") + ) + ) + elif isinstance(self._opts, SubscriptionWorkerOptions): + init_request = InitRequest(subscription=SubscriptionWorker(topic=self._opts.topic)) + + # let the membrane server know we're ready to start + await request_channel.send(ClientMessage(init_request=init_request)) async for srv_msg in client.trigger_stream(request_channel): # The response iterator will remain active until the connection is closed msg_type, val = betterproto.which_one_of(srv_msg, "content") @@ -726,13 +1102,21 @@

    Ancestors

    ctx = _ctx_from_grpc_trigger_request(srv_msg.trigger_request) try: + if len(ctx.req.trace_context) > 0: + context.attach(PROPAGATOR().extract(ctx.req.trace_context)) + if ctx.http(): func = self._http_handler elif ctx.event(): func = self._event_handler else: func = self._any_handler + response_ctx = (await func(ctx)) if asyncio.iscoroutinefunction(func) else func(ctx) + + if response_ctx is None: + response_ctx = ctx + # Send function response back to server await request_channel.send( ClientMessage( @@ -752,6 +1136,11 @@

    Ancestors

    continue if request_channel.done(): break + except grpclib.exceptions.StreamTerminatedError: + print("stream from Membrane closed, closing client stream") + except asyncio.CancelledError: + # Membrane has closed stream after init + print("stream from Membrane closed, closing client stream") except ConnectionRefusedError as cre: traceback.print_exc() raise ConnectionRefusedError("Failed to register function with Membrane") from cre @@ -759,7 +1148,6 @@

    Ancestors

    traceback.print_exc() raise Exception("An unexpected error occurred.") from e finally: - print("stream from Membrane closed, closing client stream") # The channel must be closed to complete the gRPC connection request_channel.close() channel.close()
    @@ -806,77 +1194,8 @@

    Methods

    return self
    -
    -async def run(self) -
    -
    -

    Register a new FaaS worker with the Membrane, using the provided function as the handler.

    -
    - -Expand source code - -
    async def run(self):
    -    """Register a new FaaS worker with the Membrane, using the provided function as the handler."""
    -    channel = new_default_channel()
    -    client = FaasServiceStub(channel)
    -    request_channel = AsyncChannel(close=True)
    -    # We can start be sending all the requests we already have
    -    try:
    -        await request_channel.send(ClientMessage(init_request=InitRequest()))
    -        async for srv_msg in client.trigger_stream(request_channel):
    -            # The response iterator will remain active until the connection is closed
    -            msg_type, val = betterproto.which_one_of(srv_msg, "content")
    -
    -            if msg_type == "init_response":
    -                print("function connected to Membrane")
    -                # We don't need to reply
    -                # proceed to the next available message
    -                continue
    -            if msg_type == "trigger_request":
    -                ctx = _ctx_from_grpc_trigger_request(srv_msg.trigger_request)
    -
    -                try:
    -                    if ctx.http():
    -                        func = self._http_handler
    -                    elif ctx.event():
    -                        func = self._event_handler
    -                    else:
    -                        func = self._any_handler
    -                    response_ctx = (await func(ctx)) if asyncio.iscoroutinefunction(func) else func(ctx)
    -                    # Send function response back to server
    -                    await request_channel.send(
    -                        ClientMessage(
    -                            id=srv_msg.id,
    -                            trigger_response=_grpc_response_from_ctx(response_ctx),
    -                        )
    -                    )
    -                except Exception:
    -                    # Any unhandled exceptions in the above code will end the loop
    -                    # and stop processing future triggers, we catch them here as a last resort.
    -                    print("An unexpected error occurred processing trigger or response")
    -                    traceback.print_exc()
    -                    response = _create_internal_error_response(srv_msg.trigger_request)
    -                    await request_channel.send(ClientMessage(id=srv_msg.id, trigger_response=response))
    -            else:
    -                print(f"unhandled message type {msg_type}, skipping")
    -                continue
    -            if request_channel.done():
    -                break
    -    except ConnectionRefusedError as cre:
    -        traceback.print_exc()
    -        raise ConnectionRefusedError("Failed to register function with Membrane") from cre
    -    except Exception as e:
    -        traceback.print_exc()
    -        raise Exception("An unexpected error occurred.") from e
    -    finally:
    -        print("stream from Membrane closed, closing client stream")
    -        # The channel must be closed to complete the gRPC connection
    -        request_channel.close()
    -        channel.close()
    -
    -
    -def start(self, *handlers: Union[Middleware, List[Middleware]]) +async def start(self, *handlers: Union[Middleware, List[Middleware]])

    Start the function server using the provided trigger handlers.

    @@ -884,14 +1203,13 @@

    Methods

    Expand source code -
    def start(self, *handlers: Union[Middleware, List[Middleware]]):
    +
    async def start(self, *handlers: Union[Middleware, List[Middleware]]):
         """Start the function server using the provided trigger handlers."""
         self._any_handler = compose_middleware(*handlers) if len(handlers) > 0 else None
    -    # TODO: implement the server
         if not self._any_handler and not self._http_handler and not self._event_handler:
             raise Exception("At least one handler function must be provided.")
     
    -    asyncio.run(self.run())
    + await self._run()
    @@ -924,17 +1242,24 @@

    Methods

    def from_grpc_trigger_request(trigger_request: TriggerRequest) -> HttpContext: """Construct a new HttpContext from an Http trigger from the Nitric Membrane.""" if len(trigger_request.http.headers.keys()) > 0: - headers = {k: v[0].value for (k, v) in trigger_request.http.headers.items()} + headers = {k: v.value for (k, v) in trigger_request.http.headers.items()} else: headers = trigger_request.http.headers_old + if len(trigger_request.http.query_params.keys()) > 0: + query = {k: v.value for (k, v) in trigger_request.http.query_params.items()} + else: + query = trigger_request.http.query_params_old + return HttpContext( request=HttpRequest( data=trigger_request.data, method=trigger_request.http.method, - query=trigger_request.http.query_params, + query=query, path=trigger_request.http.path, + params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, + trace_context=trigger_request.trace_context, ) ) @@ -958,17 +1283,24 @@

    Static methods

    def from_grpc_trigger_request(trigger_request: TriggerRequest) -> HttpContext: """Construct a new HttpContext from an Http trigger from the Nitric Membrane.""" if len(trigger_request.http.headers.keys()) > 0: - headers = {k: v[0].value for (k, v) in trigger_request.http.headers.items()} + headers = {k: v.value for (k, v) in trigger_request.http.headers.items()} else: headers = trigger_request.http.headers_old + if len(trigger_request.http.query_params.keys()) > 0: + query = {k: v.value for (k, v) in trigger_request.http.query_params.items()} + else: + query = trigger_request.http.query_params_old + return HttpContext( request=HttpRequest( data=trigger_request.data, method=trigger_request.http.method, - query=trigger_request.http.query_params, + query=query, path=trigger_request.http.path, + params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, + trace_context=trigger_request.trace_context, ) ) @@ -1000,9 +1332,64 @@

    Inherited members

  • +
    +class HttpMethod +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
    +
    +

    Valid query expression operators.

    +
    + +Expand source code + +
    class HttpMethod(Enum):
    +    """Valid query expression operators."""
    +
    +    GET = "GET"
    +    POST = "POST"
    +    PUT = "PUT"
    +    DELETE = "DELETE"
    +    PATCH = "PATCH"
    +    OPTIONS = "OPTIONS"
    +
    +    def __str__(self):
    +        return str(self.value)
    +
    +

    Ancestors

    +
      +
    • enum.Enum
    • +
    +

    Class variables

    +
    +
    var DELETE
    +
    +
    +
    +
    var GET
    +
    +
    +
    +
    var OPTIONS
    +
    +
    +
    +
    var PATCH
    +
    +
    +
    +
    var POST
    +
    +
    +
    +
    var PUT
    +
    +
    +
    +
    +
    class HttpRequest -(data: bytes, method: str, path: str, query: Record, headers: Record) +(data: bytes, method: str, path: str, params: Dict[str, str], query: Record, headers: Record, trace_context: Dict[str, str])

    Represents a translated Http Request forwarded from the Nitric Membrane.

    @@ -1014,13 +1401,34 @@

    Inherited members

    class HttpRequest(Request):
         """Represents a translated Http Request forwarded from the Nitric Membrane."""
     
    -    def __init__(self, data: bytes, method: str, path: str, query: Record, headers: Record):
    +    def __init__(
    +        self,
    +        data: bytes,
    +        method: str,
    +        path: str,
    +        params: Dict[str, str],
    +        query: Record,
    +        headers: Record,
    +        trace_context: Dict[str, str],
    +    ):
             """Construct a new HttpRequest."""
             super().__init__(data)
             self.method = method
             self.path = path
    +        self.params = params
             self.query = query
             self.headers = headers
    +        self.trace_context = trace_context
    +
    +    @property
    +    def json(self) -> Optional[Any]:
    +        """Get the body of the request as JSON, returns None if request body is not JSON."""
    +        try:
    +            return json.loads(self.body)
    +        except json.JSONDecodeError:
    +            return None
    +        except TypeError:
    +            return None
     
         @property
         def body(self):
    @@ -1047,6 +1455,24 @@ 

    Instance variables

    return self.data.decode("utf-8")
    +
    var json : Optional[Any]
    +
    +

    Get the body of the request as JSON, returns None if request body is not JSON.

    +
    + +Expand source code + +
    @property
    +def json(self) -> Optional[Any]:
    +    """Get the body of the request as JSON, returns None if request body is not JSON."""
    +    try:
    +        return json.loads(self.body)
    +    except json.JSONDecodeError:
    +        return None
    +    except TypeError:
    +        return None
    +
    +
    @@ -1054,26 +1480,125 @@

    Instance variables

    (status: int = 200, headers: Record = None, body: bytes = None)
    -

    Represents an Http Response to be generated by the Nitric Membrane in response to an Http Request Trigger.

    +

    Represents an HTTP Response to be generated by the Nitric Membrane in response to an HTTP Request Trigger.

    Construct a new HttpResponse.

    Expand source code
    class HttpResponse(Response):
    -    """Represents an Http Response to be generated by the Nitric Membrane in response to an Http Request Trigger."""
    +    """Represents an HTTP Response to be generated by the Nitric Membrane in response to an HTTP Request Trigger."""
     
         def __init__(self, status: int = 200, headers: Record = None, body: bytes = None):
             """Construct a new HttpResponse."""
             self.status = status
             self.headers = headers if headers else {}
    -        self.body = body if body else bytes()
    + self._body = body if body else bytes() + + @property + def body(self): + """Return the HTTP response body.""" + return self._body + + @body.setter + def body(self, value: Union[str, bytes, Any]): + if isinstance(value, str): + self._body = value.encode("utf-8") + elif isinstance(value, bytes): + self._body = value + else: + self._body = json.dumps(value).encode("utf-8") + self.headers["Content-Type"] = ["application/json"]

    Ancestors

    +

    Instance variables

    +
    +
    var body
    +
    +

    Return the HTTP response body.

    +
    + +Expand source code + +
    @property
    +def body(self):
    +    """Return the HTTP response body."""
    +    return self._body
    +
    +
    +
    +
    +
    +class MethodOptions +(security: dict[str, List[str]] = None) +
    +
    +

    Represents options when defining a method handler.

    +

    Construct a new HTTP method options object.

    +
    + +Expand source code + +
    class MethodOptions:
    +    """Represents options when defining a method handler."""
    +
    +    security: dict[str, List[str]]
    +
    +    def __init__(self, security: dict[str, List[str]] = None):
    +        """Construct a new HTTP method options object."""
    +        self.security = security
    +
    +

    Class variables

    +
    +
    var security : dict[str, typing.List[str]]
    +
    +
    +
    +
    +
    +
    +class RateWorkerOptions +(description: str, rate: int, frequency: Frequency) +
    +
    +

    Options for rate workers.

    +

    Construct a new options object.

    +
    + +Expand source code + +
    class RateWorkerOptions:
    +    """Options for rate workers."""
    +
    +    description: str
    +    rate: int
    +    frequency: Frequency
    +
    +    def __init__(self, description: str, rate: int, frequency: Frequency):
    +        """Construct a new options object."""
    +        self.description = description
    +        self.rate = rate
    +        self.frequency = frequency
    +
    +

    Class variables

    +
    +
    var description : str
    +
    +
    +
    +
    var frequencyFrequency
    +
    +
    +
    +
    var rate : int
    +
    +
    +
    +
    class Request @@ -1127,6 +1652,25 @@

    Subclasses

  • HttpResponse
  • +
    +class SubscriptionWorkerOptions +(topic: str) +
    +
    +

    Options for subscription workers.

    +

    Construct a new options object.

    +
    + +Expand source code + +
    class SubscriptionWorkerOptions:
    +    """Options for subscription workers."""
    +
    +    def __init__(self, topic: str):
    +        """Construct a new options object."""
    +        self.topic = topic
    +
    +
    class TriggerContext
    @@ -1159,7 +1703,7 @@

    Subclasses

    Methods

    -def event(self) ‑> Union[EventContext, NoneType] +def event(self) ‑> Optional[EventContext]

    Return this context as an EventContext if it is one, otherwise returns None.

    @@ -1173,7 +1717,7 @@

    Methods

    -def http(self) ‑> Union[HttpContext, NoneType] +def http(self) ‑> Optional[HttpContext]

    Return this context as an HttpContext if it is one, otherwise returns None.

    @@ -1213,6 +1757,9 @@

    Index

  • Classes

    • +

      ApiWorkerOptions

      +
    • +
    • EventContext

    • +

      HttpMethod

      + +
    • +
    • HttpRequest

    • HttpResponse

      + +
    • +
    • +

      MethodOptions

      + +
    • +
    • +

      RateWorkerOptions

      +
    • Request

      @@ -1260,6 +1849,9 @@

      Request

      Response

    • +

      SubscriptionWorkerOptions

      +
    • +
    • TriggerContext

      • event
      • diff --git a/docs/nitric/index.html b/docs/nitric/index.html index 2fbcc5a..153cc77 100644 --- a/docs/nitric/index.html +++ b/docs/nitric/index.html @@ -55,6 +55,10 @@

        Sub-modules

        Nitric API SDK.

        +
        nitric.application
        +
        +
        +
        nitric.config

        Nitric SDK Configuration Settings.

        @@ -63,6 +67,14 @@

        Sub-modules

        +
        nitric.proto
        +
        +
        +
        +
        nitric.resources
        +
        +

        Nitric Python SDK API Documentation. See: https://nitric.io/docs?lang=python for full framework documentation.

        +
        nitric.utils
        @@ -85,8 +97,11 @@

        Index

      • Sub-modules

      • diff --git a/docs/nitric/proto/index.html b/docs/nitric/proto/index.html new file mode 100644 index 0000000..2c6e107 --- /dev/null +++ b/docs/nitric/proto/index.html @@ -0,0 +1,93 @@ + + + + + + +nitric.proto API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric
        +
        +
        +
        +
        nitric.proto.validate
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/document/index.html b/docs/nitric/proto/nitric/document/index.html new file mode 100644 index 0000000..2c9d744 --- /dev/null +++ b/docs/nitric/proto/nitric/document/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.document API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.document

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.document.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/document/v1/index.html b/docs/nitric/proto/nitric/document/v1/index.html new file mode 100644 index 0000000..870dd9b --- /dev/null +++ b/docs/nitric/proto/nitric/document/v1/index.html @@ -0,0 +1,1529 @@ + + + + + + +nitric.proto.nitric.document.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.document.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/document/v1/document.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    AsyncIterator,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Collection(betterproto.Message):
        +    """Provides a Collection type for storing documents"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The collection name"""
        +
        +    parent: "Key" = betterproto.message_field(2)
        +    """
        +    Optional parent key, required when the collection is a sub-collection of
        +    another document
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Key(betterproto.Message):
        +    """Provides a document identifying key type"""
        +
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The item collection"""
        +
        +    id: str = betterproto.string_field(2)
        +    """The items unique id"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Document(betterproto.Message):
        +    """Provides a return document type"""
        +
        +    content: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
        +    """The document content (JSON object)"""
        +
        +    key: "Key" = betterproto.message_field(2)
        +    """The document's unique key, including collection/sub-collections"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ExpressionValue(betterproto.Message):
        +    int_value: int = betterproto.int64_field(1, group="kind")
        +    """Represents an integer value."""
        +
        +    double_value: float = betterproto.double_field(2, group="kind")
        +    """Represents a double value."""
        +
        +    string_value: str = betterproto.string_field(3, group="kind")
        +    """Represents a string value."""
        +
        +    bool_value: bool = betterproto.bool_field(4, group="kind")
        +    """Represents a boolean value."""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Expression(betterproto.Message):
        +    """Provides a query expression type"""
        +
        +    operand: str = betterproto.string_field(1)
        +    """The query operand or attribute"""
        +
        +    operator: str = betterproto.string_field(2)
        +    """The query operator [ == | < | <= | > | >= | startsWith ]"""
        +
        +    value: "ExpressionValue" = betterproto.message_field(3)
        +    """The query expression value"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentGetRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to retrieve"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentGetResponse(betterproto.Message):
        +    document: "Document" = betterproto.message_field(1)
        +    """The retrieved value"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentSetRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to set"""
        +
        +    content: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(3)
        +    """The document content to store (JSON object)"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentSetResponse(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentDeleteRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to delete"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentDeleteResponse(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentQueryRequest(betterproto.Message):
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The collection to query"""
        +
        +    expressions: List["Expression"] = betterproto.message_field(3)
        +    """Optional query expressions"""
        +
        +    limit: int = betterproto.int32_field(4)
        +    """Optional query fetch limit"""
        +
        +    paging_token: Dict[str, str] = betterproto.map_field(
        +        5, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Optional query paging continuation token"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentQueryResponse(betterproto.Message):
        +    documents: List["Document"] = betterproto.message_field(1)
        +    """The retrieved values"""
        +
        +    paging_token: Dict[str, str] = betterproto.map_field(
        +        2, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The query paging continuation token, when empty no further results are
        +    available
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentQueryStreamRequest(betterproto.Message):
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The collection to query"""
        +
        +    expressions: List["Expression"] = betterproto.message_field(3)
        +    """Optional query expressions"""
        +
        +    limit: int = betterproto.int32_field(4)
        +    """Optional query fetch limit"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DocumentQueryStreamResponse(betterproto.Message):
        +    document: "Document" = betterproto.message_field(1)
        +    """The stream document"""
        +
        +
        +class DocumentServiceStub(betterproto.ServiceStub):
        +    async def get(
        +        self,
        +        document_get_request: "DocumentGetRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentGetResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Get",
        +            document_get_request,
        +            DocumentGetResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def set(
        +        self,
        +        document_set_request: "DocumentSetRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentSetResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Set",
        +            document_set_request,
        +            DocumentSetResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def delete(
        +        self,
        +        document_delete_request: "DocumentDeleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentDeleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Delete",
        +            document_delete_request,
        +            DocumentDeleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def query(
        +        self,
        +        document_query_request: "DocumentQueryRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentQueryResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Query",
        +            document_query_request,
        +            DocumentQueryResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def query_stream(
        +        self,
        +        document_query_stream_request: "DocumentQueryStreamRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +        async for response in self._unary_stream(
        +            "/nitric.document.v1.DocumentService/QueryStream",
        +            document_query_stream_request,
        +            DocumentQueryStreamResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +
        +class DocumentServiceBase(ServiceBase):
        +    async def get(
        +        self, document_get_request: "DocumentGetRequest"
        +    ) -> "DocumentGetResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def set(
        +        self, document_set_request: "DocumentSetRequest"
        +    ) -> "DocumentSetResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def delete(
        +        self, document_delete_request: "DocumentDeleteRequest"
        +    ) -> "DocumentDeleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def query(
        +        self, document_query_request: "DocumentQueryRequest"
        +    ) -> "DocumentQueryResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def query_stream(
        +        self, document_query_stream_request: "DocumentQueryStreamRequest"
        +    ) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_get(
        +        self, stream: "grpclib.server.Stream[DocumentGetRequest, DocumentGetResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.get(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_set(
        +        self, stream: "grpclib.server.Stream[DocumentSetRequest, DocumentSetResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.set(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_delete(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentDeleteRequest, DocumentDeleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.delete(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_query(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentQueryRequest, DocumentQueryResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.query(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_query_stream(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentQueryStreamRequest, DocumentQueryStreamResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.query_stream,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.document.v1.DocumentService/Get": grpclib.const.Handler(
        +                self.__rpc_get,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentGetRequest,
        +                DocumentGetResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Set": grpclib.const.Handler(
        +                self.__rpc_set,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentSetRequest,
        +                DocumentSetResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Delete": grpclib.const.Handler(
        +                self.__rpc_delete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentDeleteRequest,
        +                DocumentDeleteResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Query": grpclib.const.Handler(
        +                self.__rpc_query,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentQueryRequest,
        +                DocumentQueryResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/QueryStream": grpclib.const.Handler(
        +                self.__rpc_query_stream,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DocumentQueryStreamRequest,
        +                DocumentQueryStreamResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Collection +(name: str = <object object>, parent: Key = <object object>) +
        +
        +

        Provides a Collection type for storing documents

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Collection(betterproto.Message):
        +    """Provides a Collection type for storing documents"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The collection name"""
        +
        +    parent: "Key" = betterproto.message_field(2)
        +    """
        +    Optional parent key, required when the collection is a sub-collection of
        +    another document
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var name : str
        +
        +

        The collection name

        +
        +
        var parentKey
        +
        +

        Optional parent key, required when the collection is a sub-collection of +another document

        +
        +
        +
        +
        +class Document +(content: betterproto_lib_google_protobuf.Struct = <object object>, key: Key = <object object>) +
        +
        +

        Provides a return document type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Document(betterproto.Message):
        +    """Provides a return document type"""
        +
        +    content: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
        +    """The document content (JSON object)"""
        +
        +    key: "Key" = betterproto.message_field(2)
        +    """The document's unique key, including collection/sub-collections"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var content : betterproto.lib.google.protobuf.Struct
        +
        +

        The document content (JSON object)

        +
        +
        var keyKey
        +
        +

        The document's unique key, including collection/sub-collections

        +
        +
        +
        +
        +class DocumentDeleteRequest +(key: Key = <object object>) +
        +
        +

        DocumentDeleteRequest(key: 'Key' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentDeleteRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to delete"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var keyKey
        +
        +

        Key of the document to delete

        +
        +
        + +
        +class DocumentDeleteResponse +
        +
        +

        DocumentDeleteResponse()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentDeleteResponse(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class DocumentGetRequest +(key: Key = <object object>) +
        +
        +

        DocumentGetRequest(key: 'Key' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentGetRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to retrieve"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var keyKey
        +
        +

        Key of the document to retrieve

        +
        +
        + +
        +class DocumentGetResponse +(document: Document = <object object>) +
        +
        +

        DocumentGetResponse(document: 'Document' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentGetResponse(betterproto.Message):
        +    document: "Document" = betterproto.message_field(1)
        +    """The retrieved value"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var documentDocument
        +
        +

        The retrieved value

        +
        +
        + +
        +class DocumentQueryRequest +(collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>, paging_token: Dict[str, str] = <object object>) +
        +
        +

        DocumentQueryRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = , paging_token: Dict[str, str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentQueryRequest(betterproto.Message):
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The collection to query"""
        +
        +    expressions: List["Expression"] = betterproto.message_field(3)
        +    """Optional query expressions"""
        +
        +    limit: int = betterproto.int32_field(4)
        +    """Optional query fetch limit"""
        +
        +    paging_token: Dict[str, str] = betterproto.map_field(
        +        5, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Optional query paging continuation token"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var collectionCollection
        +
        +

        The collection to query

        +
        +
        var expressions : List[Expression]
        +
        +

        Optional query expressions

        +
        +
        var limit : int
        +
        +

        Optional query fetch limit

        +
        +
        var paging_token : Dict[str, str]
        +
        +

        Optional query paging continuation token

        +
        +
        + +
        +class DocumentQueryResponse +(documents: List[ForwardRef('Document')] = <object object>, paging_token: Dict[str, str] = <object object>) +
        +
        +

        DocumentQueryResponse(documents: List[ForwardRef('Document')] = , paging_token: Dict[str, str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentQueryResponse(betterproto.Message):
        +    documents: List["Document"] = betterproto.message_field(1)
        +    """The retrieved values"""
        +
        +    paging_token: Dict[str, str] = betterproto.map_field(
        +        2, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The query paging continuation token, when empty no further results are
        +    available
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var documents : List[Document]
        +
        +

        The retrieved values

        +
        +
        var paging_token : Dict[str, str]
        +
        +

        The query paging continuation token, when empty no further results are +available

        +
        +
        + +
        +class DocumentQueryStreamRequest +(collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>) +
        +
        +

        DocumentQueryStreamRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentQueryStreamRequest(betterproto.Message):
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The collection to query"""
        +
        +    expressions: List["Expression"] = betterproto.message_field(3)
        +    """Optional query expressions"""
        +
        +    limit: int = betterproto.int32_field(4)
        +    """Optional query fetch limit"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var collectionCollection
        +
        +

        The collection to query

        +
        +
        var expressions : List[Expression]
        +
        +

        Optional query expressions

        +
        +
        var limit : int
        +
        +

        Optional query fetch limit

        +
        +
        + +
        +class DocumentQueryStreamResponse +(document: Document = <object object>) +
        +
        +

        DocumentQueryStreamResponse(document: 'Document' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentQueryStreamResponse(betterproto.Message):
        +    document: "Document" = betterproto.message_field(1)
        +    """The stream document"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var documentDocument
        +
        +

        The stream document

        +
        +
        + +
        +class DocumentServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class DocumentServiceBase(ServiceBase):
        +    async def get(
        +        self, document_get_request: "DocumentGetRequest"
        +    ) -> "DocumentGetResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def set(
        +        self, document_set_request: "DocumentSetRequest"
        +    ) -> "DocumentSetResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def delete(
        +        self, document_delete_request: "DocumentDeleteRequest"
        +    ) -> "DocumentDeleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def query(
        +        self, document_query_request: "DocumentQueryRequest"
        +    ) -> "DocumentQueryResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def query_stream(
        +        self, document_query_stream_request: "DocumentQueryStreamRequest"
        +    ) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_get(
        +        self, stream: "grpclib.server.Stream[DocumentGetRequest, DocumentGetResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.get(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_set(
        +        self, stream: "grpclib.server.Stream[DocumentSetRequest, DocumentSetResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.set(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_delete(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentDeleteRequest, DocumentDeleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.delete(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_query(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentQueryRequest, DocumentQueryResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.query(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_query_stream(
        +        self,
        +        stream: "grpclib.server.Stream[DocumentQueryStreamRequest, DocumentQueryStreamResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.query_stream,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.document.v1.DocumentService/Get": grpclib.const.Handler(
        +                self.__rpc_get,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentGetRequest,
        +                DocumentGetResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Set": grpclib.const.Handler(
        +                self.__rpc_set,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentSetRequest,
        +                DocumentSetResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Delete": grpclib.const.Handler(
        +                self.__rpc_delete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentDeleteRequest,
        +                DocumentDeleteResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/Query": grpclib.const.Handler(
        +                self.__rpc_query,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                DocumentQueryRequest,
        +                DocumentQueryResponse,
        +            ),
        +            "/nitric.document.v1.DocumentService/QueryStream": grpclib.const.Handler(
        +                self.__rpc_query_stream,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DocumentQueryStreamRequest,
        +                DocumentQueryStreamResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def delete(self, document_delete_request: DocumentDeleteRequest) ‑> DocumentDeleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def delete(
        +    self, document_delete_request: "DocumentDeleteRequest"
        +) -> "DocumentDeleteResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def get(self, document_get_request: DocumentGetRequest) ‑> DocumentGetResponse +
        +
        +
        +
        + +Expand source code + +
        async def get(
        +    self, document_get_request: "DocumentGetRequest"
        +) -> "DocumentGetResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def query(self, document_query_request: DocumentQueryRequest) ‑> DocumentQueryResponse +
        +
        +
        +
        + +Expand source code + +
        async def query(
        +    self, document_query_request: "DocumentQueryRequest"
        +) -> "DocumentQueryResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def query_stream(self, document_query_stream_request: DocumentQueryStreamRequest) ‑> AsyncIterator[DocumentQueryStreamResponse] +
        +
        +
        +
        + +Expand source code + +
        async def query_stream(
        +    self, document_query_stream_request: "DocumentQueryStreamRequest"
        +) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def set(self, document_set_request: DocumentSetRequest) ‑> DocumentSetResponse +
        +
        +
        +
        + +Expand source code + +
        async def set(
        +    self, document_set_request: "DocumentSetRequest"
        +) -> "DocumentSetResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class DocumentServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class DocumentServiceStub(betterproto.ServiceStub):
        +    async def get(
        +        self,
        +        document_get_request: "DocumentGetRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentGetResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Get",
        +            document_get_request,
        +            DocumentGetResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def set(
        +        self,
        +        document_set_request: "DocumentSetRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentSetResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Set",
        +            document_set_request,
        +            DocumentSetResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def delete(
        +        self,
        +        document_delete_request: "DocumentDeleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentDeleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Delete",
        +            document_delete_request,
        +            DocumentDeleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def query(
        +        self,
        +        document_query_request: "DocumentQueryRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "DocumentQueryResponse":
        +        return await self._unary_unary(
        +            "/nitric.document.v1.DocumentService/Query",
        +            document_query_request,
        +            DocumentQueryResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def query_stream(
        +        self,
        +        document_query_stream_request: "DocumentQueryStreamRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +        async for response in self._unary_stream(
        +            "/nitric.document.v1.DocumentService/QueryStream",
        +            document_query_stream_request,
        +            DocumentQueryStreamResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def delete(self, document_delete_request: DocumentDeleteRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> DocumentDeleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def delete(
        +    self,
        +    document_delete_request: "DocumentDeleteRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "DocumentDeleteResponse":
        +    return await self._unary_unary(
        +        "/nitric.document.v1.DocumentService/Delete",
        +        document_delete_request,
        +        DocumentDeleteResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def get(self, document_get_request: DocumentGetRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> DocumentGetResponse +
        +
        +
        +
        + +Expand source code + +
        async def get(
        +    self,
        +    document_get_request: "DocumentGetRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "DocumentGetResponse":
        +    return await self._unary_unary(
        +        "/nitric.document.v1.DocumentService/Get",
        +        document_get_request,
        +        DocumentGetResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def query(self, document_query_request: DocumentQueryRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> DocumentQueryResponse +
        +
        +
        +
        + +Expand source code + +
        async def query(
        +    self,
        +    document_query_request: "DocumentQueryRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "DocumentQueryResponse":
        +    return await self._unary_unary(
        +        "/nitric.document.v1.DocumentService/Query",
        +        document_query_request,
        +        DocumentQueryResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def query_stream(self, document_query_stream_request: DocumentQueryStreamRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[DocumentQueryStreamResponse] +
        +
        +
        +
        + +Expand source code + +
        async def query_stream(
        +    self,
        +    document_query_stream_request: "DocumentQueryStreamRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> AsyncIterator["DocumentQueryStreamResponse"]:
        +    async for response in self._unary_stream(
        +        "/nitric.document.v1.DocumentService/QueryStream",
        +        document_query_stream_request,
        +        DocumentQueryStreamResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    ):
        +        yield response
        +
        +
        +
        +async def set(self, document_set_request: DocumentSetRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> DocumentSetResponse +
        +
        +
        +
        + +Expand source code + +
        async def set(
        +    self,
        +    document_set_request: "DocumentSetRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "DocumentSetResponse":
        +    return await self._unary_unary(
        +        "/nitric.document.v1.DocumentService/Set",
        +        document_set_request,
        +        DocumentSetResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +class DocumentSetRequest +(key: Key = <object object>, content: betterproto_lib_google_protobuf.Struct = <object object>) +
        +
        +

        DocumentSetRequest(key: 'Key' = , content: 'betterproto_lib_google_protobuf.Struct' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentSetRequest(betterproto.Message):
        +    key: "Key" = betterproto.message_field(1)
        +    """Key of the document to set"""
        +
        +    content: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(3)
        +    """The document content to store (JSON object)"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var content : betterproto.lib.google.protobuf.Struct
        +
        +

        The document content to store (JSON object)

        +
        +
        var keyKey
        +
        +

        Key of the document to set

        +
        +
        + +
        +class DocumentSetResponse +
        +
        +

        DocumentSetResponse()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DocumentSetResponse(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class Expression +(operand: str = <object object>, operator: str = <object object>, value: ExpressionValue = <object object>) +
        +
        +

        Provides a query expression type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Expression(betterproto.Message):
        +    """Provides a query expression type"""
        +
        +    operand: str = betterproto.string_field(1)
        +    """The query operand or attribute"""
        +
        +    operator: str = betterproto.string_field(2)
        +    """The query operator [ == | < | <= | > | >= | startsWith ]"""
        +
        +    value: "ExpressionValue" = betterproto.message_field(3)
        +    """The query expression value"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var operand : str
        +
        +

        The query operand or attribute

        +
        +
        var operator : str
        +
        +

        The query operator [ == | < | <= | > | >= | startsWith ]

        +
        +
        var valueExpressionValue
        +
        +

        The query expression value

        +
        +
        +
        +
        +class ExpressionValue +(int_value: int = <object object>, double_value: float = <object object>, string_value: str = <object object>, bool_value: bool = <object object>) +
        +
        +

        ExpressionValue(int_value: int = , double_value: float = , string_value: str = , bool_value: bool = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ExpressionValue(betterproto.Message):
        +    int_value: int = betterproto.int64_field(1, group="kind")
        +    """Represents an integer value."""
        +
        +    double_value: float = betterproto.double_field(2, group="kind")
        +    """Represents a double value."""
        +
        +    string_value: str = betterproto.string_field(3, group="kind")
        +    """Represents a string value."""
        +
        +    bool_value: bool = betterproto.bool_field(4, group="kind")
        +    """Represents a boolean value."""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var bool_value : bool
        +
        +

        Represents a boolean value.

        +
        +
        var double_value : float
        +
        +

        Represents a double value.

        +
        +
        var int_value : int
        +
        +

        Represents an integer value.

        +
        +
        var string_value : str
        +
        +

        Represents a string value.

        +
        +
        + +
        +class Key +(collection: Collection = <object object>, id: str = <object object>) +
        +
        +

        Provides a document identifying key type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Key(betterproto.Message):
        +    """Provides a document identifying key type"""
        +
        +    collection: "Collection" = betterproto.message_field(1)
        +    """The item collection"""
        +
        +    id: str = betterproto.string_field(2)
        +    """The items unique id"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var collectionCollection
        +
        +

        The item collection

        +
        +
        var id : str
        +
        +

        The items unique id

        +
        +
        +
        + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/error/index.html b/docs/nitric/proto/nitric/error/index.html new file mode 100644 index 0000000..68f43c0 --- /dev/null +++ b/docs/nitric/proto/nitric/error/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.error API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.error

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.error.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/error/v1/index.html b/docs/nitric/proto/nitric/error/v1/index.html new file mode 100644 index 0000000..63b8344 --- /dev/null +++ b/docs/nitric/proto/nitric/error/v1/index.html @@ -0,0 +1,227 @@ + + + + + + +nitric.proto.nitric.error.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.error.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/error/v1/error.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import Dict
        +
        +import betterproto
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ErrorScope(betterproto.Message):
        +    service: str = betterproto.string_field(1)
        +    """The API service invoked, e.g. 'Service.Method'."""
        +
        +    plugin: str = betterproto.string_field(2)
        +    """The plugin method invoked, e.g. 'PluginService.Method'."""
        +
        +    args: Dict[str, str] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The plugin method arguments, ensure only non-sensitive data is specified.
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ErrorDetails(betterproto.Message):
        +    message: str = betterproto.string_field(1)
        +    """
        +    The developer error message, explaining the error and ideally solution.
        +    """
        +
        +    cause: str = betterproto.string_field(2)
        +    """The error root cause."""
        +
        +    scope: "ErrorScope" = betterproto.message_field(3)
        +    """The scope of the error."""
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class ErrorDetails +(message: str = <object object>, cause: str = <object object>, scope: ErrorScope = <object object>) +
        +
        +

        ErrorDetails(message: str = , cause: str = , scope: 'ErrorScope' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ErrorDetails(betterproto.Message):
        +    message: str = betterproto.string_field(1)
        +    """
        +    The developer error message, explaining the error and ideally solution.
        +    """
        +
        +    cause: str = betterproto.string_field(2)
        +    """The error root cause."""
        +
        +    scope: "ErrorScope" = betterproto.message_field(3)
        +    """The scope of the error."""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var cause : str
        +
        +

        The error root cause.

        +
        +
        var message : str
        +
        +

        The developer error message, explaining the error and ideally solution.

        +
        +
        var scopeErrorScope
        +
        +

        The scope of the error.

        +
        +
        + +
        +class ErrorScope +(service: str = <object object>, plugin: str = <object object>, args: Dict[str, str] = <object object>) +
        +
        +

        ErrorScope(service: str = , plugin: str = , args: Dict[str, str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ErrorScope(betterproto.Message):
        +    service: str = betterproto.string_field(1)
        +    """The API service invoked, e.g. 'Service.Method'."""
        +
        +    plugin: str = betterproto.string_field(2)
        +    """The plugin method invoked, e.g. 'PluginService.Method'."""
        +
        +    args: Dict[str, str] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The plugin method arguments, ensure only non-sensitive data is specified.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var args : Dict[str, str]
        +
        +

        The plugin method arguments, ensure only non-sensitive data is specified.

        +
        +
        var plugin : str
        +
        +

        The plugin method invoked, e.g. 'PluginService.Method'.

        +
        +
        var service : str
        +
        +

        The API service invoked, e.g. 'Service.Method'.

        +
        +
        + + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/event/index.html b/docs/nitric/proto/nitric/event/index.html new file mode 100644 index 0000000..29bdace --- /dev/null +++ b/docs/nitric/proto/nitric/event/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.event API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.event

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.event.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/event/v1/index.html b/docs/nitric/proto/nitric/event/v1/index.html new file mode 100644 index 0000000..0cf2941 --- /dev/null +++ b/docs/nitric/proto/nitric/event/v1/index.html @@ -0,0 +1,751 @@ + + + + + + +nitric.proto.nitric.event.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.event.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/event/v1/event.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class EventPublishRequest(betterproto.Message):
        +    """Request to publish an event to a topic"""
        +
        +    topic: str = betterproto.string_field(1)
        +    """The name of the topic to publish the event to"""
        +
        +    event: "NitricEvent" = betterproto.message_field(2)
        +    """The event to be published"""
        +
        +    delay: int = betterproto.uint32_field(3)
        +    """An optional delay specified in seconds (minimum 10 seconds)"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class EventPublishResponse(betterproto.Message):
        +    """Result of publishing an event"""
        +
        +    id: str = betterproto.string_field(1)
        +    """
        +    The id of the published message When an id was not supplied one should be
        +    automatically generated
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicListRequest(betterproto.Message):
        +    """Request for the Topic List method"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicListResponse(betterproto.Message):
        +    """Topic List Response"""
        +
        +    topics: List["NitricTopic"] = betterproto.message_field(1)
        +    """The list of found topics"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class NitricTopic(betterproto.Message):
        +    """Represents an event topic"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The Nitric name for the topic"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class NitricEvent(betterproto.Message):
        +    """Nitric Event Model"""
        +
        +    id: str = betterproto.string_field(1)
        +    """A Unique ID for the Nitric Event"""
        +
        +    payload_type: str = betterproto.string_field(2)
        +    """A content hint for the events payload"""
        +
        +    payload: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(3)
        +    """The payload of the event"""
        +
        +
        +class EventServiceStub(betterproto.ServiceStub):
        +    async def publish(
        +        self,
        +        event_publish_request: "EventPublishRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "EventPublishResponse":
        +        return await self._unary_unary(
        +            "/nitric.event.v1.EventService/Publish",
        +            event_publish_request,
        +            EventPublishResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class TopicServiceStub(betterproto.ServiceStub):
        +    async def list(
        +        self,
        +        topic_list_request: "TopicListRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "TopicListResponse":
        +        return await self._unary_unary(
        +            "/nitric.event.v1.TopicService/List",
        +            topic_list_request,
        +            TopicListResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class EventServiceBase(ServiceBase):
        +    async def publish(
        +        self, event_publish_request: "EventPublishRequest"
        +    ) -> "EventPublishResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_publish(
        +        self, stream: "grpclib.server.Stream[EventPublishRequest, EventPublishResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.publish(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.event.v1.EventService/Publish": grpclib.const.Handler(
        +                self.__rpc_publish,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                EventPublishRequest,
        +                EventPublishResponse,
        +            ),
        +        }
        +
        +
        +class TopicServiceBase(ServiceBase):
        +    async def list(self, topic_list_request: "TopicListRequest") -> "TopicListResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_list(
        +        self, stream: "grpclib.server.Stream[TopicListRequest, TopicListResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.list(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.event.v1.TopicService/List": grpclib.const.Handler(
        +                self.__rpc_list,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                TopicListRequest,
        +                TopicListResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class EventPublishRequest +(topic: str = <object object>, event: NitricEvent = <object object>, delay: int = <object object>) +
        +
        +

        Request to publish an event to a topic

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class EventPublishRequest(betterproto.Message):
        +    """Request to publish an event to a topic"""
        +
        +    topic: str = betterproto.string_field(1)
        +    """The name of the topic to publish the event to"""
        +
        +    event: "NitricEvent" = betterproto.message_field(2)
        +    """The event to be published"""
        +
        +    delay: int = betterproto.uint32_field(3)
        +    """An optional delay specified in seconds (minimum 10 seconds)"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var delay : int
        +
        +

        An optional delay specified in seconds (minimum 10 seconds)

        +
        +
        var eventNitricEvent
        +
        +

        The event to be published

        +
        +
        var topic : str
        +
        +

        The name of the topic to publish the event to

        +
        +
        +
        +
        +class EventPublishResponse +(id: str = <object object>) +
        +
        +

        Result of publishing an event

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class EventPublishResponse(betterproto.Message):
        +    """Result of publishing an event"""
        +
        +    id: str = betterproto.string_field(1)
        +    """
        +    The id of the published message When an id was not supplied one should be
        +    automatically generated
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var id : str
        +
        +

        The id of the published message When an id was not supplied one should be +automatically generated

        +
        +
        +
        +
        +class EventServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class EventServiceBase(ServiceBase):
        +    async def publish(
        +        self, event_publish_request: "EventPublishRequest"
        +    ) -> "EventPublishResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_publish(
        +        self, stream: "grpclib.server.Stream[EventPublishRequest, EventPublishResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.publish(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.event.v1.EventService/Publish": grpclib.const.Handler(
        +                self.__rpc_publish,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                EventPublishRequest,
        +                EventPublishResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def publish(self, event_publish_request: EventPublishRequest) ‑> EventPublishResponse +
        +
        +
        +
        + +Expand source code + +
        async def publish(
        +    self, event_publish_request: "EventPublishRequest"
        +) -> "EventPublishResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class EventServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class EventServiceStub(betterproto.ServiceStub):
        +    async def publish(
        +        self,
        +        event_publish_request: "EventPublishRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "EventPublishResponse":
        +        return await self._unary_unary(
        +            "/nitric.event.v1.EventService/Publish",
        +            event_publish_request,
        +            EventPublishResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def publish(self, event_publish_request: EventPublishRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> EventPublishResponse +
        +
        +
        +
        + +Expand source code + +
        async def publish(
        +    self,
        +    event_publish_request: "EventPublishRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "EventPublishResponse":
        +    return await self._unary_unary(
        +        "/nitric.event.v1.EventService/Publish",
        +        event_publish_request,
        +        EventPublishResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +class NitricEvent +(id: str = <object object>, payload_type: str = <object object>, payload: betterproto_lib_google_protobuf.Struct = <object object>) +
        +
        +

        Nitric Event Model

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class NitricEvent(betterproto.Message):
        +    """Nitric Event Model"""
        +
        +    id: str = betterproto.string_field(1)
        +    """A Unique ID for the Nitric Event"""
        +
        +    payload_type: str = betterproto.string_field(2)
        +    """A content hint for the events payload"""
        +
        +    payload: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(3)
        +    """The payload of the event"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var id : str
        +
        +

        A Unique ID for the Nitric Event

        +
        +
        var payload : betterproto.lib.google.protobuf.Struct
        +
        +

        The payload of the event

        +
        +
        var payload_type : str
        +
        +

        A content hint for the events payload

        +
        +
        +
        +
        +class NitricTopic +(name: str = <object object>) +
        +
        +

        Represents an event topic

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class NitricTopic(betterproto.Message):
        +    """Represents an event topic"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The Nitric name for the topic"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var name : str
        +
        +

        The Nitric name for the topic

        +
        +
        +
        +
        +class TopicListRequest +
        +
        +

        Request for the Topic List method

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicListRequest(betterproto.Message):
        +    """Request for the Topic List method"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class TopicListResponse +(topics: List[ForwardRef('NitricTopic')] = <object object>) +
        +
        +

        Topic List Response

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicListResponse(betterproto.Message):
        +    """Topic List Response"""
        +
        +    topics: List["NitricTopic"] = betterproto.message_field(1)
        +    """The list of found topics"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var topics : List[NitricTopic]
        +
        +

        The list of found topics

        +
        +
        +
        +
        +class TopicServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class TopicServiceBase(ServiceBase):
        +    async def list(self, topic_list_request: "TopicListRequest") -> "TopicListResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_list(
        +        self, stream: "grpclib.server.Stream[TopicListRequest, TopicListResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.list(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.event.v1.TopicService/List": grpclib.const.Handler(
        +                self.__rpc_list,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                TopicListRequest,
        +                TopicListResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def list(self, topic_list_request: TopicListRequest) ‑> TopicListResponse +
        +
        +
        +
        + +Expand source code + +
        async def list(self, topic_list_request: "TopicListRequest") -> "TopicListResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class TopicServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class TopicServiceStub(betterproto.ServiceStub):
        +    async def list(
        +        self,
        +        topic_list_request: "TopicListRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "TopicListResponse":
        +        return await self._unary_unary(
        +            "/nitric.event.v1.TopicService/List",
        +            topic_list_request,
        +            TopicListResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def list(self, topic_list_request: TopicListRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> TopicListResponse +
        +
        +
        +
        + +Expand source code + +
        async def list(
        +    self,
        +    topic_list_request: "TopicListRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "TopicListResponse":
        +    return await self._unary_unary(
        +        "/nitric.event.v1.TopicService/List",
        +        topic_list_request,
        +        TopicListResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/faas/index.html b/docs/nitric/proto/nitric/faas/index.html new file mode 100644 index 0000000..47bf2b3 --- /dev/null +++ b/docs/nitric/proto/nitric/faas/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.faas API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.faas

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.faas.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/faas/v1/index.html b/docs/nitric/proto/nitric/faas/v1/index.html new file mode 100644 index 0000000..a76a29f --- /dev/null +++ b/docs/nitric/proto/nitric/faas/v1/index.html @@ -0,0 +1,1431 @@ + + + + + + +nitric.proto.nitric.faas.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.faas.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/faas/v1/faas.proto
        +# plugin: python-betterproto
        +import warnings
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    AsyncIterable,
        +    AsyncIterator,
        +    Dict,
        +    Iterable,
        +    List,
        +    Optional,
        +    Union,
        +)
        +
        +import betterproto
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ClientMessage(betterproto.Message):
        +    """Messages the client is able to send to the server"""
        +
        +    id: str = betterproto.string_field(1)
        +    """Client message ID, used to pair requests/responses"""
        +
        +    init_request: "InitRequest" = betterproto.message_field(2, group="content")
        +    """
        +    Client initialisation request A worker will not be eligible for triggers
        +    until it has identified itself
        +    """
        +
        +    trigger_response: "TriggerResponse" = betterproto.message_field(3, group="content")
        +    """Client responsding with result of a trigger"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ServerMessage(betterproto.Message):
        +    """Messages the server is able to send to the client"""
        +
        +    id: str = betterproto.string_field(1)
        +    """Server message ID, used to pair requests/responses"""
        +
        +    init_response: "InitResponse" = betterproto.message_field(2, group="content")
        +    """
        +    Server responding with client configuration details to an InitRequest
        +    """
        +
        +    trigger_request: "TriggerRequest" = betterproto.message_field(3, group="content")
        +    """Server requesting client to process a trigger"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiWorkerScopes(betterproto.Message):
        +    scopes: List[str] = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiWorkerOptions(betterproto.Message):
        +    security: Dict[str, "ApiWorkerScopes"] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """Apply security definitions to this operation"""
        +
        +    security_disabled: bool = betterproto.bool_field(2)
        +    """
        +    explicitly disable security for this endpoint We need to do this as the
        +    default value of a repeated field is always empty so there is no way of
        +    knowing if security is explicitly disabled
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiWorker(betterproto.Message):
        +    api: str = betterproto.string_field(1)
        +    path: str = betterproto.string_field(2)
        +    methods: List[str] = betterproto.string_field(3)
        +    options: "ApiWorkerOptions" = betterproto.message_field(4)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SubscriptionWorker(betterproto.Message):
        +    topic: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ScheduleWorker(betterproto.Message):
        +    key: str = betterproto.string_field(1)
        +    rate: "ScheduleRate" = betterproto.message_field(10, group="cadence")
        +    cron: "ScheduleCron" = betterproto.message_field(11, group="cadence")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ScheduleRate(betterproto.Message):
        +    rate: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ScheduleCron(betterproto.Message):
        +    cron: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class InitRequest(betterproto.Message):
        +    """
        +    InitRequest - Identifies a worker as ready to recieve triggers This message
        +    will contain information on the type of triggers that a worker is capable
        +    of handling
        +    """
        +
        +    api: "ApiWorker" = betterproto.message_field(10, group="Worker")
        +    subscription: "SubscriptionWorker" = betterproto.message_field(11, group="Worker")
        +    schedule: "ScheduleWorker" = betterproto.message_field(12, group="Worker")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class InitResponse(betterproto.Message):
        +    """Placeholder message"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TriggerRequest(betterproto.Message):
        +    """The server has a trigger for the client to handle"""
        +
        +    data: bytes = betterproto.bytes_field(1)
        +    """The data in the trigger"""
        +
        +    mime_type: str = betterproto.string_field(2)
        +    """Should we supply a mime type for the data? Or rely on context?"""
        +
        +    http: "HttpTriggerContext" = betterproto.message_field(3, group="context")
        +    topic: "TopicTriggerContext" = betterproto.message_field(4, group="context")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class HeaderValue(betterproto.Message):
        +    value: List[str] = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueryValue(betterproto.Message):
        +    value: List[str] = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class HttpTriggerContext(betterproto.Message):
        +    method: str = betterproto.string_field(1)
        +    """The request method"""
        +
        +    path: str = betterproto.string_field(2)
        +    """The path of the request"""
        +
        +    headers_old: Dict[str, str] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The old request headers (preserving for backwards compatibility) TODO:
        +    Remove in 1.0
        +    """
        +
        +    query_params_old: Dict[str, str] = betterproto.map_field(
        +        4, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The old query params (preserving for backwards compatibility) TODO: Remove
        +    in 1.0
        +    """
        +
        +    headers: Dict[str, "HeaderValue"] = betterproto.map_field(
        +        5, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP request headers"""
        +
        +    query_params: Dict[str, "QueryValue"] = betterproto.map_field(
        +        6, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP Query params"""
        +
        +    path_params: Dict[str, str] = betterproto.map_field(
        +        7, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """HTTP Path parameters"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("headers_old"):
        +            warnings.warn(
        +                "HttpTriggerContext.headers_old is deprecated", DeprecationWarning
        +            )
        +        if self.is_set("query_params_old"):
        +            warnings.warn(
        +                "HttpTriggerContext.query_params_old is deprecated", DeprecationWarning
        +            )
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicTriggerContext(betterproto.Message):
        +    topic: str = betterproto.string_field(1)
        +    """The topic the message was published for"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TriggerResponse(betterproto.Message):
        +    """The worker has successfully processed a trigger"""
        +
        +    data: bytes = betterproto.bytes_field(1)
        +    """The data returned in the response"""
        +
        +    http: "HttpResponseContext" = betterproto.message_field(10, group="context")
        +    """response to a http request"""
        +
        +    topic: "TopicResponseContext" = betterproto.message_field(11, group="context")
        +    """response to a topic trigger"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class HttpResponseContext(betterproto.Message):
        +    """
        +    Specific HttpResponse message Note this does not have to be handled by the
        +    User at all but they will have the option of control If they choose...
        +    """
        +
        +    headers_old: Dict[str, str] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Old HTTP response headers (deprecated) TODO: Remove in 1.0"""
        +
        +    status: int = betterproto.int32_field(2)
        +    """The HTTP status of the request"""
        +
        +    headers: Dict[str, "HeaderValue"] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP response headers"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("headers_old"):
        +            warnings.warn(
        +                "HttpResponseContext.headers_old is deprecated", DeprecationWarning
        +            )
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicResponseContext(betterproto.Message):
        +    """
        +    Specific event response message We do not accept responses for events only
        +    whether or not they were successfully processed
        +    """
        +
        +    success: bool = betterproto.bool_field(1)
        +    """Success status of the handled event"""
        +
        +
        +class FaasServiceStub(betterproto.ServiceStub):
        +    async def trigger_stream(
        +        self,
        +        client_message_iterator: Union[
        +            AsyncIterable["ClientMessage"], Iterable["ClientMessage"]
        +        ],
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["ServerMessage"]:
        +        async for response in self._stream_stream(
        +            "/nitric.faas.v1.FaasService/TriggerStream",
        +            client_message_iterator,
        +            ClientMessage,
        +            ServerMessage,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +
        +class FaasServiceBase(ServiceBase):
        +    async def trigger_stream(
        +        self, client_message_iterator: AsyncIterator["ClientMessage"]
        +    ) -> AsyncIterator["ServerMessage"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_trigger_stream(
        +        self, stream: "grpclib.server.Stream[ClientMessage, ServerMessage]"
        +    ) -> None:
        +        request = stream.__aiter__()
        +        await self._call_rpc_handler_server_stream(
        +            self.trigger_stream,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.faas.v1.FaasService/TriggerStream": grpclib.const.Handler(
        +                self.__rpc_trigger_stream,
        +                grpclib.const.Cardinality.STREAM_STREAM,
        +                ClientMessage,
        +                ServerMessage,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class ApiWorker +(api: str = <object object>, path: str = <object object>, methods: List[str] = <object object>, options: ApiWorkerOptions = <object object>) +
        +
        +

        ApiWorker(api: str = , path: str = , methods: List[str] = , options: 'ApiWorkerOptions' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiWorker(betterproto.Message):
        +    api: str = betterproto.string_field(1)
        +    path: str = betterproto.string_field(2)
        +    methods: List[str] = betterproto.string_field(3)
        +    options: "ApiWorkerOptions" = betterproto.message_field(4)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var api : str
        +
        +
        +
        +
        var methods : List[str]
        +
        +
        +
        +
        var optionsApiWorkerOptions
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        + +
        +class ApiWorkerOptions +(security: Dict[str, ForwardRef('ApiWorkerScopes')] = <object object>, security_disabled: bool = <object object>) +
        +
        +

        ApiWorkerOptions(security: Dict[str, ForwardRef('ApiWorkerScopes')] = , security_disabled: bool = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiWorkerOptions(betterproto.Message):
        +    security: Dict[str, "ApiWorkerScopes"] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """Apply security definitions to this operation"""
        +
        +    security_disabled: bool = betterproto.bool_field(2)
        +    """
        +    explicitly disable security for this endpoint We need to do this as the
        +    default value of a repeated field is always empty so there is no way of
        +    knowing if security is explicitly disabled
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var security : Dict[str, ApiWorkerScopes]
        +
        +

        Apply security definitions to this operation

        +
        +
        var security_disabled : bool
        +
        +

        explicitly disable security for this endpoint We need to do this as the +default value of a repeated field is always empty so there is no way of +knowing if security is explicitly disabled

        +
        +
        + +
        +class ApiWorkerScopes +(scopes: List[str] = <object object>) +
        +
        +

        ApiWorkerScopes(scopes: List[str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiWorkerScopes(betterproto.Message):
        +    scopes: List[str] = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var scopes : List[str]
        +
        +
        +
        +
        + +
        +class ClientMessage +(id: str = <object object>, init_request: InitRequest = <object object>, trigger_response: TriggerResponse = <object object>) +
        +
        +

        Messages the client is able to send to the server

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ClientMessage(betterproto.Message):
        +    """Messages the client is able to send to the server"""
        +
        +    id: str = betterproto.string_field(1)
        +    """Client message ID, used to pair requests/responses"""
        +
        +    init_request: "InitRequest" = betterproto.message_field(2, group="content")
        +    """
        +    Client initialisation request A worker will not be eligible for triggers
        +    until it has identified itself
        +    """
        +
        +    trigger_response: "TriggerResponse" = betterproto.message_field(3, group="content")
        +    """Client responsding with result of a trigger"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var id : str
        +
        +

        Client message ID, used to pair requests/responses

        +
        +
        var init_requestInitRequest
        +
        +

        Client initialisation request A worker will not be eligible for triggers +until it has identified itself

        +
        +
        var trigger_responseTriggerResponse
        +
        +

        Client responsding with result of a trigger

        +
        +
        +
        +
        +class FaasServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class FaasServiceBase(ServiceBase):
        +    async def trigger_stream(
        +        self, client_message_iterator: AsyncIterator["ClientMessage"]
        +    ) -> AsyncIterator["ServerMessage"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_trigger_stream(
        +        self, stream: "grpclib.server.Stream[ClientMessage, ServerMessage]"
        +    ) -> None:
        +        request = stream.__aiter__()
        +        await self._call_rpc_handler_server_stream(
        +            self.trigger_stream,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.faas.v1.FaasService/TriggerStream": grpclib.const.Handler(
        +                self.__rpc_trigger_stream,
        +                grpclib.const.Cardinality.STREAM_STREAM,
        +                ClientMessage,
        +                ServerMessage,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def trigger_stream(self, client_message_iterator: AsyncIterator[ForwardRef('ClientMessage')]) ‑> AsyncIterator[ServerMessage] +
        +
        +
        +
        + +Expand source code + +
        async def trigger_stream(
        +    self, client_message_iterator: AsyncIterator["ClientMessage"]
        +) -> AsyncIterator["ServerMessage"]:
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class FaasServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class FaasServiceStub(betterproto.ServiceStub):
        +    async def trigger_stream(
        +        self,
        +        client_message_iterator: Union[
        +            AsyncIterable["ClientMessage"], Iterable["ClientMessage"]
        +        ],
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["ServerMessage"]:
        +        async for response in self._stream_stream(
        +            "/nitric.faas.v1.FaasService/TriggerStream",
        +            client_message_iterator,
        +            ClientMessage,
        +            ServerMessage,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def trigger_stream(self, client_message_iterator: Union[AsyncIterable[ForwardRef('ClientMessage')], Iterable[ForwardRef('ClientMessage')]], *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[ServerMessage] +
        +
        +
        +
        + +Expand source code + +
        async def trigger_stream(
        +    self,
        +    client_message_iterator: Union[
        +        AsyncIterable["ClientMessage"], Iterable["ClientMessage"]
        +    ],
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> AsyncIterator["ServerMessage"]:
        +    async for response in self._stream_stream(
        +        "/nitric.faas.v1.FaasService/TriggerStream",
        +        client_message_iterator,
        +        ClientMessage,
        +        ServerMessage,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    ):
        +        yield response
        +
        +
        +
        +
        +
        +class HeaderValue +(value: List[str] = <object object>) +
        +
        +

        HeaderValue(value: List[str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class HeaderValue(betterproto.Message):
        +    value: List[str] = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var value : List[str]
        +
        +
        +
        +
        + +
        +class HttpResponseContext +(headers_old: Dict[str, str] = <object object>, status: int = <object object>, headers: Dict[str, ForwardRef('HeaderValue')] = <object object>) +
        +
        +

        Specific HttpResponse message Note this does not have to be handled by the +User at all but they will have the option of control If they choose…

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class HttpResponseContext(betterproto.Message):
        +    """
        +    Specific HttpResponse message Note this does not have to be handled by the
        +    User at all but they will have the option of control If they choose...
        +    """
        +
        +    headers_old: Dict[str, str] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Old HTTP response headers (deprecated) TODO: Remove in 1.0"""
        +
        +    status: int = betterproto.int32_field(2)
        +    """The HTTP status of the request"""
        +
        +    headers: Dict[str, "HeaderValue"] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP response headers"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("headers_old"):
        +            warnings.warn(
        +                "HttpResponseContext.headers_old is deprecated", DeprecationWarning
        +            )
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var headers : Dict[str, HeaderValue]
        +
        +

        HTTP response headers

        +
        +
        var headers_old : Dict[str, str]
        +
        +

        Old HTTP response headers (deprecated) TODO: Remove in 1.0

        +
        +
        var status : int
        +
        +

        The HTTP status of the request

        +
        +
        +
        +
        +class HttpTriggerContext +(method: str = <object object>, path: str = <object object>, headers_old: Dict[str, str] = <object object>, query_params_old: Dict[str, str] = <object object>, headers: Dict[str, ForwardRef('HeaderValue')] = <object object>, query_params: Dict[str, ForwardRef('QueryValue')] = <object object>, path_params: Dict[str, str] = <object object>) +
        +
        +

        HttpTriggerContext(method: str = , path: str = , headers_old: Dict[str, str] = , query_params_old: Dict[str, str] = , headers: Dict[str, ForwardRef('HeaderValue')] = , query_params: Dict[str, ForwardRef('QueryValue')] = , path_params: Dict[str, str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class HttpTriggerContext(betterproto.Message):
        +    method: str = betterproto.string_field(1)
        +    """The request method"""
        +
        +    path: str = betterproto.string_field(2)
        +    """The path of the request"""
        +
        +    headers_old: Dict[str, str] = betterproto.map_field(
        +        3, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The old request headers (preserving for backwards compatibility) TODO:
        +    Remove in 1.0
        +    """
        +
        +    query_params_old: Dict[str, str] = betterproto.map_field(
        +        4, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """
        +    The old query params (preserving for backwards compatibility) TODO: Remove
        +    in 1.0
        +    """
        +
        +    headers: Dict[str, "HeaderValue"] = betterproto.map_field(
        +        5, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP request headers"""
        +
        +    query_params: Dict[str, "QueryValue"] = betterproto.map_field(
        +        6, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """HTTP Query params"""
        +
        +    path_params: Dict[str, str] = betterproto.map_field(
        +        7, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """HTTP Path parameters"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("headers_old"):
        +            warnings.warn(
        +                "HttpTriggerContext.headers_old is deprecated", DeprecationWarning
        +            )
        +        if self.is_set("query_params_old"):
        +            warnings.warn(
        +                "HttpTriggerContext.query_params_old is deprecated", DeprecationWarning
        +            )
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var headers : Dict[str, HeaderValue]
        +
        +

        HTTP request headers

        +
        +
        var headers_old : Dict[str, str]
        +
        +

        The old request headers (preserving for backwards compatibility) TODO: +Remove in 1.0

        +
        +
        var method : str
        +
        +

        The request method

        +
        +
        var path : str
        +
        +

        The path of the request

        +
        +
        var path_params : Dict[str, str]
        +
        +

        HTTP Path parameters

        +
        +
        var query_params : Dict[str, QueryValue]
        +
        +

        HTTP Query params

        +
        +
        var query_params_old : Dict[str, str]
        +
        +

        The old query params (preserving for backwards compatibility) TODO: Remove +in 1.0

        +
        +
        + +
        +class InitRequest +(api: ApiWorker = <object object>, subscription: SubscriptionWorker = <object object>, schedule: ScheduleWorker = <object object>) +
        +
        +

        InitRequest - Identifies a worker as ready to recieve triggers This message +will contain information on the type of triggers that a worker is capable +of handling

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class InitRequest(betterproto.Message):
        +    """
        +    InitRequest - Identifies a worker as ready to recieve triggers This message
        +    will contain information on the type of triggers that a worker is capable
        +    of handling
        +    """
        +
        +    api: "ApiWorker" = betterproto.message_field(10, group="Worker")
        +    subscription: "SubscriptionWorker" = betterproto.message_field(11, group="Worker")
        +    schedule: "ScheduleWorker" = betterproto.message_field(12, group="Worker")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var apiApiWorker
        +
        +
        +
        +
        var scheduleScheduleWorker
        +
        +
        +
        +
        var subscriptionSubscriptionWorker
        +
        +
        +
        +
        +
        +
        +class InitResponse +
        +
        +

        Placeholder message

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class InitResponse(betterproto.Message):
        +    """Placeholder message"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class QueryValue +(value: List[str] = <object object>) +
        +
        +

        QueryValue(value: List[str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueryValue(betterproto.Message):
        +    value: List[str] = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var value : List[str]
        +
        +
        +
        +
        + +
        +class ScheduleCron +(cron: str = <object object>) +
        +
        +

        ScheduleCron(cron: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ScheduleCron(betterproto.Message):
        +    cron: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var cron : str
        +
        +
        +
        +
        + +
        +class ScheduleRate +(rate: str = <object object>) +
        +
        +

        ScheduleRate(rate: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ScheduleRate(betterproto.Message):
        +    rate: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var rate : str
        +
        +
        +
        +
        + +
        +class ScheduleWorker +(key: str = <object object>, rate: ScheduleRate = <object object>, cron: ScheduleCron = <object object>) +
        +
        +

        ScheduleWorker(key: str = , rate: 'ScheduleRate' = , cron: 'ScheduleCron' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ScheduleWorker(betterproto.Message):
        +    key: str = betterproto.string_field(1)
        +    rate: "ScheduleRate" = betterproto.message_field(10, group="cadence")
        +    cron: "ScheduleCron" = betterproto.message_field(11, group="cadence")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var cronScheduleCron
        +
        +
        +
        +
        var key : str
        +
        +
        +
        +
        var rateScheduleRate
        +
        +
        +
        +
        + +
        +class ServerMessage +(id: str = <object object>, init_response: InitResponse = <object object>, trigger_request: TriggerRequest = <object object>) +
        +
        +

        Messages the server is able to send to the client

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ServerMessage(betterproto.Message):
        +    """Messages the server is able to send to the client"""
        +
        +    id: str = betterproto.string_field(1)
        +    """Server message ID, used to pair requests/responses"""
        +
        +    init_response: "InitResponse" = betterproto.message_field(2, group="content")
        +    """
        +    Server responding with client configuration details to an InitRequest
        +    """
        +
        +    trigger_request: "TriggerRequest" = betterproto.message_field(3, group="content")
        +    """Server requesting client to process a trigger"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var id : str
        +
        +

        Server message ID, used to pair requests/responses

        +
        +
        var init_responseInitResponse
        +
        +

        Server responding with client configuration details to an InitRequest

        +
        +
        var trigger_requestTriggerRequest
        +
        +

        Server requesting client to process a trigger

        +
        +
        +
        +
        +class SubscriptionWorker +(topic: str = <object object>) +
        +
        +

        SubscriptionWorker(topic: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SubscriptionWorker(betterproto.Message):
        +    topic: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var topic : str
        +
        +
        +
        +
        + +
        +class TopicResponseContext +(success: bool = <object object>) +
        +
        +

        Specific event response message We do not accept responses for events only +whether or not they were successfully processed

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicResponseContext(betterproto.Message):
        +    """
        +    Specific event response message We do not accept responses for events only
        +    whether or not they were successfully processed
        +    """
        +
        +    success: bool = betterproto.bool_field(1)
        +    """Success status of the handled event"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var success : bool
        +
        +

        Success status of the handled event

        +
        +
        +
        +
        +class TopicTriggerContext +(topic: str = <object object>) +
        +
        +

        TopicTriggerContext(topic: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicTriggerContext(betterproto.Message):
        +    topic: str = betterproto.string_field(1)
        +    """The topic the message was published for"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var topic : str
        +
        +

        The topic the message was published for

        +
        +
        + +
        +class TriggerRequest +(data: bytes = <object object>, mime_type: str = <object object>, http: HttpTriggerContext = <object object>, topic: TopicTriggerContext = <object object>) +
        +
        +

        The server has a trigger for the client to handle

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TriggerRequest(betterproto.Message):
        +    """The server has a trigger for the client to handle"""
        +
        +    data: bytes = betterproto.bytes_field(1)
        +    """The data in the trigger"""
        +
        +    mime_type: str = betterproto.string_field(2)
        +    """Should we supply a mime type for the data? Or rely on context?"""
        +
        +    http: "HttpTriggerContext" = betterproto.message_field(3, group="context")
        +    topic: "TopicTriggerContext" = betterproto.message_field(4, group="context")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var data : bytes
        +
        +

        The data in the trigger

        +
        +
        var httpHttpTriggerContext
        +
        +
        +
        +
        var mime_type : str
        +
        +

        Should we supply a mime type for the data? Or rely on context?

        +
        +
        var topicTopicTriggerContext
        +
        +
        +
        +
        +
        +
        +class TriggerResponse +(data: bytes = <object object>, http: HttpResponseContext = <object object>, topic: TopicResponseContext = <object object>) +
        +
        +

        The worker has successfully processed a trigger

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TriggerResponse(betterproto.Message):
        +    """The worker has successfully processed a trigger"""
        +
        +    data: bytes = betterproto.bytes_field(1)
        +    """The data returned in the response"""
        +
        +    http: "HttpResponseContext" = betterproto.message_field(10, group="context")
        +    """response to a http request"""
        +
        +    topic: "TopicResponseContext" = betterproto.message_field(11, group="context")
        +    """response to a topic trigger"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var data : bytes
        +
        +

        The data returned in the response

        +
        +
        var httpHttpResponseContext
        +
        +

        response to a http request

        +
        +
        var topicTopicResponseContext
        +
        +

        response to a topic trigger

        +
        +
        +
        + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/index.html b/docs/nitric/proto/nitric/index.html new file mode 100644 index 0000000..53be9a8 --- /dev/null +++ b/docs/nitric/proto/nitric/index.html @@ -0,0 +1,100 @@ + + + + + + +nitric.proto.nitric API documentation + + + + + + + + + + + +
        + + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/queue/index.html b/docs/nitric/proto/nitric/queue/index.html new file mode 100644 index 0000000..de96adb --- /dev/null +++ b/docs/nitric/proto/nitric/queue/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.queue API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.queue

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.queue.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/queue/v1/index.html b/docs/nitric/proto/nitric/queue/v1/index.html new file mode 100644 index 0000000..e1332bf --- /dev/null +++ b/docs/nitric/proto/nitric/queue/v1/index.html @@ -0,0 +1,1141 @@ + + + + + + +nitric.proto.nitric.queue.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.queue.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/queue/v1/queue.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueSendRequest(betterproto.Message):
        +    """Request to push a single event to a queue"""
        +
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The Nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    task: "NitricTask" = betterproto.message_field(2)
        +    """The task to push to the queue"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueSendResponse(betterproto.Message):
        +    """Result of pushing a single task to a queue"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueSendBatchRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The Nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    tasks: List["NitricTask"] = betterproto.message_field(2)
        +    """Array of tasks to push to the queue"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueSendBatchResponse(betterproto.Message):
        +    """Response for sending a collection of tasks"""
        +
        +    failed_tasks: List["FailedTask"] = betterproto.message_field(1)
        +    """A list of tasks that failed to be queued"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueReceiveRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    depth: int = betterproto.int32_field(2)
        +    """
        +    The max number of items to pop off the queue, may be capped by provider
        +    specific limitations
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueReceiveResponse(betterproto.Message):
        +    tasks: List["NitricTask"] = betterproto.message_field(1)
        +    """Array of tasks popped off the queue"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueCompleteRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The nitric name for the queue  this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    lease_id: str = betterproto.string_field(2)
        +    """Lease id of the task to be completed"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueCompleteResponse(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class FailedTask(betterproto.Message):
        +    task: "NitricTask" = betterproto.message_field(1)
        +    """The task that failed to be pushed"""
        +
        +    message: str = betterproto.string_field(2)
        +    """A message describing the failure"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class NitricTask(betterproto.Message):
        +    """A task to be sent or received from a queue."""
        +
        +    id: str = betterproto.string_field(1)
        +    """A unique id for the task"""
        +
        +    lease_id: str = betterproto.string_field(2)
        +    """
        +    The lease id unique to the pop request, this must be used to complete,
        +    extend the lease or release the task.
        +    """
        +
        +    payload_type: str = betterproto.string_field(3)
        +    """A content hint for the tasks payload"""
        +
        +    payload: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(4)
        +    """The payload of the task"""
        +
        +
        +class QueueServiceStub(betterproto.ServiceStub):
        +    async def send(
        +        self,
        +        queue_send_request: "QueueSendRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueSendResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Send",
        +            queue_send_request,
        +            QueueSendResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def send_batch(
        +        self,
        +        queue_send_batch_request: "QueueSendBatchRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueSendBatchResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/SendBatch",
        +            queue_send_batch_request,
        +            QueueSendBatchResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def receive(
        +        self,
        +        queue_receive_request: "QueueReceiveRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueReceiveResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Receive",
        +            queue_receive_request,
        +            QueueReceiveResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def complete(
        +        self,
        +        queue_complete_request: "QueueCompleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueCompleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Complete",
        +            queue_complete_request,
        +            QueueCompleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class QueueServiceBase(ServiceBase):
        +    async def send(self, queue_send_request: "QueueSendRequest") -> "QueueSendResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def send_batch(
        +        self, queue_send_batch_request: "QueueSendBatchRequest"
        +    ) -> "QueueSendBatchResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def receive(
        +        self, queue_receive_request: "QueueReceiveRequest"
        +    ) -> "QueueReceiveResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def complete(
        +        self, queue_complete_request: "QueueCompleteRequest"
        +    ) -> "QueueCompleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_send(
        +        self, stream: "grpclib.server.Stream[QueueSendRequest, QueueSendResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.send(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_send_batch(
        +        self,
        +        stream: "grpclib.server.Stream[QueueSendBatchRequest, QueueSendBatchResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.send_batch(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_receive(
        +        self, stream: "grpclib.server.Stream[QueueReceiveRequest, QueueReceiveResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.receive(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_complete(
        +        self,
        +        stream: "grpclib.server.Stream[QueueCompleteRequest, QueueCompleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.complete(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.queue.v1.QueueService/Send": grpclib.const.Handler(
        +                self.__rpc_send,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueSendRequest,
        +                QueueSendResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/SendBatch": grpclib.const.Handler(
        +                self.__rpc_send_batch,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueSendBatchRequest,
        +                QueueSendBatchResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/Receive": grpclib.const.Handler(
        +                self.__rpc_receive,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueReceiveRequest,
        +                QueueReceiveResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/Complete": grpclib.const.Handler(
        +                self.__rpc_complete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueCompleteRequest,
        +                QueueCompleteResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class FailedTask +(task: NitricTask = <object object>, message: str = <object object>) +
        +
        +

        FailedTask(task: 'NitricTask' = , message: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class FailedTask(betterproto.Message):
        +    task: "NitricTask" = betterproto.message_field(1)
        +    """The task that failed to be pushed"""
        +
        +    message: str = betterproto.string_field(2)
        +    """A message describing the failure"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var message : str
        +
        +

        A message describing the failure

        +
        +
        var taskNitricTask
        +
        +

        The task that failed to be pushed

        +
        +
        + +
        +class NitricTask +(id: str = <object object>, lease_id: str = <object object>, payload_type: str = <object object>, payload: betterproto_lib_google_protobuf.Struct = <object object>) +
        +
        +

        A task to be sent or received from a queue.

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class NitricTask(betterproto.Message):
        +    """A task to be sent or received from a queue."""
        +
        +    id: str = betterproto.string_field(1)
        +    """A unique id for the task"""
        +
        +    lease_id: str = betterproto.string_field(2)
        +    """
        +    The lease id unique to the pop request, this must be used to complete,
        +    extend the lease or release the task.
        +    """
        +
        +    payload_type: str = betterproto.string_field(3)
        +    """A content hint for the tasks payload"""
        +
        +    payload: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(4)
        +    """The payload of the task"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var id : str
        +
        +

        A unique id for the task

        +
        +
        var lease_id : str
        +
        +

        The lease id unique to the pop request, this must be used to complete, +extend the lease or release the task.

        +
        +
        var payload : betterproto.lib.google.protobuf.Struct
        +
        +

        The payload of the task

        +
        +
        var payload_type : str
        +
        +

        A content hint for the tasks payload

        +
        +
        +
        +
        +class QueueCompleteRequest +(queue: str = <object object>, lease_id: str = <object object>) +
        +
        +

        QueueCompleteRequest(queue: str = , lease_id: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueCompleteRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The nitric name for the queue  this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    lease_id: str = betterproto.string_field(2)
        +    """Lease id of the task to be completed"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var lease_id : str
        +
        +

        Lease id of the task to be completed

        +
        +
        var queue : str
        +
        +

        The nitric name for the queue +this will automatically be resolved to the +provider specific queue identifier.

        +
        +
        + +
        +class QueueCompleteResponse +
        +
        +

        QueueCompleteResponse()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueCompleteResponse(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class QueueReceiveRequest +(queue: str = <object object>, depth: int = <object object>) +
        +
        +

        QueueReceiveRequest(queue: str = , depth: int = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueReceiveRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    depth: int = betterproto.int32_field(2)
        +    """
        +    The max number of items to pop off the queue, may be capped by provider
        +    specific limitations
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var depth : int
        +
        +

        The max number of items to pop off the queue, may be capped by provider +specific limitations

        +
        +
        var queue : str
        +
        +

        The nitric name for the queue this will automatically be resolved to the +provider specific queue identifier.

        +
        +
        + +
        +class QueueReceiveResponse +(tasks: List[ForwardRef('NitricTask')] = <object object>) +
        +
        +

        QueueReceiveResponse(tasks: List[ForwardRef('NitricTask')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueReceiveResponse(betterproto.Message):
        +    tasks: List["NitricTask"] = betterproto.message_field(1)
        +    """Array of tasks popped off the queue"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var tasks : List[NitricTask]
        +
        +

        Array of tasks popped off the queue

        +
        +
        + +
        +class QueueSendBatchRequest +(queue: str = <object object>, tasks: List[ForwardRef('NitricTask')] = <object object>) +
        +
        +

        QueueSendBatchRequest(queue: str = , tasks: List[ForwardRef('NitricTask')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueSendBatchRequest(betterproto.Message):
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The Nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    tasks: List["NitricTask"] = betterproto.message_field(2)
        +    """Array of tasks to push to the queue"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var queue : str
        +
        +

        The Nitric name for the queue this will automatically be resolved to the +provider specific queue identifier.

        +
        +
        var tasks : List[NitricTask]
        +
        +

        Array of tasks to push to the queue

        +
        +
        + +
        +class QueueSendBatchResponse +(failed_tasks: List[ForwardRef('FailedTask')] = <object object>) +
        +
        +

        Response for sending a collection of tasks

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueSendBatchResponse(betterproto.Message):
        +    """Response for sending a collection of tasks"""
        +
        +    failed_tasks: List["FailedTask"] = betterproto.message_field(1)
        +    """A list of tasks that failed to be queued"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var failed_tasks : List[FailedTask]
        +
        +

        A list of tasks that failed to be queued

        +
        +
        +
        +
        +class QueueSendRequest +(queue: str = <object object>, task: NitricTask = <object object>) +
        +
        +

        Request to push a single event to a queue

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueSendRequest(betterproto.Message):
        +    """Request to push a single event to a queue"""
        +
        +    queue: str = betterproto.string_field(1)
        +    """
        +    The Nitric name for the queue this will automatically be resolved to the
        +    provider specific queue identifier.
        +    """
        +
        +    task: "NitricTask" = betterproto.message_field(2)
        +    """The task to push to the queue"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var queue : str
        +
        +

        The Nitric name for the queue this will automatically be resolved to the +provider specific queue identifier.

        +
        +
        var taskNitricTask
        +
        +

        The task to push to the queue

        +
        +
        +
        +
        +class QueueSendResponse +
        +
        +

        Result of pushing a single task to a queue

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueSendResponse(betterproto.Message):
        +    """Result of pushing a single task to a queue"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class QueueServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class QueueServiceBase(ServiceBase):
        +    async def send(self, queue_send_request: "QueueSendRequest") -> "QueueSendResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def send_batch(
        +        self, queue_send_batch_request: "QueueSendBatchRequest"
        +    ) -> "QueueSendBatchResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def receive(
        +        self, queue_receive_request: "QueueReceiveRequest"
        +    ) -> "QueueReceiveResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def complete(
        +        self, queue_complete_request: "QueueCompleteRequest"
        +    ) -> "QueueCompleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_send(
        +        self, stream: "grpclib.server.Stream[QueueSendRequest, QueueSendResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.send(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_send_batch(
        +        self,
        +        stream: "grpclib.server.Stream[QueueSendBatchRequest, QueueSendBatchResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.send_batch(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_receive(
        +        self, stream: "grpclib.server.Stream[QueueReceiveRequest, QueueReceiveResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.receive(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_complete(
        +        self,
        +        stream: "grpclib.server.Stream[QueueCompleteRequest, QueueCompleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.complete(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.queue.v1.QueueService/Send": grpclib.const.Handler(
        +                self.__rpc_send,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueSendRequest,
        +                QueueSendResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/SendBatch": grpclib.const.Handler(
        +                self.__rpc_send_batch,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueSendBatchRequest,
        +                QueueSendBatchResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/Receive": grpclib.const.Handler(
        +                self.__rpc_receive,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueReceiveRequest,
        +                QueueReceiveResponse,
        +            ),
        +            "/nitric.queue.v1.QueueService/Complete": grpclib.const.Handler(
        +                self.__rpc_complete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                QueueCompleteRequest,
        +                QueueCompleteResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def complete(self, queue_complete_request: QueueCompleteRequest) ‑> QueueCompleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def complete(
        +    self, queue_complete_request: "QueueCompleteRequest"
        +) -> "QueueCompleteResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def receive(self, queue_receive_request: QueueReceiveRequest) ‑> QueueReceiveResponse +
        +
        +
        +
        + +Expand source code + +
        async def receive(
        +    self, queue_receive_request: "QueueReceiveRequest"
        +) -> "QueueReceiveResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def send(self, queue_send_request: QueueSendRequest) ‑> QueueSendResponse +
        +
        +
        +
        + +Expand source code + +
        async def send(self, queue_send_request: "QueueSendRequest") -> "QueueSendResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def send_batch(self, queue_send_batch_request: QueueSendBatchRequest) ‑> QueueSendBatchResponse +
        +
        +
        +
        + +Expand source code + +
        async def send_batch(
        +    self, queue_send_batch_request: "QueueSendBatchRequest"
        +) -> "QueueSendBatchResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class QueueServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class QueueServiceStub(betterproto.ServiceStub):
        +    async def send(
        +        self,
        +        queue_send_request: "QueueSendRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueSendResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Send",
        +            queue_send_request,
        +            QueueSendResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def send_batch(
        +        self,
        +        queue_send_batch_request: "QueueSendBatchRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueSendBatchResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/SendBatch",
        +            queue_send_batch_request,
        +            QueueSendBatchResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def receive(
        +        self,
        +        queue_receive_request: "QueueReceiveRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueReceiveResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Receive",
        +            queue_receive_request,
        +            QueueReceiveResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def complete(
        +        self,
        +        queue_complete_request: "QueueCompleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "QueueCompleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.queue.v1.QueueService/Complete",
        +            queue_complete_request,
        +            QueueCompleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def complete(self, queue_complete_request: QueueCompleteRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> QueueCompleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def complete(
        +    self,
        +    queue_complete_request: "QueueCompleteRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "QueueCompleteResponse":
        +    return await self._unary_unary(
        +        "/nitric.queue.v1.QueueService/Complete",
        +        queue_complete_request,
        +        QueueCompleteResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def receive(self, queue_receive_request: QueueReceiveRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> QueueReceiveResponse +
        +
        +
        +
        + +Expand source code + +
        async def receive(
        +    self,
        +    queue_receive_request: "QueueReceiveRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "QueueReceiveResponse":
        +    return await self._unary_unary(
        +        "/nitric.queue.v1.QueueService/Receive",
        +        queue_receive_request,
        +        QueueReceiveResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def send(self, queue_send_request: QueueSendRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> QueueSendResponse +
        +
        +
        +
        + +Expand source code + +
        async def send(
        +    self,
        +    queue_send_request: "QueueSendRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "QueueSendResponse":
        +    return await self._unary_unary(
        +        "/nitric.queue.v1.QueueService/Send",
        +        queue_send_request,
        +        QueueSendResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def send_batch(self, queue_send_batch_request: QueueSendBatchRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> QueueSendBatchResponse +
        +
        +
        +
        + +Expand source code + +
        async def send_batch(
        +    self,
        +    queue_send_batch_request: "QueueSendBatchRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "QueueSendBatchResponse":
        +    return await self._unary_unary(
        +        "/nitric.queue.v1.QueueService/SendBatch",
        +        queue_send_batch_request,
        +        QueueSendBatchResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/resource/index.html b/docs/nitric/proto/nitric/resource/index.html new file mode 100644 index 0000000..8619c30 --- /dev/null +++ b/docs/nitric/proto/nitric/resource/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.resource API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.resource

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.resource.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/resource/v1/index.html b/docs/nitric/proto/nitric/resource/v1/index.html new file mode 100644 index 0000000..d977ec0 --- /dev/null +++ b/docs/nitric/proto/nitric/resource/v1/index.html @@ -0,0 +1,1359 @@ + + + + + + +nitric.proto.nitric.resource.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.resource.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/resource/v1/resource.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +class ResourceType(betterproto.Enum):
        +    Api = 0
        +    Function = 1
        +    Bucket = 2
        +    Queue = 3
        +    Topic = 4
        +    Schedule = 5
        +    Subscription = 6
        +    Collection = 7
        +    Policy = 8
        +    Secret = 9
        +
        +
        +class Action(betterproto.Enum):
        +    BucketFileList = 0
        +    """Bucket Permissions: 0XX"""
        +
        +    BucketFileGet = 1
        +    BucketFilePut = 2
        +    BucketFileDelete = 3
        +    TopicList = 200
        +    """Topic Permissions: 2XX"""
        +
        +    TopicDetail = 201
        +    TopicEventPublish = 202
        +    QueueSend = 300
        +    """Queue Permissions: 3XX"""
        +
        +    QueueReceive = 301
        +    QueueList = 302
        +    QueueDetail = 303
        +    CollectionDocumentRead = 400
        +    """Collection Permissions: 4XX"""
        +
        +    CollectionDocumentWrite = 401
        +    CollectionDocumentDelete = 402
        +    CollectionQuery = 403
        +    CollectionList = 404
        +    SecretPut = 500
        +    """Secret Permissions: 5XX"""
        +
        +    SecretAccess = 501
        +
        +
        +@dataclass(eq=False, repr=False)
        +class PolicyResource(betterproto.Message):
        +    principals: List["Resource"] = betterproto.message_field(1)
        +    actions: List["Action"] = betterproto.enum_field(2)
        +    resources: List["Resource"] = betterproto.message_field(3)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Resource(betterproto.Message):
        +    type: "ResourceType" = betterproto.enum_field(1)
        +    name: str = betterproto.string_field(2)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ResourceDeclareRequest(betterproto.Message):
        +    resource: "Resource" = betterproto.message_field(1)
        +    policy: "PolicyResource" = betterproto.message_field(10, group="config")
        +    bucket: "BucketResource" = betterproto.message_field(11, group="config")
        +    queue: "QueueResource" = betterproto.message_field(12, group="config")
        +    topic: "TopicResource" = betterproto.message_field(13, group="config")
        +    collection: "CollectionResource" = betterproto.message_field(14, group="config")
        +    secret: "SecretResource" = betterproto.message_field(15, group="config")
        +    api: "ApiResource" = betterproto.message_field(16, group="config")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class BucketResource(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class QueueResource(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicResource(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class CollectionResource(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretResource(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiSecurityDefinitionJwt(betterproto.Message):
        +    """protect your API with JWT authentication"""
        +
        +    issuer: str = betterproto.string_field(1)
        +    audiences: List[str] = betterproto.string_field(2)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiSecurityDefinition(betterproto.Message):
        +    jwt: "ApiSecurityDefinitionJwt" = betterproto.message_field(1, group="definition")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiScopes(betterproto.Message):
        +    scopes: List[str] = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiResource(betterproto.Message):
        +    security_definitions: Dict[str, "ApiSecurityDefinition"] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """
        +    Security definitions for the api These may be used by registered routes and
        +    operations on the API
        +    """
        +
        +    security: Dict[str, "ApiScopes"] = betterproto.map_field(
        +        2, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """root level security for this api"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ResourceDeclareResponse(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ApiResourceDetails(betterproto.Message):
        +    url: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ResourceDetailsRequest(betterproto.Message):
        +    resource: "Resource" = betterproto.message_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ResourceDetailsResponse(betterproto.Message):
        +    id: str = betterproto.string_field(1)
        +    """The identifier of the resource"""
        +
        +    provider: str = betterproto.string_field(2)
        +    """The provider this resource is deployed with (e.g. aws)"""
        +
        +    service: str = betterproto.string_field(3)
        +    """The service this resource is deployed on (e.g. ApiGateway)"""
        +
        +    api: "ApiResourceDetails" = betterproto.message_field(10, group="details")
        +
        +
        +class ResourceServiceStub(betterproto.ServiceStub):
        +    async def declare(
        +        self,
        +        resource_declare_request: "ResourceDeclareRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "ResourceDeclareResponse":
        +        return await self._unary_unary(
        +            "/nitric.resource.v1.ResourceService/Declare",
        +            resource_declare_request,
        +            ResourceDeclareResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def details(
        +        self,
        +        resource_details_request: "ResourceDetailsRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "ResourceDetailsResponse":
        +        return await self._unary_unary(
        +            "/nitric.resource.v1.ResourceService/Details",
        +            resource_details_request,
        +            ResourceDetailsResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class ResourceServiceBase(ServiceBase):
        +    async def declare(
        +        self, resource_declare_request: "ResourceDeclareRequest"
        +    ) -> "ResourceDeclareResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def details(
        +        self, resource_details_request: "ResourceDetailsRequest"
        +    ) -> "ResourceDetailsResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_declare(
        +        self,
        +        stream: "grpclib.server.Stream[ResourceDeclareRequest, ResourceDeclareResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.declare(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_details(
        +        self,
        +        stream: "grpclib.server.Stream[ResourceDetailsRequest, ResourceDetailsResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.details(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.resource.v1.ResourceService/Declare": grpclib.const.Handler(
        +                self.__rpc_declare,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                ResourceDeclareRequest,
        +                ResourceDeclareResponse,
        +            ),
        +            "/nitric.resource.v1.ResourceService/Details": grpclib.const.Handler(
        +                self.__rpc_details,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                ResourceDetailsRequest,
        +                ResourceDetailsResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Action +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        An enumeration.

        +
        + +Expand source code + +
        class Action(betterproto.Enum):
        +    BucketFileList = 0
        +    """Bucket Permissions: 0XX"""
        +
        +    BucketFileGet = 1
        +    BucketFilePut = 2
        +    BucketFileDelete = 3
        +    TopicList = 200
        +    """Topic Permissions: 2XX"""
        +
        +    TopicDetail = 201
        +    TopicEventPublish = 202
        +    QueueSend = 300
        +    """Queue Permissions: 3XX"""
        +
        +    QueueReceive = 301
        +    QueueList = 302
        +    QueueDetail = 303
        +    CollectionDocumentRead = 400
        +    """Collection Permissions: 4XX"""
        +
        +    CollectionDocumentWrite = 401
        +    CollectionDocumentDelete = 402
        +    CollectionQuery = 403
        +    CollectionList = 404
        +    SecretPut = 500
        +    """Secret Permissions: 5XX"""
        +
        +    SecretAccess = 501
        +
        +

        Ancestors

        +
          +
        • betterproto.Enum
        • +
        • enum.IntEnum
        • +
        • builtins.int
        • +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var BucketFileDelete
        +
        +
        +
        +
        var BucketFileGet
        +
        +
        +
        +
        var BucketFileList
        +
        +

        Bucket Permissions: 0XX

        +
        +
        var BucketFilePut
        +
        +
        +
        +
        var CollectionDocumentDelete
        +
        +
        +
        +
        var CollectionDocumentRead
        +
        +

        Collection Permissions: 4XX

        +
        +
        var CollectionDocumentWrite
        +
        +
        +
        +
        var CollectionList
        +
        +
        +
        +
        var CollectionQuery
        +
        +
        +
        +
        var QueueDetail
        +
        +
        +
        +
        var QueueList
        +
        +
        +
        +
        var QueueReceive
        +
        +
        +
        +
        var QueueSend
        +
        +

        Queue Permissions: 3XX

        +
        +
        var SecretAccess
        +
        +
        +
        +
        var SecretPut
        +
        +

        Secret Permissions: 5XX

        +
        +
        var TopicDetail
        +
        +
        +
        +
        var TopicEventPublish
        +
        +
        +
        +
        var TopicList
        +
        +

        Topic Permissions: 2XX

        +
        +
        +
        +
        +class ApiResource +(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = <object object>, security: Dict[str, ForwardRef('ApiScopes')] = <object object>) +
        +
        +

        ApiResource(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = , security: Dict[str, ForwardRef('ApiScopes')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiResource(betterproto.Message):
        +    security_definitions: Dict[str, "ApiSecurityDefinition"] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """
        +    Security definitions for the api These may be used by registered routes and
        +    operations on the API
        +    """
        +
        +    security: Dict[str, "ApiScopes"] = betterproto.map_field(
        +        2, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE
        +    )
        +    """root level security for this api"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var security : Dict[str, ApiScopes]
        +
        +

        root level security for this api

        +
        +
        var security_definitions : Dict[str, ApiSecurityDefinition]
        +
        +

        Security definitions for the api These may be used by registered routes and +operations on the API

        +
        +
        + +
        +class ApiResourceDetails +(url: str = <object object>) +
        +
        +

        ApiResourceDetails(url: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiResourceDetails(betterproto.Message):
        +    url: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var url : str
        +
        +
        +
        +
        + +
        +class ApiScopes +(scopes: List[str] = <object object>) +
        +
        +

        ApiScopes(scopes: List[str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiScopes(betterproto.Message):
        +    scopes: List[str] = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var scopes : List[str]
        +
        +
        +
        +
        + +
        +class ApiSecurityDefinition +(jwt: ApiSecurityDefinitionJwt = <object object>) +
        +
        +

        ApiSecurityDefinition(jwt: 'ApiSecurityDefinitionJwt' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiSecurityDefinition(betterproto.Message):
        +    jwt: "ApiSecurityDefinitionJwt" = betterproto.message_field(1, group="definition")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var jwtApiSecurityDefinitionJwt
        +
        +
        +
        +
        + +
        +class ApiSecurityDefinitionJwt +(issuer: str = <object object>, audiences: List[str] = <object object>) +
        +
        +

        protect your API with JWT authentication

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ApiSecurityDefinitionJwt(betterproto.Message):
        +    """protect your API with JWT authentication"""
        +
        +    issuer: str = betterproto.string_field(1)
        +    audiences: List[str] = betterproto.string_field(2)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var audiences : List[str]
        +
        +
        +
        +
        var issuer : str
        +
        +
        +
        +
        +
        +
        +class BucketResource +
        +
        +

        BucketResource()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class BucketResource(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class CollectionResource +
        +
        +

        CollectionResource()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class CollectionResource(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class PolicyResource +(principals: List[ForwardRef('Resource')] = <object object>, actions: List[ForwardRef('Action')] = <object object>, resources: List[ForwardRef('Resource')] = <object object>) +
        +
        +

        PolicyResource(principals: List[ForwardRef('Resource')] = , actions: List[ForwardRef('Action')] = , resources: List[ForwardRef('Resource')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class PolicyResource(betterproto.Message):
        +    principals: List["Resource"] = betterproto.message_field(1)
        +    actions: List["Action"] = betterproto.enum_field(2)
        +    resources: List["Resource"] = betterproto.message_field(3)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var principals : List[Resource]
        +
        +
        +
        +
        var resources : List[Resource]
        +
        +
        +
        +
        + +
        +class QueueResource +
        +
        +

        QueueResource()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class QueueResource(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class Resource +(type: ResourceType = <object object>, name: str = <object object>) +
        +
        +

        Resource(type: 'ResourceType' = , name: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Resource(betterproto.Message):
        +    type: "ResourceType" = betterproto.enum_field(1)
        +    name: str = betterproto.string_field(2)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var name : str
        +
        +
        +
        +
        var typeResourceType
        +
        +
        +
        +
        + +
        +class ResourceDeclareRequest +(resource: Resource = <object object>, policy: PolicyResource = <object object>, bucket: BucketResource = <object object>, queue: QueueResource = <object object>, topic: TopicResource = <object object>, collection: CollectionResource = <object object>, secret: SecretResource = <object object>, api: ApiResource = <object object>) +
        +
        +

        ResourceDeclareRequest(resource: 'Resource' = , policy: 'PolicyResource' = , bucket: 'BucketResource' = , queue: 'QueueResource' = , topic: 'TopicResource' = , collection: 'CollectionResource' = , secret: 'SecretResource' = , api: 'ApiResource' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ResourceDeclareRequest(betterproto.Message):
        +    resource: "Resource" = betterproto.message_field(1)
        +    policy: "PolicyResource" = betterproto.message_field(10, group="config")
        +    bucket: "BucketResource" = betterproto.message_field(11, group="config")
        +    queue: "QueueResource" = betterproto.message_field(12, group="config")
        +    topic: "TopicResource" = betterproto.message_field(13, group="config")
        +    collection: "CollectionResource" = betterproto.message_field(14, group="config")
        +    secret: "SecretResource" = betterproto.message_field(15, group="config")
        +    api: "ApiResource" = betterproto.message_field(16, group="config")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var apiApiResource
        +
        +
        +
        +
        var bucketBucketResource
        +
        +
        +
        +
        var collectionCollectionResource
        +
        +
        +
        +
        var policyPolicyResource
        +
        +
        +
        +
        var queueQueueResource
        +
        +
        +
        +
        var resourceResource
        +
        +
        +
        +
        var secretSecretResource
        +
        +
        +
        +
        var topicTopicResource
        +
        +
        +
        +
        + +
        +class ResourceDeclareResponse +
        +
        +

        ResourceDeclareResponse()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ResourceDeclareResponse(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class ResourceDetailsRequest +(resource: Resource = <object object>) +
        +
        +

        ResourceDetailsRequest(resource: 'Resource' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ResourceDetailsRequest(betterproto.Message):
        +    resource: "Resource" = betterproto.message_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var resourceResource
        +
        +
        +
        +
        + +
        +class ResourceDetailsResponse +(id: str = <object object>, provider: str = <object object>, service: str = <object object>, api: ApiResourceDetails = <object object>) +
        +
        +

        ResourceDetailsResponse(id: str = , provider: str = , service: str = , api: 'ApiResourceDetails' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ResourceDetailsResponse(betterproto.Message):
        +    id: str = betterproto.string_field(1)
        +    """The identifier of the resource"""
        +
        +    provider: str = betterproto.string_field(2)
        +    """The provider this resource is deployed with (e.g. aws)"""
        +
        +    service: str = betterproto.string_field(3)
        +    """The service this resource is deployed on (e.g. ApiGateway)"""
        +
        +    api: "ApiResourceDetails" = betterproto.message_field(10, group="details")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var apiApiResourceDetails
        +
        +
        +
        +
        var id : str
        +
        +

        The identifier of the resource

        +
        +
        var provider : str
        +
        +

        The provider this resource is deployed with (e.g. aws)

        +
        +
        var service : str
        +
        +

        The service this resource is deployed on (e.g. ApiGateway)

        +
        +
        + +
        +class ResourceServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class ResourceServiceBase(ServiceBase):
        +    async def declare(
        +        self, resource_declare_request: "ResourceDeclareRequest"
        +    ) -> "ResourceDeclareResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def details(
        +        self, resource_details_request: "ResourceDetailsRequest"
        +    ) -> "ResourceDetailsResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_declare(
        +        self,
        +        stream: "grpclib.server.Stream[ResourceDeclareRequest, ResourceDeclareResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.declare(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_details(
        +        self,
        +        stream: "grpclib.server.Stream[ResourceDetailsRequest, ResourceDetailsResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.details(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.resource.v1.ResourceService/Declare": grpclib.const.Handler(
        +                self.__rpc_declare,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                ResourceDeclareRequest,
        +                ResourceDeclareResponse,
        +            ),
        +            "/nitric.resource.v1.ResourceService/Details": grpclib.const.Handler(
        +                self.__rpc_details,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                ResourceDetailsRequest,
        +                ResourceDetailsResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def declare(self, resource_declare_request: ResourceDeclareRequest) ‑> ResourceDeclareResponse +
        +
        +
        +
        + +Expand source code + +
        async def declare(
        +    self, resource_declare_request: "ResourceDeclareRequest"
        +) -> "ResourceDeclareResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def details(self, resource_details_request: ResourceDetailsRequest) ‑> ResourceDetailsResponse +
        +
        +
        +
        + +Expand source code + +
        async def details(
        +    self, resource_details_request: "ResourceDetailsRequest"
        +) -> "ResourceDetailsResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class ResourceServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class ResourceServiceStub(betterproto.ServiceStub):
        +    async def declare(
        +        self,
        +        resource_declare_request: "ResourceDeclareRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "ResourceDeclareResponse":
        +        return await self._unary_unary(
        +            "/nitric.resource.v1.ResourceService/Declare",
        +            resource_declare_request,
        +            ResourceDeclareResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def details(
        +        self,
        +        resource_details_request: "ResourceDetailsRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "ResourceDetailsResponse":
        +        return await self._unary_unary(
        +            "/nitric.resource.v1.ResourceService/Details",
        +            resource_details_request,
        +            ResourceDetailsResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def declare(self, resource_declare_request: ResourceDeclareRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> ResourceDeclareResponse +
        +
        +
        +
        + +Expand source code + +
        async def declare(
        +    self,
        +    resource_declare_request: "ResourceDeclareRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "ResourceDeclareResponse":
        +    return await self._unary_unary(
        +        "/nitric.resource.v1.ResourceService/Declare",
        +        resource_declare_request,
        +        ResourceDeclareResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def details(self, resource_details_request: ResourceDetailsRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> ResourceDetailsResponse +
        +
        +
        +
        + +Expand source code + +
        async def details(
        +    self,
        +    resource_details_request: "ResourceDetailsRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "ResourceDetailsResponse":
        +    return await self._unary_unary(
        +        "/nitric.resource.v1.ResourceService/Details",
        +        resource_details_request,
        +        ResourceDetailsResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +class ResourceType +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        An enumeration.

        +
        + +Expand source code + +
        class ResourceType(betterproto.Enum):
        +    Api = 0
        +    Function = 1
        +    Bucket = 2
        +    Queue = 3
        +    Topic = 4
        +    Schedule = 5
        +    Subscription = 6
        +    Collection = 7
        +    Policy = 8
        +    Secret = 9
        +
        +

        Ancestors

        +
          +
        • betterproto.Enum
        • +
        • enum.IntEnum
        • +
        • builtins.int
        • +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var Api
        +
        +
        +
        +
        var Bucket
        +
        +
        +
        +
        var Collection
        +
        +
        +
        +
        var Function
        +
        +
        +
        +
        var Policy
        +
        +
        +
        +
        var Queue
        +
        +
        +
        +
        var Schedule
        +
        +
        +
        +
        var Secret
        +
        +
        +
        +
        var Subscription
        +
        +
        +
        +
        var Topic
        +
        +
        +
        +
        +
        +
        +class SecretResource +
        +
        +

        SecretResource()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretResource(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class TopicResource +
        +
        +

        TopicResource()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicResource(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/secret/index.html b/docs/nitric/proto/nitric/secret/index.html new file mode 100644 index 0000000..e5c1d07 --- /dev/null +++ b/docs/nitric/proto/nitric/secret/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.secret API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.secret

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.secret.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/secret/v1/index.html b/docs/nitric/proto/nitric/secret/v1/index.html new file mode 100644 index 0000000..819a1f4 --- /dev/null +++ b/docs/nitric/proto/nitric/secret/v1/index.html @@ -0,0 +1,683 @@ + + + + + + +nitric.proto.nitric.secret.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.secret.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/secret/v1/secret.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    Dict,
        +    Optional,
        +)
        +
        +import betterproto
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretPutRequest(betterproto.Message):
        +    """Request to put a secret to a Secret Store"""
        +
        +    secret: "Secret" = betterproto.message_field(1)
        +    """The Secret to put to the Secret store"""
        +
        +    value: bytes = betterproto.bytes_field(2)
        +    """The value to assign to that secret"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretPutResponse(betterproto.Message):
        +    """Result from putting the secret to a Secret Store"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The id of the secret"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretAccessRequest(betterproto.Message):
        +    """Request to get a secret from a Secret Store"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The id of the secret"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretAccessResponse(betterproto.Message):
        +    """The secret response"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The version of the secret that was requested"""
        +
        +    value: bytes = betterproto.bytes_field(2)
        +    """The value of the secret"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Secret(betterproto.Message):
        +    """The secret container"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The secret name"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SecretVersion(betterproto.Message):
        +    """A version of a secret"""
        +
        +    secret: "Secret" = betterproto.message_field(1)
        +    """Reference to the secret container"""
        +
        +    version: str = betterproto.string_field(2)
        +    """The secret version"""
        +
        +
        +class SecretServiceStub(betterproto.ServiceStub):
        +    async def put(
        +        self,
        +        secret_put_request: "SecretPutRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "SecretPutResponse":
        +        return await self._unary_unary(
        +            "/nitric.secret.v1.SecretService/Put",
        +            secret_put_request,
        +            SecretPutResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def access(
        +        self,
        +        secret_access_request: "SecretAccessRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "SecretAccessResponse":
        +        return await self._unary_unary(
        +            "/nitric.secret.v1.SecretService/Access",
        +            secret_access_request,
        +            SecretAccessResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class SecretServiceBase(ServiceBase):
        +    async def put(self, secret_put_request: "SecretPutRequest") -> "SecretPutResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def access(
        +        self, secret_access_request: "SecretAccessRequest"
        +    ) -> "SecretAccessResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_put(
        +        self, stream: "grpclib.server.Stream[SecretPutRequest, SecretPutResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.put(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_access(
        +        self, stream: "grpclib.server.Stream[SecretAccessRequest, SecretAccessResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.access(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.secret.v1.SecretService/Put": grpclib.const.Handler(
        +                self.__rpc_put,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                SecretPutRequest,
        +                SecretPutResponse,
        +            ),
        +            "/nitric.secret.v1.SecretService/Access": grpclib.const.Handler(
        +                self.__rpc_access,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                SecretAccessRequest,
        +                SecretAccessResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Secret +(name: str = <object object>) +
        +
        +

        The secret container

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Secret(betterproto.Message):
        +    """The secret container"""
        +
        +    name: str = betterproto.string_field(1)
        +    """The secret name"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var name : str
        +
        +

        The secret name

        +
        +
        +
        +
        +class SecretAccessRequest +(secret_version: SecretVersion = <object object>) +
        +
        +

        Request to get a secret from a Secret Store

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretAccessRequest(betterproto.Message):
        +    """Request to get a secret from a Secret Store"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The id of the secret"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var secret_versionSecretVersion
        +
        +

        The id of the secret

        +
        +
        +
        +
        +class SecretAccessResponse +(secret_version: SecretVersion = <object object>, value: bytes = <object object>) +
        +
        +

        The secret response

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretAccessResponse(betterproto.Message):
        +    """The secret response"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The version of the secret that was requested"""
        +
        +    value: bytes = betterproto.bytes_field(2)
        +    """The value of the secret"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var secret_versionSecretVersion
        +
        +

        The version of the secret that was requested

        +
        +
        var value : bytes
        +
        +

        The value of the secret

        +
        +
        +
        +
        +class SecretPutRequest +(secret: Secret = <object object>, value: bytes = <object object>) +
        +
        +

        Request to put a secret to a Secret Store

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretPutRequest(betterproto.Message):
        +    """Request to put a secret to a Secret Store"""
        +
        +    secret: "Secret" = betterproto.message_field(1)
        +    """The Secret to put to the Secret store"""
        +
        +    value: bytes = betterproto.bytes_field(2)
        +    """The value to assign to that secret"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var secretSecret
        +
        +

        The Secret to put to the Secret store

        +
        +
        var value : bytes
        +
        +

        The value to assign to that secret

        +
        +
        +
        +
        +class SecretPutResponse +(secret_version: SecretVersion = <object object>) +
        +
        +

        Result from putting the secret to a Secret Store

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretPutResponse(betterproto.Message):
        +    """Result from putting the secret to a Secret Store"""
        +
        +    secret_version: "SecretVersion" = betterproto.message_field(1)
        +    """The id of the secret"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var secret_versionSecretVersion
        +
        +

        The id of the secret

        +
        +
        +
        +
        +class SecretServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class SecretServiceBase(ServiceBase):
        +    async def put(self, secret_put_request: "SecretPutRequest") -> "SecretPutResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def access(
        +        self, secret_access_request: "SecretAccessRequest"
        +    ) -> "SecretAccessResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_put(
        +        self, stream: "grpclib.server.Stream[SecretPutRequest, SecretPutResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.put(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_access(
        +        self, stream: "grpclib.server.Stream[SecretAccessRequest, SecretAccessResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.access(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.secret.v1.SecretService/Put": grpclib.const.Handler(
        +                self.__rpc_put,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                SecretPutRequest,
        +                SecretPutResponse,
        +            ),
        +            "/nitric.secret.v1.SecretService/Access": grpclib.const.Handler(
        +                self.__rpc_access,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                SecretAccessRequest,
        +                SecretAccessResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def access(self, secret_access_request: SecretAccessRequest) ‑> SecretAccessResponse +
        +
        +
        +
        + +Expand source code + +
        async def access(
        +    self, secret_access_request: "SecretAccessRequest"
        +) -> "SecretAccessResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def put(self, secret_put_request: SecretPutRequest) ‑> SecretPutResponse +
        +
        +
        +
        + +Expand source code + +
        async def put(self, secret_put_request: "SecretPutRequest") -> "SecretPutResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class SecretServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class SecretServiceStub(betterproto.ServiceStub):
        +    async def put(
        +        self,
        +        secret_put_request: "SecretPutRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "SecretPutResponse":
        +        return await self._unary_unary(
        +            "/nitric.secret.v1.SecretService/Put",
        +            secret_put_request,
        +            SecretPutResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def access(
        +        self,
        +        secret_access_request: "SecretAccessRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "SecretAccessResponse":
        +        return await self._unary_unary(
        +            "/nitric.secret.v1.SecretService/Access",
        +            secret_access_request,
        +            SecretAccessResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def access(self, secret_access_request: SecretAccessRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> SecretAccessResponse +
        +
        +
        +
        + +Expand source code + +
        async def access(
        +    self,
        +    secret_access_request: "SecretAccessRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "SecretAccessResponse":
        +    return await self._unary_unary(
        +        "/nitric.secret.v1.SecretService/Access",
        +        secret_access_request,
        +        SecretAccessResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def put(self, secret_put_request: SecretPutRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> SecretPutResponse +
        +
        +
        +
        + +Expand source code + +
        async def put(
        +    self,
        +    secret_put_request: "SecretPutRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "SecretPutResponse":
        +    return await self._unary_unary(
        +        "/nitric.secret.v1.SecretService/Put",
        +        secret_put_request,
        +        SecretPutResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +class SecretVersion +(secret: Secret = <object object>, version: str = <object object>) +
        +
        +

        A version of a secret

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SecretVersion(betterproto.Message):
        +    """A version of a secret"""
        +
        +    secret: "Secret" = betterproto.message_field(1)
        +    """Reference to the secret container"""
        +
        +    version: str = betterproto.string_field(2)
        +    """The secret version"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var secretSecret
        +
        +

        Reference to the secret container

        +
        +
        var version : str
        +
        +

        The secret version

        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/storage/index.html b/docs/nitric/proto/nitric/storage/index.html new file mode 100644 index 0000000..d936a53 --- /dev/null +++ b/docs/nitric/proto/nitric/storage/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.storage API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.storage

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.storage.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/storage/v1/index.html b/docs/nitric/proto/nitric/storage/v1/index.html new file mode 100644 index 0000000..a910859 --- /dev/null +++ b/docs/nitric/proto/nitric/storage/v1/index.html @@ -0,0 +1,1358 @@ + + + + + + +nitric.proto.nitric.storage.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.storage.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/storage/v1/storage.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +class StoragePreSignUrlRequestOperation(betterproto.Enum):
        +    """Operation"""
        +
        +    READ = 0
        +    WRITE = 1
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageWriteRequest(betterproto.Message):
        +    """Request to put (create/update) a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to store in  this will be automatically resolved
        +    to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """Key to store the item under"""
        +
        +    body: bytes = betterproto.bytes_field(3)
        +    """bytes array to store"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageWriteResponse(betterproto.Message):
        +    """Result of putting a storage item"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageReadRequest(betterproto.Message):
        +    """Request to retrieve a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to retrieve from  this will be automatically
        +    resolved to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """Key of item to retrieve"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageReadResponse(betterproto.Message):
        +    """Returned storage item"""
        +
        +    body: bytes = betterproto.bytes_field(1)
        +    """The body bytes of the retrieved storage item"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageDeleteRequest(betterproto.Message):
        +    """Request to delete a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """Name of the bucket to delete from"""
        +
        +    key: str = betterproto.string_field(2)
        +    """Key of item to delete"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageDeleteResponse(betterproto.Message):
        +    """Result of deleting a storage item"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StoragePreSignUrlRequest(betterproto.Message):
        +    """
        +    Request to generate a pre-signed URL for a file to perform a specific
        +    operation, such as read or write.
        +    """
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to retrieve from  this will be automatically
        +    resolved to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """
        +    Key of item to generate the signed URL for. The URL and the token it
        +    contains will only be valid for operations on this resource specifically.
        +    """
        +
        +    operation: "StoragePreSignUrlRequestOperation" = betterproto.enum_field(3)
        +    expiry: int = betterproto.uint32_field(4)
        +    """
        +    Expiry time in seconds for the token included in the signed URL.  Time
        +    starts from when the access token is generated, not when this request is
        +    made.  e.g. time.Now().Add(expiry * time.Second) on the server
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StoragePreSignUrlResponse(betterproto.Message):
        +    url: str = betterproto.string_field(1)
        +    """
        +    The pre-signed url, restricted to the operation, resource and expiry time
        +    specified in the request.
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageListFilesRequest(betterproto.Message):
        +    bucket_name: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class File(betterproto.Message):
        +    key: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StorageListFilesResponse(betterproto.Message):
        +    files: List["File"] = betterproto.message_field(1)
        +    """keys of the files in the bucket"""
        +
        +
        +class StorageServiceStub(betterproto.ServiceStub):
        +    async def read(
        +        self,
        +        storage_read_request: "StorageReadRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageReadResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Read",
        +            storage_read_request,
        +            StorageReadResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def write(
        +        self,
        +        storage_write_request: "StorageWriteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageWriteResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Write",
        +            storage_write_request,
        +            StorageWriteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def delete(
        +        self,
        +        storage_delete_request: "StorageDeleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageDeleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Delete",
        +            storage_delete_request,
        +            StorageDeleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def pre_sign_url(
        +        self,
        +        storage_pre_sign_url_request: "StoragePreSignUrlRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StoragePreSignUrlResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/PreSignUrl",
        +            storage_pre_sign_url_request,
        +            StoragePreSignUrlResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def list_files(
        +        self,
        +        storage_list_files_request: "StorageListFilesRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageListFilesResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/ListFiles",
        +            storage_list_files_request,
        +            StorageListFilesResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +
        +class StorageServiceBase(ServiceBase):
        +    async def read(
        +        self, storage_read_request: "StorageReadRequest"
        +    ) -> "StorageReadResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def write(
        +        self, storage_write_request: "StorageWriteRequest"
        +    ) -> "StorageWriteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def delete(
        +        self, storage_delete_request: "StorageDeleteRequest"
        +    ) -> "StorageDeleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def pre_sign_url(
        +        self, storage_pre_sign_url_request: "StoragePreSignUrlRequest"
        +    ) -> "StoragePreSignUrlResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def list_files(
        +        self, storage_list_files_request: "StorageListFilesRequest"
        +    ) -> "StorageListFilesResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_read(
        +        self, stream: "grpclib.server.Stream[StorageReadRequest, StorageReadResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.read(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_write(
        +        self, stream: "grpclib.server.Stream[StorageWriteRequest, StorageWriteResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.write(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_delete(
        +        self,
        +        stream: "grpclib.server.Stream[StorageDeleteRequest, StorageDeleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.delete(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_pre_sign_url(
        +        self,
        +        stream: "grpclib.server.Stream[StoragePreSignUrlRequest, StoragePreSignUrlResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.pre_sign_url(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_list_files(
        +        self,
        +        stream: "grpclib.server.Stream[StorageListFilesRequest, StorageListFilesResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.list_files(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.storage.v1.StorageService/Read": grpclib.const.Handler(
        +                self.__rpc_read,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageReadRequest,
        +                StorageReadResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/Write": grpclib.const.Handler(
        +                self.__rpc_write,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageWriteRequest,
        +                StorageWriteResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/Delete": grpclib.const.Handler(
        +                self.__rpc_delete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageDeleteRequest,
        +                StorageDeleteResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/PreSignUrl": grpclib.const.Handler(
        +                self.__rpc_pre_sign_url,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StoragePreSignUrlRequest,
        +                StoragePreSignUrlResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/ListFiles": grpclib.const.Handler(
        +                self.__rpc_list_files,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageListFilesRequest,
        +                StorageListFilesResponse,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class File +(key: str = <object object>) +
        +
        +

        File(key: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class File(betterproto.Message):
        +    key: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var key : str
        +
        +
        +
        +
        + +
        +class StorageDeleteRequest +(bucket_name: str = <object object>, key: str = <object object>) +
        +
        +

        Request to delete a storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageDeleteRequest(betterproto.Message):
        +    """Request to delete a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """Name of the bucket to delete from"""
        +
        +    key: str = betterproto.string_field(2)
        +    """Key of item to delete"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var bucket_name : str
        +
        +

        Name of the bucket to delete from

        +
        +
        var key : str
        +
        +

        Key of item to delete

        +
        +
        +
        +
        +class StorageDeleteResponse +
        +
        +

        Result of deleting a storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageDeleteResponse(betterproto.Message):
        +    """Result of deleting a storage item"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class StorageListFilesRequest +(bucket_name: str = <object object>) +
        +
        +

        StorageListFilesRequest(bucket_name: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageListFilesRequest(betterproto.Message):
        +    bucket_name: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var bucket_name : str
        +
        +
        +
        +
        + +
        +class StorageListFilesResponse +(files: List[ForwardRef('File')] = <object object>) +
        +
        +

        StorageListFilesResponse(files: List[ForwardRef('File')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageListFilesResponse(betterproto.Message):
        +    files: List["File"] = betterproto.message_field(1)
        +    """keys of the files in the bucket"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var files : List[File]
        +
        +

        keys of the files in the bucket

        +
        +
        + +
        +class StoragePreSignUrlRequest +(bucket_name: str = <object object>, key: str = <object object>, operation: StoragePreSignUrlRequestOperation = <object object>, expiry: int = <object object>) +
        +
        +

        Request to generate a pre-signed URL for a file to perform a specific +operation, such as read or write.

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StoragePreSignUrlRequest(betterproto.Message):
        +    """
        +    Request to generate a pre-signed URL for a file to perform a specific
        +    operation, such as read or write.
        +    """
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to retrieve from  this will be automatically
        +    resolved to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """
        +    Key of item to generate the signed URL for. The URL and the token it
        +    contains will only be valid for operations on this resource specifically.
        +    """
        +
        +    operation: "StoragePreSignUrlRequestOperation" = betterproto.enum_field(3)
        +    expiry: int = betterproto.uint32_field(4)
        +    """
        +    Expiry time in seconds for the token included in the signed URL.  Time
        +    starts from when the access token is generated, not when this request is
        +    made.  e.g. time.Now().Add(expiry * time.Second) on the server
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var bucket_name : str
        +
        +

        Nitric name of the bucket to retrieve from +this will be automatically +resolved to the provider specific bucket identifier.

        +
        +
        var expiry : int
        +
        +

        Expiry time in seconds for the token included in the signed URL. +Time +starts from when the access token is generated, not when this request is +made. +e.g. time.Now().Add(expiry * time.Second) on the server

        +
        +
        var key : str
        +
        +

        Key of item to generate the signed URL for. The URL and the token it +contains will only be valid for operations on this resource specifically.

        +
        +
        var operationStoragePreSignUrlRequestOperation
        +
        +
        +
        +
        +
        +
        +class StoragePreSignUrlRequestOperation +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Operation

        +
        + +Expand source code + +
        class StoragePreSignUrlRequestOperation(betterproto.Enum):
        +    """Operation"""
        +
        +    READ = 0
        +    WRITE = 1
        +
        +

        Ancestors

        +
          +
        • betterproto.Enum
        • +
        • enum.IntEnum
        • +
        • builtins.int
        • +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var READ
        +
        +
        +
        +
        var WRITE
        +
        +
        +
        +
        +
        +
        +class StoragePreSignUrlResponse +(url: str = <object object>) +
        +
        +

        StoragePreSignUrlResponse(url: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StoragePreSignUrlResponse(betterproto.Message):
        +    url: str = betterproto.string_field(1)
        +    """
        +    The pre-signed url, restricted to the operation, resource and expiry time
        +    specified in the request.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var url : str
        +
        +

        The pre-signed url, restricted to the operation, resource and expiry time +specified in the request.

        +
        +
        + +
        +class StorageReadRequest +(bucket_name: str = <object object>, key: str = <object object>) +
        +
        +

        Request to retrieve a storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageReadRequest(betterproto.Message):
        +    """Request to retrieve a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to retrieve from  this will be automatically
        +    resolved to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """Key of item to retrieve"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var bucket_name : str
        +
        +

        Nitric name of the bucket to retrieve from +this will be automatically +resolved to the provider specific bucket identifier.

        +
        +
        var key : str
        +
        +

        Key of item to retrieve

        +
        +
        +
        +
        +class StorageReadResponse +(body: bytes = <object object>) +
        +
        +

        Returned storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageReadResponse(betterproto.Message):
        +    """Returned storage item"""
        +
        +    body: bytes = betterproto.bytes_field(1)
        +    """The body bytes of the retrieved storage item"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var body : bytes
        +
        +

        The body bytes of the retrieved storage item

        +
        +
        +
        +
        +class StorageServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class StorageServiceBase(ServiceBase):
        +    async def read(
        +        self, storage_read_request: "StorageReadRequest"
        +    ) -> "StorageReadResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def write(
        +        self, storage_write_request: "StorageWriteRequest"
        +    ) -> "StorageWriteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def delete(
        +        self, storage_delete_request: "StorageDeleteRequest"
        +    ) -> "StorageDeleteResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def pre_sign_url(
        +        self, storage_pre_sign_url_request: "StoragePreSignUrlRequest"
        +    ) -> "StoragePreSignUrlResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def list_files(
        +        self, storage_list_files_request: "StorageListFilesRequest"
        +    ) -> "StorageListFilesResponse":
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_read(
        +        self, stream: "grpclib.server.Stream[StorageReadRequest, StorageReadResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.read(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_write(
        +        self, stream: "grpclib.server.Stream[StorageWriteRequest, StorageWriteResponse]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.write(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_delete(
        +        self,
        +        stream: "grpclib.server.Stream[StorageDeleteRequest, StorageDeleteResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.delete(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_pre_sign_url(
        +        self,
        +        stream: "grpclib.server.Stream[StoragePreSignUrlRequest, StoragePreSignUrlResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.pre_sign_url(request)
        +        await stream.send_message(response)
        +
        +    async def __rpc_list_files(
        +        self,
        +        stream: "grpclib.server.Stream[StorageListFilesRequest, StorageListFilesResponse]",
        +    ) -> None:
        +        request = await stream.recv_message()
        +        response = await self.list_files(request)
        +        await stream.send_message(response)
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.storage.v1.StorageService/Read": grpclib.const.Handler(
        +                self.__rpc_read,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageReadRequest,
        +                StorageReadResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/Write": grpclib.const.Handler(
        +                self.__rpc_write,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageWriteRequest,
        +                StorageWriteResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/Delete": grpclib.const.Handler(
        +                self.__rpc_delete,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageDeleteRequest,
        +                StorageDeleteResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/PreSignUrl": grpclib.const.Handler(
        +                self.__rpc_pre_sign_url,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StoragePreSignUrlRequest,
        +                StoragePreSignUrlResponse,
        +            ),
        +            "/nitric.storage.v1.StorageService/ListFiles": grpclib.const.Handler(
        +                self.__rpc_list_files,
        +                grpclib.const.Cardinality.UNARY_UNARY,
        +                StorageListFilesRequest,
        +                StorageListFilesResponse,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def delete(self, storage_delete_request: StorageDeleteRequest) ‑> StorageDeleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def delete(
        +    self, storage_delete_request: "StorageDeleteRequest"
        +) -> "StorageDeleteResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def list_files(self, storage_list_files_request: StorageListFilesRequest) ‑> StorageListFilesResponse +
        +
        +
        +
        + +Expand source code + +
        async def list_files(
        +    self, storage_list_files_request: "StorageListFilesRequest"
        +) -> "StorageListFilesResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def pre_sign_url(self, storage_pre_sign_url_request: StoragePreSignUrlRequest) ‑> StoragePreSignUrlResponse +
        +
        +
        +
        + +Expand source code + +
        async def pre_sign_url(
        +    self, storage_pre_sign_url_request: "StoragePreSignUrlRequest"
        +) -> "StoragePreSignUrlResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def read(self, storage_read_request: StorageReadRequest) ‑> StorageReadResponse +
        +
        +
        +
        + +Expand source code + +
        async def read(
        +    self, storage_read_request: "StorageReadRequest"
        +) -> "StorageReadResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def write(self, storage_write_request: StorageWriteRequest) ‑> StorageWriteResponse +
        +
        +
        +
        + +Expand source code + +
        async def write(
        +    self, storage_write_request: "StorageWriteRequest"
        +) -> "StorageWriteResponse":
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class StorageServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class StorageServiceStub(betterproto.ServiceStub):
        +    async def read(
        +        self,
        +        storage_read_request: "StorageReadRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageReadResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Read",
        +            storage_read_request,
        +            StorageReadResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def write(
        +        self,
        +        storage_write_request: "StorageWriteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageWriteResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Write",
        +            storage_write_request,
        +            StorageWriteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def delete(
        +        self,
        +        storage_delete_request: "StorageDeleteRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageDeleteResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/Delete",
        +            storage_delete_request,
        +            StorageDeleteResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def pre_sign_url(
        +        self,
        +        storage_pre_sign_url_request: "StoragePreSignUrlRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StoragePreSignUrlResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/PreSignUrl",
        +            storage_pre_sign_url_request,
        +            StoragePreSignUrlResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +    async def list_files(
        +        self,
        +        storage_list_files_request: "StorageListFilesRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> "StorageListFilesResponse":
        +        return await self._unary_unary(
        +            "/nitric.storage.v1.StorageService/ListFiles",
        +            storage_list_files_request,
        +            StorageListFilesResponse,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        )
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def delete(self, storage_delete_request: StorageDeleteRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> StorageDeleteResponse +
        +
        +
        +
        + +Expand source code + +
        async def delete(
        +    self,
        +    storage_delete_request: "StorageDeleteRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "StorageDeleteResponse":
        +    return await self._unary_unary(
        +        "/nitric.storage.v1.StorageService/Delete",
        +        storage_delete_request,
        +        StorageDeleteResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def list_files(self, storage_list_files_request: StorageListFilesRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> StorageListFilesResponse +
        +
        +
        +
        + +Expand source code + +
        async def list_files(
        +    self,
        +    storage_list_files_request: "StorageListFilesRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "StorageListFilesResponse":
        +    return await self._unary_unary(
        +        "/nitric.storage.v1.StorageService/ListFiles",
        +        storage_list_files_request,
        +        StorageListFilesResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def pre_sign_url(self, storage_pre_sign_url_request: StoragePreSignUrlRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> StoragePreSignUrlResponse +
        +
        +
        +
        + +Expand source code + +
        async def pre_sign_url(
        +    self,
        +    storage_pre_sign_url_request: "StoragePreSignUrlRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "StoragePreSignUrlResponse":
        +    return await self._unary_unary(
        +        "/nitric.storage.v1.StorageService/PreSignUrl",
        +        storage_pre_sign_url_request,
        +        StoragePreSignUrlResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def read(self, storage_read_request: StorageReadRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> StorageReadResponse +
        +
        +
        +
        + +Expand source code + +
        async def read(
        +    self,
        +    storage_read_request: "StorageReadRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "StorageReadResponse":
        +    return await self._unary_unary(
        +        "/nitric.storage.v1.StorageService/Read",
        +        storage_read_request,
        +        StorageReadResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +async def write(self, storage_write_request: StorageWriteRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> StorageWriteResponse +
        +
        +
        +
        + +Expand source code + +
        async def write(
        +    self,
        +    storage_write_request: "StorageWriteRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> "StorageWriteResponse":
        +    return await self._unary_unary(
        +        "/nitric.storage.v1.StorageService/Write",
        +        storage_write_request,
        +        StorageWriteResponse,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    )
        +
        +
        +
        +
        +
        +class StorageWriteRequest +(bucket_name: str = <object object>, key: str = <object object>, body: bytes = <object object>) +
        +
        +

        Request to put (create/update) a storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageWriteRequest(betterproto.Message):
        +    """Request to put (create/update) a storage item"""
        +
        +    bucket_name: str = betterproto.string_field(1)
        +    """
        +    Nitric name of the bucket to store in  this will be automatically resolved
        +    to the provider specific bucket identifier.
        +    """
        +
        +    key: str = betterproto.string_field(2)
        +    """Key to store the item under"""
        +
        +    body: bytes = betterproto.bytes_field(3)
        +    """bytes array to store"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var body : bytes
        +
        +

        bytes array to store

        +
        +
        var bucket_name : str
        +
        +

        Nitric name of the bucket to store in +this will be automatically resolved +to the provider specific bucket identifier.

        +
        +
        var key : str
        +
        +

        Key to store the item under

        +
        +
        +
        +
        +class StorageWriteResponse +
        +
        +

        Result of putting a storage item

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StorageWriteResponse(betterproto.Message):
        +    """Result of putting a storage item"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/validate/index.html b/docs/nitric/proto/validate/index.html new file mode 100644 index 0000000..3802cd2 --- /dev/null +++ b/docs/nitric/proto/validate/index.html @@ -0,0 +1,4135 @@ + + + + + + +nitric.proto.validate API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.validate

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: validate/validate.proto
        +# plugin: python-betterproto
        +from dataclasses import dataclass
        +from datetime import (
        +    datetime,
        +    timedelta,
        +)
        +from typing import List
        +
        +import betterproto
        +
        +
        +class KnownRegex(betterproto.Enum):
        +    """WellKnownRegex contain some well-known patterns."""
        +
        +    UNKNOWN = 0
        +    HTTP_HEADER_NAME = 1
        +    """HTTP header name as defined by RFC 7230."""
        +
        +    HTTP_HEADER_VALUE = 2
        +    """HTTP header value as defined by RFC 7230."""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class FieldRules(betterproto.Message):
        +    """
        +    FieldRules encapsulates the rules for each type of field. Depending on the
        +    field, the correct set should be used to ensure proper validations.
        +    """
        +
        +    message: "MessageRules" = betterproto.message_field(17)
        +    float: "FloatRules" = betterproto.message_field(1, group="type")
        +    """Scalar Field Types"""
        +
        +    double: "DoubleRules" = betterproto.message_field(2, group="type")
        +    int32: "Int32Rules" = betterproto.message_field(3, group="type")
        +    int64: "Int64Rules" = betterproto.message_field(4, group="type")
        +    uint32: "UInt32Rules" = betterproto.message_field(5, group="type")
        +    uint64: "UInt64Rules" = betterproto.message_field(6, group="type")
        +    sint32: "SInt32Rules" = betterproto.message_field(7, group="type")
        +    sint64: "SInt64Rules" = betterproto.message_field(8, group="type")
        +    fixed32: "Fixed32Rules" = betterproto.message_field(9, group="type")
        +    fixed64: "Fixed64Rules" = betterproto.message_field(10, group="type")
        +    sfixed32: "SFixed32Rules" = betterproto.message_field(11, group="type")
        +    sfixed64: "SFixed64Rules" = betterproto.message_field(12, group="type")
        +    bool: "BoolRules" = betterproto.message_field(13, group="type")
        +    string: "StringRules" = betterproto.message_field(14, group="type")
        +    bytes: "BytesRules" = betterproto.message_field(15, group="type")
        +    enum: "EnumRules" = betterproto.message_field(16, group="type")
        +    """Complex Field Types"""
        +
        +    repeated: "RepeatedRules" = betterproto.message_field(18, group="type")
        +    map: "MapRules" = betterproto.message_field(19, group="type")
        +    any: "AnyRules" = betterproto.message_field(20, group="type")
        +    """Well-Known Field Types"""
        +
        +    duration: "DurationRules" = betterproto.message_field(21, group="type")
        +    timestamp: "TimestampRules" = betterproto.message_field(22, group="type")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class FloatRules(betterproto.Message):
        +    """FloatRules describes the constraints applied to `float` values"""
        +
        +    const: float = betterproto.float_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: float = betterproto.float_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: float = betterproto.float_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: float = betterproto.float_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: float = betterproto.float_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[float] = betterproto.float_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[float] = betterproto.float_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DoubleRules(betterproto.Message):
        +    """DoubleRules describes the constraints applied to `double` values"""
        +
        +    const: float = betterproto.double_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: float = betterproto.double_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: float = betterproto.double_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: float = betterproto.double_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: float = betterproto.double_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[float] = betterproto.double_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[float] = betterproto.double_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Int32Rules(betterproto.Message):
        +    """Int32Rules describes the constraints applied to `int32` values"""
        +
        +    const: int = betterproto.int32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.int32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.int32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.int32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.int32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.int32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Int64Rules(betterproto.Message):
        +    """Int64Rules describes the constraints applied to `int64` values"""
        +
        +    const: int = betterproto.int64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.int64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.int64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.int64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.int64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.int64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class UInt32Rules(betterproto.Message):
        +    """UInt32Rules describes the constraints applied to `uint32` values"""
        +
        +    const: int = betterproto.uint32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.uint32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.uint32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.uint32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.uint32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.uint32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.uint32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class UInt64Rules(betterproto.Message):
        +    """UInt64Rules describes the constraints applied to `uint64` values"""
        +
        +    const: int = betterproto.uint64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.uint64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.uint64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.uint64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.uint64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.uint64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.uint64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SInt32Rules(betterproto.Message):
        +    """SInt32Rules describes the constraints applied to `sint32` values"""
        +
        +    const: int = betterproto.sint32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sint32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sint32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sint32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sint32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sint32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sint32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SInt64Rules(betterproto.Message):
        +    """SInt64Rules describes the constraints applied to `sint64` values"""
        +
        +    const: int = betterproto.sint64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sint64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sint64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sint64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sint64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sint64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sint64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Fixed32Rules(betterproto.Message):
        +    """Fixed32Rules describes the constraints applied to `fixed32` values"""
        +
        +    const: int = betterproto.fixed32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.fixed32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.fixed32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.fixed32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.fixed32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.fixed32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.fixed32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Fixed64Rules(betterproto.Message):
        +    """Fixed64Rules describes the constraints applied to `fixed64` values"""
        +
        +    const: int = betterproto.fixed64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.fixed64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.fixed64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.fixed64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.fixed64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.fixed64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.fixed64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SFixed32Rules(betterproto.Message):
        +    """SFixed32Rules describes the constraints applied to `sfixed32` values"""
        +
        +    const: int = betterproto.sfixed32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sfixed32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sfixed32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sfixed32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sfixed32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sfixed32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sfixed32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SFixed64Rules(betterproto.Message):
        +    """SFixed64Rules describes the constraints applied to `sfixed64` values"""
        +
        +    const: int = betterproto.sfixed64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sfixed64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sfixed64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sfixed64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sfixed64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sfixed64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sfixed64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class BoolRules(betterproto.Message):
        +    """BoolRules describes the constraints applied to `bool` values"""
        +
        +    const: bool = betterproto.bool_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class StringRules(betterproto.Message):
        +    """StringRules describe the constraints applied to `string` values"""
        +
        +    const: str = betterproto.string_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    len: int = betterproto.uint64_field(19)
        +    """
        +    Len specifies that this field must be the specified number of characters
        +    (Unicode code points). Note that the number of characters may differ from
        +    the number of bytes in the string.
        +    """
        +
        +    min_len: int = betterproto.uint64_field(2)
        +    """
        +    MinLen specifies that this field must be the specified number of characters
        +    (Unicode code points) at a minimum. Note that the number of characters may
        +    differ from the number of bytes in the string.
        +    """
        +
        +    max_len: int = betterproto.uint64_field(3)
        +    """
        +    MaxLen specifies that this field must be the specified number of characters
        +    (Unicode code points) at a maximum. Note that the number of characters may
        +    differ from the number of bytes in the string.
        +    """
        +
        +    len_bytes: int = betterproto.uint64_field(20)
        +    """
        +    LenBytes specifies that this field must be the specified number of bytes at
        +    a minimum
        +    """
        +
        +    min_bytes: int = betterproto.uint64_field(4)
        +    """
        +    MinBytes specifies that this field must be the specified number of bytes at
        +    a minimum
        +    """
        +
        +    max_bytes: int = betterproto.uint64_field(5)
        +    """
        +    MaxBytes specifies that this field must be the specified number of bytes at
        +    a maximum
        +    """
        +
        +    pattern: str = betterproto.string_field(6)
        +    """
        +    Pattern specifes that this field must match against the specified regular
        +    expression (RE2 syntax). The included expression should elide any
        +    delimiters.
        +    """
        +
        +    prefix: str = betterproto.string_field(7)
        +    """
        +    Prefix specifies that this field must have the specified substring at the
        +    beginning of the string.
        +    """
        +
        +    suffix: str = betterproto.string_field(8)
        +    """
        +    Suffix specifies that this field must have the specified substring at the
        +    end of the string.
        +    """
        +
        +    contains: str = betterproto.string_field(9)
        +    """
        +    Contains specifies that this field must have the specified substring
        +    anywhere in the string.
        +    """
        +
        +    not_contains: str = betterproto.string_field(23)
        +    """
        +    NotContains specifies that this field cannot have the specified substring
        +    anywhere in the string.
        +    """
        +
        +    in_: List[str] = betterproto.string_field(10)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[str] = betterproto.string_field(11)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    email: bool = betterproto.bool_field(12, group="well_known")
        +    """
        +    Email specifies that the field must be a valid email address as defined by
        +    RFC 5322
        +    """
        +
        +    hostname: bool = betterproto.bool_field(13, group="well_known")
        +    """
        +    Hostname specifies that the field must be a valid hostname as defined by
        +    RFC 1034. This constraint does not support internationalized domain names
        +    (IDNs).
        +    """
        +
        +    ip: bool = betterproto.bool_field(14, group="well_known")
        +    """
        +    Ip specifies that the field must be a valid IP (v4 or v6) address. Valid
        +    IPv6 addresses should not include surrounding square brackets.
        +    """
        +
        +    ipv4: bool = betterproto.bool_field(15, group="well_known")
        +    """Ipv4 specifies that the field must be a valid IPv4 address."""
        +
        +    ipv6: bool = betterproto.bool_field(16, group="well_known")
        +    """
        +    Ipv6 specifies that the field must be a valid IPv6 address. Valid IPv6
        +    addresses should not include surrounding square brackets.
        +    """
        +
        +    uri: bool = betterproto.bool_field(17, group="well_known")
        +    """
        +    Uri specifies that the field must be a valid, absolute URI as defined by
        +    RFC 3986
        +    """
        +
        +    uri_ref: bool = betterproto.bool_field(18, group="well_known")
        +    """
        +    UriRef specifies that the field must be a valid URI as defined by RFC 3986
        +    and may be relative or absolute.
        +    """
        +
        +    address: bool = betterproto.bool_field(21, group="well_known")
        +    """
        +    Address specifies that the field must be either a valid hostname as defined
        +    by RFC 1034 (which does not support internationalized domain names or
        +    IDNs), or it can be a valid IP (v4 or v6).
        +    """
        +
        +    uuid: bool = betterproto.bool_field(22, group="well_known")
        +    """
        +    Uuid specifies that the field must be a valid UUID as defined by RFC 4122
        +    """
        +
        +    well_known_regex: "KnownRegex" = betterproto.enum_field(24, group="well_known")
        +    """
        +    WellKnownRegex specifies a common well known pattern defined as a regex.
        +    """
        +
        +    strict: bool = betterproto.bool_field(25)
        +    """
        +    This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable
        +    strict header validation. By default, this is true, and HTTP header
        +    validations are RFC-compliant. Setting to false will enable a looser
        +    validations that only disallows \r\n\0 characters, which can be used to
        +    bypass header matching rules.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(26)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class BytesRules(betterproto.Message):
        +    """BytesRules describe the constraints applied to `bytes` values"""
        +
        +    const: bytes = betterproto.bytes_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    len: int = betterproto.uint64_field(13)
        +    """Len specifies that this field must be the specified number of bytes"""
        +
        +    min_len: int = betterproto.uint64_field(2)
        +    """
        +    MinLen specifies that this field must be the specified number of bytes at a
        +    minimum
        +    """
        +
        +    max_len: int = betterproto.uint64_field(3)
        +    """
        +    MaxLen specifies that this field must be the specified number of bytes at a
        +    maximum
        +    """
        +
        +    pattern: str = betterproto.string_field(4)
        +    """
        +    Pattern specifes that this field must match against the specified regular
        +    expression (RE2 syntax). The included expression should elide any
        +    delimiters.
        +    """
        +
        +    prefix: bytes = betterproto.bytes_field(5)
        +    """
        +    Prefix specifies that this field must have the specified bytes at the
        +    beginning of the string.
        +    """
        +
        +    suffix: bytes = betterproto.bytes_field(6)
        +    """
        +    Suffix specifies that this field must have the specified bytes at the end
        +    of the string.
        +    """
        +
        +    contains: bytes = betterproto.bytes_field(7)
        +    """
        +    Contains specifies that this field must have the specified bytes anywhere
        +    in the string.
        +    """
        +
        +    in_: List[bytes] = betterproto.bytes_field(8)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[bytes] = betterproto.bytes_field(9)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ip: bool = betterproto.bool_field(10, group="well_known")
        +    """
        +    Ip specifies that the field must be a valid IP (v4 or v6) address in byte
        +    format
        +    """
        +
        +    ipv4: bool = betterproto.bool_field(11, group="well_known")
        +    """
        +    Ipv4 specifies that the field must be a valid IPv4 address in byte format
        +    """
        +
        +    ipv6: bool = betterproto.bool_field(12, group="well_known")
        +    """
        +    Ipv6 specifies that the field must be a valid IPv6 address in byte format
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(14)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class EnumRules(betterproto.Message):
        +    """EnumRules describe the constraints applied to enum values"""
        +
        +    const: int = betterproto.int32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    defined_only: bool = betterproto.bool_field(2)
        +    """
        +    DefinedOnly specifies that this field must be only one of the defined
        +    values for this enum, failing on any undefined value.
        +    """
        +
        +    in_: List[int] = betterproto.int32_field(3)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int32_field(4)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class MessageRules(betterproto.Message):
        +    """
        +    MessageRules describe the constraints applied to embedded message values.
        +    For message-type fields, validation is performed recursively.
        +    """
        +
        +    skip: bool = betterproto.bool_field(1)
        +    """
        +    Skip specifies that the validation rules of this field should not be
        +    evaluated
        +    """
        +
        +    required: bool = betterproto.bool_field(2)
        +    """Required specifies that this field must be set"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class RepeatedRules(betterproto.Message):
        +    """RepeatedRules describe the constraints applied to `repeated` values"""
        +
        +    min_items: int = betterproto.uint64_field(1)
        +    """
        +    MinItems specifies that this field must have the specified number of items
        +    at a minimum
        +    """
        +
        +    max_items: int = betterproto.uint64_field(2)
        +    """
        +    MaxItems specifies that this field must have the specified number of items
        +    at a maximum
        +    """
        +
        +    unique: bool = betterproto.bool_field(3)
        +    """
        +    Unique specifies that all elements in this field must be unique. This
        +    contraint is only applicable to scalar and enum types (messages are not
        +    supported).
        +    """
        +
        +    items: "FieldRules" = betterproto.message_field(4)
        +    """
        +    Items specifies the contraints to be applied to each item in the field.
        +    Repeated message fields will still execute validation against each item
        +    unless skip is specified here.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(5)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class MapRules(betterproto.Message):
        +    """MapRules describe the constraints applied to `map` values"""
        +
        +    min_pairs: int = betterproto.uint64_field(1)
        +    """
        +    MinPairs specifies that this field must have the specified number of KVs at
        +    a minimum
        +    """
        +
        +    max_pairs: int = betterproto.uint64_field(2)
        +    """
        +    MaxPairs specifies that this field must have the specified number of KVs at
        +    a maximum
        +    """
        +
        +    no_sparse: bool = betterproto.bool_field(3)
        +    """
        +    NoSparse specifies values in this field cannot be unset. This only applies
        +    to map's with message value types.
        +    """
        +
        +    keys: "FieldRules" = betterproto.message_field(4)
        +    """
        +    Keys specifies the constraints to be applied to each key in the field.
        +    """
        +
        +    values: "FieldRules" = betterproto.message_field(5)
        +    """
        +    Values specifies the constraints to be applied to the value of each key in
        +    the field. Message values will still have their validations evaluated
        +    unless skip is specified here.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(6)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class AnyRules(betterproto.Message):
        +    """
        +    AnyRules describe constraints applied exclusively to the
        +    `google.protobuf.Any` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    in_: List[str] = betterproto.string_field(2)
        +    """
        +    In specifies that this field's `type_url` must be equal to one of the
        +    specified values.
        +    """
        +
        +    not_in: List[str] = betterproto.string_field(3)
        +    """
        +    NotIn specifies that this field's `type_url` must not be equal to any of
        +    the specified values.
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DurationRules(betterproto.Message):
        +    """
        +    DurationRules describe the constraints applied exclusively to the
        +    `google.protobuf.Duration` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    const: timedelta = betterproto.message_field(2)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: timedelta = betterproto.message_field(3)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: timedelta = betterproto.message_field(4)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    inclusive
        +    """
        +
        +    gt: timedelta = betterproto.message_field(5)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive
        +    """
        +
        +    gte: timedelta = betterproto.message_field(6)
        +    """
        +    Gte specifies that this field must be greater than the specified value,
        +    inclusive
        +    """
        +
        +    in_: List[timedelta] = betterproto.message_field(7)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[timedelta] = betterproto.message_field(8)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TimestampRules(betterproto.Message):
        +    """
        +    TimestampRules describe the constraints applied exclusively to the
        +    `google.protobuf.Timestamp` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    const: datetime = betterproto.message_field(2)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: datetime = betterproto.message_field(3)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: datetime = betterproto.message_field(4)
        +    """
        +    Lte specifies that this field must be less than the specified value,
        +    inclusive
        +    """
        +
        +    gt: datetime = betterproto.message_field(5)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive
        +    """
        +
        +    gte: datetime = betterproto.message_field(6)
        +    """
        +    Gte specifies that this field must be greater than the specified value,
        +    inclusive
        +    """
        +
        +    lt_now: bool = betterproto.bool_field(7)
        +    """
        +    LtNow specifies that this must be less than the current time. LtNow can
        +    only be used with the Within rule.
        +    """
        +
        +    gt_now: bool = betterproto.bool_field(8)
        +    """
        +    GtNow specifies that this must be greater than the current time. GtNow can
        +    only be used with the Within rule.
        +    """
        +
        +    within: timedelta = betterproto.message_field(9)
        +    """
        +    Within specifies that this field must be within this duration of the
        +    current time. This constraint can be used alone or with the LtNow and GtNow
        +    rules.
        +    """
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class AnyRules +(required: bool = <object object>, in_: List[str] = <object object>, not_in: List[str] = <object object>) +
        +
        +

        AnyRules describe constraints applied exclusively to the +google.protobuf.Any well-known type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class AnyRules(betterproto.Message):
        +    """
        +    AnyRules describe constraints applied exclusively to the
        +    `google.protobuf.Any` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    in_: List[str] = betterproto.string_field(2)
        +    """
        +    In specifies that this field's `type_url` must be equal to one of the
        +    specified values.
        +    """
        +
        +    not_in: List[str] = betterproto.string_field(3)
        +    """
        +    NotIn specifies that this field's `type_url` must not be equal to any of
        +    the specified values.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var in_ : List[str]
        +
        +

        In specifies that this field's type_url must be equal to one of the +specified values.

        +
        +
        var not_in : List[str]
        +
        +

        NotIn specifies that this field's type_url must not be equal to any of +the specified values.

        +
        +
        var required : bool
        +
        +

        Required specifies that this field must be set

        +
        +
        +
        +
        +class BoolRules +(const: bool = <object object>) +
        +
        +

        BoolRules describes the constraints applied to bool values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class BoolRules(betterproto.Message):
        +    """BoolRules describes the constraints applied to `bool` values"""
        +
        +    const: bool = betterproto.bool_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : bool
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        +
        +
        +class BytesRules +(const: bytes = <object object>, len: int = <object object>, min_len: int = <object object>, max_len: int = <object object>, pattern: str = <object object>, prefix: bytes = <object object>, suffix: bytes = <object object>, contains: bytes = <object object>, in_: List[bytes] = <object object>, not_in: List[bytes] = <object object>, ip: bool = <object object>, ipv4: bool = <object object>, ipv6: bool = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        BytesRules describe the constraints applied to bytes values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class BytesRules(betterproto.Message):
        +    """BytesRules describe the constraints applied to `bytes` values"""
        +
        +    const: bytes = betterproto.bytes_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    len: int = betterproto.uint64_field(13)
        +    """Len specifies that this field must be the specified number of bytes"""
        +
        +    min_len: int = betterproto.uint64_field(2)
        +    """
        +    MinLen specifies that this field must be the specified number of bytes at a
        +    minimum
        +    """
        +
        +    max_len: int = betterproto.uint64_field(3)
        +    """
        +    MaxLen specifies that this field must be the specified number of bytes at a
        +    maximum
        +    """
        +
        +    pattern: str = betterproto.string_field(4)
        +    """
        +    Pattern specifes that this field must match against the specified regular
        +    expression (RE2 syntax). The included expression should elide any
        +    delimiters.
        +    """
        +
        +    prefix: bytes = betterproto.bytes_field(5)
        +    """
        +    Prefix specifies that this field must have the specified bytes at the
        +    beginning of the string.
        +    """
        +
        +    suffix: bytes = betterproto.bytes_field(6)
        +    """
        +    Suffix specifies that this field must have the specified bytes at the end
        +    of the string.
        +    """
        +
        +    contains: bytes = betterproto.bytes_field(7)
        +    """
        +    Contains specifies that this field must have the specified bytes anywhere
        +    in the string.
        +    """
        +
        +    in_: List[bytes] = betterproto.bytes_field(8)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[bytes] = betterproto.bytes_field(9)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ip: bool = betterproto.bool_field(10, group="well_known")
        +    """
        +    Ip specifies that the field must be a valid IP (v4 or v6) address in byte
        +    format
        +    """
        +
        +    ipv4: bool = betterproto.bool_field(11, group="well_known")
        +    """
        +    Ipv4 specifies that the field must be a valid IPv4 address in byte format
        +    """
        +
        +    ipv6: bool = betterproto.bool_field(12, group="well_known")
        +    """
        +    Ipv6 specifies that the field must be a valid IPv6 address in byte format
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(14)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : bytes
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var contains : bytes
        +
        +

        Contains specifies that this field must have the specified bytes anywhere +in the string.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[bytes]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var ip : bool
        +
        +

        Ip specifies that the field must be a valid IP (v4 or v6) address in byte +format

        +
        +
        var ipv4 : bool
        +
        +

        Ipv4 specifies that the field must be a valid IPv4 address in byte format

        +
        +
        var ipv6 : bool
        +
        +

        Ipv6 specifies that the field must be a valid IPv6 address in byte format

        +
        +
        var len : int
        +
        +

        Len specifies that this field must be the specified number of bytes

        +
        +
        var max_len : int
        +
        +

        MaxLen specifies that this field must be the specified number of bytes at a +maximum

        +
        +
        var min_len : int
        +
        +

        MinLen specifies that this field must be the specified number of bytes at a +minimum

        +
        +
        var not_in : List[bytes]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        var pattern : str
        +
        +

        Pattern specifes that this field must match against the specified regular +expression (RE2 syntax). The included expression should elide any +delimiters.

        +
        +
        var prefix : bytes
        +
        +

        Prefix specifies that this field must have the specified bytes at the +beginning of the string.

        +
        +
        var suffix : bytes
        +
        +

        Suffix specifies that this field must have the specified bytes at the end +of the string.

        +
        +
        +
        +
        +class DoubleRules +(const: float = <object object>, lt: float = <object object>, lte: float = <object object>, gt: float = <object object>, gte: float = <object object>, in_: List[float] = <object object>, not_in: List[float] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        DoubleRules describes the constraints applied to double values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DoubleRules(betterproto.Message):
        +    """DoubleRules describes the constraints applied to `double` values"""
        +
        +    const: float = betterproto.double_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: float = betterproto.double_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: float = betterproto.double_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: float = betterproto.double_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: float = betterproto.double_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[float] = betterproto.double_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[float] = betterproto.double_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : float
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : float
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : float
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[float]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : float
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : float
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[float]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class DurationRules +(required: bool = <object object>, const: datetime.timedelta = <object object>, lt: datetime.timedelta = <object object>, lte: datetime.timedelta = <object object>, gt: datetime.timedelta = <object object>, gte: datetime.timedelta = <object object>, in_: List[datetime.timedelta] = <object object>, not_in: List[datetime.timedelta] = <object object>) +
        +
        +

        DurationRules describe the constraints applied exclusively to the +google.protobuf.Duration well-known type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DurationRules(betterproto.Message):
        +    """
        +    DurationRules describe the constraints applied exclusively to the
        +    `google.protobuf.Duration` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    const: timedelta = betterproto.message_field(2)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: timedelta = betterproto.message_field(3)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: timedelta = betterproto.message_field(4)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    inclusive
        +    """
        +
        +    gt: timedelta = betterproto.message_field(5)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive
        +    """
        +
        +    gte: timedelta = betterproto.message_field(6)
        +    """
        +    Gte specifies that this field must be greater than the specified value,
        +    inclusive
        +    """
        +
        +    in_: List[timedelta] = betterproto.message_field(7)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[timedelta] = betterproto.message_field(8)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : datetime.timedelta
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : datetime.timedelta
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive

        +
        +
        var gte : datetime.timedelta
        +
        +

        Gte specifies that this field must be greater than the specified value, +inclusive

        +
        +
        var in_ : List[datetime.timedelta]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : datetime.timedelta
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : datetime.timedelta
        +
        +

        Lt specifies that this field must be less than the specified value, +inclusive

        +
        +
        var not_in : List[datetime.timedelta]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        var required : bool
        +
        +

        Required specifies that this field must be set

        +
        +
        +
        +
        +class EnumRules +(const: int = <object object>, defined_only: bool = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>) +
        +
        +

        EnumRules describe the constraints applied to enum values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class EnumRules(betterproto.Message):
        +    """EnumRules describe the constraints applied to enum values"""
        +
        +    const: int = betterproto.int32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    defined_only: bool = betterproto.bool_field(2)
        +    """
        +    DefinedOnly specifies that this field must be only one of the defined
        +    values for this enum, failing on any undefined value.
        +    """
        +
        +    in_: List[int] = betterproto.int32_field(3)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int32_field(4)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var defined_only : bool
        +
        +

        DefinedOnly specifies that this field must be only one of the defined +values for this enum, failing on any undefined value.

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class FieldRules +(message: MessageRules = <object object>, float: FloatRules = <object object>, double: DoubleRules = <object object>, int32: Int32Rules = <object object>, int64: Int64Rules = <object object>, uint32: UInt32Rules = <object object>, uint64: UInt64Rules = <object object>, sint32: SInt32Rules = <object object>, sint64: SInt64Rules = <object object>, fixed32: Fixed32Rules = <object object>, fixed64: Fixed64Rules = <object object>, sfixed32: SFixed32Rules = <object object>, sfixed64: SFixed64Rules = <object object>, bool: BoolRules = <object object>, string: StringRules = <object object>, bytes: BytesRules = <object object>, enum: EnumRules = <object object>, repeated: RepeatedRules = <object object>, map: MapRules = <object object>, any: AnyRules = <object object>, duration: DurationRules = <object object>, timestamp: TimestampRules = <object object>) +
        +
        +

        FieldRules encapsulates the rules for each type of field. Depending on the +field, the correct set should be used to ensure proper validations.

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class FieldRules(betterproto.Message):
        +    """
        +    FieldRules encapsulates the rules for each type of field. Depending on the
        +    field, the correct set should be used to ensure proper validations.
        +    """
        +
        +    message: "MessageRules" = betterproto.message_field(17)
        +    float: "FloatRules" = betterproto.message_field(1, group="type")
        +    """Scalar Field Types"""
        +
        +    double: "DoubleRules" = betterproto.message_field(2, group="type")
        +    int32: "Int32Rules" = betterproto.message_field(3, group="type")
        +    int64: "Int64Rules" = betterproto.message_field(4, group="type")
        +    uint32: "UInt32Rules" = betterproto.message_field(5, group="type")
        +    uint64: "UInt64Rules" = betterproto.message_field(6, group="type")
        +    sint32: "SInt32Rules" = betterproto.message_field(7, group="type")
        +    sint64: "SInt64Rules" = betterproto.message_field(8, group="type")
        +    fixed32: "Fixed32Rules" = betterproto.message_field(9, group="type")
        +    fixed64: "Fixed64Rules" = betterproto.message_field(10, group="type")
        +    sfixed32: "SFixed32Rules" = betterproto.message_field(11, group="type")
        +    sfixed64: "SFixed64Rules" = betterproto.message_field(12, group="type")
        +    bool: "BoolRules" = betterproto.message_field(13, group="type")
        +    string: "StringRules" = betterproto.message_field(14, group="type")
        +    bytes: "BytesRules" = betterproto.message_field(15, group="type")
        +    enum: "EnumRules" = betterproto.message_field(16, group="type")
        +    """Complex Field Types"""
        +
        +    repeated: "RepeatedRules" = betterproto.message_field(18, group="type")
        +    map: "MapRules" = betterproto.message_field(19, group="type")
        +    any: "AnyRules" = betterproto.message_field(20, group="type")
        +    """Well-Known Field Types"""
        +
        +    duration: "DurationRules" = betterproto.message_field(21, group="type")
        +    timestamp: "TimestampRules" = betterproto.message_field(22, group="type")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var anyAnyRules
        +
        +

        Well-Known Field Types

        +
        +
        var boolBoolRules
        +
        +
        +
        +
        var bytesBytesRules
        +
        +
        +
        +
        var doubleDoubleRules
        +
        +
        +
        +
        var durationDurationRules
        +
        +
        +
        +
        var enumEnumRules
        +
        +

        Complex Field Types

        +
        +
        var fixed32Fixed32Rules
        +
        +
        +
        +
        var fixed64Fixed64Rules
        +
        +
        +
        +
        var floatFloatRules
        +
        +

        Scalar Field Types

        +
        +
        var int32Int32Rules
        +
        +
        +
        +
        var int64Int64Rules
        +
        +
        +
        +
        var mapMapRules
        +
        +
        +
        +
        var messageMessageRules
        +
        +
        +
        +
        var repeatedRepeatedRules
        +
        +
        +
        +
        var sfixed32SFixed32Rules
        +
        +
        +
        +
        var sfixed64SFixed64Rules
        +
        +
        +
        +
        var sint32SInt32Rules
        +
        +
        +
        +
        var sint64SInt64Rules
        +
        +
        +
        +
        var stringStringRules
        +
        +
        +
        +
        var timestampTimestampRules
        +
        +
        +
        +
        var uint32UInt32Rules
        +
        +
        +
        +
        var uint64UInt64Rules
        +
        +
        +
        +
        +
        +
        +class Fixed32Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        Fixed32Rules describes the constraints applied to fixed32 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Fixed32Rules(betterproto.Message):
        +    """Fixed32Rules describes the constraints applied to `fixed32` values"""
        +
        +    const: int = betterproto.fixed32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.fixed32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.fixed32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.fixed32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.fixed32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.fixed32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.fixed32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class Fixed64Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        Fixed64Rules describes the constraints applied to fixed64 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Fixed64Rules(betterproto.Message):
        +    """Fixed64Rules describes the constraints applied to `fixed64` values"""
        +
        +    const: int = betterproto.fixed64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.fixed64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.fixed64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.fixed64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.fixed64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.fixed64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.fixed64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class FloatRules +(const: float = <object object>, lt: float = <object object>, lte: float = <object object>, gt: float = <object object>, gte: float = <object object>, in_: List[float] = <object object>, not_in: List[float] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        FloatRules describes the constraints applied to float values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class FloatRules(betterproto.Message):
        +    """FloatRules describes the constraints applied to `float` values"""
        +
        +    const: float = betterproto.float_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: float = betterproto.float_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: float = betterproto.float_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: float = betterproto.float_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: float = betterproto.float_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[float] = betterproto.float_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[float] = betterproto.float_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : float
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : float
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : float
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[float]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : float
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : float
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[float]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class Int32Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        Int32Rules describes the constraints applied to int32 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Int32Rules(betterproto.Message):
        +    """Int32Rules describes the constraints applied to `int32` values"""
        +
        +    const: int = betterproto.int32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.int32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.int32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.int32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.int32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.int32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class Int64Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        Int64Rules describes the constraints applied to int64 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Int64Rules(betterproto.Message):
        +    """Int64Rules describes the constraints applied to `int64` values"""
        +
        +    const: int = betterproto.int64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.int64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.int64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.int64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.int64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.int64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.int64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class KnownRegex +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        WellKnownRegex contain some well-known patterns.

        +
        + +Expand source code + +
        class KnownRegex(betterproto.Enum):
        +    """WellKnownRegex contain some well-known patterns."""
        +
        +    UNKNOWN = 0
        +    HTTP_HEADER_NAME = 1
        +    """HTTP header name as defined by RFC 7230."""
        +
        +    HTTP_HEADER_VALUE = 2
        +    """HTTP header value as defined by RFC 7230."""
        +
        +

        Ancestors

        +
          +
        • betterproto.Enum
        • +
        • enum.IntEnum
        • +
        • builtins.int
        • +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var HTTP_HEADER_NAME
        +
        +

        HTTP header name as defined by RFC 7230.

        +
        +
        var HTTP_HEADER_VALUE
        +
        +

        HTTP header value as defined by RFC 7230.

        +
        +
        var UNKNOWN
        +
        +
        +
        +
        +
        +
        +class MapRules +(min_pairs: int = <object object>, max_pairs: int = <object object>, no_sparse: bool = <object object>, keys: FieldRules = <object object>, values: FieldRules = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        MapRules describe the constraints applied to map values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class MapRules(betterproto.Message):
        +    """MapRules describe the constraints applied to `map` values"""
        +
        +    min_pairs: int = betterproto.uint64_field(1)
        +    """
        +    MinPairs specifies that this field must have the specified number of KVs at
        +    a minimum
        +    """
        +
        +    max_pairs: int = betterproto.uint64_field(2)
        +    """
        +    MaxPairs specifies that this field must have the specified number of KVs at
        +    a maximum
        +    """
        +
        +    no_sparse: bool = betterproto.bool_field(3)
        +    """
        +    NoSparse specifies values in this field cannot be unset. This only applies
        +    to map's with message value types.
        +    """
        +
        +    keys: "FieldRules" = betterproto.message_field(4)
        +    """
        +    Keys specifies the constraints to be applied to each key in the field.
        +    """
        +
        +    values: "FieldRules" = betterproto.message_field(5)
        +    """
        +    Values specifies the constraints to be applied to the value of each key in
        +    the field. Message values will still have their validations evaluated
        +    unless skip is specified here.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(6)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var keysFieldRules
        +
        +

        Keys specifies the constraints to be applied to each key in the field.

        +
        +
        var max_pairs : int
        +
        +

        MaxPairs specifies that this field must have the specified number of KVs at +a maximum

        +
        +
        var min_pairs : int
        +
        +

        MinPairs specifies that this field must have the specified number of KVs at +a minimum

        +
        +
        var no_sparse : bool
        +
        +

        NoSparse specifies values in this field cannot be unset. This only applies +to map's with message value types.

        +
        +
        var valuesFieldRules
        +
        +

        Values specifies the constraints to be applied to the value of each key in +the field. Message values will still have their validations evaluated +unless skip is specified here.

        +
        +
        +
        +
        +class MessageRules +(skip: bool = <object object>, required: bool = <object object>) +
        +
        +

        MessageRules describe the constraints applied to embedded message values. +For message-type fields, validation is performed recursively.

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class MessageRules(betterproto.Message):
        +    """
        +    MessageRules describe the constraints applied to embedded message values.
        +    For message-type fields, validation is performed recursively.
        +    """
        +
        +    skip: bool = betterproto.bool_field(1)
        +    """
        +    Skip specifies that the validation rules of this field should not be
        +    evaluated
        +    """
        +
        +    required: bool = betterproto.bool_field(2)
        +    """Required specifies that this field must be set"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var required : bool
        +
        +

        Required specifies that this field must be set

        +
        +
        var skip : bool
        +
        +

        Skip specifies that the validation rules of this field should not be +evaluated

        +
        +
        +
        +
        +class RepeatedRules +(min_items: int = <object object>, max_items: int = <object object>, unique: bool = <object object>, items: FieldRules = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        RepeatedRules describe the constraints applied to repeated values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class RepeatedRules(betterproto.Message):
        +    """RepeatedRules describe the constraints applied to `repeated` values"""
        +
        +    min_items: int = betterproto.uint64_field(1)
        +    """
        +    MinItems specifies that this field must have the specified number of items
        +    at a minimum
        +    """
        +
        +    max_items: int = betterproto.uint64_field(2)
        +    """
        +    MaxItems specifies that this field must have the specified number of items
        +    at a maximum
        +    """
        +
        +    unique: bool = betterproto.bool_field(3)
        +    """
        +    Unique specifies that all elements in this field must be unique. This
        +    contraint is only applicable to scalar and enum types (messages are not
        +    supported).
        +    """
        +
        +    items: "FieldRules" = betterproto.message_field(4)
        +    """
        +    Items specifies the contraints to be applied to each item in the field.
        +    Repeated message fields will still execute validation against each item
        +    unless skip is specified here.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(5)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var itemsFieldRules
        +
        +

        Items specifies the contraints to be applied to each item in the field. +Repeated message fields will still execute validation against each item +unless skip is specified here.

        +
        +
        var max_items : int
        +
        +

        MaxItems specifies that this field must have the specified number of items +at a maximum

        +
        +
        var min_items : int
        +
        +

        MinItems specifies that this field must have the specified number of items +at a minimum

        +
        +
        var unique : bool
        +
        +

        Unique specifies that all elements in this field must be unique. This +contraint is only applicable to scalar and enum types (messages are not +supported).

        +
        +
        +
        +
        +class SFixed32Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        SFixed32Rules describes the constraints applied to sfixed32 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SFixed32Rules(betterproto.Message):
        +    """SFixed32Rules describes the constraints applied to `sfixed32` values"""
        +
        +    const: int = betterproto.sfixed32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sfixed32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sfixed32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sfixed32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sfixed32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sfixed32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sfixed32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class SFixed64Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        SFixed64Rules describes the constraints applied to sfixed64 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SFixed64Rules(betterproto.Message):
        +    """SFixed64Rules describes the constraints applied to `sfixed64` values"""
        +
        +    const: int = betterproto.sfixed64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sfixed64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sfixed64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sfixed64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sfixed64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sfixed64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sfixed64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class SInt32Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        SInt32Rules describes the constraints applied to sint32 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SInt32Rules(betterproto.Message):
        +    """SInt32Rules describes the constraints applied to `sint32` values"""
        +
        +    const: int = betterproto.sint32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sint32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sint32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sint32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sint32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sint32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sint32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class SInt64Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        SInt64Rules describes the constraints applied to sint64 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SInt64Rules(betterproto.Message):
        +    """SInt64Rules describes the constraints applied to `sint64` values"""
        +
        +    const: int = betterproto.sint64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.sint64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.sint64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.sint64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.sint64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.sint64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.sint64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class StringRules +(const: str = <object object>, len: int = <object object>, min_len: int = <object object>, max_len: int = <object object>, len_bytes: int = <object object>, min_bytes: int = <object object>, max_bytes: int = <object object>, pattern: str = <object object>, prefix: str = <object object>, suffix: str = <object object>, contains: str = <object object>, not_contains: str = <object object>, in_: List[str] = <object object>, not_in: List[str] = <object object>, email: bool = <object object>, hostname: bool = <object object>, ip: bool = <object object>, ipv4: bool = <object object>, ipv6: bool = <object object>, uri: bool = <object object>, uri_ref: bool = <object object>, address: bool = <object object>, uuid: bool = <object object>, well_known_regex: KnownRegex = <object object>, strict: bool = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        StringRules describe the constraints applied to string values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class StringRules(betterproto.Message):
        +    """StringRules describe the constraints applied to `string` values"""
        +
        +    const: str = betterproto.string_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    len: int = betterproto.uint64_field(19)
        +    """
        +    Len specifies that this field must be the specified number of characters
        +    (Unicode code points). Note that the number of characters may differ from
        +    the number of bytes in the string.
        +    """
        +
        +    min_len: int = betterproto.uint64_field(2)
        +    """
        +    MinLen specifies that this field must be the specified number of characters
        +    (Unicode code points) at a minimum. Note that the number of characters may
        +    differ from the number of bytes in the string.
        +    """
        +
        +    max_len: int = betterproto.uint64_field(3)
        +    """
        +    MaxLen specifies that this field must be the specified number of characters
        +    (Unicode code points) at a maximum. Note that the number of characters may
        +    differ from the number of bytes in the string.
        +    """
        +
        +    len_bytes: int = betterproto.uint64_field(20)
        +    """
        +    LenBytes specifies that this field must be the specified number of bytes at
        +    a minimum
        +    """
        +
        +    min_bytes: int = betterproto.uint64_field(4)
        +    """
        +    MinBytes specifies that this field must be the specified number of bytes at
        +    a minimum
        +    """
        +
        +    max_bytes: int = betterproto.uint64_field(5)
        +    """
        +    MaxBytes specifies that this field must be the specified number of bytes at
        +    a maximum
        +    """
        +
        +    pattern: str = betterproto.string_field(6)
        +    """
        +    Pattern specifes that this field must match against the specified regular
        +    expression (RE2 syntax). The included expression should elide any
        +    delimiters.
        +    """
        +
        +    prefix: str = betterproto.string_field(7)
        +    """
        +    Prefix specifies that this field must have the specified substring at the
        +    beginning of the string.
        +    """
        +
        +    suffix: str = betterproto.string_field(8)
        +    """
        +    Suffix specifies that this field must have the specified substring at the
        +    end of the string.
        +    """
        +
        +    contains: str = betterproto.string_field(9)
        +    """
        +    Contains specifies that this field must have the specified substring
        +    anywhere in the string.
        +    """
        +
        +    not_contains: str = betterproto.string_field(23)
        +    """
        +    NotContains specifies that this field cannot have the specified substring
        +    anywhere in the string.
        +    """
        +
        +    in_: List[str] = betterproto.string_field(10)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[str] = betterproto.string_field(11)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    email: bool = betterproto.bool_field(12, group="well_known")
        +    """
        +    Email specifies that the field must be a valid email address as defined by
        +    RFC 5322
        +    """
        +
        +    hostname: bool = betterproto.bool_field(13, group="well_known")
        +    """
        +    Hostname specifies that the field must be a valid hostname as defined by
        +    RFC 1034. This constraint does not support internationalized domain names
        +    (IDNs).
        +    """
        +
        +    ip: bool = betterproto.bool_field(14, group="well_known")
        +    """
        +    Ip specifies that the field must be a valid IP (v4 or v6) address. Valid
        +    IPv6 addresses should not include surrounding square brackets.
        +    """
        +
        +    ipv4: bool = betterproto.bool_field(15, group="well_known")
        +    """Ipv4 specifies that the field must be a valid IPv4 address."""
        +
        +    ipv6: bool = betterproto.bool_field(16, group="well_known")
        +    """
        +    Ipv6 specifies that the field must be a valid IPv6 address. Valid IPv6
        +    addresses should not include surrounding square brackets.
        +    """
        +
        +    uri: bool = betterproto.bool_field(17, group="well_known")
        +    """
        +    Uri specifies that the field must be a valid, absolute URI as defined by
        +    RFC 3986
        +    """
        +
        +    uri_ref: bool = betterproto.bool_field(18, group="well_known")
        +    """
        +    UriRef specifies that the field must be a valid URI as defined by RFC 3986
        +    and may be relative or absolute.
        +    """
        +
        +    address: bool = betterproto.bool_field(21, group="well_known")
        +    """
        +    Address specifies that the field must be either a valid hostname as defined
        +    by RFC 1034 (which does not support internationalized domain names or
        +    IDNs), or it can be a valid IP (v4 or v6).
        +    """
        +
        +    uuid: bool = betterproto.bool_field(22, group="well_known")
        +    """
        +    Uuid specifies that the field must be a valid UUID as defined by RFC 4122
        +    """
        +
        +    well_known_regex: "KnownRegex" = betterproto.enum_field(24, group="well_known")
        +    """
        +    WellKnownRegex specifies a common well known pattern defined as a regex.
        +    """
        +
        +    strict: bool = betterproto.bool_field(25)
        +    """
        +    This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable
        +    strict header validation. By default, this is true, and HTTP header
        +    validations are RFC-compliant. Setting to false will enable a looser
        +    validations that only disallows \r\n\0 characters, which can be used to
        +    bypass header matching rules.
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(26)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var address : bool
        +
        +

        Address specifies that the field must be either a valid hostname as defined +by RFC 1034 (which does not support internationalized domain names or +IDNs), or it can be a valid IP (v4 or v6).

        +
        +
        var const : str
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var contains : str
        +
        +

        Contains specifies that this field must have the specified substring +anywhere in the string.

        +
        +
        var email : bool
        +
        +

        Email specifies that the field must be a valid email address as defined by +RFC 5322

        +
        +
        var hostname : bool
        +
        +

        Hostname specifies that the field must be a valid hostname as defined by +RFC 1034. This constraint does not support internationalized domain names +(IDNs).

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[str]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var ip : bool
        +
        +

        Ip specifies that the field must be a valid IP (v4 or v6) address. Valid +IPv6 addresses should not include surrounding square brackets.

        +
        +
        var ipv4 : bool
        +
        +

        Ipv4 specifies that the field must be a valid IPv4 address.

        +
        +
        var ipv6 : bool
        +
        +

        Ipv6 specifies that the field must be a valid IPv6 address. Valid IPv6 +addresses should not include surrounding square brackets.

        +
        +
        var len : int
        +
        +

        Len specifies that this field must be the specified number of characters +(Unicode code points). Note that the number of characters may differ from +the number of bytes in the string.

        +
        +
        var len_bytes : int
        +
        +

        LenBytes specifies that this field must be the specified number of bytes at +a minimum

        +
        +
        var max_bytes : int
        +
        +

        MaxBytes specifies that this field must be the specified number of bytes at +a maximum

        +
        +
        var max_len : int
        +
        +

        MaxLen specifies that this field must be the specified number of characters +(Unicode code points) at a maximum. Note that the number of characters may +differ from the number of bytes in the string.

        +
        +
        var min_bytes : int
        +
        +

        MinBytes specifies that this field must be the specified number of bytes at +a minimum

        +
        +
        var min_len : int
        +
        +

        MinLen specifies that this field must be the specified number of characters +(Unicode code points) at a minimum. Note that the number of characters may +differ from the number of bytes in the string.

        +
        +
        var not_contains : str
        +
        +

        NotContains specifies that this field cannot have the specified substring +anywhere in the string.

        +
        +
        var not_in : List[str]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        var pattern : str
        +
        +

        Pattern specifes that this field must match against the specified regular +expression (RE2 syntax). The included expression should elide any +delimiters.

        +
        +
        var prefix : str
        +
        +

        Prefix specifies that this field must have the specified substring at the +beginning of the string.

        +
        +
        var strict : bool
        +
        +

        This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable +strict header validation. By default, this is true, and HTTP header +validations are RFC-compliant. Setting to false will enable a looser +validations that only disallows + characters, which can be used to +bypass header matching rules.

        +
        +
        var suffix : str
        +
        +

        Suffix specifies that this field must have the specified substring at the +end of the string.

        +
        +
        var uri : bool
        +
        +

        Uri specifies that the field must be a valid, absolute URI as defined by +RFC 3986

        +
        +
        var uri_ref : bool
        +
        +

        UriRef specifies that the field must be a valid URI as defined by RFC 3986 +and may be relative or absolute.

        +
        +
        var uuid : bool
        +
        +

        Uuid specifies that the field must be a valid UUID as defined by RFC 4122

        +
        +
        var well_known_regexKnownRegex
        +
        +

        WellKnownRegex specifies a common well known pattern defined as a regex.

        +
        +
        +
        +
        +class TimestampRules +(required: bool = <object object>, const: datetime.datetime = <object object>, lt: datetime.datetime = <object object>, lte: datetime.datetime = <object object>, gt: datetime.datetime = <object object>, gte: datetime.datetime = <object object>, lt_now: bool = <object object>, gt_now: bool = <object object>, within: datetime.timedelta = <object object>) +
        +
        +

        TimestampRules describe the constraints applied exclusively to the +google.protobuf.Timestamp well-known type

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TimestampRules(betterproto.Message):
        +    """
        +    TimestampRules describe the constraints applied exclusively to the
        +    `google.protobuf.Timestamp` well-known type
        +    """
        +
        +    required: bool = betterproto.bool_field(1)
        +    """Required specifies that this field must be set"""
        +
        +    const: datetime = betterproto.message_field(2)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: datetime = betterproto.message_field(3)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: datetime = betterproto.message_field(4)
        +    """
        +    Lte specifies that this field must be less than the specified value,
        +    inclusive
        +    """
        +
        +    gt: datetime = betterproto.message_field(5)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive
        +    """
        +
        +    gte: datetime = betterproto.message_field(6)
        +    """
        +    Gte specifies that this field must be greater than the specified value,
        +    inclusive
        +    """
        +
        +    lt_now: bool = betterproto.bool_field(7)
        +    """
        +    LtNow specifies that this must be less than the current time. LtNow can
        +    only be used with the Within rule.
        +    """
        +
        +    gt_now: bool = betterproto.bool_field(8)
        +    """
        +    GtNow specifies that this must be greater than the current time. GtNow can
        +    only be used with the Within rule.
        +    """
        +
        +    within: timedelta = betterproto.message_field(9)
        +    """
        +    Within specifies that this field must be within this duration of the
        +    current time. This constraint can be used alone or with the LtNow and GtNow
        +    rules.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : datetime.datetime
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : datetime.datetime
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive

        +
        +
        var gt_now : bool
        +
        +

        GtNow specifies that this must be greater than the current time. GtNow can +only be used with the Within rule.

        +
        +
        var gte : datetime.datetime
        +
        +

        Gte specifies that this field must be greater than the specified value, +inclusive

        +
        +
        var lt : datetime.datetime
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lt_now : bool
        +
        +

        LtNow specifies that this must be less than the current time. LtNow can +only be used with the Within rule.

        +
        +
        var lte : datetime.datetime
        +
        +

        Lte specifies that this field must be less than the specified value, +inclusive

        +
        +
        var required : bool
        +
        +

        Required specifies that this field must be set

        +
        +
        var within : datetime.timedelta
        +
        +

        Within specifies that this field must be within this duration of the +current time. This constraint can be used alone or with the LtNow and GtNow +rules.

        +
        +
        +
        +
        +class UInt32Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        UInt32Rules describes the constraints applied to uint32 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class UInt32Rules(betterproto.Message):
        +    """UInt32Rules describes the constraints applied to `uint32` values"""
        +
        +    const: int = betterproto.uint32_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.uint32_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.uint32_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.uint32_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.uint32_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.uint32_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.uint32_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +class UInt64Rules +(const: int = <object object>, lt: int = <object object>, lte: int = <object object>, gt: int = <object object>, gte: int = <object object>, in_: List[int] = <object object>, not_in: List[int] = <object object>, ignore_empty: bool = <object object>) +
        +
        +

        UInt64Rules describes the constraints applied to uint64 values

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class UInt64Rules(betterproto.Message):
        +    """UInt64Rules describes the constraints applied to `uint64` values"""
        +
        +    const: int = betterproto.uint64_field(1)
        +    """Const specifies that this field must be exactly the specified value"""
        +
        +    lt: int = betterproto.uint64_field(2)
        +    """
        +    Lt specifies that this field must be less than the specified value,
        +    exclusive
        +    """
        +
        +    lte: int = betterproto.uint64_field(3)
        +    """
        +    Lte specifies that this field must be less than or equal to the specified
        +    value, inclusive
        +    """
        +
        +    gt: int = betterproto.uint64_field(4)
        +    """
        +    Gt specifies that this field must be greater than the specified value,
        +    exclusive. If the value of Gt is larger than a specified Lt or Lte, the
        +    range is reversed.
        +    """
        +
        +    gte: int = betterproto.uint64_field(5)
        +    """
        +    Gte specifies that this field must be greater than or equal to the
        +    specified value, inclusive. If the value of Gte is larger than a specified
        +    Lt or Lte, the range is reversed.
        +    """
        +
        +    in_: List[int] = betterproto.uint64_field(6)
        +    """
        +    In specifies that this field must be equal to one of the specified values
        +    """
        +
        +    not_in: List[int] = betterproto.uint64_field(7)
        +    """
        +    NotIn specifies that this field cannot be equal to one of the specified
        +    values
        +    """
        +
        +    ignore_empty: bool = betterproto.bool_field(8)
        +    """
        +    IgnoreEmpty specifies that the validation rules of this field should be
        +    evaluated only if the field is not empty
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var const : int
        +
        +

        Const specifies that this field must be exactly the specified value

        +
        +
        var gt : int
        +
        +

        Gt specifies that this field must be greater than the specified value, +exclusive. If the value of Gt is larger than a specified Lt or Lte, the +range is reversed.

        +
        +
        var gte : int
        +
        +

        Gte specifies that this field must be greater than or equal to the +specified value, inclusive. If the value of Gte is larger than a specified +Lt or Lte, the range is reversed.

        +
        +
        var ignore_empty : bool
        +
        +

        IgnoreEmpty specifies that the validation rules of this field should be +evaluated only if the field is not empty

        +
        +
        var in_ : List[int]
        +
        +

        In specifies that this field must be equal to one of the specified values

        +
        +
        var lt : int
        +
        +

        Lt specifies that this field must be less than the specified value, +exclusive

        +
        +
        var lte : int
        +
        +

        Lte specifies that this field must be less than or equal to the specified +value, inclusive

        +
        +
        var not_in : List[int]
        +
        +

        NotIn specifies that this field cannot be equal to one of the specified +values

        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/apis.html b/docs/nitric/resources/apis.html new file mode 100644 index 0000000..5209d3b --- /dev/null +++ b/docs/nitric/resources/apis.html @@ -0,0 +1,1356 @@ + + + + + + +nitric.resources.apis API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.apis

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +from typing import List, Union
        +from dataclasses import dataclass
        +from nitric.faas import ApiWorkerOptions, FunctionServer, HttpMiddleware, Middleware, MethodOptions, HttpMethod
        +from nitric.application import Nitric
        +from nitric.resources.base import BaseResource
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    ApiResource,
        +    ApiScopes,
        +    ApiSecurityDefinition,
        +    ApiSecurityDefinitionJwt,
        +    ResourceDeclareRequest,
        +    ResourceDetailsRequest,
        +)
        +from grpclib import GRPCError
        +from nitric.api.exception import exception_from_grpc_error
        +
        +
        +@dataclass
        +class ApiDetails:
        +    """Represents the APIs deployment details."""
        +
        +    # the identifier of the resource
        +    id: str
        +    # The provider this resource is deployed with (e.g. aws)
        +    provider: str
        +    # The service this resource is deployed on (e.g. ApiGateway)
        +    service: str
        +    # The url of the API
        +    url: str
        +
        +
        +@dataclass
        +class JwtSecurityDefinition:
        +    """Represents the JWT security definition for an API."""
        +
        +    issuer: str
        +    audiences: List[str]
        +
        +
        +# TODO: Union type for multiple security definition mappings
        +# type SecurityDefinition = JwtSecurityDefinition;
        +
        +SecurityDefinition = JwtSecurityDefinition
        +
        +
        +class ApiOptions:
        +    """Represents options when creating an API, such as middleware to be applied to all HTTP request to the API."""
        +
        +    path: str
        +    middleware: Union[HttpMiddleware, List[HttpMiddleware], None]
        +    security_definitions: Union[dict[str, SecurityDefinition], None]
        +    security: Union[dict[str, List[str]], None]
        +
        +    def __init__(
        +        self,
        +        path: str = "",
        +        middleware: List[Middleware] = [],
        +        security_definitions: dict[str, SecurityDefinition] = None,
        +        security: dict[str, List[str]] = None,
        +    ):
        +        """Construct a new API options object."""
        +        self.middleware = middleware
        +        self.security_definitions = security_definitions
        +        self.security = security
        +        self.path = path
        +
        +
        +class RouteOptions:
        +    """Represents options when creating a route, such as middleware to be applied to all HTTP Methods for the route."""
        +
        +    middleware: Union[None, List[Middleware]]
        +
        +    def __init__(self, middleware: List[Middleware] = []):
        +        """Construct a new route options object."""
        +        self.middleware = middleware
        +
        +
        +def _to_resource(b: Api) -> Resource:
        +    return Resource(name=b.name, type=ResourceType.Api)
        +
        +
        +def _security_definition_to_grpc_declaration(
        +    security_definitions: dict[str, SecurityDefinition]
        +) -> Union[dict[str, ApiSecurityDefinition], None]:
        +    if security_definitions is None or len(security_definitions) == 0:
        +        return None
        +    return {
        +        k: ApiSecurityDefinition(jwt=ApiSecurityDefinitionJwt(issuer=v.issuer, audiences=v.audiences))
        +        for k, v in security_definitions.items()
        +    }
        +
        +
        +def _security_to_grpc_declaration(security: dict[str, List[str]]) -> dict[str, ApiScopes] | None:
        +    if security is None or len(security) == 0:
        +        return None
        +    return {k: ApiScopes(v) for k, v in security.items()}
        +
        +
        +class Api(BaseResource):
        +    """An HTTP API."""
        +
        +    app: Nitric
        +    name: str
        +    path: str
        +    middleware: List[HttpMiddleware]
        +    routes: List[Route]
        +    security_definitions: dict[str, SecurityDefinition]
        +    security: dict[str, List[str]]
        +
        +    def __init__(self, name: str, opts: ApiOptions = None):
        +        """Construct a new HTTP API."""
        +        super().__init__()
        +        if opts is None:
        +            opts = ApiOptions()
        +
        +        self.name = name
        +        self.middleware = opts.middleware if opts.middleware is not None else []
        +        self.path = opts.path
        +        self.routes = []
        +        self.security_definitions = opts.security_definitions
        +        self.security = opts.security
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(
        +                    resource=_to_resource(self),
        +                    api=ApiResource(
        +                        security_definitions=_security_definition_to_grpc_declaration(self.security_definitions),
        +                        security=_security_to_grpc_declaration(self.security),
        +                    ),
        +                )
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _route(self, match: str, opts: RouteOptions = None) -> Route:
        +        """Define an HTTP route to be handled by this API."""
        +        if opts is None:
        +            opts = RouteOptions()
        +
        +        r = Route(self, match, opts)
        +        self.routes.append(r)
        +        return r
        +
        +    def all(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(
        +                [
        +                    HttpMethod.GET,
        +                    HttpMethod.POST,
        +                    HttpMethod.PATCH,
        +                    HttpMethod.PUT,
        +                    HttpMethod.DELETE,
        +                    HttpMethod.OPTIONS,
        +                ],
        +                function,
        +                opts=opts,
        +            )
        +
        +        return decorator
        +
        +    def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(methods, function, opts=opts)
        +
        +        return decorator
        +
        +    def get(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.get(function, opts=opts)
        +
        +        return decorator
        +
        +    def post(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP POST requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.post(function, opts=opts)
        +
        +        return decorator
        +
        +    def delete(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP DELETE requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.delete(function, opts=opts)
        +
        +        return decorator
        +
        +    def options(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP OPTIONS requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.options(function, opts=opts)
        +
        +        return decorator
        +
        +    def patch(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PATCH requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.patch(function, opts=opts)
        +
        +        return decorator
        +
        +    def put(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PUT requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.put(function, opts=opts)
        +
        +        return decorator
        +
        +    async def _details(self) -> ApiDetails:
        +        """Get the API deployment details."""
        +        try:
        +            res = await self._resources_stub.details(
        +                resource_details_request=ResourceDetailsRequest(
        +                    resource=_to_resource(self),
        +                )
        +            )
        +            return ApiDetails(res.id, res.provider, res.service, res.api.url)
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    async def URL(self) -> str:
        +        """Get the APIs live URL."""
        +        details = await self._details()
        +        return details.url
        +
        +
        +class Route:
        +    """An HTTP route."""
        +
        +    api: Api
        +    path: str
        +    middleware: List[Middleware]
        +
        +    def __init__(self, api: Api, path: str, opts: RouteOptions):
        +        """Define a route to be handled by the provided API."""
        +        self.api = api
        +        self.path = api.path.join(path)
        +        self.middleware = opts.middleware if opts.middleware is not None else []
        +
        +    def method(self, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for multiple HTTP Methods."""
        +        return Method(self, methods, *middleware, opts=opts).start()
        +
        +    def get(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP GET requests."""
        +        return self.method([HttpMethod.GET], *middleware, opts=opts)
        +
        +    def post(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP POST requests."""
        +        return self.method([HttpMethod.POST], *middleware, opts=opts)
        +
        +    def put(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP PUT requests."""
        +        return self.method([HttpMethod.PUT], *middleware, opts=opts)
        +
        +    def patch(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP PATCH requests."""
        +        return self.method([HttpMethod.PATCH], *middleware, opts=opts)
        +
        +    def delete(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP DELETE requests."""
        +        return self.method([HttpMethod.DELETE], *middleware, opts=opts)
        +
        +    def options(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP OPTIONS requests."""
        +        return self.method([HttpMethod.OPTIONS], *middleware, opts=opts)
        +
        +
        +class Method:
        +    """A method handler."""
        +
        +    server: FunctionServer
        +    route: Route
        +    methods: List[HttpMethod]
        +    opts: MethodOptions
        +
        +    def __init__(
        +        self, route: Route, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None
        +    ):
        +        """Construct a method handler for the specified route."""
        +        self.route = route
        +        self.methods = methods
        +        self.server = FunctionServer(ApiWorkerOptions(route.api.name, route.path, methods, opts))
        +        self.server.http(*route.api.middleware, *route.middleware, *middleware)
        +
        +    def start(self):
        +        """Start the server which will respond to incoming requests."""
        +        Nitric._register_worker(self.server)
        +
        +
        +def api(name: str, opts: ApiOptions = None) -> Api:
        +    """Create a new API resource."""
        +    return Nitric._create_resource(Api, name, opts=opts)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def api(name: str, opts: ApiOptions = None) ‑> Api +
        +
        +

        Create a new API resource.

        +
        + +Expand source code + +
        def api(name: str, opts: ApiOptions = None) -> Api:
        +    """Create a new API resource."""
        +    return Nitric._create_resource(Api, name, opts=opts)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Api +(name: str, opts: ApiOptions = None) +
        +
        +

        An HTTP API.

        +

        Construct a new HTTP API.

        +
        + +Expand source code + +
        class Api(BaseResource):
        +    """An HTTP API."""
        +
        +    app: Nitric
        +    name: str
        +    path: str
        +    middleware: List[HttpMiddleware]
        +    routes: List[Route]
        +    security_definitions: dict[str, SecurityDefinition]
        +    security: dict[str, List[str]]
        +
        +    def __init__(self, name: str, opts: ApiOptions = None):
        +        """Construct a new HTTP API."""
        +        super().__init__()
        +        if opts is None:
        +            opts = ApiOptions()
        +
        +        self.name = name
        +        self.middleware = opts.middleware if opts.middleware is not None else []
        +        self.path = opts.path
        +        self.routes = []
        +        self.security_definitions = opts.security_definitions
        +        self.security = opts.security
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(
        +                    resource=_to_resource(self),
        +                    api=ApiResource(
        +                        security_definitions=_security_definition_to_grpc_declaration(self.security_definitions),
        +                        security=_security_to_grpc_declaration(self.security),
        +                    ),
        +                )
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _route(self, match: str, opts: RouteOptions = None) -> Route:
        +        """Define an HTTP route to be handled by this API."""
        +        if opts is None:
        +            opts = RouteOptions()
        +
        +        r = Route(self, match, opts)
        +        self.routes.append(r)
        +        return r
        +
        +    def all(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(
        +                [
        +                    HttpMethod.GET,
        +                    HttpMethod.POST,
        +                    HttpMethod.PATCH,
        +                    HttpMethod.PUT,
        +                    HttpMethod.DELETE,
        +                    HttpMethod.OPTIONS,
        +                ],
        +                function,
        +                opts=opts,
        +            )
        +
        +        return decorator
        +
        +    def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(methods, function, opts=opts)
        +
        +        return decorator
        +
        +    def get(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.get(function, opts=opts)
        +
        +        return decorator
        +
        +    def post(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP POST requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.post(function, opts=opts)
        +
        +        return decorator
        +
        +    def delete(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP DELETE requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.delete(function, opts=opts)
        +
        +        return decorator
        +
        +    def options(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP OPTIONS requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.options(function, opts=opts)
        +
        +        return decorator
        +
        +    def patch(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PATCH requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.patch(function, opts=opts)
        +
        +        return decorator
        +
        +    def put(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PUT requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.put(function, opts=opts)
        +
        +        return decorator
        +
        +    async def _details(self) -> ApiDetails:
        +        """Get the API deployment details."""
        +        try:
        +            res = await self._resources_stub.details(
        +                resource_details_request=ResourceDetailsRequest(
        +                    resource=_to_resource(self),
        +                )
        +            )
        +            return ApiDetails(res.id, res.provider, res.service, res.api.url)
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    async def URL(self) -> str:
        +        """Get the APIs live URL."""
        +        details = await self._details()
        +        return details.url
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var appNitric
        +
        +
        +
        +
        var middleware : List[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]]]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        var routes : List[Route]
        +
        +
        +
        +
        var security : dict[str, typing.List[str]]
        +
        +
        +
        +
        var security_definitions : dict[str, JwtSecurityDefinition]
        +
        +
        +
        +
        +

        Methods

        +
        +
        +async def URL(self) ‑> str +
        +
        +

        Get the APIs live URL.

        +
        + +Expand source code + +
        async def URL(self) -> str:
        +    """Get the APIs live URL."""
        +    details = await self._details()
        +    return details.url
        +
        +
        +
        +def all(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def all(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.method(
        +            [
        +                HttpMethod.GET,
        +                HttpMethod.POST,
        +                HttpMethod.PATCH,
        +                HttpMethod.PUT,
        +                HttpMethod.DELETE,
        +                HttpMethod.OPTIONS,
        +            ],
        +            function,
        +            opts=opts,
        +        )
        +
        +    return decorator
        +
        +
        +
        +def delete(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP DELETE requests.

        +
        + +Expand source code + +
        def delete(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP DELETE requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.delete(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def get(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def get(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.get(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.method(methods, function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def options(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP OPTIONS requests.

        +
        + +Expand source code + +
        def options(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP OPTIONS requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.options(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def patch(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP PATCH requests.

        +
        + +Expand source code + +
        def patch(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP PATCH requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.patch(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def post(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP POST requests.

        +
        + +Expand source code + +
        def post(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP POST requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.post(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def put(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP PUT requests.

        +
        + +Expand source code + +
        def put(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP PUT requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.put(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class ApiDetails +(id: str, provider: str, service: str, url: str) +
        +
        +

        Represents the APIs deployment details.

        +
        + +Expand source code + +
        @dataclass
        +class ApiDetails:
        +    """Represents the APIs deployment details."""
        +
        +    # the identifier of the resource
        +    id: str
        +    # The provider this resource is deployed with (e.g. aws)
        +    provider: str
        +    # The service this resource is deployed on (e.g. ApiGateway)
        +    service: str
        +    # The url of the API
        +    url: str
        +
        +

        Class variables

        +
        +
        var id : str
        +
        +
        +
        +
        var provider : str
        +
        +
        +
        +
        var service : str
        +
        +
        +
        +
        var url : str
        +
        +
        +
        +
        +
        +
        +class ApiOptions +(path: str = '', middleware: List[Middleware] = [], security_definitions: dict[str, JwtSecurityDefinition] = None, security: dict[str, List[str]] = None) +
        +
        +

        Represents options when creating an API, such as middleware to be applied to all HTTP request to the API.

        +

        Construct a new API options object.

        +
        + +Expand source code + +
        class ApiOptions:
        +    """Represents options when creating an API, such as middleware to be applied to all HTTP request to the API."""
        +
        +    path: str
        +    middleware: Union[HttpMiddleware, List[HttpMiddleware], None]
        +    security_definitions: Union[dict[str, SecurityDefinition], None]
        +    security: Union[dict[str, List[str]], None]
        +
        +    def __init__(
        +        self,
        +        path: str = "",
        +        middleware: List[Middleware] = [],
        +        security_definitions: dict[str, SecurityDefinition] = None,
        +        security: dict[str, List[str]] = None,
        +    ):
        +        """Construct a new API options object."""
        +        self.middleware = middleware
        +        self.security_definitions = security_definitions
        +        self.security = security
        +        self.path = path
        +
        +

        Class variables

        +
        +
        var middleware : Union[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]], List[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]]], NoneType]
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        var security : Optional[dict[str, List[str]]]
        +
        +
        +
        +
        var security_definitions : Optional[dict[str, JwtSecurityDefinition]]
        +
        +
        +
        +
        +
        +
        +class JwtSecurityDefinition +(issuer: str, audiences: List[str]) +
        +
        +

        Represents the JWT security definition for an API.

        +
        + +Expand source code + +
        @dataclass
        +class JwtSecurityDefinition:
        +    """Represents the JWT security definition for an API."""
        +
        +    issuer: str
        +    audiences: List[str]
        +
        +

        Class variables

        +
        +
        var audiences : List[str]
        +
        +
        +
        +
        var issuer : str
        +
        +
        +
        +
        +
        +
        +class SecurityDefinition +(issuer: str, audiences: List[str]) +
        +
        +

        Represents the JWT security definition for an API.

        +
        + +Expand source code + +
        @dataclass
        +class JwtSecurityDefinition:
        +    """Represents the JWT security definition for an API."""
        +
        +    issuer: str
        +    audiences: List[str]
        +
        +

        Class variables

        +
        +
        var audiences : List[str]
        +
        +
        +
        +
        var issuer : str
        +
        +
        +
        +
        +
        +
        +class Method +(route: Route, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        A method handler.

        +

        Construct a method handler for the specified route.

        +
        + +Expand source code + +
        class Method:
        +    """A method handler."""
        +
        +    server: FunctionServer
        +    route: Route
        +    methods: List[HttpMethod]
        +    opts: MethodOptions
        +
        +    def __init__(
        +        self, route: Route, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None
        +    ):
        +        """Construct a method handler for the specified route."""
        +        self.route = route
        +        self.methods = methods
        +        self.server = FunctionServer(ApiWorkerOptions(route.api.name, route.path, methods, opts))
        +        self.server.http(*route.api.middleware, *route.middleware, *middleware)
        +
        +    def start(self):
        +        """Start the server which will respond to incoming requests."""
        +        Nitric._register_worker(self.server)
        +
        +

        Class variables

        +
        +
        var methods : List[HttpMethod]
        +
        +
        +
        +
        var optsMethodOptions
        +
        +
        +
        +
        var routeRoute
        +
        +
        +
        +
        var serverFunctionServer
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def start(self) +
        +
        +

        Start the server which will respond to incoming requests.

        +
        + +Expand source code + +
        def start(self):
        +    """Start the server which will respond to incoming requests."""
        +    Nitric._register_worker(self.server)
        +
        +
        +
        +
        +
        +class Route +(api: Api, path: str, opts: RouteOptions) +
        +
        +

        An HTTP route.

        +

        Define a route to be handled by the provided API.

        +
        + +Expand source code + +
        class Route:
        +    """An HTTP route."""
        +
        +    api: Api
        +    path: str
        +    middleware: List[Middleware]
        +
        +    def __init__(self, api: Api, path: str, opts: RouteOptions):
        +        """Define a route to be handled by the provided API."""
        +        self.api = api
        +        self.path = api.path.join(path)
        +        self.middleware = opts.middleware if opts.middleware is not None else []
        +
        +    def method(self, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for multiple HTTP Methods."""
        +        return Method(self, methods, *middleware, opts=opts).start()
        +
        +    def get(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP GET requests."""
        +        return self.method([HttpMethod.GET], *middleware, opts=opts)
        +
        +    def post(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP POST requests."""
        +        return self.method([HttpMethod.POST], *middleware, opts=opts)
        +
        +    def put(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP PUT requests."""
        +        return self.method([HttpMethod.PUT], *middleware, opts=opts)
        +
        +    def patch(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP PATCH requests."""
        +        return self.method([HttpMethod.PATCH], *middleware, opts=opts)
        +
        +    def delete(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP DELETE requests."""
        +        return self.method([HttpMethod.DELETE], *middleware, opts=opts)
        +
        +    def options(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +        """Register middleware for HTTP OPTIONS requests."""
        +        return self.method([HttpMethod.OPTIONS], *middleware, opts=opts)
        +
        +

        Class variables

        +
        +
        var apiApi
        +
        +
        +
        +
        var middleware : List[Callable[[~C, Callable], Coroutine[Any, Any, ~C]]]
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def delete(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP DELETE requests.

        +
        + +Expand source code + +
        def delete(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP DELETE requests."""
        +    return self.method([HttpMethod.DELETE], *middleware, opts=opts)
        +
        +
        +
        +def get(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP GET requests.

        +
        + +Expand source code + +
        def get(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP GET requests."""
        +    return self.method([HttpMethod.GET], *middleware, opts=opts)
        +
        +
        +
        +def method(self, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for multiple HTTP Methods.

        +
        + +Expand source code + +
        def method(self, methods: List[HttpMethod], *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for multiple HTTP Methods."""
        +    return Method(self, methods, *middleware, opts=opts).start()
        +
        +
        +
        +def options(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP OPTIONS requests.

        +
        + +Expand source code + +
        def options(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP OPTIONS requests."""
        +    return self.method([HttpMethod.OPTIONS], *middleware, opts=opts)
        +
        +
        +
        +def patch(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP PATCH requests.

        +
        + +Expand source code + +
        def patch(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP PATCH requests."""
        +    return self.method([HttpMethod.PATCH], *middleware, opts=opts)
        +
        +
        +
        +def post(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP POST requests.

        +
        + +Expand source code + +
        def post(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP POST requests."""
        +    return self.method([HttpMethod.POST], *middleware, opts=opts)
        +
        +
        +
        +def put(self, *middleware: HttpMiddleware, opts: MethodOptions = None) +
        +
        +

        Register middleware for HTTP PUT requests.

        +
        + +Expand source code + +
        def put(self, *middleware: HttpMiddleware, opts: MethodOptions = None):
        +    """Register middleware for HTTP PUT requests."""
        +    return self.method([HttpMethod.PUT], *middleware, opts=opts)
        +
        +
        +
        +
        +
        +class RouteOptions +(middleware: List[Middleware] = []) +
        +
        +

        Represents options when creating a route, such as middleware to be applied to all HTTP Methods for the route.

        +

        Construct a new route options object.

        +
        + +Expand source code + +
        class RouteOptions:
        +    """Represents options when creating a route, such as middleware to be applied to all HTTP Methods for the route."""
        +
        +    middleware: Union[None, List[Middleware]]
        +
        +    def __init__(self, middleware: List[Middleware] = []):
        +        """Construct a new route options object."""
        +        self.middleware = middleware
        +
        +

        Class variables

        +
        +
        var middleware : Optional[List[Callable[[~C, Callable], Coroutine[Any, Any, ~C]]]]
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/base.html b/docs/nitric/resources/base.html new file mode 100644 index 0000000..a82c334 --- /dev/null +++ b/docs/nitric/resources/base.html @@ -0,0 +1,354 @@ + + + + + + +nitric.resources.base API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.base

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +import asyncio
        +from abc import ABC, abstractmethod
        +from asyncio import Task
        +
        +from typing import TypeVar, Type, Union, List
        +
        +from grpclib import GRPCError
        +from nitric.proto.nitric.resource.v1 import (
        +    Action,
        +    PolicyResource,
        +    Resource,
        +    ResourceType,
        +    ResourceDeclareRequest,
        +    ResourceServiceStub,
        +)
        +
        +from nitric.api.exception import exception_from_grpc_error, NitricResourceException
        +from nitric.utils import new_default_channel
        +
        +T = TypeVar("T", bound="BaseResource")
        +
        +
        +class BaseResource(ABC):
        +    """A base resource class with common functionality."""
        +
        +    cache = {}
        +
        +    def __init__(self):
        +        """Construct a new resource."""
        +        self._reg: Union[Task, None] = None
        +        self._channel = new_default_channel()
        +        self._resources_stub = ResourceServiceStub(channel=self._channel)
        +
        +    @abstractmethod
        +    async def _register(self):
        +        pass
        +
        +    @classmethod
        +    def make(cls: Type[T], name: str, *args, **kwargs) -> T:
        +        """
        +        Create and register the resource.
        +
        +        The registration process for resources async, so this method should be used instead of __init__.
        +        """
        +        # Todo: store the resource reference in a cache to avoid duplicate registrations
        +        r = cls(name, *args, **kwargs)
        +        try:
        +            loop = asyncio.get_running_loop()
        +            r._reg = loop.create_task(r._register())
        +        except RuntimeError:
        +            loop = asyncio.get_event_loop()
        +            loop.run_until_complete(r._register())
        +
        +        return r
        +
        +
        +class SecureResource(BaseResource):
        +    """A secure base resource class."""
        +
        +    @abstractmethod
        +    def _to_resource(self) -> Resource:
        +        pass
        +
        +    @abstractmethod
        +    def _perms_to_actions(self, *args: str) -> List[Action]:
        +        pass
        +
        +    async def _register_policy_async(self, *args: str):
        +        # if self._reg is not None:
        +        #     await asyncio.wait({self._reg})
        +
        +        policy = PolicyResource(
        +            principals=[Resource(type=ResourceType.Function)],
        +            actions=self._perms_to_actions(*args),
        +            resources=[self._to_resource()],
        +        )
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(
        +                    resource=Resource(type=ResourceType.Policy), policy=policy
        +                )
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _register_policy(self, *args: str):
        +        try:
        +            loop = asyncio.get_event_loop()
        +            loop.run_until_complete(self._register_policy_async(*args))
        +        except RuntimeError:
        +            # TODO: Check nitric runtime ENV variable
        +            raise NitricResourceException(
        +                "Nitric resources cannot be declared at runtime e.g. within the scope of a function. \
        +                    Move resource declarations to the top level of scripts so that they can be safely provisioned"
        +            )
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class BaseResource +
        +
        +

        A base resource class with common functionality.

        +

        Construct a new resource.

        +
        + +Expand source code + +
        class BaseResource(ABC):
        +    """A base resource class with common functionality."""
        +
        +    cache = {}
        +
        +    def __init__(self):
        +        """Construct a new resource."""
        +        self._reg: Union[Task, None] = None
        +        self._channel = new_default_channel()
        +        self._resources_stub = ResourceServiceStub(channel=self._channel)
        +
        +    @abstractmethod
        +    async def _register(self):
        +        pass
        +
        +    @classmethod
        +    def make(cls: Type[T], name: str, *args, **kwargs) -> T:
        +        """
        +        Create and register the resource.
        +
        +        The registration process for resources async, so this method should be used instead of __init__.
        +        """
        +        # Todo: store the resource reference in a cache to avoid duplicate registrations
        +        r = cls(name, *args, **kwargs)
        +        try:
        +            loop = asyncio.get_running_loop()
        +            r._reg = loop.create_task(r._register())
        +        except RuntimeError:
        +            loop = asyncio.get_event_loop()
        +            loop.run_until_complete(r._register())
        +
        +        return r
        +
        +

        Ancestors

        +
          +
        • abc.ABC
        • +
        +

        Subclasses

        + +

        Class variables

        +
        +
        var cache
        +
        +
        +
        +
        +

        Static methods

        +
        +
        +def make(name: str, *args, **kwargs) ‑> ~T +
        +
        +

        Create and register the resource.

        +

        The registration process for resources async, so this method should be used instead of init.

        +
        + +Expand source code + +
        @classmethod
        +def make(cls: Type[T], name: str, *args, **kwargs) -> T:
        +    """
        +    Create and register the resource.
        +
        +    The registration process for resources async, so this method should be used instead of __init__.
        +    """
        +    # Todo: store the resource reference in a cache to avoid duplicate registrations
        +    r = cls(name, *args, **kwargs)
        +    try:
        +        loop = asyncio.get_running_loop()
        +        r._reg = loop.create_task(r._register())
        +    except RuntimeError:
        +        loop = asyncio.get_event_loop()
        +        loop.run_until_complete(r._register())
        +
        +    return r
        +
        +
        +
        +
        +
        +class SecureResource +
        +
        +

        A secure base resource class.

        +

        Construct a new resource.

        +
        + +Expand source code + +
        class SecureResource(BaseResource):
        +    """A secure base resource class."""
        +
        +    @abstractmethod
        +    def _to_resource(self) -> Resource:
        +        pass
        +
        +    @abstractmethod
        +    def _perms_to_actions(self, *args: str) -> List[Action]:
        +        pass
        +
        +    async def _register_policy_async(self, *args: str):
        +        # if self._reg is not None:
        +        #     await asyncio.wait({self._reg})
        +
        +        policy = PolicyResource(
        +            principals=[Resource(type=ResourceType.Function)],
        +            actions=self._perms_to_actions(*args),
        +            resources=[self._to_resource()],
        +        )
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(
        +                    resource=Resource(type=ResourceType.Policy), policy=policy
        +                )
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _register_policy(self, *args: str):
        +        try:
        +            loop = asyncio.get_event_loop()
        +            loop.run_until_complete(self._register_policy_async(*args))
        +        except RuntimeError:
        +            # TODO: Check nitric runtime ENV variable
        +            raise NitricResourceException(
        +                "Nitric resources cannot be declared at runtime e.g. within the scope of a function. \
        +                    Move resource declarations to the top level of scripts so that they can be safely provisioned"
        +            )
        +
        +

        Ancestors

        + +

        Subclasses

        + +

        Inherited members

        + +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/buckets.html b/docs/nitric/resources/buckets.html new file mode 100644 index 0000000..9c7eb41 --- /dev/null +++ b/docs/nitric/resources/buckets.html @@ -0,0 +1,336 @@ + + + + + + +nitric.resources.buckets API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.buckets

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +from nitric.api.exception import exception_from_grpc_error
        +from nitric.api.storage import BucketRef, Storage
        +from typing import List, Union
        +from enum import Enum
        +from grpclib import GRPCError
        +
        +from nitric.application import Nitric
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    Action,
        +    ResourceDeclareRequest,
        +)
        +
        +from nitric.resources.base import SecureResource
        +
        +
        +class BucketPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    reading = "reading"
        +    writing = "writing"
        +    deleting = "deleting"
        +
        +
        +class Bucket(SecureResource):
        +    """A bucket resource, used for storage and retrieval of blob/binary data."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Create a bucket with the name provided or references it if it already exists."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: [Union[BucketPermission, str]]) -> List[Action]:
        +        permission_actions_map = {
        +            BucketPermission.reading: [Action.BucketFileGet, Action.BucketFileList],
        +            BucketPermission.writing: [Action.BucketFilePut],
        +            BucketPermission.deleting: [Action.BucketFileDelete],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, BucketPermission) else BucketPermission[permission.lower()]
        +            for permission in args
        +        ]
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Bucket)
        +
        +    def allow(self, *args: Union[BucketPermission, str]) -> BucketRef:
        +        """Request the required permissions for this resource."""
        +        self._register_policy(*args)
        +
        +        return Storage().bucket(self.name)
        +
        +
        +def bucket(name: str) -> Bucket:
        +    """
        +    Create and register a bucket.
        +
        +    If a bucket has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Bucket, name)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def bucket(name: str) ‑> Bucket +
        +
        +

        Create and register a bucket.

        +

        If a bucket has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def bucket(name: str) -> Bucket:
        +    """
        +    Create and register a bucket.
        +
        +    If a bucket has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Bucket, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Bucket +(name: str) +
        +
        +

        A bucket resource, used for storage and retrieval of blob/binary data.

        +

        Create a bucket with the name provided or references it if it already exists.

        +
        + +Expand source code + +
        class Bucket(SecureResource):
        +    """A bucket resource, used for storage and retrieval of blob/binary data."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Create a bucket with the name provided or references it if it already exists."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: [Union[BucketPermission, str]]) -> List[Action]:
        +        permission_actions_map = {
        +            BucketPermission.reading: [Action.BucketFileGet, Action.BucketFileList],
        +            BucketPermission.writing: [Action.BucketFilePut],
        +            BucketPermission.deleting: [Action.BucketFileDelete],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, BucketPermission) else BucketPermission[permission.lower()]
        +            for permission in args
        +        ]
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Bucket)
        +
        +    def allow(self, *args: Union[BucketPermission, str]) -> BucketRef:
        +        """Request the required permissions for this resource."""
        +        self._register_policy(*args)
        +
        +        return Storage().bucket(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[BucketPermission, str]) ‑> BucketRef +
        +
        +

        Request the required permissions for this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[BucketPermission, str]) -> BucketRef:
        +    """Request the required permissions for this resource."""
        +    self._register_policy(*args)
        +
        +    return Storage().bucket(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class BucketPermission +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Valid query expression operators.

        +
        + +Expand source code + +
        class BucketPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    reading = "reading"
        +    writing = "writing"
        +    deleting = "deleting"
        +
        +

        Ancestors

        +
          +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var deleting
        +
        +
        +
        +
        var reading
        +
        +
        +
        +
        var writing
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/collections.html b/docs/nitric/resources/collections.html new file mode 100644 index 0000000..1ae62ae --- /dev/null +++ b/docs/nitric/resources/collections.html @@ -0,0 +1,330 @@ + + + + + + +nitric.resources.collections API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.collections

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +from nitric.api.documents import CollectionRef, Documents
        +from nitric.api.exception import exception_from_grpc_error
        +from typing import List, Union
        +from enum import Enum
        +from grpclib import GRPCError
        +
        +from nitric.application import Nitric
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    Action,
        +    ResourceDeclareRequest,
        +)
        +
        +from nitric.resources.base import SecureResource
        +
        +
        +class CollectionPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    reading = "reading"
        +    writing = "writing"
        +    deleting = "deleting"
        +
        +
        +class Collection(SecureResource):
        +    """A document collection resource."""
        +
        +    def __init__(self, name: str):
        +        """Construct a new document collection."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Collection)
        +
        +    def _perms_to_actions(self, *args: Union[CollectionPermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            CollectionPermission.reading: [
        +                Action.CollectionDocumentRead,
        +                Action.CollectionQuery,
        +                Action.CollectionList,
        +            ],
        +            CollectionPermission.writing: [Action.CollectionDocumentWrite, Action.CollectionList],
        +            CollectionPermission.deleting: [Action.CollectionDocumentDelete, Action.CollectionList],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, CollectionPermission) else CollectionPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def allow(self, *args: Union[CollectionPermission, str]) -> CollectionRef:
        +        """Request the required permissions for this collection."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Documents().collection(self.name)
        +
        +
        +def collection(name: str) -> Collection:
        +    """
        +    Create and register a collection.
        +
        +    If a collection has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Collection, name)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def collection(name: str) ‑> Collection +
        +
        +

        Create and register a collection.

        +

        If a collection has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def collection(name: str) -> Collection:
        +    """
        +    Create and register a collection.
        +
        +    If a collection has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Collection, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Collection +(name: str) +
        +
        +

        A document collection resource.

        +

        Construct a new document collection.

        +
        + +Expand source code + +
        class Collection(SecureResource):
        +    """A document collection resource."""
        +
        +    def __init__(self, name: str):
        +        """Construct a new document collection."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Collection)
        +
        +    def _perms_to_actions(self, *args: Union[CollectionPermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            CollectionPermission.reading: [
        +                Action.CollectionDocumentRead,
        +                Action.CollectionQuery,
        +                Action.CollectionList,
        +            ],
        +            CollectionPermission.writing: [Action.CollectionDocumentWrite, Action.CollectionList],
        +            CollectionPermission.deleting: [Action.CollectionDocumentDelete, Action.CollectionList],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, CollectionPermission) else CollectionPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def allow(self, *args: Union[CollectionPermission, str]) -> CollectionRef:
        +        """Request the required permissions for this collection."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Documents().collection(self.name)
        +
        +

        Ancestors

        + +

        Methods

        +
        +
        +def allow(self, *args: Union[CollectionPermission, str]) ‑> CollectionRef +
        +
        +

        Request the required permissions for this collection.

        +
        + +Expand source code + +
        def allow(self, *args: Union[CollectionPermission, str]) -> CollectionRef:
        +    """Request the required permissions for this collection."""
        +    # Ensure registration of the resource is complete before requesting permissions.
        +    self._register_policy(*args)
        +
        +    return Documents().collection(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class CollectionPermission +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Valid query expression operators.

        +
        + +Expand source code + +
        class CollectionPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    reading = "reading"
        +    writing = "writing"
        +    deleting = "deleting"
        +
        +

        Ancestors

        +
          +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var deleting
        +
        +
        +
        +
        var reading
        +
        +
        +
        +
        var writing
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/index.html b/docs/nitric/resources/index.html new file mode 100644 index 0000000..b9bd510 --- /dev/null +++ b/docs/nitric/resources/index.html @@ -0,0 +1,1600 @@ + + + + + + +nitric.resources API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources

        +
        +
        +

        Nitric Python SDK API Documentation. See: https://nitric.io/docs?lang=python for full framework documentation.

        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +"""Nitric Python SDK API Documentation. See: https://nitric.io/docs?lang=python for full framework documentation."""
        +
        +from nitric.resources.apis import Api, api, MethodOptions, ApiOptions, ApiDetails, JwtSecurityDefinition
        +from nitric.resources.buckets import Bucket, bucket
        +from nitric.resources.collections import Collection, collection
        +from nitric.resources.queues import Queue, queue
        +from nitric.resources.schedules import Schedule, schedule
        +from nitric.resources.secrets import Secret, secret
        +from nitric.resources.topics import Topic, topic
        +
        +__all__ = [
        +    "api",
        +    "Api",
        +    "ApiOptions",
        +    "ApiDetails",
        +    "JwtSecurityDefinition",
        +    "MethodOptions",
        +    "bucket",
        +    "Bucket",
        +    "collection",
        +    "Collection",
        +    "queue",
        +    "Queue",
        +    "Schedule",
        +    "schedule",
        +    "secret",
        +    "Secret",
        +    "topic",
        +    "Topic",
        +]
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.resources.apis
        +
        +
        +
        +
        nitric.resources.base
        +
        +
        +
        +
        nitric.resources.buckets
        +
        +
        +
        +
        nitric.resources.collections
        +
        +
        +
        +
        nitric.resources.queues
        +
        +
        +
        +
        nitric.resources.schedules
        +
        +
        +
        +
        nitric.resources.secrets
        +
        +
        +
        +
        nitric.resources.topics
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def api(name: str, opts: ApiOptions = None) ‑> Api +
        +
        +

        Create a new API resource.

        +
        + +Expand source code + +
        def api(name: str, opts: ApiOptions = None) -> Api:
        +    """Create a new API resource."""
        +    return Nitric._create_resource(Api, name, opts=opts)
        +
        +
        +
        +def bucket(name: str) ‑> Bucket +
        +
        +

        Create and register a bucket.

        +

        If a bucket has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def bucket(name: str) -> Bucket:
        +    """
        +    Create and register a bucket.
        +
        +    If a bucket has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Bucket, name)
        +
        +
        +
        +def collection(name: str) ‑> Collection +
        +
        +

        Create and register a collection.

        +

        If a collection has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def collection(name: str) -> Collection:
        +    """
        +    Create and register a collection.
        +
        +    If a collection has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Collection, name)
        +
        +
        +
        +def queue(name: str) ‑> Queue +
        +
        +

        Create and register a queue.

        +

        If a queue has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def queue(name: str) -> Queue:
        +    """
        +    Create and register a queue.
        +
        +    If a queue has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Queue, name)
        +
        +
        +
        +def schedule(description: str, every: str) +
        +
        +

        Return a schedule decorator.

        +
        + +Expand source code + +
        def schedule(description: str, every: str):
        +    """Return a schedule decorator."""
        +
        +    def decorator(func: EventMiddleware):
        +        r = Schedule(description)
        +        r.every(every, func)
        +        return r
        +
        +    return decorator
        +
        +
        +
        +def secret(name: str) ‑> Secret +
        +
        +

        Create and registers a secret.

        +

        If a secret has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def secret(name: str) -> Secret:
        +    """
        +    Create and registers a secret.
        +
        +    If a secret has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Secret, name)
        +
        +
        +
        +def topic(name: str) ‑> Topic +
        +
        +

        Create and register a topic.

        +

        If a topic has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def topic(name: str) -> Topic:
        +    """
        +    Create and register a topic.
        +
        +    If a topic has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Topic, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Api +(name: str, opts: ApiOptions = None) +
        +
        +

        An HTTP API.

        +

        Construct a new HTTP API.

        +
        + +Expand source code + +
        class Api(BaseResource):
        +    """An HTTP API."""
        +
        +    app: Nitric
        +    name: str
        +    path: str
        +    middleware: List[HttpMiddleware]
        +    routes: List[Route]
        +    security_definitions: dict[str, SecurityDefinition]
        +    security: dict[str, List[str]]
        +
        +    def __init__(self, name: str, opts: ApiOptions = None):
        +        """Construct a new HTTP API."""
        +        super().__init__()
        +        if opts is None:
        +            opts = ApiOptions()
        +
        +        self.name = name
        +        self.middleware = opts.middleware if opts.middleware is not None else []
        +        self.path = opts.path
        +        self.routes = []
        +        self.security_definitions = opts.security_definitions
        +        self.security = opts.security
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(
        +                    resource=_to_resource(self),
        +                    api=ApiResource(
        +                        security_definitions=_security_definition_to_grpc_declaration(self.security_definitions),
        +                        security=_security_to_grpc_declaration(self.security),
        +                    ),
        +                )
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _route(self, match: str, opts: RouteOptions = None) -> Route:
        +        """Define an HTTP route to be handled by this API."""
        +        if opts is None:
        +            opts = RouteOptions()
        +
        +        r = Route(self, match, opts)
        +        self.routes.append(r)
        +        return r
        +
        +    def all(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(
        +                [
        +                    HttpMethod.GET,
        +                    HttpMethod.POST,
        +                    HttpMethod.PATCH,
        +                    HttpMethod.PUT,
        +                    HttpMethod.DELETE,
        +                    HttpMethod.OPTIONS,
        +                ],
        +                function,
        +                opts=opts,
        +            )
        +
        +        return decorator
        +
        +    def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.method(methods, function, opts=opts)
        +
        +        return decorator
        +
        +    def get(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP GET requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.get(function, opts=opts)
        +
        +        return decorator
        +
        +    def post(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP POST requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.post(function, opts=opts)
        +
        +        return decorator
        +
        +    def delete(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP DELETE requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.delete(function, opts=opts)
        +
        +        return decorator
        +
        +    def options(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP OPTIONS requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.options(function, opts=opts)
        +
        +        return decorator
        +
        +    def patch(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PATCH requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.patch(function, opts=opts)
        +
        +        return decorator
        +
        +    def put(self, match: str, opts: MethodOptions = None):
        +        """Define an HTTP route which will respond to HTTP PUT requests."""
        +        if opts is None:
        +            opts = MethodOptions()
        +
        +        def decorator(function: HttpMiddleware):
        +            r = self._route(match)
        +            r.put(function, opts=opts)
        +
        +        return decorator
        +
        +    async def _details(self) -> ApiDetails:
        +        """Get the API deployment details."""
        +        try:
        +            res = await self._resources_stub.details(
        +                resource_details_request=ResourceDetailsRequest(
        +                    resource=_to_resource(self),
        +                )
        +            )
        +            return ApiDetails(res.id, res.provider, res.service, res.api.url)
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    async def URL(self) -> str:
        +        """Get the APIs live URL."""
        +        details = await self._details()
        +        return details.url
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var appNitric
        +
        +
        +
        +
        var middleware : List[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]]]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        var routes : List[Route]
        +
        +
        +
        +
        var security : dict[str, typing.List[str]]
        +
        +
        +
        +
        var security_definitions : dict[str, JwtSecurityDefinition]
        +
        +
        +
        +
        +

        Methods

        +
        +
        +async def URL(self) ‑> str +
        +
        +

        Get the APIs live URL.

        +
        + +Expand source code + +
        async def URL(self) -> str:
        +    """Get the APIs live URL."""
        +    details = await self._details()
        +    return details.url
        +
        +
        +
        +def all(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def all(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.method(
        +            [
        +                HttpMethod.GET,
        +                HttpMethod.POST,
        +                HttpMethod.PATCH,
        +                HttpMethod.PUT,
        +                HttpMethod.DELETE,
        +                HttpMethod.OPTIONS,
        +            ],
        +            function,
        +            opts=opts,
        +        )
        +
        +    return decorator
        +
        +
        +
        +def delete(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP DELETE requests.

        +
        + +Expand source code + +
        def delete(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP DELETE requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.delete(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def get(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def get(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.get(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP GET requests.

        +
        + +Expand source code + +
        def methods(self, methods: List[HttpMethod], match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP GET requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.method(methods, function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def options(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP OPTIONS requests.

        +
        + +Expand source code + +
        def options(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP OPTIONS requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.options(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def patch(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP PATCH requests.

        +
        + +Expand source code + +
        def patch(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP PATCH requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.patch(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def post(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP POST requests.

        +
        + +Expand source code + +
        def post(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP POST requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.post(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +def put(self, match: str, opts: MethodOptions = None) +
        +
        +

        Define an HTTP route which will respond to HTTP PUT requests.

        +
        + +Expand source code + +
        def put(self, match: str, opts: MethodOptions = None):
        +    """Define an HTTP route which will respond to HTTP PUT requests."""
        +    if opts is None:
        +        opts = MethodOptions()
        +
        +    def decorator(function: HttpMiddleware):
        +        r = self._route(match)
        +        r.put(function, opts=opts)
        +
        +    return decorator
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class ApiDetails +(id: str, provider: str, service: str, url: str) +
        +
        +

        Represents the APIs deployment details.

        +
        + +Expand source code + +
        @dataclass
        +class ApiDetails:
        +    """Represents the APIs deployment details."""
        +
        +    # the identifier of the resource
        +    id: str
        +    # The provider this resource is deployed with (e.g. aws)
        +    provider: str
        +    # The service this resource is deployed on (e.g. ApiGateway)
        +    service: str
        +    # The url of the API
        +    url: str
        +
        +

        Class variables

        +
        +
        var id : str
        +
        +
        +
        +
        var provider : str
        +
        +
        +
        +
        var service : str
        +
        +
        +
        +
        var url : str
        +
        +
        +
        +
        +
        +
        +class ApiOptions +(path: str = '', middleware: List[Middleware] = [], security_definitions: dict[str, SecurityDefinition] = None, security: dict[str, List[str]] = None) +
        +
        +

        Represents options when creating an API, such as middleware to be applied to all HTTP request to the API.

        +

        Construct a new API options object.

        +
        + +Expand source code + +
        class ApiOptions:
        +    """Represents options when creating an API, such as middleware to be applied to all HTTP request to the API."""
        +
        +    path: str
        +    middleware: Union[HttpMiddleware, List[HttpMiddleware], None]
        +    security_definitions: Union[dict[str, SecurityDefinition], None]
        +    security: Union[dict[str, List[str]], None]
        +
        +    def __init__(
        +        self,
        +        path: str = "",
        +        middleware: List[Middleware] = [],
        +        security_definitions: dict[str, SecurityDefinition] = None,
        +        security: dict[str, List[str]] = None,
        +    ):
        +        """Construct a new API options object."""
        +        self.middleware = middleware
        +        self.security_definitions = security_definitions
        +        self.security = security
        +        self.path = path
        +
        +

        Class variables

        +
        +
        var middleware : Union[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]], List[Callable[[HttpContext, Coroutine[Any, Any, Optional[HttpContext]]], Coroutine[Any, Any, Optional[HttpContext]]]], NoneType]
        +
        +
        +
        +
        var path : str
        +
        +
        +
        +
        var security : Optional[dict[str, List[str]]]
        +
        +
        +
        +
        var security_definitions : Optional[dict[str, JwtSecurityDefinition]]
        +
        +
        +
        +
        +
        +
        +class Bucket +(name: str) +
        +
        +

        A bucket resource, used for storage and retrieval of blob/binary data.

        +

        Create a bucket with the name provided or references it if it already exists.

        +
        + +Expand source code + +
        class Bucket(SecureResource):
        +    """A bucket resource, used for storage and retrieval of blob/binary data."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Create a bucket with the name provided or references it if it already exists."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: [Union[BucketPermission, str]]) -> List[Action]:
        +        permission_actions_map = {
        +            BucketPermission.reading: [Action.BucketFileGet, Action.BucketFileList],
        +            BucketPermission.writing: [Action.BucketFilePut],
        +            BucketPermission.deleting: [Action.BucketFileDelete],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, BucketPermission) else BucketPermission[permission.lower()]
        +            for permission in args
        +        ]
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Bucket)
        +
        +    def allow(self, *args: Union[BucketPermission, str]) -> BucketRef:
        +        """Request the required permissions for this resource."""
        +        self._register_policy(*args)
        +
        +        return Storage().bucket(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[BucketPermission, str]) ‑> BucketRef +
        +
        +

        Request the required permissions for this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[BucketPermission, str]) -> BucketRef:
        +    """Request the required permissions for this resource."""
        +    self._register_policy(*args)
        +
        +    return Storage().bucket(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class Collection +(name: str) +
        +
        +

        A document collection resource.

        +

        Construct a new document collection.

        +
        + +Expand source code + +
        class Collection(SecureResource):
        +    """A document collection resource."""
        +
        +    def __init__(self, name: str):
        +        """Construct a new document collection."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Collection)
        +
        +    def _perms_to_actions(self, *args: Union[CollectionPermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            CollectionPermission.reading: [
        +                Action.CollectionDocumentRead,
        +                Action.CollectionQuery,
        +                Action.CollectionList,
        +            ],
        +            CollectionPermission.writing: [Action.CollectionDocumentWrite, Action.CollectionList],
        +            CollectionPermission.deleting: [Action.CollectionDocumentDelete, Action.CollectionList],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, CollectionPermission) else CollectionPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    def allow(self, *args: Union[CollectionPermission, str]) -> CollectionRef:
        +        """Request the required permissions for this collection."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Documents().collection(self.name)
        +
        +

        Ancestors

        + +

        Methods

        +
        +
        +def allow(self, *args: Union[CollectionPermission, str]) ‑> CollectionRef +
        +
        +

        Request the required permissions for this collection.

        +
        + +Expand source code + +
        def allow(self, *args: Union[CollectionPermission, str]) -> CollectionRef:
        +    """Request the required permissions for this collection."""
        +    # Ensure registration of the resource is complete before requesting permissions.
        +    self._register_policy(*args)
        +
        +    return Documents().collection(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class JwtSecurityDefinition +(issuer: str, audiences: List[str]) +
        +
        +

        Represents the JWT security definition for an API.

        +
        + +Expand source code + +
        @dataclass
        +class JwtSecurityDefinition:
        +    """Represents the JWT security definition for an API."""
        +
        +    issuer: str
        +    audiences: List[str]
        +
        +

        Class variables

        +
        +
        var audiences : List[str]
        +
        +
        +
        +
        var issuer : str
        +
        +
        +
        +
        +
        +
        +class MethodOptions +(security: dict[str, List[str]] = None) +
        +
        +

        Represents options when defining a method handler.

        +

        Construct a new HTTP method options object.

        +
        + +Expand source code + +
        class MethodOptions:
        +    """Represents options when defining a method handler."""
        +
        +    security: dict[str, List[str]]
        +
        +    def __init__(self, security: dict[str, List[str]] = None):
        +        """Construct a new HTTP method options object."""
        +        self.security = security
        +
        +

        Class variables

        +
        +
        var security : dict[str, typing.List[str]]
        +
        +
        +
        +
        +
        +
        +class Queue +(name: str) +
        +
        +

        A queue resource.

        +

        Construct a new queue resource.

        +
        + +Expand source code + +
        class Queue(SecureResource):
        +    """A queue resource."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new queue resource."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Queue)
        +
        +    def _perms_to_actions(self, *args: Union[QueuePermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            QueuePermission.sending: [Action.QueueSend, Action.QueueList, Action.QueueDetail],
        +            QueuePermission.receiving: [Action.QueueReceive, Action.QueueList, Action.QueueDetail],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, QueuePermission) else QueuePermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def allow(self, *args: Union[QueuePermission, str]) -> QueueRef:
        +        """Request the required permissions for this queue."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Queues().queue(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[QueuePermission, str]) ‑> QueueRef +
        +
        +

        Request the required permissions for this queue.

        +
        + +Expand source code + +
        def allow(self, *args: Union[QueuePermission, str]) -> QueueRef:
        +    """Request the required permissions for this queue."""
        +    # Ensure registration of the resource is complete before requesting permissions.
        +    self._register_policy(*args)
        +
        +    return Queues().queue(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class Schedule +(description: str) +
        +
        +

        A schedule for running functions on a cadence.

        +

        Construct a new schedule.

        +
        + +Expand source code + +
        class Schedule:
        +    """A schedule for running functions on a cadence."""
        +
        +    description: str
        +    server: FunctionServer
        +
        +    def start(self):
        +        """Start the function server that executes the scheduled middleware."""
        +        return self.server.start()
        +
        +    def __init__(self, description: str):
        +        """Construct a new schedule."""
        +        self.description = description
        +
        +    def every(self, rate_description: str, *middleware: EventMiddleware):
        +        """
        +        Register middleware to be run at the specified rate.
        +
        +        E.g. every("3 hours")
        +        """
        +        rate_description = rate_description.lower()
        +
        +        if not any([frequency in rate_description for frequency in Frequency.as_str_list()]):
        +            # handle singular frequencies. e.g. every('day')
        +            rate_description = f"1 {rate_description}s"  # 'day' becomes '1 days'
        +
        +        rate, freq_str = rate_description.split(" ")
        +        freq = Frequency.from_str(freq_str)
        +
        +        if not rate.isdigit():
        +            raise Exception("invalid rate expression, expression must begin with a positive integer")
        +
        +        if not freq:
        +            raise Exception(
        +                f"invalid rate expression, frequency must be one of ${Frequency.as_str_list()}, received ${freq_str}"
        +            )
        +
        +        opts = RateWorkerOptions(self.description, int(rate), freq)
        +
        +        self.server = FunctionServer(opts)
        +        self.server.event(*middleware)
        +        return Nitric._register_worker(self.server)
        +
        +

        Class variables

        +
        +
        var description : str
        +
        +
        +
        +
        var serverFunctionServer
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def every(self, rate_description: str, *middleware: EventMiddleware) +
        +
        +

        Register middleware to be run at the specified rate.

        +

        E.g. every("3 hours")

        +
        + +Expand source code + +
        def every(self, rate_description: str, *middleware: EventMiddleware):
        +    """
        +    Register middleware to be run at the specified rate.
        +
        +    E.g. every("3 hours")
        +    """
        +    rate_description = rate_description.lower()
        +
        +    if not any([frequency in rate_description for frequency in Frequency.as_str_list()]):
        +        # handle singular frequencies. e.g. every('day')
        +        rate_description = f"1 {rate_description}s"  # 'day' becomes '1 days'
        +
        +    rate, freq_str = rate_description.split(" ")
        +    freq = Frequency.from_str(freq_str)
        +
        +    if not rate.isdigit():
        +        raise Exception("invalid rate expression, expression must begin with a positive integer")
        +
        +    if not freq:
        +        raise Exception(
        +            f"invalid rate expression, frequency must be one of ${Frequency.as_str_list()}, received ${freq_str}"
        +        )
        +
        +    opts = RateWorkerOptions(self.description, int(rate), freq)
        +
        +    self.server = FunctionServer(opts)
        +    self.server.event(*middleware)
        +    return Nitric._register_worker(self.server)
        +
        +
        +
        +def start(self) +
        +
        +

        Start the function server that executes the scheduled middleware.

        +
        + +Expand source code + +
        def start(self):
        +    """Start the function server that executes the scheduled middleware."""
        +    return self.server.start()
        +
        +
        +
        +
        +
        +class Secret +(name: str) +
        +
        +

        A secret resource, used for storing and retrieving secret versions and values.

        +

        Construct a new secret resource reference.

        +
        + +Expand source code + +
        class Secret(SecureResource):
        +    """A secret resource, used for storing and retrieving secret versions and values."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new secret resource reference."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Secret)
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: Union[SecretPermission, str]) -> List[Action]:
        +        permissions_actions_map = {
        +            SecretPermission.accessing: [Action.SecretAccess],
        +            SecretPermission.putting: [Action.SecretPut],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, SecretPermission) else SecretPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permissions_actions_map[perm]]
        +
        +    def allow(self, *args: Union[SecretPermission, str]) -> SecretContainerRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Secrets().secret(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[SecretPermission, str]) ‑> SecretContainerRef +
        +
        +

        Request the specified permissions to this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[SecretPermission, str]) -> SecretContainerRef:
        +    """Request the specified permissions to this resource."""
        +    self._register_policy(*args)
        +
        +    return Secrets().secret(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class Topic +(name: str) +
        +
        +

        A topic resource, used for asynchronous messaging between functions.

        +

        Construct a new topic.

        +
        + +Expand source code + +
        class Topic(SecureResource):
        +    """A topic resource, used for asynchronous messaging between functions."""
        +
        +    name: str
        +    actions: List[Action]
        +    server: FunctionServer
        +
        +    def __init__(self, name: str):
        +        """Construct a new topic."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Topic)
        +
        +    def _perms_to_actions(self, *args: Union[TopicPermission, str]) -> List[Action]:
        +        _permMap = {TopicPermission.publishing: [Action.TopicEventPublish]}
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, TopicPermission) else TopicPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in _permMap[perm]]
        +
        +    def allow(self, *args: Union[TopicPermission, str]) -> TopicRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Events().topic(self.name)
        +
        +    def subscribe(self, func: EventMiddleware):
        +        """Create and return a subscription decorator for this topic."""
        +        self.server = FunctionServer(SubscriptionWorkerOptions(topic=self.name))
        +        self.server.event(func)
        +        Nitric._register_worker(self.server)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        var serverFunctionServer
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[TopicPermission, str]) ‑> TopicRef +
        +
        +

        Request the specified permissions to this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[TopicPermission, str]) -> TopicRef:
        +    """Request the specified permissions to this resource."""
        +    self._register_policy(*args)
        +
        +    return Events().topic(self.name)
        +
        +
        +
        +def subscribe(self, func: EventMiddleware) +
        +
        +

        Create and return a subscription decorator for this topic.

        +
        + +Expand source code + +
        def subscribe(self, func: EventMiddleware):
        +    """Create and return a subscription decorator for this topic."""
        +    self.server = FunctionServer(SubscriptionWorkerOptions(topic=self.name))
        +    self.server.event(func)
        +    Nitric._register_worker(self.server)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/queues.html b/docs/nitric/resources/queues.html new file mode 100644 index 0000000..46d7c00 --- /dev/null +++ b/docs/nitric/resources/queues.html @@ -0,0 +1,331 @@ + + + + + + +nitric.resources.queues API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.queues

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +from nitric.api.exception import exception_from_grpc_error
        +from typing import List, Union
        +from enum import Enum
        +from grpclib import GRPCError
        +from nitric.api.queues import QueueRef, Queues
        +from nitric.application import Nitric
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    Action,
        +    ResourceDeclareRequest,
        +)
        +
        +from nitric.resources.base import SecureResource
        +
        +
        +class QueuePermission(Enum):
        +    """Valid query expression operators."""
        +
        +    sending = "sending"
        +    receiving = "receiving"
        +
        +
        +class Queue(SecureResource):
        +    """A queue resource."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new queue resource."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Queue)
        +
        +    def _perms_to_actions(self, *args: Union[QueuePermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            QueuePermission.sending: [Action.QueueSend, Action.QueueList, Action.QueueDetail],
        +            QueuePermission.receiving: [Action.QueueReceive, Action.QueueList, Action.QueueDetail],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, QueuePermission) else QueuePermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def allow(self, *args: Union[QueuePermission, str]) -> QueueRef:
        +        """Request the required permissions for this queue."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Queues().queue(self.name)
        +
        +
        +def queue(name: str) -> Queue:
        +    """
        +    Create and register a queue.
        +
        +    If a queue has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Queue, name)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def queue(name: str) ‑> Queue +
        +
        +

        Create and register a queue.

        +

        If a queue has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def queue(name: str) -> Queue:
        +    """
        +    Create and register a queue.
        +
        +    If a queue has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Queue, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Queue +(name: str) +
        +
        +

        A queue resource.

        +

        Construct a new queue resource.

        +
        + +Expand source code + +
        class Queue(SecureResource):
        +    """A queue resource."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new queue resource."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Queue)
        +
        +    def _perms_to_actions(self, *args: Union[QueuePermission, str]) -> List[Action]:
        +        permission_actions_map = {
        +            QueuePermission.sending: [Action.QueueSend, Action.QueueList, Action.QueueDetail],
        +            QueuePermission.receiving: [Action.QueueReceive, Action.QueueList, Action.QueueDetail],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, QueuePermission) else QueuePermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permission_actions_map[perm]]
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def allow(self, *args: Union[QueuePermission, str]) -> QueueRef:
        +        """Request the required permissions for this queue."""
        +        # Ensure registration of the resource is complete before requesting permissions.
        +        self._register_policy(*args)
        +
        +        return Queues().queue(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[QueuePermission, str]) ‑> QueueRef +
        +
        +

        Request the required permissions for this queue.

        +
        + +Expand source code + +
        def allow(self, *args: Union[QueuePermission, str]) -> QueueRef:
        +    """Request the required permissions for this queue."""
        +    # Ensure registration of the resource is complete before requesting permissions.
        +    self._register_policy(*args)
        +
        +    return Queues().queue(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class QueuePermission +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Valid query expression operators.

        +
        + +Expand source code + +
        class QueuePermission(Enum):
        +    """Valid query expression operators."""
        +
        +    sending = "sending"
        +    receiving = "receiving"
        +
        +

        Ancestors

        +
          +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var receiving
        +
        +
        +
        +
        var sending
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/schedules.html b/docs/nitric/resources/schedules.html new file mode 100644 index 0000000..6337e09 --- /dev/null +++ b/docs/nitric/resources/schedules.html @@ -0,0 +1,301 @@ + + + + + + +nitric.resources.schedules API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.schedules

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +from nitric.application import Nitric
        +from nitric.faas import FunctionServer, EventMiddleware, RateWorkerOptions, Frequency
        +
        +
        +class Schedule:
        +    """A schedule for running functions on a cadence."""
        +
        +    description: str
        +    server: FunctionServer
        +
        +    def start(self):
        +        """Start the function server that executes the scheduled middleware."""
        +        return self.server.start()
        +
        +    def __init__(self, description: str):
        +        """Construct a new schedule."""
        +        self.description = description
        +
        +    def every(self, rate_description: str, *middleware: EventMiddleware):
        +        """
        +        Register middleware to be run at the specified rate.
        +
        +        E.g. every("3 hours")
        +        """
        +        rate_description = rate_description.lower()
        +
        +        if not any([frequency in rate_description for frequency in Frequency.as_str_list()]):
        +            # handle singular frequencies. e.g. every('day')
        +            rate_description = f"1 {rate_description}s"  # 'day' becomes '1 days'
        +
        +        rate, freq_str = rate_description.split(" ")
        +        freq = Frequency.from_str(freq_str)
        +
        +        if not rate.isdigit():
        +            raise Exception("invalid rate expression, expression must begin with a positive integer")
        +
        +        if not freq:
        +            raise Exception(
        +                f"invalid rate expression, frequency must be one of ${Frequency.as_str_list()}, received ${freq_str}"
        +            )
        +
        +        opts = RateWorkerOptions(self.description, int(rate), freq)
        +
        +        self.server = FunctionServer(opts)
        +        self.server.event(*middleware)
        +        return Nitric._register_worker(self.server)
        +
        +
        +def schedule(description: str, every: str):
        +    """Return a schedule decorator."""
        +
        +    def decorator(func: EventMiddleware):
        +        r = Schedule(description)
        +        r.every(every, func)
        +        return r
        +
        +    return decorator
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def schedule(description: str, every: str) +
        +
        +

        Return a schedule decorator.

        +
        + +Expand source code + +
        def schedule(description: str, every: str):
        +    """Return a schedule decorator."""
        +
        +    def decorator(func: EventMiddleware):
        +        r = Schedule(description)
        +        r.every(every, func)
        +        return r
        +
        +    return decorator
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Schedule +(description: str) +
        +
        +

        A schedule for running functions on a cadence.

        +

        Construct a new schedule.

        +
        + +Expand source code + +
        class Schedule:
        +    """A schedule for running functions on a cadence."""
        +
        +    description: str
        +    server: FunctionServer
        +
        +    def start(self):
        +        """Start the function server that executes the scheduled middleware."""
        +        return self.server.start()
        +
        +    def __init__(self, description: str):
        +        """Construct a new schedule."""
        +        self.description = description
        +
        +    def every(self, rate_description: str, *middleware: EventMiddleware):
        +        """
        +        Register middleware to be run at the specified rate.
        +
        +        E.g. every("3 hours")
        +        """
        +        rate_description = rate_description.lower()
        +
        +        if not any([frequency in rate_description for frequency in Frequency.as_str_list()]):
        +            # handle singular frequencies. e.g. every('day')
        +            rate_description = f"1 {rate_description}s"  # 'day' becomes '1 days'
        +
        +        rate, freq_str = rate_description.split(" ")
        +        freq = Frequency.from_str(freq_str)
        +
        +        if not rate.isdigit():
        +            raise Exception("invalid rate expression, expression must begin with a positive integer")
        +
        +        if not freq:
        +            raise Exception(
        +                f"invalid rate expression, frequency must be one of ${Frequency.as_str_list()}, received ${freq_str}"
        +            )
        +
        +        opts = RateWorkerOptions(self.description, int(rate), freq)
        +
        +        self.server = FunctionServer(opts)
        +        self.server.event(*middleware)
        +        return Nitric._register_worker(self.server)
        +
        +

        Class variables

        +
        +
        var description : str
        +
        +
        +
        +
        var serverFunctionServer
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def every(self, rate_description: str, *middleware: EventMiddleware) +
        +
        +

        Register middleware to be run at the specified rate.

        +

        E.g. every("3 hours")

        +
        + +Expand source code + +
        def every(self, rate_description: str, *middleware: EventMiddleware):
        +    """
        +    Register middleware to be run at the specified rate.
        +
        +    E.g. every("3 hours")
        +    """
        +    rate_description = rate_description.lower()
        +
        +    if not any([frequency in rate_description for frequency in Frequency.as_str_list()]):
        +        # handle singular frequencies. e.g. every('day')
        +        rate_description = f"1 {rate_description}s"  # 'day' becomes '1 days'
        +
        +    rate, freq_str = rate_description.split(" ")
        +    freq = Frequency.from_str(freq_str)
        +
        +    if not rate.isdigit():
        +        raise Exception("invalid rate expression, expression must begin with a positive integer")
        +
        +    if not freq:
        +        raise Exception(
        +            f"invalid rate expression, frequency must be one of ${Frequency.as_str_list()}, received ${freq_str}"
        +        )
        +
        +    opts = RateWorkerOptions(self.description, int(rate), freq)
        +
        +    self.server = FunctionServer(opts)
        +    self.server.event(*middleware)
        +    return Nitric._register_worker(self.server)
        +
        +
        +
        +def start(self) +
        +
        +

        Start the function server that executes the scheduled middleware.

        +
        + +Expand source code + +
        def start(self):
        +    """Start the function server that executes the scheduled middleware."""
        +    return self.server.start()
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/secrets.html b/docs/nitric/resources/secrets.html new file mode 100644 index 0000000..998fb5a --- /dev/null +++ b/docs/nitric/resources/secrets.html @@ -0,0 +1,330 @@ + + + + + + +nitric.resources.secrets API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.secrets

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +from nitric.api.exception import exception_from_grpc_error
        +from typing import List, Union
        +from enum import Enum
        +from grpclib import GRPCError
        +
        +from nitric.application import Nitric
        +from nitric.api.secrets import Secrets, SecretContainerRef
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    Action,
        +    ResourceDeclareRequest,
        +)
        +
        +from nitric.resources.base import SecureResource
        +
        +
        +class SecretPermission(Enum):
        +    """Available permissions that can be requested for secret resources."""
        +
        +    accessing = "accessing"
        +    putting = "putting"
        +
        +
        +class Secret(SecureResource):
        +    """A secret resource, used for storing and retrieving secret versions and values."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new secret resource reference."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Secret)
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: Union[SecretPermission, str]) -> List[Action]:
        +        permissions_actions_map = {
        +            SecretPermission.accessing: [Action.SecretAccess],
        +            SecretPermission.putting: [Action.SecretPut],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, SecretPermission) else SecretPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permissions_actions_map[perm]]
        +
        +    def allow(self, *args: Union[SecretPermission, str]) -> SecretContainerRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Secrets().secret(self.name)
        +
        +
        +#
        +def secret(name: str) -> Secret:
        +    """
        +    Create and registers a secret.
        +
        +    If a secret has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Secret, name)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def secret(name: str) ‑> Secret +
        +
        +

        Create and registers a secret.

        +

        If a secret has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def secret(name: str) -> Secret:
        +    """
        +    Create and registers a secret.
        +
        +    If a secret has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Secret, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Secret +(name: str) +
        +
        +

        A secret resource, used for storing and retrieving secret versions and values.

        +

        Construct a new secret resource reference.

        +
        + +Expand source code + +
        class Secret(SecureResource):
        +    """A secret resource, used for storing and retrieving secret versions and values."""
        +
        +    name: str
        +    actions: List[Action]
        +
        +    def __init__(self, name: str):
        +        """Construct a new secret resource reference."""
        +        super().__init__()
        +        self.name = name
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Secret)
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _perms_to_actions(self, *args: Union[SecretPermission, str]) -> List[Action]:
        +        permissions_actions_map = {
        +            SecretPermission.accessing: [Action.SecretAccess],
        +            SecretPermission.putting: [Action.SecretPut],
        +        }
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, SecretPermission) else SecretPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in permissions_actions_map[perm]]
        +
        +    def allow(self, *args: Union[SecretPermission, str]) -> SecretContainerRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Secrets().secret(self.name)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[SecretPermission, str]) ‑> SecretContainerRef +
        +
        +

        Request the specified permissions to this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[SecretPermission, str]) -> SecretContainerRef:
        +    """Request the specified permissions to this resource."""
        +    self._register_policy(*args)
        +
        +    return Secrets().secret(self.name)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class SecretPermission +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Available permissions that can be requested for secret resources.

        +
        + +Expand source code + +
        class SecretPermission(Enum):
        +    """Available permissions that can be requested for secret resources."""
        +
        +    accessing = "accessing"
        +    putting = "putting"
        +
        +

        Ancestors

        +
          +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var accessing
        +
        +
        +
        +
        var putting
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/resources/topics.html b/docs/nitric/resources/topics.html new file mode 100644 index 0000000..05fb81a --- /dev/null +++ b/docs/nitric/resources/topics.html @@ -0,0 +1,352 @@ + + + + + + +nitric.resources.topics API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.resources.topics

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +from __future__ import annotations
        +
        +from nitric.api.events import Events, TopicRef
        +from nitric.api.exception import exception_from_grpc_error
        +from typing import List, Union
        +from enum import Enum
        +from grpclib import GRPCError
        +from nitric.application import Nitric
        +from nitric.faas import EventMiddleware, FunctionServer, SubscriptionWorkerOptions
        +from nitric.proto.nitric.resource.v1 import (
        +    Resource,
        +    ResourceType,
        +    Action,
        +    ResourceDeclareRequest,
        +)
        +
        +from nitric.resources.base import SecureResource
        +
        +
        +class TopicPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    publishing = "publishing"
        +
        +
        +class Topic(SecureResource):
        +    """A topic resource, used for asynchronous messaging between functions."""
        +
        +    name: str
        +    actions: List[Action]
        +    server: FunctionServer
        +
        +    def __init__(self, name: str):
        +        """Construct a new topic."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Topic)
        +
        +    def _perms_to_actions(self, *args: Union[TopicPermission, str]) -> List[Action]:
        +        _permMap = {TopicPermission.publishing: [Action.TopicEventPublish]}
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, TopicPermission) else TopicPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in _permMap[perm]]
        +
        +    def allow(self, *args: Union[TopicPermission, str]) -> TopicRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Events().topic(self.name)
        +
        +    def subscribe(self, func: EventMiddleware):
        +        """Create and return a subscription decorator for this topic."""
        +        self.server = FunctionServer(SubscriptionWorkerOptions(topic=self.name))
        +        self.server.event(func)
        +        Nitric._register_worker(self.server)
        +
        +
        +def topic(name: str) -> Topic:
        +    """
        +    Create and register a topic.
        +
        +    If a topic has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Topic, name)
        +
        +
        +
        +
        +
        +
        +
        +

        Functions

        +
        +
        +def topic(name: str) ‑> Topic +
        +
        +

        Create and register a topic.

        +

        If a topic has already been registered with the same name, the original reference will be reused.

        +
        + +Expand source code + +
        def topic(name: str) -> Topic:
        +    """
        +    Create and register a topic.
        +
        +    If a topic has already been registered with the same name, the original reference will be reused.
        +    """
        +    return Nitric._create_resource(Topic, name)
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Topic +(name: str) +
        +
        +

        A topic resource, used for asynchronous messaging between functions.

        +

        Construct a new topic.

        +
        + +Expand source code + +
        class Topic(SecureResource):
        +    """A topic resource, used for asynchronous messaging between functions."""
        +
        +    name: str
        +    actions: List[Action]
        +    server: FunctionServer
        +
        +    def __init__(self, name: str):
        +        """Construct a new topic."""
        +        super().__init__()
        +        self.name = name
        +
        +    async def _register(self):
        +        try:
        +            await self._resources_stub.declare(
        +                resource_declare_request=ResourceDeclareRequest(resource=self._to_resource())
        +            )
        +        except GRPCError as grpc_err:
        +            raise exception_from_grpc_error(grpc_err)
        +
        +    def _to_resource(self) -> Resource:
        +        return Resource(name=self.name, type=ResourceType.Topic)
        +
        +    def _perms_to_actions(self, *args: Union[TopicPermission, str]) -> List[Action]:
        +        _permMap = {TopicPermission.publishing: [Action.TopicEventPublish]}
        +        # convert strings to the enum value where needed
        +        perms = [
        +            permission if isinstance(permission, TopicPermission) else TopicPermission[permission.lower()]
        +            for permission in args
        +        ]
        +
        +        return [action for perm in perms for action in _permMap[perm]]
        +
        +    def allow(self, *args: Union[TopicPermission, str]) -> TopicRef:
        +        """Request the specified permissions to this resource."""
        +        self._register_policy(*args)
        +
        +        return Events().topic(self.name)
        +
        +    def subscribe(self, func: EventMiddleware):
        +        """Create and return a subscription decorator for this topic."""
        +        self.server = FunctionServer(SubscriptionWorkerOptions(topic=self.name))
        +        self.server.event(func)
        +        Nitric._register_worker(self.server)
        +
        +

        Ancestors

        + +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        var serverFunctionServer
        +
        +
        +
        +
        +

        Methods

        +
        +
        +def allow(self, *args: Union[TopicPermission, str]) ‑> TopicRef +
        +
        +

        Request the specified permissions to this resource.

        +
        + +Expand source code + +
        def allow(self, *args: Union[TopicPermission, str]) -> TopicRef:
        +    """Request the specified permissions to this resource."""
        +    self._register_policy(*args)
        +
        +    return Events().topic(self.name)
        +
        +
        +
        +def subscribe(self, func: EventMiddleware) +
        +
        +

        Create and return a subscription decorator for this topic.

        +
        + +Expand source code + +
        def subscribe(self, func: EventMiddleware):
        +    """Create and return a subscription decorator for this topic."""
        +    self.server = FunctionServer(SubscriptionWorkerOptions(topic=self.name))
        +    self.server.event(func)
        +    Nitric._register_worker(self.server)
        +
        +
        +
        +

        Inherited members

        + +
        +
        +class TopicPermission +(value, names=None, *, module=None, qualname=None, type=None, start=1) +
        +
        +

        Valid query expression operators.

        +
        + +Expand source code + +
        class TopicPermission(Enum):
        +    """Valid query expression operators."""
        +
        +    publishing = "publishing"
        +
        +

        Ancestors

        +
          +
        • enum.Enum
        • +
        +

        Class variables

        +
        +
        var publishing
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/nitric/application.py b/nitric/application.py index 617ea56..ee42a0d 100644 --- a/nitric/application.py +++ b/nitric/application.py @@ -1,4 +1,30 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import asyncio +import os + +from opentelemetry import trace +from opentelemetry.sdk.trace import TracerProvider, sampling +from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter +from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter +from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient + from nitric.faas import FunctionServer from nitric.api.exception import NitricUnavailableException @@ -40,6 +66,27 @@ def _create_resource(cls, resource: Type[BT], name: str, *args, **kwargs) -> BT: 'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"' ) + @classmethod + def _create_tracer(cls) -> TracerProvider: + local_run = os.environ.OTELCOL_BIN is not None + samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT + + # If its a local run use a console exporter, otherwise export using OTEL Protocol + exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) + if local_run: + exporter = ConsoleSpanExporter() + + provider = TracerProvider( + active_span_processor=BatchSpanProcessor(exporter), + sampler=sampling.TraceIdRatioBased(samplePercent / 100 if samplePercent is not None else 100), + ) + trace.set_tracer_provider(provider) + + grpc_client_instrumentor = GrpcInstrumentorClient() + grpc_client_instrumentor.instrument() + + return provider + @classmethod def run(cls): """ @@ -47,6 +94,7 @@ def run(cls): This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ + provider = cls._create_tracer() try: try: loop = asyncio.get_running_loop() @@ -60,3 +108,6 @@ def run(cls): raise NitricUnavailableException( 'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"' ) + finally: + if provider is not None: + provider.force_flush() diff --git a/nitric/faas.py b/nitric/faas.py index 6d1c34b..dec8528 100644 --- a/nitric/faas.py +++ b/nitric/faas.py @@ -23,6 +23,7 @@ import json import traceback from typing import Dict, Union, List, TypeVar, Callable, Coroutine, Any, Optional +from opentelemetry import context, propagate import betterproto from betterproto.grpc.util.async_channel import AsyncChannel @@ -46,6 +47,7 @@ from abc import ABC Record = Dict[str, Union[str, List[str]]] +PROPAGATOR = propagate.get_global_textmap() class HttpMethod(Enum): @@ -134,7 +136,16 @@ def _grpc_response_from_ctx(ctx: TriggerContext) -> TriggerResponse: class HttpRequest(Request): """Represents a translated Http Request forwarded from the Nitric Membrane.""" - def __init__(self, data: bytes, method: str, path: str, params: Dict[str, str], query: Record, headers: Record): + def __init__( + self, + data: bytes, + method: str, + path: str, + params: Dict[str, str], + query: Record, + headers: Record, + trace_context: Dict[str, str], + ): """Construct a new HttpRequest.""" super().__init__(data) self.method = method @@ -142,6 +153,7 @@ def __init__(self, data: bytes, method: str, path: str, params: Dict[str, str], self.params = params self.query = query self.headers = headers + self.trace_context = trace_context @property def json(self) -> Optional[Any]: @@ -218,20 +230,19 @@ def from_grpc_trigger_request(trigger_request: TriggerRequest) -> HttpContext: path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, + trace_context=trigger_request.trace_context, ) ) -# ====== Events ====== - - class EventRequest(Request): """Represents a translated Event, from a Subscribed Topic, forwarded from the Nitric Membrane.""" - def __init__(self, data: bytes, topic: str): + def __init__(self, data: bytes, topic: str, trace_context: Dict[str, str]): """Construct a new EventRequest.""" super().__init__(data) self.topic = topic + self.trace_context = trace_context @property def payload(self) -> bytes: @@ -263,7 +274,13 @@ def event(self) -> EventContext: @staticmethod def from_grpc_trigger_request(trigger_request: TriggerRequest): """Construct a new EventContext from an Event trigger from the Nitric Membrane.""" - return EventContext(request=EventRequest(data=trigger_request.data, topic=trigger_request.topic.topic)) + return EventContext( + request=EventRequest( + data=trigger_request.data, + topic=trigger_request.topic.topic, + trace_context=trigger_request.trace_context, + ) + ) # async def face(inpp: int) -> str: @@ -487,12 +504,16 @@ async def _run(self): ctx = _ctx_from_grpc_trigger_request(srv_msg.trigger_request) try: + if len(ctx.req.trace_context) > 0: + context.attach(PROPAGATOR().extract(ctx.req.trace_context)) + if ctx.http(): func = self._http_handler elif ctx.event(): func = self._event_handler else: func = self._any_handler + response_ctx = (await func(ctx)) if asyncio.iscoroutinefunction(func) else func(ctx) if response_ctx is None: diff --git a/nitric/proto/__init__.py b/nitric/proto/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/__init__.py +++ b/nitric/proto/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/document/__init__.py b/nitric/proto/nitric/document/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/document/__init__.py +++ b/nitric/proto/nitric/document/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/document/v1/__init__.py b/nitric/proto/nitric/document/v1/__init__.py index 0321bc6..3b1cf26 100644 --- a/nitric/proto/nitric/document/v1/__init__.py +++ b/nitric/proto/nitric/document/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/document/v1/document.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/error/__init__.py b/nitric/proto/nitric/error/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/error/__init__.py +++ b/nitric/proto/nitric/error/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/error/v1/__init__.py b/nitric/proto/nitric/error/v1/__init__.py index 09e6ec8..71de5c7 100644 --- a/nitric/proto/nitric/error/v1/__init__.py +++ b/nitric/proto/nitric/error/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/error/v1/error.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/event/__init__.py b/nitric/proto/nitric/event/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/event/__init__.py +++ b/nitric/proto/nitric/event/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/event/v1/__init__.py b/nitric/proto/nitric/event/v1/__init__.py index cd16894..af1b5bb 100644 --- a/nitric/proto/nitric/event/v1/__init__.py +++ b/nitric/proto/nitric/event/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/event/v1/event.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/faas/__init__.py b/nitric/proto/nitric/faas/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/faas/__init__.py +++ b/nitric/proto/nitric/faas/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/faas/v1/__init__.py b/nitric/proto/nitric/faas/v1/__init__.py index fe43648..1c61931 100644 --- a/nitric/proto/nitric/faas/v1/__init__.py +++ b/nitric/proto/nitric/faas/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/faas/v1/faas.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/queue/__init__.py b/nitric/proto/nitric/queue/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/queue/__init__.py +++ b/nitric/proto/nitric/queue/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/queue/v1/__init__.py b/nitric/proto/nitric/queue/v1/__init__.py index 3ceb3e3..039d7f9 100644 --- a/nitric/proto/nitric/queue/v1/__init__.py +++ b/nitric/proto/nitric/queue/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/queue/v1/queue.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/resource/__init__.py b/nitric/proto/nitric/resource/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/resource/__init__.py +++ b/nitric/proto/nitric/resource/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/resource/v1/__init__.py b/nitric/proto/nitric/resource/v1/__init__.py index 8d62270..ed7e525 100644 --- a/nitric/proto/nitric/resource/v1/__init__.py +++ b/nitric/proto/nitric/resource/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/resource/v1/resource.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/secret/__init__.py b/nitric/proto/nitric/secret/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/secret/__init__.py +++ b/nitric/proto/nitric/secret/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/secret/v1/__init__.py b/nitric/proto/nitric/secret/v1/__init__.py index c369d3d..e5e0553 100644 --- a/nitric/proto/nitric/secret/v1/__init__.py +++ b/nitric/proto/nitric/secret/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/secret/v1/secret.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/storage/__init__.py b/nitric/proto/nitric/storage/__init__.py index e69de29..4eb07ea 100644 --- a/nitric/proto/nitric/storage/__init__.py +++ b/nitric/proto/nitric/storage/__init__.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/nitric/proto/nitric/storage/v1/__init__.py b/nitric/proto/nitric/storage/v1/__init__.py index 6e6130e..6d86f0a 100644 --- a/nitric/proto/nitric/storage/v1/__init__.py +++ b/nitric/proto/nitric/storage/v1/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/storage/v1/storage.proto # plugin: python-betterproto diff --git a/nitric/proto/validate/__init__.py b/nitric/proto/validate/__init__.py index 8b5dd42..685cbab 100644 --- a/nitric/proto/validate/__init__.py +++ b/nitric/proto/validate/__init__.py @@ -1,3 +1,22 @@ +# +# Copyright (c) 2021 Nitric Technologies Pty Ltd. +# +# This file is part of Nitric Python 3 SDK. +# See https://github.com/nitrictech/python-sdk for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: validate/validate.proto # plugin: python-betterproto diff --git a/setup.py b/setup.py index b32d73d..c06325f 100644 --- a/setup.py +++ b/setup.py @@ -42,10 +42,11 @@ def get_current_version_tag(): ], setup_requires=["wheel"], install_requires=[ - # "nitric-api==0.18.0", - "protobuf==3.19.5", - "betterproto==2.0.0b5", "asyncio", + "opentelemetry-api", + "opentelemetry-sdk", + "opentelemetry-exporter-otlp-proto-grpc", + "opentelemetry-instrumentation-grpc", ], extras_require={ "dev": [ From a28139916885e70c465a6962de9e8347d1532e47 Mon Sep 17 00:00:00 2001 From: Ryan Cartwright Date: Wed, 29 Mar 2023 12:11:18 +1100 Subject: [PATCH 2/4] generate sources --- nitric/proto/__init__.py | 18 ------------------ nitric/proto/nitric/document/__init__.py | 18 ------------------ nitric/proto/nitric/document/v1/__init__.py | 19 ------------------- nitric/proto/nitric/error/__init__.py | 18 ------------------ nitric/proto/nitric/error/v1/__init__.py | 19 ------------------- nitric/proto/nitric/event/__init__.py | 18 ------------------ nitric/proto/nitric/event/v1/__init__.py | 19 ------------------- nitric/proto/nitric/faas/__init__.py | 18 ------------------ nitric/proto/nitric/faas/v1/__init__.py | 19 ------------------- nitric/proto/nitric/queue/__init__.py | 18 ------------------ nitric/proto/nitric/queue/v1/__init__.py | 19 ------------------- nitric/proto/nitric/resource/__init__.py | 18 ------------------ nitric/proto/nitric/resource/v1/__init__.py | 19 ------------------- nitric/proto/nitric/secret/__init__.py | 18 ------------------ nitric/proto/nitric/secret/v1/__init__.py | 19 ------------------- nitric/proto/nitric/storage/__init__.py | 18 ------------------ nitric/proto/nitric/storage/v1/__init__.py | 19 ------------------- nitric/proto/validate/__init__.py | 19 ------------------- 18 files changed, 333 deletions(-) diff --git a/nitric/proto/__init__.py b/nitric/proto/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/__init__.py +++ b/nitric/proto/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/document/__init__.py b/nitric/proto/nitric/document/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/document/__init__.py +++ b/nitric/proto/nitric/document/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/document/v1/__init__.py b/nitric/proto/nitric/document/v1/__init__.py index 3b1cf26..0321bc6 100644 --- a/nitric/proto/nitric/document/v1/__init__.py +++ b/nitric/proto/nitric/document/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/document/v1/document.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/error/__init__.py b/nitric/proto/nitric/error/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/error/__init__.py +++ b/nitric/proto/nitric/error/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/error/v1/__init__.py b/nitric/proto/nitric/error/v1/__init__.py index 71de5c7..09e6ec8 100644 --- a/nitric/proto/nitric/error/v1/__init__.py +++ b/nitric/proto/nitric/error/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/error/v1/error.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/event/__init__.py b/nitric/proto/nitric/event/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/event/__init__.py +++ b/nitric/proto/nitric/event/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/event/v1/__init__.py b/nitric/proto/nitric/event/v1/__init__.py index af1b5bb..cd16894 100644 --- a/nitric/proto/nitric/event/v1/__init__.py +++ b/nitric/proto/nitric/event/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/event/v1/event.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/faas/__init__.py b/nitric/proto/nitric/faas/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/faas/__init__.py +++ b/nitric/proto/nitric/faas/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/faas/v1/__init__.py b/nitric/proto/nitric/faas/v1/__init__.py index 1c61931..fe43648 100644 --- a/nitric/proto/nitric/faas/v1/__init__.py +++ b/nitric/proto/nitric/faas/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/faas/v1/faas.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/queue/__init__.py b/nitric/proto/nitric/queue/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/queue/__init__.py +++ b/nitric/proto/nitric/queue/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/queue/v1/__init__.py b/nitric/proto/nitric/queue/v1/__init__.py index 039d7f9..3ceb3e3 100644 --- a/nitric/proto/nitric/queue/v1/__init__.py +++ b/nitric/proto/nitric/queue/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/queue/v1/queue.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/resource/__init__.py b/nitric/proto/nitric/resource/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/resource/__init__.py +++ b/nitric/proto/nitric/resource/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/resource/v1/__init__.py b/nitric/proto/nitric/resource/v1/__init__.py index ed7e525..8d62270 100644 --- a/nitric/proto/nitric/resource/v1/__init__.py +++ b/nitric/proto/nitric/resource/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/resource/v1/resource.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/secret/__init__.py b/nitric/proto/nitric/secret/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/secret/__init__.py +++ b/nitric/proto/nitric/secret/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/secret/v1/__init__.py b/nitric/proto/nitric/secret/v1/__init__.py index e5e0553..c369d3d 100644 --- a/nitric/proto/nitric/secret/v1/__init__.py +++ b/nitric/proto/nitric/secret/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/secret/v1/secret.proto # plugin: python-betterproto diff --git a/nitric/proto/nitric/storage/__init__.py b/nitric/proto/nitric/storage/__init__.py index 4eb07ea..e69de29 100644 --- a/nitric/proto/nitric/storage/__init__.py +++ b/nitric/proto/nitric/storage/__init__.py @@ -1,18 +0,0 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/nitric/proto/nitric/storage/v1/__init__.py b/nitric/proto/nitric/storage/v1/__init__.py index 6d86f0a..6e6130e 100644 --- a/nitric/proto/nitric/storage/v1/__init__.py +++ b/nitric/proto/nitric/storage/v1/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: proto/storage/v1/storage.proto # plugin: python-betterproto diff --git a/nitric/proto/validate/__init__.py b/nitric/proto/validate/__init__.py index 685cbab..8b5dd42 100644 --- a/nitric/proto/validate/__init__.py +++ b/nitric/proto/validate/__init__.py @@ -1,22 +1,3 @@ -# -# Copyright (c) 2021 Nitric Technologies Pty Ltd. -# -# This file is part of Nitric Python 3 SDK. -# See https://github.com/nitrictech/python-sdk for further info. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: validate/validate.proto # plugin: python-betterproto From d9077c3f1864f4aa1ac8631c09f074898f49ab9a Mon Sep 17 00:00:00 2001 From: Ryan Cartwright Date: Wed, 29 Mar 2023 14:56:02 +1100 Subject: [PATCH 3/4] update contracts --- makefile | 2 +- nitric/faas.py | 4 +- nitric/proto/nitric/deploy/__init__.py | 0 nitric/proto/nitric/deploy/v1/__init__.py | 323 ++++++++++++++++++++++ nitric/proto/nitric/faas/v1/__init__.py | 15 + 5 files changed, 341 insertions(+), 3 deletions(-) create mode 100644 nitric/proto/nitric/deploy/__init__.py create mode 100644 nitric/proto/nitric/deploy/v1/__init__.py diff --git a/makefile b/makefile index f99815d..0d00e05 100644 --- a/makefile +++ b/makefile @@ -16,7 +16,7 @@ clean: @rm -rf ./build @rm -rf ./dist -NITRIC_VERSION="v0.20.0-rc.2" +NITRIC_VERSION="v0.24.0-rc.7" download: @curl -L https://github.com/nitrictech/nitric/releases/download/${NITRIC_VERSION}/contracts.tgz -o contracts.tgz diff --git a/nitric/faas.py b/nitric/faas.py index dec8528..1c2c887 100644 --- a/nitric/faas.py +++ b/nitric/faas.py @@ -230,7 +230,7 @@ def from_grpc_trigger_request(trigger_request: TriggerRequest) -> HttpContext: path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -278,7 +278,7 @@ def from_grpc_trigger_request(trigger_request: TriggerRequest): request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) diff --git a/nitric/proto/nitric/deploy/__init__.py b/nitric/proto/nitric/deploy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nitric/proto/nitric/deploy/v1/__init__.py b/nitric/proto/nitric/deploy/v1/__init__.py new file mode 100644 index 0000000..5e252a2 --- /dev/null +++ b/nitric/proto/nitric/deploy/v1/__init__.py @@ -0,0 +1,323 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: proto/deploy/v1/deploy.proto +# plugin: python-betterproto +import warnings +from dataclasses import dataclass +from typing import ( + TYPE_CHECKING, + AsyncIterator, + Dict, + List, + Optional, +) + +import betterproto +import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf +import grpclib +from betterproto.grpc.grpclib_server import ServiceBase + +from ...resource import v1 as __resource_v1__ + + +if TYPE_CHECKING: + import grpclib.server + from betterproto.grpc.grpclib_client import MetadataLike + from grpclib.metadata import Deadline + + +@dataclass(eq=False, repr=False) +class DeployUpRequest(betterproto.Message): + spec: "Spec" = betterproto.message_field(1) + """The spec to deploy""" + + attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(2) + """ + A map of attributes related to the deploy request this allows for adding + project identifiers etc. + """ + + +@dataclass(eq=False, repr=False) +class DeployUpEvent(betterproto.Message): + message: "DeployEventMessage" = betterproto.message_field(1, group="content") + result: "DeployUpEventResult" = betterproto.message_field(2, group="content") + + +@dataclass(eq=False, repr=False) +class DeployEventMessage(betterproto.Message): + """Messages to provide status updates on the deployment""" + + message: str = betterproto.string_field(1) + + +@dataclass(eq=False, repr=False) +class UpResult(betterproto.Message): + string_result: str = betterproto.string_field(1, group="content") + """Simple formatted string output as result""" + + +@dataclass(eq=False, repr=False) +class DeployUpEventResult(betterproto.Message): + """Terminal message indicating deployment success""" + + success: bool = betterproto.bool_field(1) + """Indicate the success status""" + + result: "UpResult" = betterproto.message_field(2) + """ + Output state as a struct, this can be provided as an output file or pretty + printed for CLI output + """ + + +@dataclass(eq=False, repr=False) +class DeployDownRequest(betterproto.Message): + attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1) + """ + A map of attributes related to the deploy request this allows for adding + project identifiers etc. + """ + + +@dataclass(eq=False, repr=False) +class DeployDownEvent(betterproto.Message): + message: "DeployEventMessage" = betterproto.message_field(1, group="content") + result: "DeployDownEventResult" = betterproto.message_field(2, group="content") + + +@dataclass(eq=False, repr=False) +class DeployDownEventResult(betterproto.Message): + """Terminal message indicating deployment success""" + + pass + + +@dataclass(eq=False, repr=False) +class ImageSource(betterproto.Message): + """An image source to be used for execution unit deployment""" + + uri: str = betterproto.string_field(1) + """ + URI of the docker image TODO: May also need to provide auth information + (although this should just be configured on the running client already) + """ + + +@dataclass(eq=False, repr=False) +class ExecutionUnit(betterproto.Message): + """A unit of execution (i.e. function/container)""" + + image: "ImageSource" = betterproto.message_field(1, group="source") + """Container image as a execution unit""" + + workers: int = betterproto.int32_field(10) + """Expected worker count for this execution unit""" + + timeout: int = betterproto.int32_field(11) + """Configurable timeout for request handling""" + + memory: int = betterproto.int32_field(12) + """Configurable memory size for this instance""" + + type: str = betterproto.string_field(13) + """ + A simple type property describes the requested type of execution unit that + this should be for this project, a provider can implement how this request + is satisfied in any way + """ + + env: Dict[str, str] = betterproto.map_field( + 14, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + """Environment variables for this execution unit""" + + def __post_init__(self) -> None: + super().__post_init__() + if self.is_set("timeout"): + warnings.warn("ExecutionUnit.timeout is deprecated", DeprecationWarning) + if self.is_set("memory"): + warnings.warn("ExecutionUnit.memory is deprecated", DeprecationWarning) + + +@dataclass(eq=False, repr=False) +class Bucket(betterproto.Message): + pass + + +@dataclass(eq=False, repr=False) +class Topic(betterproto.Message): + subscriptions: List["SubscriptionTarget"] = betterproto.message_field(1) + """TODO: Include topic specifications here""" + + +@dataclass(eq=False, repr=False) +class Queue(betterproto.Message): + pass + + +@dataclass(eq=False, repr=False) +class Collection(betterproto.Message): + pass + + +@dataclass(eq=False, repr=False) +class Secret(betterproto.Message): + pass + + +@dataclass(eq=False, repr=False) +class SubscriptionTarget(betterproto.Message): + execution_unit: str = betterproto.string_field(1, group="target") + """The name of an execution unit to target""" + + +@dataclass(eq=False, repr=False) +class TopicSubscription(betterproto.Message): + target: "SubscriptionTarget" = betterproto.message_field(1) + + +@dataclass(eq=False, repr=False) +class Api(betterproto.Message): + openapi: str = betterproto.string_field(1, group="document") + """ + An OpenAPI document for deployment This document will contain extensions + that hint of execution units that should be targeted as part of the + deployment + """ + + +@dataclass(eq=False, repr=False) +class ScheduleTarget(betterproto.Message): + execution_unit: str = betterproto.string_field(1, group="target") + """The name of an execution unit to target""" + + +@dataclass(eq=False, repr=False) +class Schedule(betterproto.Message): + cron: str = betterproto.string_field(1) + target: "ScheduleTarget" = betterproto.message_field(2) + + +@dataclass(eq=False, repr=False) +class Resource(betterproto.Message): + name: str = betterproto.string_field(1) + type: "__resource_v1__.ResourceType" = betterproto.enum_field(2) + execution_unit: "ExecutionUnit" = betterproto.message_field(10, group="config") + bucket: "Bucket" = betterproto.message_field(11, group="config") + topic: "Topic" = betterproto.message_field(12, group="config") + queue: "Queue" = betterproto.message_field(13, group="config") + api: "Api" = betterproto.message_field(14, group="config") + policy: "Policy" = betterproto.message_field(15, group="config") + schedule: "Schedule" = betterproto.message_field(16, group="config") + collection: "Collection" = betterproto.message_field(17, group="config") + secret: "Secret" = betterproto.message_field(18, group="config") + + +@dataclass(eq=False, repr=False) +class Policy(betterproto.Message): + """ + TODO: This is already defined in our resource contracts... Need to + determine if it's worth re-using unfortunately there are parts we don't + want to duplicate, such as API config + """ + + principals: List["Resource"] = betterproto.message_field(1) + actions: List["__resource_v1__.Action"] = betterproto.enum_field(2) + """ + TODO: Split out discrete action definitions from resources Also need to + allow custom action types as well Should incorporate action re-use here... + """ + + resources: List["Resource"] = betterproto.message_field(3) + + +@dataclass(eq=False, repr=False) +class Spec(betterproto.Message): + resources: List["Resource"] = betterproto.message_field(1) + """list of resources to deploy""" + + +class DeployServiceStub(betterproto.ServiceStub): + async def up( + self, + deploy_up_request: "DeployUpRequest", + *, + timeout: Optional[float] = None, + deadline: Optional["Deadline"] = None, + metadata: Optional["MetadataLike"] = None + ) -> AsyncIterator["DeployUpEvent"]: + async for response in self._unary_stream( + "/nitric.deploy.v1.DeployService/Up", + deploy_up_request, + DeployUpEvent, + timeout=timeout, + deadline=deadline, + metadata=metadata, + ): + yield response + + async def down( + self, + deploy_down_request: "DeployDownRequest", + *, + timeout: Optional[float] = None, + deadline: Optional["Deadline"] = None, + metadata: Optional["MetadataLike"] = None + ) -> AsyncIterator["DeployDownEvent"]: + async for response in self._unary_stream( + "/nitric.deploy.v1.DeployService/Down", + deploy_down_request, + DeployDownEvent, + timeout=timeout, + deadline=deadline, + metadata=metadata, + ): + yield response + + +class DeployServiceBase(ServiceBase): + async def up( + self, deploy_up_request: "DeployUpRequest" + ) -> AsyncIterator["DeployUpEvent"]: + raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) + + async def down( + self, deploy_down_request: "DeployDownRequest" + ) -> AsyncIterator["DeployDownEvent"]: + raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) + + async def __rpc_up( + self, stream: "grpclib.server.Stream[DeployUpRequest, DeployUpEvent]" + ) -> None: + request = await stream.recv_message() + await self._call_rpc_handler_server_stream( + self.up, + stream, + request, + ) + + async def __rpc_down( + self, stream: "grpclib.server.Stream[DeployDownRequest, DeployDownEvent]" + ) -> None: + request = await stream.recv_message() + await self._call_rpc_handler_server_stream( + self.down, + stream, + request, + ) + + def __mapping__(self) -> Dict[str, grpclib.const.Handler]: + return { + "/nitric.deploy.v1.DeployService/Up": grpclib.const.Handler( + self.__rpc_up, + grpclib.const.Cardinality.UNARY_STREAM, + DeployUpRequest, + DeployUpEvent, + ), + "/nitric.deploy.v1.DeployService/Down": grpclib.const.Handler( + self.__rpc_down, + grpclib.const.Cardinality.UNARY_STREAM, + DeployDownRequest, + DeployDownEvent, + ), + } diff --git a/nitric/proto/nitric/faas/v1/__init__.py b/nitric/proto/nitric/faas/v1/__init__.py index fe43648..afe2713 100644 --- a/nitric/proto/nitric/faas/v1/__init__.py +++ b/nitric/proto/nitric/faas/v1/__init__.py @@ -128,6 +128,13 @@ class InitResponse(betterproto.Message): pass +@dataclass(eq=False, repr=False) +class TraceContext(betterproto.Message): + values: Dict[str, str] = betterproto.map_field( + 1, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + + @dataclass(eq=False, repr=False) class TriggerRequest(betterproto.Message): """The server has a trigger for the client to handle""" @@ -138,6 +145,14 @@ class TriggerRequest(betterproto.Message): mime_type: str = betterproto.string_field(2) """Should we supply a mime type for the data? Or rely on context?""" + trace_context: "TraceContext" = betterproto.message_field(10) + """ + TraceInformation from the membrane Allows tying traces from external + triggers (e.g. HttpRequests) into each event request/response pair of the + Bidirectional stream. which cannot be facilitated by OOTB stream + interceptors from OTEL. + """ + http: "HttpTriggerContext" = betterproto.message_field(3, group="context") topic: "TopicTriggerContext" = betterproto.message_field(4, group="context") From 849a7caed76995988499ca2f796cc8afde0693b3 Mon Sep 17 00:00:00 2001 From: Ryan Cartwright Date: Tue, 11 Apr 2023 11:47:32 +1000 Subject: [PATCH 4/4] check for local run if otel binary is missing --- docs/nitric/application.html | 24 +- docs/nitric/faas.html | 12 +- docs/nitric/proto/nitric/deploy/index.html | 88 + docs/nitric/proto/nitric/deploy/v1/index.html | 1550 +++++++++++++++++ .../proto/nitric/document/v1/index.html | 18 +- docs/nitric/proto/nitric/error/v1/index.html | 4 +- docs/nitric/proto/nitric/faas/v1/index.html | 90 +- docs/nitric/proto/nitric/index.html | 5 + docs/nitric/proto/nitric/queue/v1/index.html | 10 +- .../proto/nitric/resource/v1/index.html | 18 +- .../nitric/proto/nitric/storage/v1/index.html | 8 +- nitric/application.py | 8 +- 12 files changed, 1772 insertions(+), 63 deletions(-) create mode 100644 docs/nitric/proto/nitric/deploy/index.html create mode 100644 docs/nitric/proto/nitric/deploy/v1/index.html diff --git a/docs/nitric/application.html b/docs/nitric/application.html index 6953e02..90f26a2 100644 --- a/docs/nitric/application.html +++ b/docs/nitric/application.html @@ -45,7 +45,7 @@

        Module nitric.application

        # limitations under the License. # import asyncio -import os +from os import getenv, environ from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider, sampling @@ -96,17 +96,17 @@

        Module nitric.application

        @classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT + local_run = "OTELCOL_BIN" not in environ + samplePercent = int(getenv("NITRIC_TRACE_SAMPLE_PERCENT", "100")) / 100.0 # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) if local_run: exporter = ConsoleSpanExporter() - + provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100) + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider) @@ -123,7 +123,7 @@

        Module nitric.application

        This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: @@ -192,17 +192,17 @@

        Classes

        @classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT + local_run = "OTELCOL_BIN" not in environ + samplePercent = int(getenv("NITRIC_TRACE_SAMPLE_PERCENT", "100")) / 100.0 # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) if local_run: exporter = ConsoleSpanExporter() - + provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100) + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider) @@ -219,7 +219,7 @@

        Classes

        This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: @@ -256,7 +256,7 @@

        Static methods

        This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: diff --git a/docs/nitric/faas.html b/docs/nitric/faas.html index ed1be85..533e579 100644 --- a/docs/nitric/faas.html +++ b/docs/nitric/faas.html @@ -258,7 +258,7 @@

        Module nitric.faas

        path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -306,7 +306,7 @@

        Module nitric.faas

        request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -779,7 +779,7 @@

        Classes

        request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -806,7 +806,7 @@

        Static methods

        request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -1259,7 +1259,7 @@

        Methods

        path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -1300,7 +1300,7 @@

        Static methods

        path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) diff --git a/docs/nitric/proto/nitric/deploy/index.html b/docs/nitric/proto/nitric/deploy/index.html new file mode 100644 index 0000000..f3022f1 --- /dev/null +++ b/docs/nitric/proto/nitric/deploy/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.deploy API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.deploy

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +
        +
        +

        Sub-modules

        +
        +
        nitric.proto.nitric.deploy.v1
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/deploy/v1/index.html b/docs/nitric/proto/nitric/deploy/v1/index.html new file mode 100644 index 0000000..3b307f6 --- /dev/null +++ b/docs/nitric/proto/nitric/deploy/v1/index.html @@ -0,0 +1,1550 @@ + + + + + + +nitric.proto.nitric.deploy.v1 API documentation + + + + + + + + + + + +
        +
        +
        +

        Module nitric.proto.nitric.deploy.v1

        +
        +
        +
        + +Expand source code + +
        #
        +# Copyright (c) 2021 Nitric Technologies Pty Ltd.
        +#
        +# This file is part of Nitric Python 3 SDK.
        +# See https://github.com/nitrictech/python-sdk for further info.
        +#
        +# Licensed under the Apache License, Version 2.0 (the "License");
        +# you may not use this file except in compliance with the License.
        +# You may obtain a copy of the License at
        +#
        +#     http://www.apache.org/licenses/LICENSE-2.0
        +#
        +# Unless required by applicable law or agreed to in writing, software
        +# distributed under the License is distributed on an "AS IS" BASIS,
        +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        +# See the License for the specific language governing permissions and
        +# limitations under the License.
        +#
        +
        +# Generated by the protocol buffer compiler.  DO NOT EDIT!
        +# sources: proto/deploy/v1/deploy.proto
        +# plugin: python-betterproto
        +import warnings
        +from dataclasses import dataclass
        +from typing import (
        +    TYPE_CHECKING,
        +    AsyncIterator,
        +    Dict,
        +    List,
        +    Optional,
        +)
        +
        +import betterproto
        +import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
        +import grpclib
        +from betterproto.grpc.grpclib_server import ServiceBase
        +
        +from ...resource import v1 as __resource_v1__
        +
        +
        +if TYPE_CHECKING:
        +    import grpclib.server
        +    from betterproto.grpc.grpclib_client import MetadataLike
        +    from grpclib.metadata import Deadline
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployUpRequest(betterproto.Message):
        +    spec: "Spec" = betterproto.message_field(1)
        +    """The spec to deploy"""
        +
        +    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(2)
        +    """
        +    A map of attributes related to the deploy request this allows for adding
        +    project identifiers etc.
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployUpEvent(betterproto.Message):
        +    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
        +    result: "DeployUpEventResult" = betterproto.message_field(2, group="content")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployEventMessage(betterproto.Message):
        +    """Messages to provide status updates on the deployment"""
        +
        +    message: str = betterproto.string_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class UpResult(betterproto.Message):
        +    string_result: str = betterproto.string_field(1, group="content")
        +    """Simple formatted string output as result"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployUpEventResult(betterproto.Message):
        +    """Terminal message indicating deployment success"""
        +
        +    success: bool = betterproto.bool_field(1)
        +    """Indicate the success status"""
        +
        +    result: "UpResult" = betterproto.message_field(2)
        +    """
        +    Output state as a struct, this can be provided as an output file or pretty
        +    printed for CLI output
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployDownRequest(betterproto.Message):
        +    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
        +    """
        +    A map of attributes related to the deploy request this allows for adding
        +    project identifiers etc.
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployDownEvent(betterproto.Message):
        +    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
        +    result: "DeployDownEventResult" = betterproto.message_field(2, group="content")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class DeployDownEventResult(betterproto.Message):
        +    """Terminal message indicating deployment success"""
        +
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ImageSource(betterproto.Message):
        +    """An image source to be used for execution unit deployment"""
        +
        +    uri: str = betterproto.string_field(1)
        +    """
        +    URI of the docker image TODO: May also need to provide auth information
        +    (although this should just be configured on the running client already)
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ExecutionUnit(betterproto.Message):
        +    """A unit of execution (i.e. function/container)"""
        +
        +    image: "ImageSource" = betterproto.message_field(1, group="source")
        +    """Container image as a execution unit"""
        +
        +    workers: int = betterproto.int32_field(10)
        +    """Expected worker count for this execution unit"""
        +
        +    timeout: int = betterproto.int32_field(11)
        +    """Configurable timeout for request handling"""
        +
        +    memory: int = betterproto.int32_field(12)
        +    """Configurable memory size for this instance"""
        +
        +    type: str = betterproto.string_field(13)
        +    """
        +    A simple type property describes the requested type of execution unit that
        +    this should be for this project, a provider can implement how this request
        +    is satisfied in any way
        +    """
        +
        +    env: Dict[str, str] = betterproto.map_field(
        +        14, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Environment variables for this execution unit"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("timeout"):
        +            warnings.warn("ExecutionUnit.timeout is deprecated", DeprecationWarning)
        +        if self.is_set("memory"):
        +            warnings.warn("ExecutionUnit.memory is deprecated", DeprecationWarning)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Bucket(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Topic(betterproto.Message):
        +    subscriptions: List["SubscriptionTarget"] = betterproto.message_field(1)
        +    """TODO: Include topic specifications here"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Queue(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Collection(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Secret(betterproto.Message):
        +    pass
        +
        +
        +@dataclass(eq=False, repr=False)
        +class SubscriptionTarget(betterproto.Message):
        +    execution_unit: str = betterproto.string_field(1, group="target")
        +    """The name of an execution unit to target"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class TopicSubscription(betterproto.Message):
        +    target: "SubscriptionTarget" = betterproto.message_field(1)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Api(betterproto.Message):
        +    openapi: str = betterproto.string_field(1, group="document")
        +    """
        +    An OpenAPI document for deployment This document will contain extensions
        +    that hint of execution units that should be targeted as part of the
        +    deployment
        +    """
        +
        +
        +@dataclass(eq=False, repr=False)
        +class ScheduleTarget(betterproto.Message):
        +    execution_unit: str = betterproto.string_field(1, group="target")
        +    """The name of an execution unit to target"""
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Schedule(betterproto.Message):
        +    cron: str = betterproto.string_field(1)
        +    target: "ScheduleTarget" = betterproto.message_field(2)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Resource(betterproto.Message):
        +    name: str = betterproto.string_field(1)
        +    type: "__resource_v1__.ResourceType" = betterproto.enum_field(2)
        +    execution_unit: "ExecutionUnit" = betterproto.message_field(10, group="config")
        +    bucket: "Bucket" = betterproto.message_field(11, group="config")
        +    topic: "Topic" = betterproto.message_field(12, group="config")
        +    queue: "Queue" = betterproto.message_field(13, group="config")
        +    api: "Api" = betterproto.message_field(14, group="config")
        +    policy: "Policy" = betterproto.message_field(15, group="config")
        +    schedule: "Schedule" = betterproto.message_field(16, group="config")
        +    collection: "Collection" = betterproto.message_field(17, group="config")
        +    secret: "Secret" = betterproto.message_field(18, group="config")
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Policy(betterproto.Message):
        +    """
        +    TODO: This is already defined in our resource contracts... Need to
        +    determine if it's worth re-using unfortunately there are parts we don't
        +    want to duplicate, such as API config
        +    """
        +
        +    principals: List["Resource"] = betterproto.message_field(1)
        +    actions: List["__resource_v1__.Action"] = betterproto.enum_field(2)
        +    """
        +    TODO: Split out discrete action definitions from resources Also need to
        +    allow custom action types as well Should incorporate action re-use here...
        +    """
        +
        +    resources: List["Resource"] = betterproto.message_field(3)
        +
        +
        +@dataclass(eq=False, repr=False)
        +class Spec(betterproto.Message):
        +    resources: List["Resource"] = betterproto.message_field(1)
        +    """list of resources to deploy"""
        +
        +
        +class DeployServiceStub(betterproto.ServiceStub):
        +    async def up(
        +        self,
        +        deploy_up_request: "DeployUpRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DeployUpEvent"]:
        +        async for response in self._unary_stream(
        +            "/nitric.deploy.v1.DeployService/Up",
        +            deploy_up_request,
        +            DeployUpEvent,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +    async def down(
        +        self,
        +        deploy_down_request: "DeployDownRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DeployDownEvent"]:
        +        async for response in self._unary_stream(
        +            "/nitric.deploy.v1.DeployService/Down",
        +            deploy_down_request,
        +            DeployDownEvent,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +
        +class DeployServiceBase(ServiceBase):
        +    async def up(
        +        self, deploy_up_request: "DeployUpRequest"
        +    ) -> AsyncIterator["DeployUpEvent"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def down(
        +        self, deploy_down_request: "DeployDownRequest"
        +    ) -> AsyncIterator["DeployDownEvent"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_up(
        +        self, stream: "grpclib.server.Stream[DeployUpRequest, DeployUpEvent]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.up,
        +            stream,
        +            request,
        +        )
        +
        +    async def __rpc_down(
        +        self, stream: "grpclib.server.Stream[DeployDownRequest, DeployDownEvent]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.down,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.deploy.v1.DeployService/Up": grpclib.const.Handler(
        +                self.__rpc_up,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DeployUpRequest,
        +                DeployUpEvent,
        +            ),
        +            "/nitric.deploy.v1.DeployService/Down": grpclib.const.Handler(
        +                self.__rpc_down,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DeployDownRequest,
        +                DeployDownEvent,
        +            ),
        +        }
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Classes

        +
        +
        +class Api +(openapi: str = <object object>) +
        +
        +

        Api(openapi: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Api(betterproto.Message):
        +    openapi: str = betterproto.string_field(1, group="document")
        +    """
        +    An OpenAPI document for deployment This document will contain extensions
        +    that hint of execution units that should be targeted as part of the
        +    deployment
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var openapi : str
        +
        +

        An OpenAPI document for deployment This document will contain extensions +that hint of execution units that should be targeted as part of the +deployment

        +
        +
        + +
        +class Bucket +
        +
        +

        Bucket()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Bucket(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class Collection +
        +
        +

        Collection()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Collection(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class DeployDownEvent +(message: DeployEventMessage = <object object>, result: DeployDownEventResult = <object object>) +
        +
        +

        DeployDownEvent(message: 'DeployEventMessage' = , result: 'DeployDownEventResult' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployDownEvent(betterproto.Message):
        +    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
        +    result: "DeployDownEventResult" = betterproto.message_field(2, group="content")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var messageDeployEventMessage
        +
        +
        +
        +
        var resultDeployDownEventResult
        +
        +
        +
        +
        + +
        +class DeployDownEventResult +
        +
        +

        Terminal message indicating deployment success

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployDownEventResult(betterproto.Message):
        +    """Terminal message indicating deployment success"""
        +
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class DeployDownRequest +(attributes: betterproto_lib_google_protobuf.Struct = <object object>) +
        +
        +

        DeployDownRequest(attributes: 'betterproto_lib_google_protobuf.Struct' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployDownRequest(betterproto.Message):
        +    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
        +    """
        +    A map of attributes related to the deploy request this allows for adding
        +    project identifiers etc.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var attributes : betterproto.lib.google.protobuf.Struct
        +
        +

        A map of attributes related to the deploy request this allows for adding +project identifiers etc.

        +
        +
        + +
        +class DeployEventMessage +(message: str = <object object>) +
        +
        +

        Messages to provide status updates on the deployment

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployEventMessage(betterproto.Message):
        +    """Messages to provide status updates on the deployment"""
        +
        +    message: str = betterproto.string_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var message : str
        +
        +
        +
        +
        +
        +
        +class DeployServiceBase +
        +
        +

        Base class for async gRPC servers.

        +
        + +Expand source code + +
        class DeployServiceBase(ServiceBase):
        +    async def up(
        +        self, deploy_up_request: "DeployUpRequest"
        +    ) -> AsyncIterator["DeployUpEvent"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def down(
        +        self, deploy_down_request: "DeployDownRequest"
        +    ) -> AsyncIterator["DeployDownEvent"]:
        +        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +    async def __rpc_up(
        +        self, stream: "grpclib.server.Stream[DeployUpRequest, DeployUpEvent]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.up,
        +            stream,
        +            request,
        +        )
        +
        +    async def __rpc_down(
        +        self, stream: "grpclib.server.Stream[DeployDownRequest, DeployDownEvent]"
        +    ) -> None:
        +        request = await stream.recv_message()
        +        await self._call_rpc_handler_server_stream(
        +            self.down,
        +            stream,
        +            request,
        +        )
        +
        +    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        +        return {
        +            "/nitric.deploy.v1.DeployService/Up": grpclib.const.Handler(
        +                self.__rpc_up,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DeployUpRequest,
        +                DeployUpEvent,
        +            ),
        +            "/nitric.deploy.v1.DeployService/Down": grpclib.const.Handler(
        +                self.__rpc_down,
        +                grpclib.const.Cardinality.UNARY_STREAM,
        +                DeployDownRequest,
        +                DeployDownEvent,
        +            ),
        +        }
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_server.ServiceBase
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def down(self, deploy_down_request: DeployDownRequest) ‑> AsyncIterator[DeployDownEvent] +
        +
        +
        +
        + +Expand source code + +
        async def down(
        +    self, deploy_down_request: "DeployDownRequest"
        +) -> AsyncIterator["DeployDownEvent"]:
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +async def up(self, deploy_up_request: DeployUpRequest) ‑> AsyncIterator[DeployUpEvent] +
        +
        +
        +
        + +Expand source code + +
        async def up(
        +    self, deploy_up_request: "DeployUpRequest"
        +) -> AsyncIterator["DeployUpEvent"]:
        +    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
        +
        +
        +
        +
        +
        +class DeployServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
        +
        +

        Base class for async gRPC clients.

        +
        + +Expand source code + +
        class DeployServiceStub(betterproto.ServiceStub):
        +    async def up(
        +        self,
        +        deploy_up_request: "DeployUpRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DeployUpEvent"]:
        +        async for response in self._unary_stream(
        +            "/nitric.deploy.v1.DeployService/Up",
        +            deploy_up_request,
        +            DeployUpEvent,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +    async def down(
        +        self,
        +        deploy_down_request: "DeployDownRequest",
        +        *,
        +        timeout: Optional[float] = None,
        +        deadline: Optional["Deadline"] = None,
        +        metadata: Optional["MetadataLike"] = None
        +    ) -> AsyncIterator["DeployDownEvent"]:
        +        async for response in self._unary_stream(
        +            "/nitric.deploy.v1.DeployService/Down",
        +            deploy_down_request,
        +            DeployDownEvent,
        +            timeout=timeout,
        +            deadline=deadline,
        +            metadata=metadata,
        +        ):
        +            yield response
        +
        +

        Ancestors

        +
          +
        • betterproto.grpc.grpclib_client.ServiceStub
        • +
        • abc.ABC
        • +
        +

        Methods

        +
        +
        +async def down(self, deploy_down_request: DeployDownRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[DeployDownEvent] +
        +
        +
        +
        + +Expand source code + +
        async def down(
        +    self,
        +    deploy_down_request: "DeployDownRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> AsyncIterator["DeployDownEvent"]:
        +    async for response in self._unary_stream(
        +        "/nitric.deploy.v1.DeployService/Down",
        +        deploy_down_request,
        +        DeployDownEvent,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    ):
        +        yield response
        +
        +
        +
        +async def up(self, deploy_up_request: DeployUpRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[DeployUpEvent] +
        +
        +
        +
        + +Expand source code + +
        async def up(
        +    self,
        +    deploy_up_request: "DeployUpRequest",
        +    *,
        +    timeout: Optional[float] = None,
        +    deadline: Optional["Deadline"] = None,
        +    metadata: Optional["MetadataLike"] = None
        +) -> AsyncIterator["DeployUpEvent"]:
        +    async for response in self._unary_stream(
        +        "/nitric.deploy.v1.DeployService/Up",
        +        deploy_up_request,
        +        DeployUpEvent,
        +        timeout=timeout,
        +        deadline=deadline,
        +        metadata=metadata,
        +    ):
        +        yield response
        +
        +
        +
        +
        +
        +class DeployUpEvent +(message: DeployEventMessage = <object object>, result: DeployUpEventResult = <object object>) +
        +
        +

        DeployUpEvent(message: 'DeployEventMessage' = , result: 'DeployUpEventResult' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployUpEvent(betterproto.Message):
        +    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
        +    result: "DeployUpEventResult" = betterproto.message_field(2, group="content")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var messageDeployEventMessage
        +
        +
        +
        +
        var resultDeployUpEventResult
        +
        +
        +
        +
        + +
        +class DeployUpEventResult +(success: bool = <object object>, result: UpResult = <object object>) +
        +
        +

        Terminal message indicating deployment success

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployUpEventResult(betterproto.Message):
        +    """Terminal message indicating deployment success"""
        +
        +    success: bool = betterproto.bool_field(1)
        +    """Indicate the success status"""
        +
        +    result: "UpResult" = betterproto.message_field(2)
        +    """
        +    Output state as a struct, this can be provided as an output file or pretty
        +    printed for CLI output
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var resultUpResult
        +
        +

        Output state as a struct, this can be provided as an output file or pretty +printed for CLI output

        +
        +
        var success : bool
        +
        +

        Indicate the success status

        +
        +
        +
        +
        +class DeployUpRequest +(spec: Spec = <object object>, attributes: betterproto_lib_google_protobuf.Struct = <object object>) +
        +
        +

        DeployUpRequest(spec: 'Spec' = , attributes: 'betterproto_lib_google_protobuf.Struct' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class DeployUpRequest(betterproto.Message):
        +    spec: "Spec" = betterproto.message_field(1)
        +    """The spec to deploy"""
        +
        +    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(2)
        +    """
        +    A map of attributes related to the deploy request this allows for adding
        +    project identifiers etc.
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var attributes : betterproto.lib.google.protobuf.Struct
        +
        +

        A map of attributes related to the deploy request this allows for adding +project identifiers etc.

        +
        +
        var specSpec
        +
        +

        The spec to deploy

        +
        +
        + +
        +class ExecutionUnit +(image: ImageSource = <object object>, workers: int = <object object>, timeout: int = <object object>, memory: int = <object object>, type: str = <object object>, env: Dict[str, str] = <object object>) +
        +
        +

        A unit of execution (i.e. function/container)

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ExecutionUnit(betterproto.Message):
        +    """A unit of execution (i.e. function/container)"""
        +
        +    image: "ImageSource" = betterproto.message_field(1, group="source")
        +    """Container image as a execution unit"""
        +
        +    workers: int = betterproto.int32_field(10)
        +    """Expected worker count for this execution unit"""
        +
        +    timeout: int = betterproto.int32_field(11)
        +    """Configurable timeout for request handling"""
        +
        +    memory: int = betterproto.int32_field(12)
        +    """Configurable memory size for this instance"""
        +
        +    type: str = betterproto.string_field(13)
        +    """
        +    A simple type property describes the requested type of execution unit that
        +    this should be for this project, a provider can implement how this request
        +    is satisfied in any way
        +    """
        +
        +    env: Dict[str, str] = betterproto.map_field(
        +        14, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +    """Environment variables for this execution unit"""
        +
        +    def __post_init__(self) -> None:
        +        super().__post_init__()
        +        if self.is_set("timeout"):
        +            warnings.warn("ExecutionUnit.timeout is deprecated", DeprecationWarning)
        +        if self.is_set("memory"):
        +            warnings.warn("ExecutionUnit.memory is deprecated", DeprecationWarning)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var env : Dict[str, str]
        +
        +

        Environment variables for this execution unit

        +
        +
        var imageImageSource
        +
        +

        Container image as a execution unit

        +
        +
        var memory : int
        +
        +

        Configurable memory size for this instance

        +
        +
        var timeout : int
        +
        +

        Configurable timeout for request handling

        +
        +
        var type : str
        +
        +

        A simple type property describes the requested type of execution unit that +this should be for this project, a provider can implement how this request +is satisfied in any way

        +
        +
        var workers : int
        +
        +

        Expected worker count for this execution unit

        +
        +
        +
        +
        +class ImageSource +(uri: str = <object object>) +
        +
        +

        An image source to be used for execution unit deployment

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ImageSource(betterproto.Message):
        +    """An image source to be used for execution unit deployment"""
        +
        +    uri: str = betterproto.string_field(1)
        +    """
        +    URI of the docker image TODO: May also need to provide auth information
        +    (although this should just be configured on the running client already)
        +    """
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var uri : str
        +
        +

        URI of the docker image TODO: May also need to provide auth information +(although this should just be configured on the running client already)

        +
        +
        +
        +
        +class Policy +(principals: List[ForwardRef('Resource')] = <object object>, actions: List[ForwardRef('__resource_v1__.Action')] = <object object>, resources: List[ForwardRef('Resource')] = <object object>) +
        +
        +

        TODO: This is already defined in our resource contracts… Need to +determine if it's worth re-using unfortunately there are parts we don't +want to duplicate, such as API config

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Policy(betterproto.Message):
        +    """
        +    TODO: This is already defined in our resource contracts... Need to
        +    determine if it's worth re-using unfortunately there are parts we don't
        +    want to duplicate, such as API config
        +    """
        +
        +    principals: List["Resource"] = betterproto.message_field(1)
        +    actions: List["__resource_v1__.Action"] = betterproto.enum_field(2)
        +    """
        +    TODO: Split out discrete action definitions from resources Also need to
        +    allow custom action types as well Should incorporate action re-use here...
        +    """
        +
        +    resources: List["Resource"] = betterproto.message_field(3)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var actions : List[Action]
        +
        +

        TODO: Split out discrete action definitions from resources Also need to +allow custom action types as well Should incorporate action re-use here…

        +
        +
        var principals : List[Resource]
        +
        +
        +
        +
        var resources : List[Resource]
        +
        +
        +
        +
        +
        +
        +class Queue +
        +
        +

        Queue()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Queue(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class Resource +(name: str = <object object>, type: __resource_v1__.ResourceType = <object object>, execution_unit: ExecutionUnit = <object object>, bucket: Bucket = <object object>, topic: Topic = <object object>, queue: Queue = <object object>, api: Api = <object object>, policy: Policy = <object object>, schedule: Schedule = <object object>, collection: Collection = <object object>, secret: Secret = <object object>) +
        +
        +

        Resource(name: str = , type: 'resource_v1.ResourceType' = , execution_unit: 'ExecutionUnit' = , bucket: 'Bucket' = , topic: 'Topic' = , queue: 'Queue' = , api: 'Api' = , policy: 'Policy' = , schedule: 'Schedule' = , collection: 'Collection' = , secret: 'Secret' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Resource(betterproto.Message):
        +    name: str = betterproto.string_field(1)
        +    type: "__resource_v1__.ResourceType" = betterproto.enum_field(2)
        +    execution_unit: "ExecutionUnit" = betterproto.message_field(10, group="config")
        +    bucket: "Bucket" = betterproto.message_field(11, group="config")
        +    topic: "Topic" = betterproto.message_field(12, group="config")
        +    queue: "Queue" = betterproto.message_field(13, group="config")
        +    api: "Api" = betterproto.message_field(14, group="config")
        +    policy: "Policy" = betterproto.message_field(15, group="config")
        +    schedule: "Schedule" = betterproto.message_field(16, group="config")
        +    collection: "Collection" = betterproto.message_field(17, group="config")
        +    secret: "Secret" = betterproto.message_field(18, group="config")
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var apiApi
        +
        +
        +
        +
        var bucketBucket
        +
        +
        +
        +
        var collectionCollection
        +
        +
        +
        +
        var execution_unitExecutionUnit
        +
        +
        +
        +
        var name : str
        +
        +
        +
        +
        var policyPolicy
        +
        +
        +
        +
        var queueQueue
        +
        +
        +
        +
        var scheduleSchedule
        +
        +
        +
        +
        var secretSecret
        +
        +
        +
        +
        var topicTopic
        +
        +
        +
        +
        var typeResourceType
        +
        +
        +
        +
        + +
        +class Schedule +(cron: str = <object object>, target: ScheduleTarget = <object object>) +
        +
        +

        Schedule(cron: str = , target: 'ScheduleTarget' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Schedule(betterproto.Message):
        +    cron: str = betterproto.string_field(1)
        +    target: "ScheduleTarget" = betterproto.message_field(2)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var cron : str
        +
        +
        +
        +
        var targetScheduleTarget
        +
        +
        +
        +
        + +
        +class ScheduleTarget +(execution_unit: str = <object object>) +
        +
        +

        ScheduleTarget(execution_unit: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class ScheduleTarget(betterproto.Message):
        +    execution_unit: str = betterproto.string_field(1, group="target")
        +    """The name of an execution unit to target"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var execution_unit : str
        +
        +

        The name of an execution unit to target

        +
        +
        + +
        +class Secret +
        +
        +

        Secret()

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Secret(betterproto.Message):
        +    pass
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +
        +
        +class Spec +(resources: List[ForwardRef('Resource')] = <object object>) +
        +
        +

        Spec(resources: List[ForwardRef('Resource')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Spec(betterproto.Message):
        +    resources: List["Resource"] = betterproto.message_field(1)
        +    """list of resources to deploy"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var resources : List[Resource]
        +
        +

        list of resources to deploy

        +
        +
        + +
        +class SubscriptionTarget +(execution_unit: str = <object object>) +
        +
        +

        SubscriptionTarget(execution_unit: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class SubscriptionTarget(betterproto.Message):
        +    execution_unit: str = betterproto.string_field(1, group="target")
        +    """The name of an execution unit to target"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var execution_unit : str
        +
        +

        The name of an execution unit to target

        +
        +
        + +
        +class Topic +(subscriptions: List[ForwardRef('SubscriptionTarget')] = <object object>) +
        +
        +

        Topic(subscriptions: List[ForwardRef('SubscriptionTarget')] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class Topic(betterproto.Message):
        +    subscriptions: List["SubscriptionTarget"] = betterproto.message_field(1)
        +    """TODO: Include topic specifications here"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var subscriptions : List[SubscriptionTarget]
        +
        +

        TODO: Include topic specifications here

        +
        +
        + +
        +class TopicSubscription +(target: SubscriptionTarget = <object object>) +
        +
        +

        TopicSubscription(target: 'SubscriptionTarget' = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TopicSubscription(betterproto.Message):
        +    target: "SubscriptionTarget" = betterproto.message_field(1)
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var targetSubscriptionTarget
        +
        +
        +
        +
        + +
        +class UpResult +(string_result: str = <object object>) +
        +
        +

        UpResult(string_result: str = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class UpResult(betterproto.Message):
        +    string_result: str = betterproto.string_field(1, group="content")
        +    """Simple formatted string output as result"""
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var string_result : str
        +
        +

        Simple formatted string output as result

        +
        +
        + + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/document/v1/index.html b/docs/nitric/proto/nitric/document/v1/index.html index 870dd9b..e961349 100644 --- a/docs/nitric/proto/nitric/document/v1/index.html +++ b/docs/nitric/proto/nitric/document/v1/index.html @@ -502,7 +502,7 @@

        Class variables

        (key: Key = <object object>)
        -

        DocumentDeleteRequest(key: 'Key' = )

        +

        DocumentDeleteRequest(key: 'Key' = )

        Expand source code @@ -549,7 +549,7 @@

        Ancestors

        (key: Key = <object object>)
        -

        DocumentGetRequest(key: 'Key' = )

        +

        DocumentGetRequest(key: 'Key' = )

        Expand source code @@ -577,7 +577,7 @@

        Class variables

        (document: Document = <object object>)
        -

        DocumentGetResponse(document: 'Document' = )

        +

        DocumentGetResponse(document: 'Document' = )

        Expand source code @@ -605,7 +605,7 @@

        Class variables

        (collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>, paging_token: Dict[str, str] = <object object>)
        -

        DocumentQueryRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = , paging_token: Dict[str, str] = )

        +

        DocumentQueryRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = , paging_token: Dict[str, str] = )

        Expand source code @@ -656,7 +656,7 @@

        Class variables

        (documents: List[ForwardRef('Document')] = <object object>, paging_token: Dict[str, str] = <object object>)
        -

        DocumentQueryResponse(documents: List[ForwardRef('Document')] = , paging_token: Dict[str, str] = )

        +

        DocumentQueryResponse(documents: List[ForwardRef('Document')] = , paging_token: Dict[str, str] = )

        Expand source code @@ -697,7 +697,7 @@

        Class variables

        (collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>)
        -

        DocumentQueryStreamRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = )

        +

        DocumentQueryStreamRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = )

        Expand source code @@ -739,7 +739,7 @@

        Class variables

        (document: Document = <object object>)
        -

        DocumentQueryStreamResponse(document: 'Document' = )

        +

        DocumentQueryStreamResponse(document: 'Document' = )

        Expand source code @@ -1203,7 +1203,7 @@

        Methods

        (key: Key = <object object>, content: betterproto_lib_google_protobuf.Struct = <object object>)
        -

        DocumentSetRequest(key: 'Key' = , content: 'betterproto_lib_google_protobuf.Struct' = )

        +

        DocumentSetRequest(key: 'Key' = , content: 'betterproto_lib_google_protobuf.Struct' = )

        Expand source code @@ -1301,7 +1301,7 @@

        Class variables

        (int_value: int = <object object>, double_value: float = <object object>, string_value: str = <object object>, bool_value: bool = <object object>)
        -

        ExpressionValue(int_value: int = , double_value: float = , string_value: str = , bool_value: bool = )

        +

        ExpressionValue(int_value: int = , double_value: float = , string_value: str = , bool_value: bool = )

        Expand source code diff --git a/docs/nitric/proto/nitric/error/v1/index.html b/docs/nitric/proto/nitric/error/v1/index.html index 63b8344..30322c5 100644 --- a/docs/nitric/proto/nitric/error/v1/index.html +++ b/docs/nitric/proto/nitric/error/v1/index.html @@ -98,7 +98,7 @@

        Classes

        (message: str = <object object>, cause: str = <object object>, scope: ErrorScope = <object object>)
        -

        ErrorDetails(message: str = , cause: str = , scope: 'ErrorScope' = )

        +

        ErrorDetails(message: str = , cause: str = , scope: 'ErrorScope' = )

        Expand source code @@ -142,7 +142,7 @@

        Class variables

        (service: str = <object object>, plugin: str = <object object>, args: Dict[str, str] = <object object>)
        -

        ErrorScope(service: str = , plugin: str = , args: Dict[str, str] = )

        +

        ErrorScope(service: str = , plugin: str = , args: Dict[str, str] = )

        Expand source code diff --git a/docs/nitric/proto/nitric/faas/v1/index.html b/docs/nitric/proto/nitric/faas/v1/index.html index a76a29f..d54803c 100644 --- a/docs/nitric/proto/nitric/faas/v1/index.html +++ b/docs/nitric/proto/nitric/faas/v1/index.html @@ -175,6 +175,13 @@

        Module nitric.proto.nitric.faas.v1

        pass +@dataclass(eq=False, repr=False) +class TraceContext(betterproto.Message): + values: Dict[str, str] = betterproto.map_field( + 1, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + + @dataclass(eq=False, repr=False) class TriggerRequest(betterproto.Message): """The server has a trigger for the client to handle""" @@ -185,6 +192,14 @@

        Module nitric.proto.nitric.faas.v1

        mime_type: str = betterproto.string_field(2) """Should we supply a mime type for the data? Or rely on context?""" + trace_context: "TraceContext" = betterproto.message_field(10) + """ + TraceInformation from the membrane Allows tying traces from external + triggers (e.g. HttpRequests) into each event request/response pair of the + Bidirectional stream. which cannot be facilitated by OOTB stream + interceptors from OTEL. + """ + http: "HttpTriggerContext" = betterproto.message_field(3, group="context") topic: "TopicTriggerContext" = betterproto.message_field(4, group="context") @@ -373,7 +388,7 @@

        Classes

        (api: str = <object object>, path: str = <object object>, methods: List[str] = <object object>, options: ApiWorkerOptions = <object object>)
        -

        ApiWorker(api: str = , path: str = , methods: List[str] = , options: 'ApiWorkerOptions' = )

        +

        ApiWorker(api: str = , path: str = , methods: List[str] = , options: 'ApiWorkerOptions' = )

        Expand source code @@ -415,7 +430,7 @@

        Class variables

        (security: Dict[str, ForwardRef('ApiWorkerScopes')] = <object object>, security_disabled: bool = <object object>)
        -

        ApiWorkerOptions(security: Dict[str, ForwardRef('ApiWorkerScopes')] = , security_disabled: bool = )

        +

        ApiWorkerOptions(security: Dict[str, ForwardRef('ApiWorkerScopes')] = , security_disabled: bool = )

        Expand source code @@ -458,7 +473,7 @@

        Class variables

        (scopes: List[str] = <object object>)
        -

        ApiWorkerScopes(scopes: List[str] = )

        +

        ApiWorkerScopes(scopes: List[str] = )

        Expand source code @@ -664,7 +679,7 @@

        Methods

        (value: List[str] = <object object>)
        -

        HeaderValue(value: List[str] = )

        +

        HeaderValue(value: List[str] = )

        Expand source code @@ -750,7 +765,7 @@

        Class variables

        (method: str = <object object>, path: str = <object object>, headers_old: Dict[str, str] = <object object>, query_params_old: Dict[str, str] = <object object>, headers: Dict[str, ForwardRef('HeaderValue')] = <object object>, query_params: Dict[str, ForwardRef('QueryValue')] = <object object>, path_params: Dict[str, str] = <object object>)
        -

        HttpTriggerContext(method: str = , path: str = , headers_old: Dict[str, str] = , query_params_old: Dict[str, str] = , headers: Dict[str, ForwardRef('HeaderValue')] = , query_params: Dict[str, ForwardRef('QueryValue')] = , path_params: Dict[str, str] = )

        +

        HttpTriggerContext(method: str = , path: str = , headers_old: Dict[str, str] = , query_params_old: Dict[str, str] = , headers: Dict[str, ForwardRef('HeaderValue')] = , query_params: Dict[str, ForwardRef('QueryValue')] = , path_params: Dict[str, str] = )

        Expand source code @@ -915,7 +930,7 @@

        Ancestors

        (value: List[str] = <object object>)
        -

        QueryValue(value: List[str] = )

        +

        QueryValue(value: List[str] = )

        Expand source code @@ -942,7 +957,7 @@

        Class variables

        (cron: str = <object object>)
        -

        ScheduleCron(cron: str = )

        +

        ScheduleCron(cron: str = )

        Expand source code @@ -969,7 +984,7 @@

        Class variables

        (rate: str = <object object>)
        -

        ScheduleRate(rate: str = )

        +

        ScheduleRate(rate: str = )

        Expand source code @@ -996,7 +1011,7 @@

        Class variables

        (key: str = <object object>, rate: ScheduleRate = <object object>, cron: ScheduleCron = <object object>)
        -

        ScheduleWorker(key: str = , rate: 'ScheduleRate' = , cron: 'ScheduleCron' = )

        +

        ScheduleWorker(key: str = , rate: 'ScheduleRate' = , cron: 'ScheduleCron' = )

        Expand source code @@ -1079,7 +1094,7 @@

        Class variables

        (topic: str = <object object>)
        -

        SubscriptionWorker(topic: str = )

        +

        SubscriptionWorker(topic: str = )

        Expand source code @@ -1140,7 +1155,7 @@

        Class variables

        (topic: str = <object object>)
        -

        TopicTriggerContext(topic: str = )

        +

        TopicTriggerContext(topic: str = )

        Expand source code @@ -1163,9 +1178,38 @@

        Class variables

        +
        +class TraceContext +(values: Dict[str, str] = <object object>) +
        +
        +

        TraceContext(values: Dict[str, str] = )

        +
        + +Expand source code + +
        @dataclass(eq=False, repr=False)
        +class TraceContext(betterproto.Message):
        +    values: Dict[str, str] = betterproto.map_field(
        +        1, betterproto.TYPE_STRING, betterproto.TYPE_STRING
        +    )
        +
        +

        Ancestors

        +
          +
        • betterproto.Message
        • +
        • abc.ABC
        • +
        +

        Class variables

        +
        +
        var values : Dict[str, str]
        +
        +
        +
        +
        +
        class TriggerRequest -(data: bytes = <object object>, mime_type: str = <object object>, http: HttpTriggerContext = <object object>, topic: TopicTriggerContext = <object object>) +(data: bytes = <object object>, mime_type: str = <object object>, trace_context: TraceContext = <object object>, http: HttpTriggerContext = <object object>, topic: TopicTriggerContext = <object object>)

        The server has a trigger for the client to handle

        @@ -1183,6 +1227,14 @@

        Class variables

        mime_type: str = betterproto.string_field(2) """Should we supply a mime type for the data? Or rely on context?""" + trace_context: "TraceContext" = betterproto.message_field(10) + """ + TraceInformation from the membrane Allows tying traces from external + triggers (e.g. HttpRequests) into each event request/response pair of the + Bidirectional stream. which cannot be facilitated by OOTB stream + interceptors from OTEL. + """ + http: "HttpTriggerContext" = betterproto.message_field(3, group="context") topic: "TopicTriggerContext" = betterproto.message_field(4, group="context") @@ -1209,6 +1261,13 @@

        Class variables

        +
        var trace_contextTraceContext
        +
        +

        TraceInformation from the membrane Allows tying traces from external +triggers (e.g. HttpRequests) into each event request/response pair of the +Bidirectional stream. which cannot be facilitated by OOTB stream +interceptors from OTEL.

        +
        @@ -1403,12 +1462,19 @@

        TraceContext

        + + +
      • TriggerRequest

      • diff --git a/docs/nitric/proto/nitric/index.html b/docs/nitric/proto/nitric/index.html index 53be9a8..8c42e05 100644 --- a/docs/nitric/proto/nitric/index.html +++ b/docs/nitric/proto/nitric/index.html @@ -26,6 +26,10 @@

        Namespace nitric.proto.nitric

        Sub-modules

        +
        nitric.proto.nitric.deploy
        +
        +
        +
        nitric.proto.nitric.document
        @@ -80,6 +84,7 @@

        Index

      • Sub-modules

      • -

        FailedTask(task: 'NitricTask' = , message: str = )

        +

        FailedTask(task: 'NitricTask' = , message: str = )

        Expand source code @@ -428,7 +428,7 @@

        Class variables

        (queue: str = <object object>, lease_id: str = <object object>)
        -

        QueueCompleteRequest(queue: str = , lease_id: str = )

        +

        QueueCompleteRequest(queue: str = , lease_id: str = )

        Expand source code @@ -487,7 +487,7 @@

        Ancestors

        (queue: str = <object object>, depth: int = <object object>)
        -

        QueueReceiveRequest(queue: str = , depth: int = )

        +

        QueueReceiveRequest(queue: str = , depth: int = )

        Expand source code @@ -530,7 +530,7 @@

        Class variables

        (tasks: List[ForwardRef('NitricTask')] = <object object>)
        -

        QueueReceiveResponse(tasks: List[ForwardRef('NitricTask')] = )

        +

        QueueReceiveResponse(tasks: List[ForwardRef('NitricTask')] = )

        Expand source code @@ -558,7 +558,7 @@

        Class variables

        (queue: str = <object object>, tasks: List[ForwardRef('NitricTask')] = <object object>)
        -

        QueueSendBatchRequest(queue: str = , tasks: List[ForwardRef('NitricTask')] = )

        +

        QueueSendBatchRequest(queue: str = , tasks: List[ForwardRef('NitricTask')] = )

        Expand source code diff --git a/docs/nitric/proto/nitric/resource/v1/index.html b/docs/nitric/proto/nitric/resource/v1/index.html index d977ec0..cb3c949 100644 --- a/docs/nitric/proto/nitric/resource/v1/index.html +++ b/docs/nitric/proto/nitric/resource/v1/index.html @@ -441,7 +441,7 @@

        Class variables

        (security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = <object object>, security: Dict[str, ForwardRef('ApiScopes')] = <object object>)
        -

        ApiResource(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = , security: Dict[str, ForwardRef('ApiScopes')] = )

        +

        ApiResource(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = , security: Dict[str, ForwardRef('ApiScopes')] = )

        Expand source code @@ -484,7 +484,7 @@

        Class variables

        (url: str = <object object>)
        -

        ApiResourceDetails(url: str = )

        +

        ApiResourceDetails(url: str = )

        Expand source code @@ -511,7 +511,7 @@

        Class variables

        (scopes: List[str] = <object object>)
        -

        ApiScopes(scopes: List[str] = )

        +

        ApiScopes(scopes: List[str] = )

        Expand source code @@ -538,7 +538,7 @@

        Class variables

        (jwt: ApiSecurityDefinitionJwt = <object object>)
        -

        ApiSecurityDefinition(jwt: 'ApiSecurityDefinitionJwt' = )

        +

        ApiSecurityDefinition(jwt: 'ApiSecurityDefinitionJwt' = )

        Expand source code @@ -637,7 +637,7 @@

        Ancestors

        (principals: List[ForwardRef('Resource')] = <object object>, actions: List[ForwardRef('Action')] = <object object>, resources: List[ForwardRef('Resource')] = <object object>)
        -

        PolicyResource(principals: List[ForwardRef('Resource')] = , actions: List[ForwardRef('Action')] = , resources: List[ForwardRef('Resource')] = )

        +

        PolicyResource(principals: List[ForwardRef('Resource')] = , actions: List[ForwardRef('Action')] = , resources: List[ForwardRef('Resource')] = )

        Expand source code @@ -693,7 +693,7 @@

        Ancestors

        (type: ResourceType = <object object>, name: str = <object object>)
        -

        Resource(type: 'ResourceType' = , name: str = )

        +

        Resource(type: 'ResourceType' = , name: str = )

        Expand source code @@ -725,7 +725,7 @@

        Class variables

        (resource: Resource = <object object>, policy: PolicyResource = <object object>, bucket: BucketResource = <object object>, queue: QueueResource = <object object>, topic: TopicResource = <object object>, collection: CollectionResource = <object object>, secret: SecretResource = <object object>, api: ApiResource = <object object>)
        -

        ResourceDeclareRequest(resource: 'Resource' = , policy: 'PolicyResource' = , bucket: 'BucketResource' = , queue: 'QueueResource' = , topic: 'TopicResource' = , collection: 'CollectionResource' = , secret: 'SecretResource' = , api: 'ApiResource' = )

        +

        ResourceDeclareRequest(resource: 'Resource' = , policy: 'PolicyResource' = , bucket: 'BucketResource' = , queue: 'QueueResource' = , topic: 'TopicResource' = , collection: 'CollectionResource' = , secret: 'SecretResource' = , api: 'ApiResource' = )

        Expand source code @@ -806,7 +806,7 @@

        Ancestors

        (resource: Resource = <object object>)
        -

        ResourceDetailsRequest(resource: 'Resource' = )

        +

        ResourceDetailsRequest(resource: 'Resource' = )

        Expand source code @@ -833,7 +833,7 @@

        Class variables

        (id: str = <object object>, provider: str = <object object>, service: str = <object object>, api: ApiResourceDetails = <object object>)
        -

        ResourceDetailsResponse(id: str = , provider: str = , service: str = , api: 'ApiResourceDetails' = )

        +

        ResourceDetailsResponse(id: str = , provider: str = , service: str = , api: 'ApiResourceDetails' = )

        Expand source code diff --git a/docs/nitric/proto/nitric/storage/v1/index.html b/docs/nitric/proto/nitric/storage/v1/index.html index a910859..14bf58c 100644 --- a/docs/nitric/proto/nitric/storage/v1/index.html +++ b/docs/nitric/proto/nitric/storage/v1/index.html @@ -391,7 +391,7 @@

        Classes

        (key: str = <object object>)
        -

        File(key: str = )

        +

        File(key: str = )

        Expand source code @@ -476,7 +476,7 @@

        Ancestors

        (bucket_name: str = <object object>)
        -

        StorageListFilesRequest(bucket_name: str = )

        +

        StorageListFilesRequest(bucket_name: str = )

        Expand source code @@ -503,7 +503,7 @@

        Class variables

        (files: List[ForwardRef('File')] = <object object>)
        -

        StorageListFilesResponse(files: List[ForwardRef('File')] = )

        +

        StorageListFilesResponse(files: List[ForwardRef('File')] = )

        Expand source code @@ -636,7 +636,7 @@

        Class variables

        (url: str = <object object>)
        -

        StoragePreSignUrlResponse(url: str = )

        +

        StoragePreSignUrlResponse(url: str = )

        Expand source code diff --git a/nitric/application.py b/nitric/application.py index ee42a0d..0812f22 100644 --- a/nitric/application.py +++ b/nitric/application.py @@ -17,7 +17,7 @@ # limitations under the License. # import asyncio -import os +from os import getenv, environ from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider, sampling @@ -68,8 +68,8 @@ def _create_resource(cls, resource: Type[BT], name: str, *args, **kwargs) -> BT: @classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT + local_run = "OTELCOL_BIN" not in environ + samplePercent = int(getenv("NITRIC_TRACE_SAMPLE_PERCENT", "100")) / 100.0 # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) @@ -78,7 +78,7 @@ def _create_tracer(cls) -> TracerProvider: provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent / 100 if samplePercent is not None else 100), + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider)