Skip to content

bug: EntityGroupId model does not fit api response #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JuliusHarald opened this issue Aug 4, 2022 · 7 comments · Fixed by #72 or #74
Closed

bug: EntityGroupId model does not fit api response #70

JuliusHarald opened this issue Aug 4, 2022 · 7 comments · Fixed by #72 or #74

Comments

@JuliusHarald
Copy link

JuliusHarald commented Aug 4, 2022

Hi,

while working with RestClientPE I used the method get_entity_groups_by_type("DEVICE"), as a result I received a list with this:
AttributeError("module 'tb_rest_client.models.models_ce' has no attribute 'EntityGroupId'")

When I started to look into it with the debugger I discovered, that the error happens in api_client.py in the method def __deserialize(self, data, klass): .

My guess is that the API send back this response:

[
  {
    "id": {
      "entityType": "ENTITY_GROUP",
      "id": "---"
    },
    "createdTime": 1648113081174,
    "type": "DEVICE",
    "name": "All",
    "ownerId": {
      "entityType": "TENANT",
      "id": "---"
    },
    "additionalInfo": null,
    "configuration": {
      "columns": [
        {
          "type": "ENTITY_FIELD",
          "key": "created_time",
          "sortOrder": "DESC"
        },
...

but in the entity_group_id model there is no field entityType only id , so this does not fit and provoke the error

@samson0v
Copy link
Contributor

samson0v commented Aug 5, 2022

Hi @JuliusHarald, what version of the rest client and ThingsBoard you are using?

@JuliusHarald
Copy link
Author

Hi @JuliusHarald, what version of the rest client and ThingsBoard you are using?

Hi @samson0v I am using Version 1.4

@imbeacon
Copy link
Member

imbeacon commented Aug 8, 2022

Hi @JuliusHarald ,

Please try to import EntityGroupId from tb_rest_client.models.models_pe like from tb_rest_client.models.models_pe import EntityGroupId.

@JuliusHarald
Copy link
Author

JuliusHarald commented Aug 9, 2022

Hi @imbeacon ,

I do that, my code is something like this:

            from tb_rest_client import RestClientPE
            from tb_rest_client.models.models_pe import EntityGroupId
           
           ...

           with RestClientPE(base_url=url) as rest_client:
                rest_client.login(username=username, password=password)
                device_group_info_list = rest_client.get_entity_groups_by_type("DEVICE")

and the device_group_info_list that I receive looks like this:
[AttributeError("module 'tb_rest_client.models.models_ce' has no attribute 'EntityGroupId'"), AttributeError("module 'tb_rest_client.models.models_ce' has no attribute 'EntityGroupId'"), AttributeError("module 'tb_rest_client.models.models_ce' has no attribute 'EntityGroupId'")]

@imbeacon
Copy link
Member

imbeacon commented Aug 9, 2022

@JuliusHarald It looks like something wrong in the rest client with deserialisation of the response, we will investigate and fix it.

@samson0v samson0v linked a pull request Aug 9, 2022 that will close this issue
@imbeacon
Copy link
Member

imbeacon commented Aug 9, 2022

@JuliusHarald Please try to use the version from the master branch.

@JuliusHarald
Copy link
Author

JuliusHarald commented Aug 10, 2022

Yes, it is better, I get a result back with the group information.
But unfortunately one of the most important information ofr me is "id" and there I get this message:
'id': TypeError("__init__() got an unexpected keyword argument 'entity_type'"),

Full Output of one group:
{'additional_info': None, 'configuration': {'actions': {}, 'columns': [{'key': 'created_time', 'sortOrder': 'DESC', 'type': 'ENTITY_FIELD'}, {'key': 'name', 'sortOrder': 'NONE', 'type': 'ENTITY_FIELD'}, {'key': 'device_profile', 'sortOrder': 'NONE', 'type': 'ENTITY_FIELD'}, {'key': 'label', 'sortOrder': 'NONE', 'type': 'ENTITY_FIELD'}], 'settings': {}}, 'created_time': 1648113081174, 'edge_group_all': False, 'external_id': None, 'group_all': True, 'id': TypeError("__init__() got an unexpected keyword argument 'entity_type'"), 'name': 'All', 'owner_id': {'entity_type': 'TENANT', 'id': '---'}, 'owner_ids': [{'entity_type': 'TENANT', 'id': '---f'}], 'type': 'DEVICE'},

@imbeacon imbeacon reopened this Aug 10, 2022
@samson0v samson0v linked a pull request Aug 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants