Skip to content

Commit

Permalink
Update generated code
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Gisondi <antonio.gisondi@secomind.com>
  • Loading branch information
harlem88 committed Dec 5, 2023
1 parent 61362a7 commit 83a7666
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 46 deletions.
14 changes: 9 additions & 5 deletions python/astarteplatform/msghub/astarte_message_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions python/astarteplatform/msghub/astarte_message_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
from google.protobuf import empty_pb2 as _empty_pb2
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from astarteplatform.msghub import astarte_type_pb2 as _astarte_type_pb2
from astarteplatform.msghub import message_hub_error_pb2 as _message_hub_error_pb2
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

class AstarteMessageResult(_message.Message):
__slots__ = ["astarte_message", "hub_error"]
ASTARTE_MESSAGE_FIELD_NUMBER: _ClassVar[int]
HUB_ERROR_FIELD_NUMBER: _ClassVar[int]
astarte_message: AstarteMessage
hub_error: _message_hub_error_pb2.MessageHubError
def __init__(self, astarte_message: _Optional[_Union[AstarteMessage, _Mapping]] = ..., hub_error: _Optional[_Union[_message_hub_error_pb2.MessageHubError, _Mapping]] = ...) -> None: ...

class AstarteMessage(_message.Message):
__slots__ = ["interface_name", "path", "astarte_data", "astarte_unset", "timestamp"]
INTERFACE_NAME_FIELD_NUMBER: _ClassVar[int]
Expand Down
27 changes: 27 additions & 0 deletions python/astarteplatform/msghub/message_hub_error_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions python/astarteplatform/msghub/message_hub_error_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

class MessageHubError(_message.Message):
__slots__ = ["error_code", "error_description"]
class ErrorCode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []
UNKNOWN: _ClassVar[MessageHubError.ErrorCode]
ASTARTE_INVALID_DATA: _ClassVar[MessageHubError.ErrorCode]
ASTARTE_SDK_ERROR: _ClassVar[MessageHubError.ErrorCode]
CONVERSION_ERROR: _ClassVar[MessageHubError.ErrorCode]
UNKNOWN: MessageHubError.ErrorCode
ASTARTE_INVALID_DATA: MessageHubError.ErrorCode
ASTARTE_SDK_ERROR: MessageHubError.ErrorCode
CONVERSION_ERROR: MessageHubError.ErrorCode
ERROR_CODE_FIELD_NUMBER: _ClassVar[int]
ERROR_DESCRIPTION_FIELD_NUMBER: _ClassVar[int]
error_code: MessageHubError.ErrorCode
error_description: str
def __init__(self, error_code: _Optional[_Union[MessageHubError.ErrorCode, str]] = ..., error_description: _Optional[str] = ...) -> None: ...
4 changes: 4 additions & 0 deletions python/astarteplatform/msghub/message_hub_error_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

9 changes: 6 additions & 3 deletions python/astarteplatform/msghub/message_hub_service_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion python/astarteplatform/msghub/message_hub_service_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from google.protobuf import empty_pb2 as _empty_pb2
from astarteplatform.msghub import astarte_message_pb2 as _astarte_message_pb2
from astarteplatform.msghub import astarte_type_pb2 as _astarte_type_pb2
from astarteplatform.msghub import message_hub_error_pb2 as _message_hub_error_pb2
from astarteplatform.msghub import node_pb2 as _node_pb2
from google.protobuf import descriptor as _descriptor
from typing import ClassVar as _ClassVar
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

class MessageHubResult(_message.Message):
__slots__ = ["empty_message", "hub_error"]
EMPTY_MESSAGE_FIELD_NUMBER: _ClassVar[int]
HUB_ERROR_FIELD_NUMBER: _ClassVar[int]
empty_message: _empty_pb2.Empty
hub_error: _message_hub_error_pb2.MessageHubError
def __init__(self, empty_message: _Optional[_Union[_empty_pb2.Empty, _Mapping]] = ..., hub_error: _Optional[_Union[_message_hub_error_pb2.MessageHubError, _Mapping]] = ...) -> None: ...
28 changes: 14 additions & 14 deletions python/astarteplatform/msghub/message_hub_service_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import grpc

from astarteplatform.msghub import astarte_message_pb2 as astarteplatform_dot_msghub_dot_astarte__message__pb2
from astarteplatform.msghub import message_hub_service_pb2 as astarteplatform_dot_msghub_dot_message__hub__service__pb2
from astarteplatform.msghub import node_pb2 as astarteplatform_dot_msghub_dot_node__pb2
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2


