From 9926b6960d27fea31c898482580b76afcdc10c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Cs=C3=B3ka?= Date: Thu, 21 Mar 2024 23:21:39 +0100 Subject: [PATCH 1/2] Update the peers endpoint --- docs/MessagesApi.md | 8 ++++---- docs/NodePeersResponse.md | 2 +- hoprd_sdk/api/messages_api.py | 8 ++++---- hoprd_sdk/models/node_peers_response.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/MessagesApi.md b/docs/MessagesApi.md index 180845c..9abd005 100644 --- a/docs/MessagesApi.md +++ b/docs/MessagesApi.md @@ -142,7 +142,7 @@ configuration.api_key['X-Auth-Token'] = 'YOUR_API_KEY' # create an instance of the API class api_instance = hoprd_sdk.MessagesApi(hoprd_sdk.ApiClient(configuration)) -body = hoprd_sdk.GetMessageBodyRequest() # GetMessageBodyRequest | Tag of message queue and optionally a timestamp since from to start peeking +body = hoprd_sdk.GetMessageBodyRequest() # GetMessageBodyRequest | Tag of message queue and optionally a timestamp since from to start peeking. When an empty object or an object with a `tag: 0` is provided, it fetches all the messages. try: # Peek the list of messages currently present in the nodes message inbox, filtered by tag, @@ -156,7 +156,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**GetMessageBodyRequest**](GetMessageBodyRequest.md)| Tag of message queue and optionally a timestamp since from to start peeking | + **body** | [**GetMessageBodyRequest**](GetMessageBodyRequest.md)| Tag of message queue and optionally a timestamp since from to start peeking. When an empty object or an object with a `tag: 0` is provided, it fetches all the messages. | ### Return type @@ -250,7 +250,7 @@ configuration.api_key['X-Auth-Token'] = 'YOUR_API_KEY' # create an instance of the API class api_instance = hoprd_sdk.MessagesApi(hoprd_sdk.ApiClient(configuration)) -body = hoprd_sdk.TagQueryRequest() # TagQueryRequest | Tag of message queue to pop from +body = hoprd_sdk.TagQueryRequest() # TagQueryRequest | Tag of message queue to pop from. When an empty object or an object with a `tag: 0` is provided, it lists and removes all the messages. try: # Get the list of messages currently present in the nodes message inbox. @@ -264,7 +264,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**TagQueryRequest**](TagQueryRequest.md)| Tag of message queue to pop from | + **body** | [**TagQueryRequest**](TagQueryRequest.md)| Tag of message queue to pop from. When an empty object or an object with a `tag: 0` is provided, it lists and removes all the messages. | ### Return type diff --git a/docs/NodePeersResponse.md b/docs/NodePeersResponse.md index 332c297..3bcf385 100644 --- a/docs/NodePeersResponse.md +++ b/docs/NodePeersResponse.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**announced** | [**list[PeerInfo]**](PeerInfo.md) | | +**announced** | [**list[AnnouncedPeer]**](AnnouncedPeer.md) | | **connected** | [**list[PeerInfo]**](PeerInfo.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/hoprd_sdk/api/messages_api.py b/hoprd_sdk/api/messages_api.py index 0690514..9d3dcd7 100644 --- a/hoprd_sdk/api/messages_api.py +++ b/hoprd_sdk/api/messages_api.py @@ -232,7 +232,7 @@ def peek_all(self, body, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool - :param GetMessageBodyRequest body: Tag of message queue and optionally a timestamp since from to start peeking (required) + :param GetMessageBodyRequest body: Tag of message queue and optionally a timestamp since from to start peeking. When an empty object or an object with a `tag: 0` is provided, it fetches all the messages. (required) :return: MessagePopAllResponse If the method is called asynchronously, returns the request thread. @@ -254,7 +254,7 @@ def peek_all_with_http_info(self, body, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool - :param GetMessageBodyRequest body: Tag of message queue and optionally a timestamp since from to start peeking (required) + :param GetMessageBodyRequest body: Tag of message queue and optionally a timestamp since from to start peeking. When an empty object or an object with a `tag: 0` is provided, it fetches all the messages. (required) :return: MessagePopAllResponse If the method is called asynchronously, returns the request thread. @@ -430,7 +430,7 @@ def pop_all(self, body, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool - :param TagQueryRequest body: Tag of message queue to pop from (required) + :param TagQueryRequest body: Tag of message queue to pop from. When an empty object or an object with a `tag: 0` is provided, it lists and removes all the messages. (required) :return: MessagePopAllResponse If the method is called asynchronously, returns the request thread. @@ -452,7 +452,7 @@ def pop_all_with_http_info(self, body, **kwargs): # noqa: E501 >>> result = thread.get() :param async_req bool - :param TagQueryRequest body: Tag of message queue to pop from (required) + :param TagQueryRequest body: Tag of message queue to pop from. When an empty object or an object with a `tag: 0` is provided, it lists and removes all the messages. (required) :return: MessagePopAllResponse If the method is called asynchronously, returns the request thread. diff --git a/hoprd_sdk/models/node_peers_response.py b/hoprd_sdk/models/node_peers_response.py index 1265203..f5687f5 100644 --- a/hoprd_sdk/models/node_peers_response.py +++ b/hoprd_sdk/models/node_peers_response.py @@ -28,7 +28,7 @@ class NodePeersResponse(object): and the value is json key in definition. """ swagger_types = { - 'announced': 'list[PeerInfo]', + 'announced': 'list[AnnouncedPeer]', 'connected': 'list[PeerInfo]' } @@ -51,7 +51,7 @@ def announced(self): :return: The announced of this NodePeersResponse. # noqa: E501 - :rtype: list[PeerInfo] + :rtype: list[AnnouncedPeer] """ return self._announced @@ -61,7 +61,7 @@ def announced(self, announced): :param announced: The announced of this NodePeersResponse. # noqa: E501 - :type: list[PeerInfo] + :type: list[AnnouncedPeer] """ if announced is None: raise ValueError("Invalid value for `announced`, must not be `None`") # noqa: E501 From 4e1ed7b55bd235c8a558628b2ad019f099985004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Cs=C3=B3ka?= Date: Fri, 22 Mar 2024 00:26:59 +0100 Subject: [PATCH 2/2] Add schema object --- README.md | 1 + docs/AnnouncedPeer.md | 10 +++ hoprd_sdk/__init__.py | 1 + hoprd_sdk/models/__init__.py | 1 + hoprd_sdk/models/announced_peer.py | 138 +++++++++++++++++++++++++++++ test/test_announced_peer.py | 39 ++++++++ 6 files changed, 190 insertions(+) create mode 100644 docs/AnnouncedPeer.md create mode 100644 hoprd_sdk/models/announced_peer.py create mode 100644 test/test_announced_peer.py diff --git a/README.md b/README.md index e8853c2..5d5784b 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ Class | Method | HTTP request | Description - [AccountAddressesResponse](docs/AccountAddressesResponse.md) - [AccountBalancesResponse](docs/AccountBalancesResponse.md) - [AliasPeerIdBodyRequest](docs/AliasPeerIdBodyRequest.md) + - [AnnouncedPeer](docs/AnnouncedPeer.md) - [ApiError](docs/ApiError.md) - [ChannelInfoResponse](docs/ChannelInfoResponse.md) - [ChannelTicket](docs/ChannelTicket.md) diff --git a/docs/AnnouncedPeer.md b/docs/AnnouncedPeer.md new file mode 100644 index 0000000..bd4cddc --- /dev/null +++ b/docs/AnnouncedPeer.md @@ -0,0 +1,10 @@ +# AnnouncedPeer + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**peer_address** | **str** | | +**peer_id** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/hoprd_sdk/__init__.py b/hoprd_sdk/__init__.py index 0bc7028..61ac796 100644 --- a/hoprd_sdk/__init__.py +++ b/hoprd_sdk/__init__.py @@ -31,6 +31,7 @@ from hoprd_sdk.models.account_addresses_response import AccountAddressesResponse from hoprd_sdk.models.account_balances_response import AccountBalancesResponse from hoprd_sdk.models.alias_peer_id_body_request import AliasPeerIdBodyRequest +from hoprd_sdk.models.announced_peer import AnnouncedPeer from hoprd_sdk.models.api_error import ApiError from hoprd_sdk.models.channel_info_response import ChannelInfoResponse from hoprd_sdk.models.channel_ticket import ChannelTicket diff --git a/hoprd_sdk/models/__init__.py b/hoprd_sdk/models/__init__.py index 51ac1b5..272c59f 100644 --- a/hoprd_sdk/models/__init__.py +++ b/hoprd_sdk/models/__init__.py @@ -17,6 +17,7 @@ from hoprd_sdk.models.account_addresses_response import AccountAddressesResponse from hoprd_sdk.models.account_balances_response import AccountBalancesResponse from hoprd_sdk.models.alias_peer_id_body_request import AliasPeerIdBodyRequest +from hoprd_sdk.models.announced_peer import AnnouncedPeer from hoprd_sdk.models.api_error import ApiError from hoprd_sdk.models.channel_info_response import ChannelInfoResponse from hoprd_sdk.models.channel_ticket import ChannelTicket diff --git a/hoprd_sdk/models/announced_peer.py b/hoprd_sdk/models/announced_peer.py new file mode 100644 index 0000000..6d7345e --- /dev/null +++ b/hoprd_sdk/models/announced_peer.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + hoprd-api + + API server using the hopr-lib created HOPR node and exposing it using a HTTP REST API # noqa: E501 + + OpenAPI spec version: 0.2.1 + Contact: tech@hoprnet.org + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +import pprint +import re # noqa: F401 + +import six + +class AnnouncedPeer(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'peer_address': 'str', + 'peer_id': 'str' + } + + attribute_map = { + 'peer_address': 'peerAddress', + 'peer_id': 'peerId' + } + + def __init__(self, peer_address=None, peer_id=None): # noqa: E501 + """AnnouncedPeer - a model defined in Swagger""" # noqa: E501 + self._peer_address = None + self._peer_id = None + self.discriminator = None + self.peer_address = peer_address + self.peer_id = peer_id + + @property + def peer_address(self): + """Gets the peer_address of this AnnouncedPeer. # noqa: E501 + + + :return: The peer_address of this AnnouncedPeer. # noqa: E501 + :rtype: str + """ + return self._peer_address + + @peer_address.setter + def peer_address(self, peer_address): + """Sets the peer_address of this AnnouncedPeer. + + + :param peer_address: The peer_address of this AnnouncedPeer. # noqa: E501 + :type: str + """ + if peer_address is None: + raise ValueError("Invalid value for `peer_address`, must not be `None`") # noqa: E501 + + self._peer_address = peer_address + + @property + def peer_id(self): + """Gets the peer_id of this AnnouncedPeer. # noqa: E501 + + + :return: The peer_id of this AnnouncedPeer. # noqa: E501 + :rtype: str + """ + return self._peer_id + + @peer_id.setter + def peer_id(self, peer_id): + """Sets the peer_id of this AnnouncedPeer. + + + :param peer_id: The peer_id of this AnnouncedPeer. # noqa: E501 + :type: str + """ + if peer_id is None: + raise ValueError("Invalid value for `peer_id`, must not be `None`") # noqa: E501 + + self._peer_id = peer_id + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(AnnouncedPeer, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, AnnouncedPeer): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/test/test_announced_peer.py b/test/test_announced_peer.py new file mode 100644 index 0000000..b2fe5ca --- /dev/null +++ b/test/test_announced_peer.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + hoprd-api + + API server using the hopr-lib created HOPR node and exposing it using a HTTP REST API # noqa: E501 + + OpenAPI spec version: 0.2.1 + Contact: tech@hoprnet.org + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import + +import unittest + +import hoprd_sdk +from hoprd_sdk.models.announced_peer import AnnouncedPeer # noqa: E501 +from hoprd_sdk.rest import ApiException + + +class TestAnnouncedPeer(unittest.TestCase): + """AnnouncedPeer unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAnnouncedPeer(self): + """Test AnnouncedPeer""" + # FIXME: construct object with mandatory attributes with example values + # model = hoprd_sdk.models.announced_peer.AnnouncedPeer() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main()