From 5421e1898d3f768308a2599cef618318673f76dc Mon Sep 17 00:00:00 2001 From: Jordan Halterman Date: Mon, 30 Nov 2020 14:58:25 -0800 Subject: [PATCH 1/2] Generate Python bindings --- Makefile | 4 ++-- build/bin/compile-protos.sh | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 8b87aca8..f8c35a5d 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ export GO111MODULE=on .PHONY: build -ONOS_BUILD_VERSION := v0.6.6 -ONOS_PROTOC_VERSION := v0.6.6 +ONOS_BUILD_VERSION := v0.6.7 +ONOS_PROTOC_VERSION := v0.6.7 BUF_VERSION := 0.27.1 all: protos diff --git a/build/bin/compile-protos.sh b/build/bin/compile-protos.sh index b1b9d3b6..3fbc29f4 100755 --- a/build/bin/compile-protos.sh +++ b/build/bin/compile-protos.sh @@ -51,21 +51,18 @@ protoc --proto_path=$proto_path \ proto/onos/topo/*.proto ### Python Protobuf code generation -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/e2sub \ -# proto/onos/e2sub/endpoint/*.proto -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/e2sub \ -# proto/onos/e2sub/subscription/*.proto -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/e2sub \ -# proto/onos/e2sub/task/*.proto -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/e2t \ -# proto/onos/e2t/admin/*.proto -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/e2t \ -# proto/onos/e2t/e2/*.proto -#protoc --proto_path=$proto_path \ -# --python_betterproto_out=./python/onos/topo \ -# proto/onos/topo/*.proto +protoc --proto_path=$proto_path \ + --python_betterproto_out=./python \ + proto/onos/e2sub/endpoint/endpoint.proto \ + proto/onos/e2sub/subscription/subscription.proto \ + proto/onos/e2sub/task/task.proto \ + proto/onos/e2t/admin/admin.proto \ + proto/onos/e2t/e2/e2.proto \ + proto/onos/topo/topo.proto + +mv ./python/onos/e2sub/endpoint/__init__.py ./python/onos/e2sub/endpoint.py && rm -r ./python/onos/e2sub/endpoint +mv ./python/onos/e2sub/subscription/__init__.py ./python/onos/e2sub/subscription.py && rm -r ./python/onos/e2sub/subscription +mv ./python/onos/e2sub/task/__init__.py ./python/onos/e2sub/task.py && rm -r ./python/onos/e2sub/task +mv ./python/onos/e2t/admin/__init__.py ./python/onos/e2t/admin.py && rm -r ./python/onos/e2t/admin +mv ./python/onos/e2t/e2/__init__.py ./python/onos/e2t/e2.py && rm -r ./python/onos/e2t/e2 +mv ./python/onos/topo/__init__.py ./python/onos/topo/topo.py && touch ./python/onos/topo/__init__.py From 1157ea7108932e72ceddbd77befb4e748a87715a Mon Sep 17 00:00:00 2001 From: Jordan Halterman Date: Mon, 30 Nov 2020 16:03:47 -0800 Subject: [PATCH 2/2] Add Python codes --- python/__init__.py | 0 python/gogoproto/__init__.py | 6 + python/onos/__init__.py | 0 python/onos/e2sub/__init__.py | 0 python/onos/e2sub/endpoint.py | 244 ++++++++++++++++++++++ python/onos/e2sub/subscription.py | 255 +++++++++++++++++++++++ python/onos/e2sub/task.py | 259 +++++++++++++++++++++++ python/onos/e2t/__init__.py | 0 python/onos/e2t/admin.py | 215 +++++++++++++++++++ python/onos/e2t/e2.py | 109 ++++++++++ python/onos/topo/__init__.py | 0 python/onos/topo/topo.py | 334 ++++++++++++++++++++++++++++++ 12 files changed, 1422 insertions(+) create mode 100644 python/__init__.py create mode 100644 python/gogoproto/__init__.py create mode 100644 python/onos/__init__.py create mode 100644 python/onos/e2sub/__init__.py create mode 100644 python/onos/e2sub/endpoint.py create mode 100644 python/onos/e2sub/subscription.py create mode 100644 python/onos/e2sub/task.py create mode 100644 python/onos/e2t/__init__.py create mode 100644 python/onos/e2t/admin.py create mode 100644 python/onos/e2t/e2.py create mode 100644 python/onos/topo/__init__.py create mode 100644 python/onos/topo/topo.py diff --git a/python/__init__.py b/python/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/gogoproto/__init__.py b/python/gogoproto/__init__.py new file mode 100644 index 00000000..1d57db1a --- /dev/null +++ b/python/gogoproto/__init__.py @@ -0,0 +1,6 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: gogoproto/gogo.proto +# plugin: python-betterproto +from dataclasses import dataclass + +import betterproto diff --git a/python/onos/__init__.py b/python/onos/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/onos/e2sub/__init__.py b/python/onos/e2sub/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/onos/e2sub/endpoint.py b/python/onos/e2sub/endpoint.py new file mode 100644 index 00000000..a2a69ebf --- /dev/null +++ b/python/onos/e2sub/endpoint.py @@ -0,0 +1,244 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/e2sub/endpoint/endpoint.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterator, List, Optional + +import betterproto +import grpclib + + +class EventType(betterproto.Enum): + """Type of change""" + + NONE = 0 + ADDED = 1 + REMOVED = 3 + + +@dataclass(eq=False, repr=False) +class TerminationEndpoint(betterproto.Message): + """ + Termination is a record identifying the IP address and TCP port coordinates + where the E2 termination service is available. + """ + + id: str = betterproto.string_field(1) + revision: int = betterproto.uint64_field(2) + ip: str = betterproto.string_field(3) + port: int = betterproto.uint32_field(4) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Event(betterproto.Message): + """Event is an end-point event""" + + type: "EventType" = betterproto.enum_field(1) + endpoint: "TerminationEndpoint" = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class AddTerminationRequest(betterproto.Message): + """ + AddTerminationRequest is a request for adding a new termination point + """ + + endpoint: "TerminationEndpoint" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class AddTerminationResponse(betterproto.Message): + """ + AddTerminationResponse is a response to adding a new termination point + """ + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetTerminationRequest(betterproto.Message): + """ + GetTerminationRequest is a request for getting existing termination point + """ + + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetTerminationResponse(betterproto.Message): + """ + GetTerminationResponse is a response with invormation about a requested + termination point + """ + + endpoint: "TerminationEndpoint" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class RemoveTerminationRequest(betterproto.Message): + """RemoveTerminationRequest is a request for removing termination point""" + + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class RemoveTerminationResponse(betterproto.Message): + """ + RemoveTerminationResponse is a response to removing a termination point + """ + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListTerminationsRequest(betterproto.Message): + """ + ListTerminationsRequest is a request to list all available E2 terminations + """ + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListTerminationsResponse(betterproto.Message): + """ + ListTerminationsResponse is a response to list all available E2 + terminations + """ + + endpoints: List["TerminationEndpoint"] = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchTerminationsRequest(betterproto.Message): + """ + WatchTerminationsRequest is a request to receive a stream of all E2 + termination changes. + """ + + noreplay: bool = betterproto.bool_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchTerminationsResponse(betterproto.Message): + """ + WatchTerminationsResponse is a response indicating a change in the + available E2 termination end-points. + """ + + event: "Event" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +class E2RegistryServiceStub(betterproto.ServiceStub): + """ + E2RegistryService manages subscription and subscription delete requests + """ + + async def add_termination( + self, *, endpoint: "TerminationEndpoint" = None + ) -> "AddTerminationResponse": + """AddTermination registers new E2 termination end-point.""" + + request = AddTerminationRequest() + if endpoint is not None: + request.endpoint = endpoint + + return await self._unary_unary( + "/onos.e2sub.endpoint.E2RegistryService/AddTermination", + request, + AddTerminationResponse, + ) + + async def get_termination(self, *, id: str = "") -> "GetTerminationResponse": + """GetTermination retrieves information about a specific end-point""" + + request = GetTerminationRequest() + request.id = id + + return await self._unary_unary( + "/onos.e2sub.endpoint.E2RegistryService/GetTermination", + request, + GetTerminationResponse, + ) + + async def remove_termination(self, *, id: str = "") -> "RemoveTerminationResponse": + """ + RemoveTermination removes the specified E2 termination end-point. + """ + + request = RemoveTerminationRequest() + request.id = id + + return await self._unary_unary( + "/onos.e2sub.endpoint.E2RegistryService/RemoveTermination", + request, + RemoveTerminationResponse, + ) + + async def list_terminations(self) -> "ListTerminationsResponse": + """ + ListTerminations returns the list of currently registered E2 + terminations. + """ + + request = ListTerminationsRequest() + + return await self._unary_unary( + "/onos.e2sub.endpoint.E2RegistryService/ListTerminations", + request, + ListTerminationsResponse, + ) + + async def watch_terminations( + self, *, noreplay: bool = False + ) -> AsyncIterator["WatchTerminationsResponse"]: + """ + WatchTerminations returns a stream of changes in the set of available + E2 terminations. + """ + + request = WatchTerminationsRequest() + request.noreplay = noreplay + + async for response in self._unary_stream( + "/onos.e2sub.endpoint.E2RegistryService/WatchTerminations", + request, + WatchTerminationsResponse, + ): + yield response diff --git a/python/onos/e2sub/subscription.py b/python/onos/e2sub/subscription.py new file mode 100644 index 00000000..8062da22 --- /dev/null +++ b/python/onos/e2sub/subscription.py @@ -0,0 +1,255 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/e2sub/subscription/subscription.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterator, List, Optional + +import betterproto +import grpclib + + +class Status(betterproto.Enum): + """Status is a subscription status""" + + ACTIVE = 0 + PENDING_DELETE = 1 + + +class EventType(betterproto.Enum): + """EventType is a subscription event type""" + + NONE = 0 + ADDED = 1 + UPDATED = 2 + REMOVED = 3 + + +class Encoding(betterproto.Enum): + """Encoding indicates a payload encoding""" + + ENCODING_ASN1 = 0 + ENCODING_PROTO = 1 + + +@dataclass(eq=False, repr=False) +class Lifecycle(betterproto.Message): + """Lifecycle is the subscription lifecycle""" + + status: "Status" = betterproto.enum_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Event(betterproto.Message): + """Event is a subscription event""" + + type: "EventType" = betterproto.enum_field(1) + subscription: "Subscription" = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ServiceModel(betterproto.Message): + """ServiceModel is a service model definition""" + + id: str = betterproto.string_field(4) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Payload(betterproto.Message): + """Payload is a subscription payload""" + + encoding: "Encoding" = betterproto.enum_field(1) + bytes: bytes = betterproto.bytes_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Subscription(betterproto.Message): + """Subscription is a subscription state""" + + id: str = betterproto.string_field(1) + revision: int = betterproto.uint64_field(2) + app_id: str = betterproto.string_field(3) + e2_node_id: str = betterproto.string_field(4) + service_model: "ServiceModel" = betterproto.message_field(5) + payload: "Payload" = betterproto.message_field(6) + lifecycle: "Lifecycle" = betterproto.message_field(7) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class AddSubscriptionRequest(betterproto.Message): + """AddSubscriptionRequest a subscription request""" + + subscription: "Subscription" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class AddSubscriptionResponse(betterproto.Message): + """AddSubscriptionResponse a subscription response""" + + subscription: "Subscription" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class RemoveSubscriptionRequest(betterproto.Message): + """RemoveSubscriptionRequest a subscription delete request""" + + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class RemoveSubscriptionResponse(betterproto.Message): + """RemoveSubscriptionResponse a subscription delete response""" + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetSubscriptionRequest(betterproto.Message): + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetSubscriptionResponse(betterproto.Message): + subscription: "Subscription" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListSubscriptionsRequest(betterproto.Message): + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListSubscriptionsResponse(betterproto.Message): + subscriptions: List["Subscription"] = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchSubscriptionsRequest(betterproto.Message): + noreplay: bool = betterproto.bool_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchSubscriptionsResponse(betterproto.Message): + event: "Event" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +class E2SubscriptionServiceStub(betterproto.ServiceStub): + """ + SubscriptionService manages subscription and subscription delete requests + """ + + async def add_subscription( + self, *, subscription: "Subscription" = None + ) -> "AddSubscriptionResponse": + """AddSubscription establishes E2 subscriptions on E2 Node.""" + + request = AddSubscriptionRequest() + if subscription is not None: + request.subscription = subscription + + return await self._unary_unary( + "/onos.e2sub.subscription.E2SubscriptionService/AddSubscription", + request, + AddSubscriptionResponse, + ) + + async def remove_subscription( + self, *, id: str = "" + ) -> "RemoveSubscriptionResponse": + """RemoveSubscription removes E2 subscriptions on E2 Node.""" + + request = RemoveSubscriptionRequest() + request.id = id + + return await self._unary_unary( + "/onos.e2sub.subscription.E2SubscriptionService/RemoveSubscription", + request, + RemoveSubscriptionResponse, + ) + + async def get_subscription(self, *, id: str = "") -> "GetSubscriptionResponse": + """ + GetSubscription retrieves information about a specific subscription in + the list of existing subscriptions + """ + + request = GetSubscriptionRequest() + request.id = id + + return await self._unary_unary( + "/onos.e2sub.subscription.E2SubscriptionService/GetSubscription", + request, + GetSubscriptionResponse, + ) + + async def list_subscriptions(self) -> "ListSubscriptionsResponse": + """ + ListSubscriptions returns the list of current existing subscriptions + """ + + request = ListSubscriptionsRequest() + + return await self._unary_unary( + "/onos.e2sub.subscription.E2SubscriptionService/ListSubscriptions", + request, + ListSubscriptionsResponse, + ) + + async def watch_subscriptions( + self, *, noreplay: bool = False + ) -> AsyncIterator["WatchSubscriptionsResponse"]: + """WatchSubscriptions returns a stream of subscription changes""" + + request = WatchSubscriptionsRequest() + request.noreplay = noreplay + + async for response in self._unary_stream( + "/onos.e2sub.subscription.E2SubscriptionService/WatchSubscriptions", + request, + WatchSubscriptionsResponse, + ): + yield response diff --git a/python/onos/e2sub/task.py b/python/onos/e2sub/task.py new file mode 100644 index 00000000..2c5c93ee --- /dev/null +++ b/python/onos/e2sub/task.py @@ -0,0 +1,259 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/e2sub/task/task.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterator, List, Optional + +import betterproto +import grpclib + + +class Phase(betterproto.Enum): + """Phase is a subscription task phase""" + + # OPEN is a subscription task open phase + OPEN = 0 + # CLOSE is a subscription task close phase + CLOSE = 1 + + +class Status(betterproto.Enum): + """Status is a subscription task status""" + + # PENDING indicates the subscription task phase is pending + PENDING = 0 + # COMPLETE indicates the subscription task phase is complete + COMPLETE = 1 + + +class EventType(betterproto.Enum): + """Type of change""" + + NONE = 0 + CREATED = 1 + UPDATED = 2 + REMOVED = 3 + + +@dataclass(eq=False, repr=False) +class Lifecycle(betterproto.Message): + """Lifecycle is a subscription task status""" + + phase: "Phase" = betterproto.enum_field(1) + status: "Status" = betterproto.enum_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class SubscriptionTask(betterproto.Message): + """ + SubscriptionTask is a task representing a subscription between an E2 + termination and an E2 node + """ + + id: str = betterproto.string_field(1) + revision: int = betterproto.uint64_field(2) + subscription_id: str = betterproto.string_field(3) + endpoint_id: str = betterproto.string_field(4) + lifecycle: "Lifecycle" = betterproto.message_field(5) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Event(betterproto.Message): + """Event is a SubscriptionTask event""" + + type: "EventType" = betterproto.enum_field(1) + task: "SubscriptionTask" = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetSubscriptionTaskRequest(betterproto.Message): + """ + GetSubscriptionTaskRequest is a request for getting existing + SubscriptionTask + """ + + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetSubscriptionTaskResponse(betterproto.Message): + """ + GetSubscriptionTaskResponse is a response with invormation about a + requested SubscriptionTask + """ + + task: "SubscriptionTask" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListSubscriptionTasksRequest(betterproto.Message): + """ + ListSubscriptionTasksRequest is a request to list all available + SubscriptionTasks + """ + + subscription_id: str = betterproto.string_field(1) + endpoint_id: str = betterproto.string_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListSubscriptionTasksResponse(betterproto.Message): + """ + ListSubscriptionTasksResponse is a response to list all available + SubscriptionTasks + """ + + tasks: List["SubscriptionTask"] = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchSubscriptionTasksRequest(betterproto.Message): + """ + WatchSubscriptionTasksRequest is a request to receive a stream of all + SubscriptionTask changes. + """ + + noreplay: bool = betterproto.bool_field(1) + subscription_id: str = betterproto.string_field(2) + endpoint_id: str = betterproto.string_field(3) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchSubscriptionTasksResponse(betterproto.Message): + """ + WatchSubscriptionTasksResponse is a response indicating a change in the + available SubscriptionTasks. + """ + + event: "Event" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class UpdateSubscriptionTaskRequest(betterproto.Message): + """ + UpdateSubscriptionTaskRequest is a request for updating a SubscriptionTask + status + """ + + task: "SubscriptionTask" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class UpdateSubscriptionTaskResponse(betterproto.Message): + """ + UpdateSubscriptionTaskResponse is a response to updating a SubscriptionTask + status + """ + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +class E2SubscriptionTaskServiceStub(betterproto.ServiceStub): + """ + E2SubscriptionTaskService manages subscription tasks between E2 termination + points and E2 nodes + """ + + async def get_subscription_task( + self, *, id: str = "" + ) -> "GetSubscriptionTaskResponse": + """GetSubscriptionTask retrieves information about a specific task""" + + request = GetSubscriptionTaskRequest() + request.id = id + + return await self._unary_unary( + "/onos.e2sub.task.E2SubscriptionTaskService/GetSubscriptionTask", + request, + GetSubscriptionTaskResponse, + ) + + async def list_subscription_tasks( + self, *, subscription_id: str = "", endpoint_id: str = "" + ) -> "ListSubscriptionTasksResponse": + """ + ListSubscriptionTasks returns the list of currently registered E2 + Tasks. + """ + + request = ListSubscriptionTasksRequest() + request.subscription_id = subscription_id + request.endpoint_id = endpoint_id + + return await self._unary_unary( + "/onos.e2sub.task.E2SubscriptionTaskService/ListSubscriptionTasks", + request, + ListSubscriptionTasksResponse, + ) + + async def watch_subscription_tasks( + self, + *, + noreplay: bool = False, + subscription_id: str = "", + endpoint_id: str = "", + ) -> AsyncIterator["WatchSubscriptionTasksResponse"]: + """ + WatchSubscriptionTasks returns a stream of changes in the set of + available E2 Tasks. + """ + + request = WatchSubscriptionTasksRequest() + request.noreplay = noreplay + request.subscription_id = subscription_id + request.endpoint_id = endpoint_id + + async for response in self._unary_stream( + "/onos.e2sub.task.E2SubscriptionTaskService/WatchSubscriptionTasks", + request, + WatchSubscriptionTasksResponse, + ): + yield response + + async def update_subscription_task( + self, *, task: "SubscriptionTask" = None + ) -> "UpdateSubscriptionTaskResponse": + """UpdateSubscriptionTask updates a task status""" + + request = UpdateSubscriptionTaskRequest() + if task is not None: + request.task = task + + return await self._unary_unary( + "/onos.e2sub.task.E2SubscriptionTaskService/UpdateSubscriptionTask", + request, + UpdateSubscriptionTaskResponse, + ) diff --git a/python/onos/e2t/__init__.py b/python/onos/e2t/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/onos/e2t/admin.py b/python/onos/e2t/admin.py new file mode 100644 index 00000000..a39cc1c8 --- /dev/null +++ b/python/onos/e2t/admin.py @@ -0,0 +1,215 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/e2t/admin/admin.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterable, AsyncIterator, Iterable, List, Optional, Union + +import betterproto +import grpclib + + +class E2NodeConnectionType(betterproto.Enum): + """E2NodeConnectionType specifies the type of an E2 connection""" + + UNKNOWN = 0 + G_NB = 1 + E_NB = 2 + ENG_MB = 3 + NGE_NB = 4 + + +@dataclass(eq=False, repr=False) +class UploadRegisterServiceModelRequest(betterproto.Message): + """ + UploadRegisterServiceModelRequest is for streaming a model plugin file to + the server. There is a built in limit in gRPC of 4MB - plugin is usually + around 20MB so break in to chunks of approx 1-2MB. + """ + + # so_file is the name being streamed. + so_file: str = betterproto.string_field(1) + # content is the bytes content. + content: bytes = betterproto.bytes_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class UploadRegisterServiceModelResponse(betterproto.Message): + """ + UploadRegisterServiceModelResponse carries status of model plugin + registration. + """ + + # name is name of the model plugin. + name: str = betterproto.string_field(1) + # version is the semantic version of the model plugin. + version: str = betterproto.string_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListRegisteredServiceModelsResponse(betterproto.Message): + """ + ListRegisteredServiceModelsResponse is general information about a service + model plugin. + """ + + # name is the name given to the service model plugin - no spaces and title + # case. + name: str = betterproto.string_field(1) + # version is the semantic version of the Plugin e.g. 1.0.0. + version: str = betterproto.string_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListRegisteredServiceModelsRequest(betterproto.Message): + """ + ListRegisteredServiceModelsRequest carries data for querying registered + service model plugins. + """ + + # An optional filter on the name of the model plugins to list. + model_name: str = betterproto.string_field(1) + # An optional filter on the version of the model plugins to list + model_version: str = betterproto.string_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListE2NodeConnectionsRequest(betterproto.Message): + """ + ListE2NodeConnectionsRequest carries request for a list of E2 node SCTP + connections. + """ + + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListE2NodeConnectionsResponse(betterproto.Message): + """ + ListE2NodeConnectionsResponse carries information about the SCTP connection + to the remote E2 node. + """ + + remote_ip: List[str] = betterproto.string_field(1) + remote_port: int = betterproto.uint32_field(2) + id: str = betterproto.string_field(3) + plmn_id: str = betterproto.string_field(4) + connection_type: "E2NodeConnectionType" = betterproto.enum_field(5) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class DropE2NodeConnectionsRequest(betterproto.Message): + """DropE2NodeConnectionsRequest carries drop connection request""" + + connections: List["ListE2NodeConnectionsResponse"] = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class DropE2NodeConnectionsResponse(betterproto.Message): + """DropE2NodeConnectionsResponse carries drop connection response""" + + success: List[bool] = betterproto.bool_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +class E2TAdminServiceStub(betterproto.ServiceStub): + """ + E2TAdminService provides means for enhanced interactions with the ONOS RIC + E2 Termination service. + """ + + async def upload_register_service_model( + self, + request_iterator: Union[ + AsyncIterable["UploadRegisterServiceModelRequest"], + Iterable["UploadRegisterServiceModelRequest"], + ], + ) -> "UploadRegisterServiceModelResponse": + """ + UploadRegisterServiceModel uploads and adds the model plugin to the + list of supported models. The file is serialized in to Chunks of less + than 4MB so as not to break the gRPC byte array limit + """ + + return await self._stream_unary( + "/onos.e2t.admin.E2TAdminService/UploadRegisterServiceModel", + request_iterator, + UploadRegisterServiceModelRequest, + UploadRegisterServiceModelResponse, + ) + + async def list_registered_service_models( + self, *, model_name: str = "", model_version: str = "" + ) -> AsyncIterator["ListRegisteredServiceModelsResponse"]: + """ + ListRegisteredServiceModels returns a stream of registered service + models. + """ + + request = ListRegisteredServiceModelsRequest() + request.model_name = model_name + request.model_version = model_version + + async for response in self._unary_stream( + "/onos.e2t.admin.E2TAdminService/ListRegisteredServiceModels", + request, + ListRegisteredServiceModelsResponse, + ): + yield response + + async def list_e2_node_connections( + self, + ) -> AsyncIterator["ListE2NodeConnectionsResponse"]: + """ + ListE2NodeConnections returns a stream of existing SCTP connections. + """ + + request = ListE2NodeConnectionsRequest() + + async for response in self._unary_stream( + "/onos.e2t.admin.E2TAdminService/ListE2NodeConnections", + request, + ListE2NodeConnectionsResponse, + ): + yield response + + async def drop_e2_node_connections( + self, *, connections: Optional[List["ListE2NodeConnectionsResponse"]] = None + ) -> "DropE2NodeConnectionsResponse": + """ + DropE2NodeConnections drops the specified E2 node SCTP connections + """ + + connections = connections or [] + + request = DropE2NodeConnectionsRequest() + if connections is not None: + request.connections = connections + + return await self._unary_unary( + "/onos.e2t.admin.E2TAdminService/DropE2NodeConnections", + request, + DropE2NodeConnectionsResponse, + ) diff --git a/python/onos/e2t/e2.py b/python/onos/e2t/e2.py new file mode 100644 index 00000000..cf154dac --- /dev/null +++ b/python/onos/e2t/e2.py @@ -0,0 +1,109 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/e2t/e2/e2.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterable, AsyncIterator, Iterable, Optional, Union + +import betterproto +import grpclib + + +class EncodingType(betterproto.Enum): + """EncodingType determines encoding type for the response messages""" + + PROTO = 0 + ASN1_PER = 1 + ASN1_XER = 2 + + +class ResponseStatus(betterproto.Enum): + """ResponseStatus""" + + FAILED = 0 + SUCCEEDED = 1 + + +@dataclass(eq=False, repr=False) +class ServiceModelInfo(betterproto.Message): + """ServiceModelInfo E2 service model information""" + + service_model_id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class RequestHeader(betterproto.Message): + """ + RequestHeader a common request header for all requests including encoding + type, client/xApp/session info, ordering info, etc + """ + + encoding_type: "EncodingType" = betterproto.enum_field(1) + service_model_info: "ServiceModelInfo" = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ResponseHeader(betterproto.Message): + """ + ResponseHeader a common response header for all responses including + encoding type, client/xApp/session info, ordering info, etc + """ + + encoding_type: "EncodingType" = betterproto.enum_field(1) + service_model_info: "ServiceModelInfo" = betterproto.message_field(2) + response_status: "ResponseStatus" = betterproto.enum_field(3) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class StreamRequest(betterproto.Message): + """StreamRequest""" + + header: "RequestHeader" = betterproto.message_field(1) + app_id: str = betterproto.string_field(2) + instance_id: str = betterproto.string_field(3) + subscription_id: str = betterproto.string_field(4) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class StreamResponse(betterproto.Message): + """StreamResponse""" + + header: "ResponseHeader" = betterproto.message_field(1) + payload: bytes = betterproto.bytes_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +class E2TServiceStub(betterproto.ServiceStub): + """ + E2TService provides means for enhanced interactions with the ONOS RIC E2 + Termination service. + """ + + async def stream( + self, + request_iterator: Union[ + AsyncIterable["StreamRequest"], Iterable["StreamRequest"] + ], + ) -> AsyncIterator["StreamResponse"]: + """Stream opens an indications stream""" + + async for response in self._stream_stream( + "/onos.e2t.e2.E2TService/Stream", + request_iterator, + StreamRequest, + StreamResponse, + ): + yield response diff --git a/python/onos/topo/__init__.py b/python/onos/topo/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/onos/topo/topo.py b/python/onos/topo/topo.py new file mode 100644 index 00000000..9eb77c64 --- /dev/null +++ b/python/onos/topo/topo.py @@ -0,0 +1,334 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: onos/topo/topo.proto +# plugin: python-betterproto +from dataclasses import dataclass +from typing import AsyncIterator, Dict, List, Optional + +import betterproto +import grpclib + + +class EventType(betterproto.Enum): + """EventType is a topo operation event type""" + + NONE = 0 + ADDED = 1 + UPDATED = 2 + REMOVED = 3 + + +class Protocol(betterproto.Enum): + """Protocol to interact with a device""" + + # UNKNOWN_PROTOCOL constant needed to go around proto3 nullifying the 0 + # values + UNKNOWN_PROTOCOL = 0 + # GNMI protocol reference + GNMI = 1 + # P4RUNTIME protocol reference + P4RUNTIME = 2 + # GNOI protocol reference + GNOI = 3 + # E2 Control Plane Protocol + E2AP = 4 + + +class ConnectivityState(betterproto.Enum): + """ + ConnectivityState represents the L3 reachability of a device from the + service container (e.g. enos-config), independently of gRPC or the service + itself (e.g. gNMI) + """ + + # UNKNOWN_CONNECTIVITY_STATE constant needed to go around proto3 nullifying + # the 0 values + UNKNOWN_CONNECTIVITY_STATE = 0 + # REACHABLE indicates the the service can reach the device at L3 + REACHABLE = 1 + # UNREACHABLE indicates the the service can't reach the device at L3 + UNREACHABLE = 2 + + +class ChannelState(betterproto.Enum): + """ + ConnectivityState represents the state of a gRPC channel to the device from + the service container + """ + + # UNKNOWN_CHANNEL_STATE constant needed to go around proto3 nullifying the 0 + # values + UNKNOWN_CHANNEL_STATE = 0 + # CONNECTED indicates the corresponding grpc channel is connected on this + # device + CONNECTED = 1 + # DISCONNECTED indicates the corresponding grpc channel is not connected on + # this device + DISCONNECTED = 2 + + +class ServiceState(betterproto.Enum): + """ + ServiceState represents the state of the gRPC service (e.g. gNMI) to the + device from the service container + """ + + # UNKNOWN_SERVICE_STATE constant needed to go around proto3 nullifying the 0 + # values + UNKNOWN_SERVICE_STATE = 0 + # AVAILABLE indicates the corresponding grpc service is available + AVAILABLE = 1 + # UNAVAILABLE indicates the corresponding grpc service is not available + UNAVAILABLE = 2 + # CONNECTING indicates the corresponding protocol is in the connecting phase + # on this device + CONNECTING = 3 + + +class ObjectType(betterproto.Enum): + UNSPECIFIED = 0 + ENTITY = 1 + RELATION = 2 + KIND = 3 + + +@dataclass(eq=False, repr=False) +class Event(betterproto.Message): + """Event is a topo operation event""" + + type: "EventType" = betterproto.enum_field(1) + object: "Object" = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class CreateRequest(betterproto.Message): + object: "Object" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class CreateResponse(betterproto.Message): + object: "Object" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetRequest(betterproto.Message): + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class GetResponse(betterproto.Message): + object: "Object" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class UpdateRequest(betterproto.Message): + object: "Object" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class UpdateResponse(betterproto.Message): + object: "Object" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class DeleteRequest(betterproto.Message): + id: str = betterproto.string_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class DeleteResponse(betterproto.Message): + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListRequest(betterproto.Message): + pass + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ListResponse(betterproto.Message): + objects: List["Object"] = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchRequest(betterproto.Message): + noreplay: bool = betterproto.bool_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class WatchResponse(betterproto.Message): + event: "Event" = betterproto.message_field(1) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Object(betterproto.Message): + id: str = betterproto.string_field(1) + revision: int = betterproto.uint64_field(2) + type: "ObjectType" = betterproto.enum_field(3) + entity: "Entity" = betterproto.message_field(4, group="obj") + relation: "Relation" = betterproto.message_field(5, group="obj") + kind: "Kind" = betterproto.message_field(6, group="obj") + attributes: Dict[str, str] = betterproto.map_field( + 7, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Entity(betterproto.Message): + """Entity represents any "thing" that is represented in the topology""" + + # user-defined entity kind + kind_id: str = betterproto.string_field(1) + protocols: List["ProtocolState"] = betterproto.message_field(2) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Relation(betterproto.Message): + # user defined relation kind + kind_id: str = betterproto.string_field(1) + src_entity_id: str = betterproto.string_field(2) + tgt_entity_id: str = betterproto.string_field(3) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class Kind(betterproto.Message): + name: str = betterproto.string_field(1) + # Map of attributes and their default values for this Kind + attributes: Dict[str, str] = betterproto.map_field( + 2, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + + def __post_init__(self) -> None: + super().__post_init__() + + +@dataclass(eq=False, repr=False) +class ProtocolState(betterproto.Message): + """ + ProtocolState contains information related to service and connectivity to a + device + """ + + # The protocol to which state relates + protocol: "Protocol" = betterproto.enum_field(1) + # ConnectivityState contains the L3 connectivity information + connectivity_state: "ConnectivityState" = betterproto.enum_field(2) + # ChannelState relates to the availability of the gRPC channel + channel_state: "ChannelState" = betterproto.enum_field(3) + # ServiceState indicates the availability of the gRPC servic on top of the + # channel + service_state: "ServiceState" = betterproto.enum_field(4) + + def __post_init__(self) -> None: + super().__post_init__() + + +class TopoStub(betterproto.ServiceStub): + """EntityService provides an API for managing entities.""" + + async def create(self, *, object: "Object" = None) -> "CreateResponse": + """Create a new topology object""" + + request = CreateRequest() + if object is not None: + request.object = object + + return await self._unary_unary( + "/onos.topo.Topo/Create", request, CreateResponse + ) + + async def get(self, *, id: str = "") -> "GetResponse": + """Get an object from topology""" + + request = GetRequest() + request.id = id + + return await self._unary_unary("/onos.topo.Topo/Get", request, GetResponse) + + async def update(self, *, object: "Object" = None) -> "UpdateResponse": + """Update an existing topology object""" + + request = UpdateRequest() + if object is not None: + request.object = object + + return await self._unary_unary( + "/onos.topo.Topo/Update", request, UpdateResponse + ) + + async def delete(self, *, id: str = "") -> "DeleteResponse": + """Delete an object from topology""" + + request = DeleteRequest() + request.id = id + + return await self._unary_unary( + "/onos.topo.Topo/Delete", request, DeleteResponse + ) + + async def list(self) -> "ListResponse": + """List gets a stream of requested objects""" + + request = ListRequest() + + return await self._unary_unary("/onos.topo.Topo/List", request, ListResponse) + + async def watch(self, *, noreplay: bool = False) -> AsyncIterator["WatchResponse"]: + """Watch returns a stream of topo change notifications""" + + request = WatchRequest() + request.noreplay = noreplay + + async for response in self._unary_stream( + "/onos.topo.Topo/Watch", + request, + WatchResponse, + ): + yield response