class MessageHubStub(object):
Expand All @@ -19,17 +19,17 @@ def __init__(self, channel):
self.Attach = channel.unary_stream(
'/astarteplatform.msghub.MessageHub/Attach',
request_serializer=astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
response_deserializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.FromString,
response_deserializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessageResult.FromString,
)
self.Send = channel.unary_unary(
'/astarteplatform.msghub.MessageHub/Send',
request_serializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.SerializeToString,
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
request_serializer=astarteplatform_dot_msghub_dot_node__pb2.NodeMessage.SerializeToString,
response_deserializer=astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.FromString,
)
self.Detach = channel.unary_unary(
'/astarteplatform.msghub.MessageHub/Detach',
request_serializer=astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
response_deserializer=astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.FromString,
)


Expand All @@ -45,7 +45,7 @@ def Attach(self, request, context):
raise NotImplementedError('Method not implemented!')

def Send(self, request, context):
"""This function should be used to send an `AstarteMessage` to Astarte.
"""This function should be used to send a `NodeMessage` to Astarte.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
Expand All @@ -64,17 +64,17 @@ def add_MessageHubServicer_to_server(servicer, server):
'Attach': grpc.unary_stream_rpc_method_handler(
servicer.Attach,
request_deserializer=astarteplatform_dot_msghub_dot_node__pb2.Node.FromString,
response_serializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.SerializeToString,
response_serializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessageResult.SerializeToString,
),
'Send': grpc.unary_unary_rpc_method_handler(
servicer.Send,
request_deserializer=astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.FromString,
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
request_deserializer=astarteplatform_dot_msghub_dot_node__pb2.NodeMessage.FromString,
response_serializer=astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.SerializeToString,
),
'Detach': grpc.unary_unary_rpc_method_handler(
servicer.Detach,
request_deserializer=astarteplatform_dot_msghub_dot_node__pb2.Node.FromString,
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
response_serializer=astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
Expand All @@ -99,7 +99,7 @@ def Attach(request,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/astarteplatform.msghub.MessageHub/Attach',
astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.FromString,
astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessageResult.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

Expand All @@ -115,8 +115,8 @@ def Send(request,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/astarteplatform.msghub.MessageHub/Send',
astarteplatform_dot_msghub_dot_astarte__message__pb2.AstarteMessage.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
astarteplatform_dot_msghub_dot_node__pb2.NodeMessage.SerializeToString,
astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

Expand All @@ -133,6 +133,6 @@ def Detach(request,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/astarteplatform.msghub.MessageHub/Detach',
astarteplatform_dot_msghub_dot_node__pb2.Node.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
astarteplatform_dot_msghub_dot_message__hub__service__pb2.MessageHubResult.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
9 changes: 6 additions & 3 deletions python/astarteplatform/msghub/node_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion python/astarteplatform/msghub/node_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from astarteplatform.msghub import astarte_message_pb2 as _astarte_message_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Optional as _Optional
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor

Expand All @@ -12,3 +13,11 @@ class Node(_message.Message):
uuid: str
interface_jsons: _containers.RepeatedScalarFieldContainer[bytes]
def __init__(self, uuid: _Optional[str] = ..., interface_jsons: _Optional[_Iterable[bytes]] = ...) -> None: ...

class NodeMessage(_message.Message):
__slots__ = ["uuid", "astarte_message"]
UUID_FIELD_NUMBER: _ClassVar[int]
ASTARTE_MESSAGE_FIELD_NUMBER: _ClassVar[int]
uuid: str
astarte_message: _astarte_message_pb2.AstarteMessage
def __init__(self, uuid: _Optional[str] = ..., astarte_message: _Optional[_Union[_astarte_message_pb2.AstarteMessage, _Mapping]] = ...) -> None: ...
10 changes: 8 additions & 2 deletions rust/astarte-message-hub-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use clap::Parser;

use astarte_message_hub_proto::astarte_message::Payload;
use astarte_message_hub_proto::message_hub_client::MessageHubClient;
use astarte_message_hub_proto::AstarteMessage;
use astarte_message_hub_proto::{AstarteMessage, NodeMessage};
use astarte_message_hub_proto::Node;
use log::info;

Expand Down Expand Up @@ -110,7 +110,13 @@ async fn run_example_client() {
timestamp: None,
payload: Some(Payload::AstarteData(elapsed_str.into())),
};
client.send(msg).await.unwrap();

let node_msg = NodeMessage {
uuid: args.uuid.clone(),
astarte_message: Some(msg)
};

client.send(node_msg).await.unwrap();

count += 1;
}
Expand Down
Loading

0 comments on commit 83a7666

Please sign in to comment.