diff --git a/tb_rest_client/api/api_ce/__init__.py b/tb_rest_client/api/api_ce/__init__.py index d35b2ea2..7612bd8a 100644 --- a/tb_rest_client/api/api_ce/__init__.py +++ b/tb_rest_client/api/api_ce/__init__.py @@ -1,47 +1,34 @@ from .o_auth_2_config_template_controller_api import OAuth2ConfigTemplateControllerApi from .asset_controller_api import AssetControllerApi -from .asset_controller_api import AssetControllerApi from .rule_chain_controller_api import RuleChainControllerApi from .auth_controller_api import AuthControllerApi from .event_controller_api import EventControllerApi from .telemetry_controller_api import TelemetryControllerApi from .alarm_controller_api import AlarmControllerApi from .edge_controller_api import EdgeControllerApi -from .edge_controller_api import EdgeControllerApi from .rpc_v_2_controller_api import RpcV2ControllerApi -from .rpc_v_2_controller_api import RpcV2ControllerApi -from .edge_event_controller_api import EdgeEventControllerApi from .edge_event_controller_api import EdgeEventControllerApi from .customer_controller_api import CustomerControllerApi -from .customer_controller_api import CustomerControllerApi -from .user_controller_api import UserControllerApi from .user_controller_api import UserControllerApi from .queue_controller_api import QueueControllerApi from .rpc_v_1_controller_api import RpcV1ControllerApi from .device_controller_api import DeviceControllerApi -from .device_controller_api import DeviceControllerApi from .entity_relation_controller_api import EntityRelationControllerApi from .entity_view_controller_api import EntityViewControllerApi -from .entity_view_controller_api import EntityViewControllerApi -from .admin_controller_api import AdminControllerApi from .admin_controller_api import AdminControllerApi from .sign_up_controller_api import SignUpControllerApi -from .sign_up_controller_api import SignUpControllerApi from .tb_resource_controller_api import TbResourceControllerApi from .o_auth_2_controller_api import OAuth2ControllerApi from .tenant_profile_controller_api import TenantProfileControllerApi from .widgets_bundle_controller_api import WidgetsBundleControllerApi from .device_profile_controller_api import DeviceProfileControllerApi from .dashboard_controller_api import DashboardControllerApi -from .dashboard_controller_api import DashboardControllerApi from .entity_query_controller_api import EntityQueryControllerApi from .widget_type_controller_api import WidgetTypeControllerApi from .audit_log_controller_api import AuditLogControllerApi from .lwm_2m_controller_api import Lwm2mControllerApi -from .lwm_2m_controller_api import Lwm2mControllerApi from .component_descriptor_controller_api import ComponentDescriptorControllerApi from .tenant_controller_api import TenantControllerApi -from .tenant_controller_api import TenantControllerApi from .ota_package_controller_api import OtaPackageControllerApi from .entities_version_control_controller_api import EntitiesVersionControlControllerApi from .device_api_controller_api import DeviceApiControllerApi diff --git a/tb_rest_client/api/api_ce/asset_controller_api.py b/tb_rest_client/api/api_ce/asset_controller_api.py index f99c0b76..7f90c7b0 100644 --- a/tb_rest_client/api/api_ce/asset_controller_api.py +++ b/tb_rest_client/api/api_ce/asset_controller_api.py @@ -1747,7 +1747,7 @@ def process_assets_bulk_import_using_post_with_http_info(self, **kwargs): # noq def save_asset_using_post(self, **kwargs): # noqa: E501 """Create Or Update Asset (saveAsset) # noqa: E501 - Creates or Updates the Asset. When creating asset, platform generates Asset Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Asset id will be present in the response. Specify existing Asset id to update the asset. Referencing non-existing Asset Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. # noqa: E501 + Creates or Updates the Asset. When creating asset, platform generates Asset Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Asset id will be present in the response. Specify existing Asset id to update the asset. Referencing non-existing Asset Id will cause 'Not Found' error. Security check is performed to verify that the user has 'WRITE' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.save_asset_using_post(async_req=True) @@ -1755,6 +1755,7 @@ def save_asset_using_post(self, **kwargs): # noqa: E501 :param async_req bool :param Asset body: + :param str entity_group_id: A string value representing the Entity Group Id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'. If specified, the entity will be added to the corresponding entity group. :return: Asset If the method is called asynchronously, returns the request thread. @@ -1769,7 +1770,7 @@ def save_asset_using_post(self, **kwargs): # noqa: E501 def save_asset_using_post_with_http_info(self, **kwargs): # noqa: E501 """Create Or Update Asset (saveAsset) # noqa: E501 - Creates or Updates the Asset. When creating asset, platform generates Asset Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Asset id will be present in the response. Specify existing Asset id to update the asset. Referencing non-existing Asset Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. # noqa: E501 + Creates or Updates the Asset. When creating asset, platform generates Asset Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Asset id will be present in the response. Specify existing Asset id to update the asset. Referencing non-existing Asset Id will cause 'Not Found' error. Security check is performed to verify that the user has 'WRITE' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.save_asset_using_post_with_http_info(async_req=True) @@ -1777,12 +1778,13 @@ def save_asset_using_post_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool :param Asset body: + :param str entity_group_id: A string value representing the Entity Group Id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'. If specified, the entity will be added to the corresponding entity group. :return: Asset If the method is called asynchronously, returns the request thread. """ - all_params = ['body'] # noqa: E501 + all_params = ['body', 'entity_group_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1803,6 +1805,8 @@ def save_asset_using_post_with_http_info(self, **kwargs): # noqa: E501 path_params = {} query_params = [] + if 'entity_group_id' in params: + query_params.append(('entityGroupId', params['entity_group_id'])) # noqa: E501 header_params = {} @@ -1824,7 +1828,7 @@ def save_asset_using_post_with_http_info(self, **kwargs): # noqa: E501 auth_settings = ['X-Authorization'] # noqa: E501 return self.api_client.call_api( - '/api/asset', 'POST', + '/api/asset{?entityGroupId}', 'POST', path_params, query_params, header_params, diff --git a/tb_rest_client/api/api_ce/customer_controller_api.py b/tb_rest_client/api/api_ce/customer_controller_api.py index af4bb2d5..fa34bbfc 100644 --- a/tb_rest_client/api/api_ce/customer_controller_api.py +++ b/tb_rest_client/api/api_ce/customer_controller_api.py @@ -225,7 +225,7 @@ def get_customer_by_id_using_get_with_http_info(self, customer_id, **kwargs): # def get_customer_title_by_id_using_get(self, customer_id, **kwargs): # noqa: E501 """Get Customer Title (getCustomerTitleById) # noqa: E501 - Get the title of the customer. If the user has the authority of 'Tenant Administrator', the server checks that the customer is owned by the same tenant. If the user has the authority of 'Customer User', the server checks that the user belongs to the customer. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. # noqa: E501 + Get the title of the customer. If the user has the authority of 'Tenant Administrator', the server checks that the customer is owned by the same tenant. If the user has the authority of 'Customer User', the server checks that the user belongs to the customer. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. Security check is performed to verify that the user has 'READ' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_customer_title_by_id_using_get(customer_id, async_req=True) @@ -247,7 +247,7 @@ def get_customer_title_by_id_using_get(self, customer_id, **kwargs): # noqa: E5 def get_customer_title_by_id_using_get_with_http_info(self, customer_id, **kwargs): # noqa: E501 """Get Customer Title (getCustomerTitleById) # noqa: E501 - Get the title of the customer. If the user has the authority of 'Tenant Administrator', the server checks that the customer is owned by the same tenant. If the user has the authority of 'Customer User', the server checks that the user belongs to the customer. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. # noqa: E501 + Get the title of the customer. If the user has the authority of 'Tenant Administrator', the server checks that the customer is owned by the same tenant. If the user has the authority of 'Customer User', the server checks that the user belongs to the customer. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. Security check is performed to verify that the user has 'READ' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_customer_title_by_id_using_get_with_http_info(customer_id, async_req=True) @@ -278,7 +278,8 @@ def get_customer_title_by_id_using_get_with_http_info(self, customer_id, **kwarg # verify the required parameter 'customer_id' is set if ('customer_id' not in params or params['customer_id'] is None): - raise ValueError("Missing the required parameter `customer_id` when calling `get_customer_title_by_id_using_get`") # noqa: E501 + raise ValueError( + "Missing the required parameter `customer_id` when calling `get_customer_title_by_id_using_get`") # noqa: E501 collection_formats = {} @@ -625,7 +626,7 @@ def get_tenant_customer_using_get_with_http_info(self, customer_title, **kwargs) def save_customer_using_post(self, **kwargs): # noqa: E501 """Create or update Customer (saveCustomer) # noqa: E501 - Creates or Updates the Customer. When creating customer, platform generates Customer Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Customer Id will be present in the response. Specify existing Customer Id to update the Customer. Referencing non-existing Customer Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' authority. # noqa: E501 + Creates or Updates the Customer. When creating customer, platform generates Customer Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Customer Id will be present in the response. Specify existing Customer Id to update the Customer. Referencing non-existing Customer Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. Security check is performed to verify that the user has 'WRITE' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.save_customer_using_post(async_req=True) @@ -633,6 +634,7 @@ def save_customer_using_post(self, **kwargs): # noqa: E501 :param async_req bool :param Customer body: + :param str entity_group_id: A string value representing the Entity Group Id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'. If specified, the entity will be added to the corresponding entity group. :return: Customer If the method is called asynchronously, returns the request thread. @@ -647,7 +649,7 @@ def save_customer_using_post(self, **kwargs): # noqa: E501 def save_customer_using_post_with_http_info(self, **kwargs): # noqa: E501 """Create or update Customer (saveCustomer) # noqa: E501 - Creates or Updates the Customer. When creating customer, platform generates Customer Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Customer Id will be present in the response. Specify existing Customer Id to update the Customer. Referencing non-existing Customer Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' authority. # noqa: E501 + Creates or Updates the Customer. When creating customer, platform generates Customer Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Customer Id will be present in the response. Specify existing Customer Id to update the Customer. Referencing non-existing Customer Id will cause 'Not Found' error. Available for users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority. Security check is performed to verify that the user has 'WRITE' permission for the entity (entities). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.save_customer_using_post_with_http_info(async_req=True) @@ -655,12 +657,13 @@ def save_customer_using_post_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool :param Customer body: + :param str entity_group_id: A string value representing the Entity Group Id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'. If specified, the entity will be added to the corresponding entity group. :return: Customer If the method is called asynchronously, returns the request thread. """ - all_params = ['body'] # noqa: E501 + all_params = ['body', 'entity_group_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -681,6 +684,8 @@ def save_customer_using_post_with_http_info(self, **kwargs): # noqa: E501 path_params = {} query_params = [] + if 'entity_group_id' in params: + query_params.append(('entityGroupId', params['entity_group_id'])) # noqa: E501 header_params = {} @@ -699,10 +704,10 @@ def save_customer_using_post_with_http_info(self, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['X-Authorization'] # noqa: E501 + auth_settings = ['HTTP login form'] # noqa: E501 return self.api_client.call_api( - '/api/customer', 'POST', + '/api/customer{?entityGroupId}', 'POST', path_params, query_params, header_params, diff --git a/tb_rest_client/api/api_ce/telemetry_controller_api.py b/tb_rest_client/api/api_ce/telemetry_controller_api.py index 0bf8307a..bbd93d8a 100644 --- a/tb_rest_client/api/api_ce/telemetry_controller_api.py +++ b/tb_rest_client/api/api_ce/telemetry_controller_api.py @@ -1667,7 +1667,7 @@ def save_entity_telemetry_with_ttl_using_post(self, entity_type, entity_id, scop :param str entity_type: A string value representing the entity type. For example, 'DEVICE' (required) :param str entity_id: A string value representing the entity id. For example, '784f394c-42b6-435a-983c-b7beff2784f9' (required) :param str scope: Value is deprecated, reserved for backward compatibility and not used in the API call implementation. Specify any scope for compatibility (required) - :param int ttl: A long value representing TTL (Time to Live) parameter. (required) + :param str ttl: A long value representing TTL (Time to Live) parameter. (required) :param str body: :return: DeferredResultResponseEntity If the method is called asynchronously, diff --git a/tb_rest_client/api/api_pe/__init__.py b/tb_rest_client/api/api_pe/__init__.py index fdb7d803..6cc5cca8 100644 --- a/tb_rest_client/api/api_pe/__init__.py +++ b/tb_rest_client/api/api_pe/__init__.py @@ -1,54 +1,40 @@ from .self_registration_controller_api import SelfRegistrationControllerApi from .http_integration_controller_api import HttpIntegrationControllerApi from .asset_controller_api import AssetControllerApi -from .asset_controller_api import AssetControllerApi from .device_group_ota_package_controller_api import DeviceGroupOtaPackageControllerApi from .edge_controller_api import EdgeControllerApi -from .edge_controller_api import EdgeControllerApi from .ocean_connect_integration_controller_api import OceanConnectIntegrationControllerApi from .user_permissions_controller_api import UserPermissionsControllerApi from .owner_controller_api import OwnerControllerApi from .rpc_v_2_controller_api import RpcV2ControllerApi -from .rpc_v_2_controller_api import RpcV2ControllerApi -from .edge_event_controller_api import EdgeEventControllerApi from .edge_event_controller_api import EdgeEventControllerApi from .customer_controller_api import CustomerControllerApi -from .customer_controller_api import CustomerControllerApi -from .user_controller_api import UserControllerApi from .user_controller_api import UserControllerApi from .group_permission_controller_api import GroupPermissionControllerApi from .device_controller_api import DeviceControllerApi -from .device_controller_api import DeviceControllerApi from .converter_controller_api import ConverterControllerApi from .entity_view_controller_api import EntityViewControllerApi -from .entity_view_controller_api import EntityViewControllerApi from .rule_engine_controller_api import RuleEngineControllerApi from .admin_controller_api import AdminControllerApi -from .admin_controller_api import AdminControllerApi from .t_mobile_iot_cdp_integration_controller_api import TMobileIotCdpIntegrationControllerApi from .sign_up_controller_api import SignUpControllerApi -from .sign_up_controller_api import SignUpControllerApi from .trail_controller_api import TrailControllerApi from .thing_park_integration_controller_api import ThingParkIntegrationControllerApi from .sig_fox_integration_controller_api import SigFoxIntegrationControllerApi from .scheduler_event_controller_api import SchedulerEventControllerApi from .report_controller_api import ReportControllerApi from .dashboard_controller_api import DashboardControllerApi -from .dashboard_controller_api import DashboardControllerApi from .integration_controller_api import IntegrationControllerApi from .custom_menu_controller_api import CustomMenuControllerApi from .lwm_2m_controller_api import Lwm2mControllerApi -from .lwm_2m_controller_api import Lwm2mControllerApi from .custom_translation_controller_api import CustomTranslationControllerApi from .role_controller_api import RoleControllerApi from .blob_entity_controller_api import BlobEntityControllerApi from .loriot_integration_controller_api import LoriotIntegrationControllerApi from .tenant_controller_api import TenantControllerApi -from .tenant_controller_api import TenantControllerApi from .chirp_stack_integration_controller_api import ChirpStackIntegrationControllerApi from .white_labeling_controller_api import WhiteLabelingControllerApi from .ota_package_controller_api import OtaPackageControllerApi -from .ota_package_controller_api import OtaPackageControllerApi from .entity_group_controller_api import EntityGroupControllerApi from .subscription_controller_api import SubscriptionControllerApi from .solution_controller_api import SolutionControllerApi diff --git a/tb_rest_client/api/api_pe/converter_controller_api.py b/tb_rest_client/api/api_pe/converter_controller_api.py index 5395b606..d07ca262 100644 --- a/tb_rest_client/api/api_pe/converter_controller_api.py +++ b/tb_rest_client/api/api_pe/converter_controller_api.py @@ -329,6 +329,7 @@ def get_converters_using_get(self, page_size, page, **kwargs): # noqa: E501 :param async_req bool :param int page_size: Maximum amount of entities in a one page (required) :param int page: Sequence number of page starting from 0 (required) + :param bool is_edge_template: Fetch edge template converters :param str text_search: The case insensitive 'startsWith' filter based on the converter name. :param str sort_property: Property of entity to sort by :param str sort_order: Sort order. ASC (ASCENDING) or DESC (DESCENDING) @@ -355,6 +356,7 @@ def get_converters_using_get_with_http_info(self, page_size, page, **kwargs): # :param async_req bool :param int page_size: Maximum amount of entities in a one page (required) :param int page: Sequence number of page starting from 0 (required) + :param bool is_edge_template: Fetch edge template converters :param str text_search: The case insensitive 'startsWith' filter based on the converter name. :param str sort_property: Property of entity to sort by :param str sort_order: Sort order. ASC (ASCENDING) or DESC (DESCENDING) @@ -363,7 +365,7 @@ def get_converters_using_get_with_http_info(self, page_size, page, **kwargs): # returns the request thread. """ - all_params = ['page_size', 'page', 'text_search', 'sort_property', 'sort_order'] # noqa: E501 + all_params = ['page_size', 'page', 'is_edge_template', 'text_search', 'sort_property', 'sort_order'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -392,6 +394,8 @@ def get_converters_using_get_with_http_info(self, page_size, page, **kwargs): # path_params = {} query_params = [] + if 'is_edge_template' in params: + query_params.append(('isEdgeTemplate', params['is_edge_template'])) # noqa: E501 if 'page_size' in params: query_params.append(('pageSize', params['page_size'])) # noqa: E501 if 'page' in params: @@ -417,7 +421,7 @@ def get_converters_using_get_with_http_info(self, page_size, page, **kwargs): # auth_settings = ['X-Authorization'] # noqa: E501 return self.api_client.call_api( - '/api/converters{?page,pageSize,sortOrder,sortProperty,textSearch}', 'GET', + '/api/converters{?isEdgeTemplate,page,pageSize,sortOrder,sortProperty,textSearch}', 'GET', path_params, query_params, header_params, diff --git a/tb_rest_client/api/api_pe/customer_controller_api.py b/tb_rest_client/api/api_pe/customer_controller_api.py index ceb3c4b4..03e96d84 100644 --- a/tb_rest_client/api/api_pe/customer_controller_api.py +++ b/tb_rest_client/api/api_pe/customer_controller_api.py @@ -296,7 +296,7 @@ def get_customer_title_by_id_using_get_with_http_info(self, customer_id, **kwarg body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['application/text', 'application/json']) # noqa: E501 + ['application/text']) # noqa: E501 # Authentication setting auth_settings = ['X-Authorization'] # noqa: E501 diff --git a/tb_rest_client/models/models_pe/allowed_permissions_info.py b/tb_rest_client/models/models_pe/allowed_permissions_info.py index 15fe4206..0f7a70fa 100644 --- a/tb_rest_client/models/models_pe/allowed_permissions_info.py +++ b/tb_rest_client/models/models_pe/allowed_permissions_info.py @@ -134,7 +134,7 @@ def allowed_resources(self, allowed_resources): :param allowed_resources: The allowed_resources of this AllowedPermissionsInfo. # noqa: E501 :type: list[str] """ - allowed_values = ["ADMIN_SETTINGS", "ALARM", "ALL", "API_USAGE_STATE", "ASSET", "ASSET_GROUP", "AUDIT_LOG", "BLOB_ENTITY", "CONVERTER", "CUSTOMER", "CUSTOMER_GROUP", "DASHBOARD", "DASHBOARD_GROUP", "DEVICE", "DEVICE_GROUP", "DEVICE_PROFILE", "EDGE", "EDGE_GROUP", "ENTITY_VIEW", "ENTITY_VIEW_GROUP", "GROUP_PERMISSION", "INTEGRATION", "OAUTH2_CONFIGURATION_INFO", "OAUTH2_CONFIGURATION_TEMPLATE", "OTA_PACKAGE", "PROFILE", "QUEUE", "ROLE", "RULE_CHAIN", "SCHEDULER_EVENT", "TB_RESOURCE", "TENANT", "TENANT_PROFILE", "USER", "USER_GROUP", "VERSION_CONTROL", "WHITE_LABELING", "WIDGETS_BUNDLE", "WIDGET_TYPE"] # noqa: E501 + allowed_values = ["BILLING", "ADMIN_SETTINGS", "ALARM", "ALL", "API_USAGE_STATE", "ASSET", "ASSET_GROUP", "AUDIT_LOG", "BLOB_ENTITY", "CONVERTER", "CUSTOMER", "CUSTOMER_GROUP", "DASHBOARD", "DASHBOARD_GROUP", "DEVICE", "DEVICE_GROUP", "DEVICE_PROFILE", "EDGE", "EDGE_GROUP", "ENTITY_VIEW", "ENTITY_VIEW_GROUP", "GROUP_PERMISSION", "INTEGRATION", "OAUTH2_CONFIGURATION_INFO", "OAUTH2_CONFIGURATION_TEMPLATE", "OTA_PACKAGE", "PROFILE", "QUEUE", "ROLE", "RULE_CHAIN", "SCHEDULER_EVENT", "TB_RESOURCE", "TENANT", "TENANT_PROFILE", "USER", "USER_GROUP", "VERSION_CONTROL", "WHITE_LABELING", "WIDGETS_BUNDLE", "WIDGET_TYPE"] # noqa: E501 if not set(allowed_resources).issubset(set(allowed_values)): raise ValueError( "Invalid values for `allowed_resources` [{0}], must be a subset of [{1}]" # noqa: E501 diff --git a/tb_rest_client/models/models_pe/asset.py b/tb_rest_client/models/models_pe/asset.py index 9dafc477..58cf5751 100644 --- a/tb_rest_client/models/models_pe/asset.py +++ b/tb_rest_client/models/models_pe/asset.py @@ -15,9 +15,10 @@ import six + class Asset(object): """NOTE: This class is auto generated by the swagger code generator program. -from tb_rest_client.api_client import ApiClient + from tb_rest_client.api_client import ApiClient Do not edit the class manually. """ """ @@ -53,7 +54,8 @@ class Asset(object): 'owner_id': 'ownerId' } - def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, customer_id=None, name=None, type=None, label=None, additional_info=None, owner_id=None): # noqa: E501 + def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, customer_id=None, name=None, + type=None, label=None, additional_info=None, owner_id=None): # noqa: E501 """Asset - a model defined in Swagger""" # noqa: E501 self._external_id = None self._id = None diff --git a/tb_rest_client/models/models_pe/contact_basedobject.py b/tb_rest_client/models/models_pe/contact_basedobject.py index dc7b5e7b..f271f5d9 100644 --- a/tb_rest_client/models/models_pe/contact_basedobject.py +++ b/tb_rest_client/models/models_pe/contact_basedobject.py @@ -15,6 +15,7 @@ import six + class ContactBasedobject(object): """NOTE: This class is auto generated by the swagger code generator program. from tb_rest_client.api_client import ApiClient @@ -28,21 +29,28 @@ class ContactBasedobject(object): and the value is json key in definition. """ swagger_types = { + 'active': 'bool', 'additional_info': 'JsonNode', 'address': 'str', 'address2': 'str', 'city': 'str', 'country': 'str', 'created_time': 'int', + 'current_period_start_ts': 'int', 'email': 'str', 'id': 'object', + 'last_inactive_ts': 'int', 'name': 'str', 'phone': 'str', + 'region': 'str', 'state': 'str', - 'zip': 'str' + 'tenant_profile_id': 'TenantProfileId', + 'zip': 'str', + 'title': 'str', } attribute_map = { + 'active': 'active', 'additional_info': 'additionalInfo', 'address': 'address', 'address2': 'address2', @@ -54,10 +62,17 @@ class ContactBasedobject(object): 'name': 'name', 'phone': 'phone', 'state': 'state', - 'zip': 'zip' + 'zip': 'zip', + 'title': 'title', + 'current_period_start_ts': 'currentPeriodStartTs', + 'last_inactive_ts': 'lastInactiveTs', + 'region': 'region', + 'tenant_profile_id': 'tenantProfileId' } - def __init__(self, additional_info=None, address=None, address2=None, city=None, country=None, created_time=None, email=None, id=None, name=None, phone=None, state=None, zip=None): # noqa: E501 + def __init__(self, additional_info=None, address=None, address2=None, city=None, country=None, created_time=None, + email=None, id=None, name=None, phone=None, state=None, zip=None, title=None, active=None, + current_period_start_ts=None, last_inactive_ts=None, region=None, tenant_profile_id=None): # noqa: E501 """ContactBasedobject - a model defined in Swagger""" # noqa: E501 self._additional_info = None self._address = None @@ -72,6 +87,13 @@ def __init__(self, additional_info=None, address=None, address2=None, city=None, self._state = None self._zip = None self.discriminator = None + self._title = title + self.active = active + self.current_period_start_ts = current_period_start_ts + self.last_inactive_ts = last_inactive_ts + self.region = region + self.tenant_profile_id = tenant_profile_id + if additional_info is not None: self.additional_info = additional_info if address is not None: @@ -97,6 +119,10 @@ def __init__(self, additional_info=None, address=None, address2=None, city=None, if zip is not None: self.zip = zip + @property + def title(self): + return self._title + @property def additional_info(self): """Gets the additional_info of this ContactBasedobject. # noqa: E501 diff --git a/tb_rest_client/models/models_pe/customer.py b/tb_rest_client/models/models_pe/customer.py index bb621c13..c28a368f 100644 --- a/tb_rest_client/models/models_pe/customer.py +++ b/tb_rest_client/models/models_pe/customer.py @@ -247,8 +247,6 @@ def tenant_id(self, tenant_id): :param tenant_id: The tenant_id of this Customer. # noqa: E501 :type: TenantId """ - if tenant_id is None: - raise ValueError("Invalid value for `tenant_id`, must not be `None`") # noqa: E501 self._tenant_id = tenant_id @@ -335,8 +333,6 @@ def country(self, country): :param country: The country of this Customer. # noqa: E501 :type: str """ - if country is None: - raise ValueError("Invalid value for `country`, must not be `None`") # noqa: E501 self._country = country @@ -360,8 +356,6 @@ def state(self, state): :param state: The state of this Customer. # noqa: E501 :type: str """ - if state is None: - raise ValueError("Invalid value for `state`, must not be `None`") # noqa: E501 self._state = state @@ -385,8 +379,6 @@ def city(self, city): :param city: The city of this Customer. # noqa: E501 :type: str """ - if city is None: - raise ValueError("Invalid value for `city`, must not be `None`") # noqa: E501 self._city = city @@ -410,8 +402,6 @@ def address(self, address): :param address: The address of this Customer. # noqa: E501 :type: str """ - if address is None: - raise ValueError("Invalid value for `address`, must not be `None`") # noqa: E501 self._address = address @@ -435,8 +425,6 @@ def address2(self, address2): :param address2: The address2 of this Customer. # noqa: E501 :type: str """ - if address2 is None: - raise ValueError("Invalid value for `address2`, must not be `None`") # noqa: E501 self._address2 = address2 @@ -460,8 +448,6 @@ def zip(self, zip): :param zip: The zip of this Customer. # noqa: E501 :type: str """ - if zip is None: - raise ValueError("Invalid value for `zip`, must not be `None`") # noqa: E501 self._zip = zip @@ -485,8 +471,6 @@ def phone(self, phone): :param phone: The phone of this Customer. # noqa: E501 :type: str """ - if phone is None: - raise ValueError("Invalid value for `phone`, must not be `None`") # noqa: E501 self._phone = phone @@ -510,8 +494,6 @@ def email(self, email): :param email: The email of this Customer. # noqa: E501 :type: str """ - if email is None: - raise ValueError("Invalid value for `email`, must not be `None`") # noqa: E501 self._email = email diff --git a/tb_rest_client/models/models_pe/dashboard.py b/tb_rest_client/models/models_pe/dashboard.py index de6042f6..5b5675e5 100644 --- a/tb_rest_client/models/models_pe/dashboard.py +++ b/tb_rest_client/models/models_pe/dashboard.py @@ -39,7 +39,8 @@ class Dashboard(object): 'mobile_hide': 'bool', 'mobile_order': 'int', 'name': 'str', - 'configuration': 'JsonNode' + 'configuration': 'JsonNode', + 'id': 'DashboardId' } attribute_map = { @@ -54,10 +55,11 @@ class Dashboard(object): 'mobile_hide': 'mobileHide', 'mobile_order': 'mobileOrder', 'name': 'name', - 'configuration': 'configuration' + 'configuration': 'configuration', + 'id': 'id' } - def __init__(self, external_id=None, created_time=None, tenant_id=None, customer_id=None, owner_id=None, title=None, image=None, assigned_customers=None, mobile_hide=None, mobile_order=None, name=None, configuration=None): # noqa: E501 + def __init__(self, external_id=None, created_time=None, tenant_id=None, customer_id=None, owner_id=None, title=None, image=None, assigned_customers=None, mobile_hide=None, mobile_order=None, name=None, configuration=None, id=None): # noqa: E501 """Dashboard - a model defined in Swagger""" # noqa: E501 self._external_id = None self._created_time = None @@ -71,6 +73,7 @@ def __init__(self, external_id=None, created_time=None, tenant_id=None, customer self._mobile_order = None self._name = None self._configuration = None + self.id = id self.discriminator = None if external_id is not None: self.external_id = external_id diff --git a/tb_rest_client/models/models_pe/device_credentials.py b/tb_rest_client/models/models_pe/device_credentials.py index fd52fdec..76ba2e9e 100644 --- a/tb_rest_client/models/models_pe/device_credentials.py +++ b/tb_rest_client/models/models_pe/device_credentials.py @@ -82,8 +82,8 @@ def id(self, id): :param id: The id of this DeviceCredentials. # noqa: E501 :type: DeviceCredentialsId """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 + # if id is None: + # raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -128,8 +128,8 @@ def device_id(self, device_id): :param device_id: The device_id of this DeviceCredentials. # noqa: E501 :type: DeviceId """ - if device_id is None: - raise ValueError("Invalid value for `device_id`, must not be `None`") # noqa: E501 + # if device_id is None: + # raise ValueError("Invalid value for `device_id`, must not be `None`") # noqa: E501 self._device_id = device_id diff --git a/tb_rest_client/models/models_pe/device_credentials_id.py b/tb_rest_client/models/models_pe/device_credentials_id.py index d831e6ad..86896fbd 100644 --- a/tb_rest_client/models/models_pe/device_credentials_id.py +++ b/tb_rest_client/models/models_pe/device_credentials_id.py @@ -29,12 +29,10 @@ class DeviceCredentialsId(object): """ swagger_types = { 'id': 'str', - 'entity_type': 'str' } attribute_map = { 'id': 'id', - 'entity_type': 'entityType' } def __init__(self, id=None): # noqa: E501 diff --git a/tb_rest_client/models/models_pe/device_profile.py b/tb_rest_client/models/models_pe/device_profile.py index 5deaf620..7654bd67 100644 --- a/tb_rest_client/models/models_pe/device_profile.py +++ b/tb_rest_client/models/models_pe/device_profile.py @@ -36,7 +36,7 @@ class DeviceProfile(object): 'default': 'bool', 'default_dashboard_id': 'DashboardId', 'default_rule_chain_id': 'RuleChainId', - 'default_queue_id': 'QueueId', + 'default_queue_name': 'str', 'firmware_id': 'OtaPackageId', 'software_id': 'OtaPackageId', 'description': 'str', @@ -57,7 +57,7 @@ class DeviceProfile(object): 'default': 'default', 'default_dashboard_id': 'defaultDashboardId', 'default_rule_chain_id': 'defaultRuleChainId', - 'default_queue_id': 'defaultQueueId', + 'default_queue_name': 'defaultQueueName', 'firmware_id': 'firmwareId', 'software_id': 'softwareId', 'description': 'description', @@ -69,7 +69,7 @@ class DeviceProfile(object): 'type': 'type' } - def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, name=None, default=None, default_dashboard_id=None, default_rule_chain_id=None, default_queue_id=None, firmware_id=None, software_id=None, description=None, image=None, provision_device_key=None, transport_type=None, provision_type=None, profile_data=None, type=None): # noqa: E501 + def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, name=None, default=None, default_dashboard_id=None, default_rule_chain_id=None, default_queue_name=None, firmware_id=None, software_id=None, description=None, image=None, provision_device_key=None, transport_type=None, provision_type=None, profile_data=None, type=None): # noqa: E501 """DeviceProfile - a model defined in Swagger""" # noqa: E501 self._external_id = None self._id = None @@ -79,7 +79,7 @@ def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, self._default = None self._default_dashboard_id = None self._default_rule_chain_id = None - self._default_queue_id = None + self._default_queue_name = None self._firmware_id = None self._software_id = None self._description = None @@ -106,8 +106,8 @@ def __init__(self, external_id=None, id=None, created_time=None, tenant_id=None, self.default_dashboard_id = default_dashboard_id if default_rule_chain_id is not None: self.default_rule_chain_id = default_rule_chain_id - if default_queue_id is not None: - self.default_queue_id = default_queue_id + if default_queue_name is not None: + self._default_queue_name = default_queue_name if firmware_id is not None: self.firmware_id = firmware_id if software_id is not None: @@ -302,25 +302,25 @@ def default_rule_chain_id(self, default_rule_chain_id): self._default_rule_chain_id = default_rule_chain_id @property - def default_queue_id(self): - """Gets the default_queue_id of this DeviceProfile. # noqa: E501 + def default_queue_name(self): + """Gets the default_queue_name of this DeviceProfile. # noqa: E501 - :return: The default_queue_id of this DeviceProfile. # noqa: E501 + :return: The default_queue_name of this DeviceProfile. # noqa: E501 :rtype: QueueId """ - return self._default_queue_id + return self._default_queue_name - @default_queue_id.setter - def default_queue_id(self, default_queue_id): - """Sets the default_queue_id of this DeviceProfile. + @default_queue_name.setter + def default_queue_name(self, default_queue_name): + """Sets the default_queue_name of this DeviceProfile. - :param default_queue_id: The default_queue_id of this DeviceProfile. # noqa: E501 + :param default_queue_name: The default_queue_name of this DeviceProfile. # noqa: E501 :type: QueueId """ - self._default_queue_id = default_queue_id + self._default_queue_name = default_queue_name @property def firmware_id(self): diff --git a/tb_rest_client/models/models_pe/home_dashboard.py b/tb_rest_client/models/models_pe/home_dashboard.py index 6d118d13..640f56c1 100644 --- a/tb_rest_client/models/models_pe/home_dashboard.py +++ b/tb_rest_client/models/models_pe/home_dashboard.py @@ -40,7 +40,8 @@ class HomeDashboard(object): 'mobile_order': 'int', 'name': 'str', 'configuration': 'JsonNode', - 'hide_dashboard_toolbar': 'bool' + 'hide_dashboard_toolbar': 'bool', + 'id': 'DashboardId' } attribute_map = { @@ -56,10 +57,11 @@ class HomeDashboard(object): 'mobile_order': 'mobileOrder', 'name': 'name', 'configuration': 'configuration', - 'hide_dashboard_toolbar': 'hideDashboardToolbar' + 'hide_dashboard_toolbar': 'hideDashboardToolbar', + 'id': 'id' } - def __init__(self, external_id=None, created_time=None, tenant_id=None, customer_id=None, owner_id=None, title=None, image=None, assigned_customers=None, mobile_hide=None, mobile_order=None, name=None, configuration=None, hide_dashboard_toolbar=None): # noqa: E501 + def __init__(self, external_id=None, created_time=None, tenant_id=None, customer_id=None, owner_id=None, title=None, image=None, assigned_customers=None, mobile_hide=None, mobile_order=None, name=None, configuration=None, hide_dashboard_toolbar=None, id=None): # noqa: E501 """HomeDashboard - a model defined in Swagger""" # noqa: E501 self._external_id = None self._created_time = None @@ -74,6 +76,7 @@ def __init__(self, external_id=None, created_time=None, tenant_id=None, customer self._name = None self._configuration = None self._hide_dashboard_toolbar = None + self.id = id self.discriminator = None if external_id is not None: self.external_id = external_id diff --git a/tb_rest_client/models/models_pe/role.py b/tb_rest_client/models/models_pe/role.py index bfd83d43..604bb92a 100644 --- a/tb_rest_client/models/models_pe/role.py +++ b/tb_rest_client/models/models_pe/role.py @@ -167,8 +167,6 @@ def tenant_id(self, tenant_id): :param tenant_id: The tenant_id of this Role. # noqa: E501 :type: TenantId """ - if tenant_id is None: - raise ValueError("Invalid value for `tenant_id`, must not be `None`") # noqa: E501 self._tenant_id = tenant_id diff --git a/tb_rest_client/models/models_pe/short_entity_view.py b/tb_rest_client/models/models_pe/short_entity_view.py index 3ba8d3a4..0c429a95 100644 --- a/tb_rest_client/models/models_pe/short_entity_view.py +++ b/tb_rest_client/models/models_pe/short_entity_view.py @@ -29,21 +29,27 @@ class ShortEntityView(object): """ swagger_types = { 'id': 'EntityId', - 'name': 'str' + 'name': 'str', + 'created_time': 'int', + 'device_profile': 'DeviceProfile' } attribute_map = { 'id': 'id', - 'name': 'name' + 'name': 'name', + 'created_time': 'createdTime', + 'device_profile': 'deviceProfile' } - def __init__(self, id=None, name=None): # noqa: E501 + def __init__(self, id=None, name=None, created_time=None, device_profile=None): # noqa: E501 """ShortEntityView - a model defined in Swagger""" # noqa: E501 self._id = None self._name = None self.discriminator = None self.id = id self.name = name + self.created_time = created_time + self.device_profile = device_profile @property def id(self): diff --git a/tb_rest_client/models/models_pe/tenant.py b/tb_rest_client/models/models_pe/tenant.py index affbf569..6dd58715 100644 --- a/tb_rest_client/models/models_pe/tenant.py +++ b/tb_rest_client/models/models_pe/tenant.py @@ -359,8 +359,8 @@ def address2(self, address2): :param address2: The address2 of this Tenant. # noqa: E501 :type: str """ - if address2 is None: - raise ValueError("Invalid value for `address2`, must not be `None`") # noqa: E501 + # if address2 is None: + # raise ValueError("Invalid value for `address2`, must not be `None`") # noqa: E501 self._address2 = address2 @@ -384,8 +384,8 @@ def zip(self, zip): :param zip: The zip of this Tenant. # noqa: E501 :type: str """ - if zip is None: - raise ValueError("Invalid value for `zip`, must not be `None`") # noqa: E501 + # if zip is None: + # raise ValueError("Invalid value for `zip`, must not be `None`") # noqa: E501 self._zip = zip @@ -409,8 +409,8 @@ def phone(self, phone): :param phone: The phone of this Tenant. # noqa: E501 :type: str """ - if phone is None: - raise ValueError("Invalid value for `phone`, must not be `None`") # noqa: E501 + # if phone is None: + # raise ValueError("Invalid value for `phone`, must not be `None`") # noqa: E501 self._phone = phone @@ -434,8 +434,8 @@ def email(self, email): :param email: The email of this Tenant. # noqa: E501 :type: str """ - if email is None: - raise ValueError("Invalid value for `email`, must not be `None`") # noqa: E501 + # if email is None: + # raise ValueError("Invalid value for `email`, must not be `None`") # noqa: E501 self._email = email diff --git a/tb_rest_client/rest_client_base.py b/tb_rest_client/rest_client_base.py index 3289203f..d144393a 100644 --- a/tb_rest_client/rest_client_base.py +++ b/tb_rest_client/rest_client_base.py @@ -443,19 +443,19 @@ def save_entity_attributes_v2(self, entity_id: EntityId, scope: str, body=body) def save_entity_telemetry(self, entity_id: EntityId, scope: str, - body: Optional[str] = None): + body: Optional[dict] = None): entity_type = self.get_type(entity_id) entity_id = self.get_id(entity_id) return self.telemetry_controller.save_entity_telemetry_using_post(entity_type=entity_type, entity_id=entity_id, scope=scope, body=body) def save_entity_telemetry_with_ttl(self, entity_id: EntityId, scope: str, ttl: int, - body: Optional[str] = None): + body: Optional[dict] = None): entity_type = self.get_type(entity_id) entity_id = self.get_id(entity_id) return self.telemetry_controller.save_entity_telemetry_with_ttl_using_post(entity_type=entity_type, entity_id=entity_id, scope=scope, - ttl=ttl, body=body) + ttl=str(ttl), body=body) def get_attributes(self, entity_id: EntityId, keys: Optional[str] = None): entity_type = self.get_type(entity_id) @@ -797,9 +797,12 @@ def delete_relations(self, entity_id: EntityId) -> None: return self.entity_relation_controller.delete_relations_using_delete(entity_id=entity_id, entity_type=entity_type) - def delete_relation(self, from_id: EntityId, from_type: str, relation_type: str, to_id: EntityId, to_type: str, + def delete_relation(self, from_id: EntityId, relation_type: str, to_id: EntityId, relation_type_group: Optional[str] = None) -> None: + from_type = self.get_type(from_id) from_id = self.get_id(from_id) + + to_type = self.get_type(to_id) to_id = self.get_id(to_id) return self.entity_relation_controller.delete_relation_using_delete(from_id=from_id, from_type=from_type, relation_type=relation_type, to_id=to_id, @@ -815,22 +818,27 @@ def find_by_query_v3(self, body: Optional[EntityRelationsQuery] = None) -> List[ def save_relation(self, body: Optional[EntityRelation] = None) -> None: return self.entity_relation_controller.save_relation_using_post(body=body) - def find_by_to(self, to_id: EntityId, to_type: str, relation_type: str, relation_type_group: Optional[str] = None) -> List[ + def find_by_to(self, to_id: EntityId, relation_type: str, relation_type_group: Optional[str] = None) -> List[ EntityRelation]: + to_type = self.get_type(to_id) to_id = self.get_id(to_id) return self.entity_relation_controller.find_by_to_using_get(to_id=to_id, to_type=to_type, relation_type=relation_type, relation_type_group=relation_type_group) - def find_info_by_from(self, from_id: EntityId, from_type: str, + def find_info_by_from(self, from_id: EntityId, relation_type_group: Optional[str] = None) -> List[EntityRelationInfo]: + from_type = self.get_type(from_id) from_id = self.get_id(from_id) return self.entity_relation_controller.find_info_by_from_using_get(from_id=from_id, from_type=from_type, relation_type_group=relation_type_group) - def get_relation(self, from_id: EntityId, from_type: str, relation_type: str, to_id: EntityId, to_type: str, + def get_relation(self, from_id: EntityId, relation_type: str, to_id: EntityId, relation_type_group: Optional[str] = None) -> EntityRelation: + from_type = self.get_type(from_id) from_id = self.get_id(from_id) + + to_type = self.get_type(to_id) to_id = self.get_id(to_id) return self.entity_relation_controller.get_relation_using_get(from_id=from_id, from_type=from_type, relation_type=relation_type, to_id=to_id, @@ -843,8 +851,9 @@ def find_by_from_v1(self, from_id: EntityId, from_type: str, relation_type_group return self.entity_relation_controller.find_by_from_using_get1(from_id=from_id, from_type=from_type, relation_type_group=relation_type_group) - def find_by_from(self, from_id: EntityId, from_type: str, relation_type: str, + def find_by_from(self, from_id: EntityId, relation_type: str, relation_type_group: Optional[str] = None) -> List[EntityRelation]: + from_type = self.get_type(from_id) from_id = self.get_id(from_id) return self.entity_relation_controller.find_by_from_using_get(from_id=from_id, from_type=from_type, relation_type=relation_type, diff --git a/tb_rest_client/rest_client_ce.py b/tb_rest_client/rest_client_ce.py index 01f1bbc1..08b94322 100644 --- a/tb_rest_client/rest_client_ce.py +++ b/tb_rest_client/rest_client_ce.py @@ -862,9 +862,12 @@ def delete_relations(self, entity_id: EntityId) -> None: return self.entity_relation_controller.delete_relations_using_delete(entity_id=entity_id, entity_type=entity_type) - def delete_relation(self, from_id: EntityId, from_type: str, relation_type: str, to_id: EntityId, to_type: str, + def delete_relation(self, from_id: EntityId, relation_type: str, to_id: EntityId, relation_type_group: Optional[str] = None) -> None: + from_type = self.get_type(from_id) from_id = self.get_id(from_id) + + to_type = self.get_type(to_id) to_id = self.get_id(to_id) return self.entity_relation_controller.delete_relation_using_delete(from_id=from_id, from_type=from_type, relation_type=relation_type, to_id=to_id, diff --git a/tb_rest_client/rest_client_pe.py b/tb_rest_client/rest_client_pe.py index 3e59f500..affa79c7 100644 --- a/tb_rest_client/rest_client_pe.py +++ b/tb_rest_client/rest_client_pe.py @@ -117,10 +117,12 @@ def get_asset_by_id(self, asset_id: AssetId) -> Asset: return self.asset_controller.get_asset_by_id_using_get(asset_id=asset_id) def get_assets_by_ids(self, asset_ids: list) -> List[Asset]: - return self.asset_controller.get_assets_by_ids_using_get(asset_ids=str(asset_ids)) + asset_ids = ','.join(asset_ids) + return self.asset_controller.get_assets_by_ids_using_get(asset_ids=asset_ids) - def save_asset(self, body: Optional[Asset] = None) -> Asset: - return self.asset_controller.save_asset_using_post(body=body) + def save_asset(self, body: Optional[Asset] = None, entity_group_id: EntityGroupId = None): + entity_group_id = self.get_id(entity_group_id) + return self.asset_controller.save_asset_using_post(body=body, entity_group_id=entity_group_id) def asset_get_tenant_assets(self, page_size: int, page: int, type: Optional[str] = None,text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None) -> PageDataAsset: @@ -354,8 +356,9 @@ def get_short_customer_info_by_id(self, customer_id: CustomerId) -> Union[ customer_id = self.get_id(customer_id) return self.customer_controller.get_short_customer_info_by_id_using_get(customer_id=customer_id) - def save_customer(self, body: Optional[Customer] = None) -> Customer: - return self.customer_controller.save_customer_using_post(body=body) + def save_customer(self, entity_group_id: EntityGroupId = None, body: Optional[Customer] = None) -> Customer: + entity_group_id = self.get_id(entity_group_id) + return self.customer_controller.save_customer_using_post(entity_group_id=entity_group_id, body=body) def get_tenant_customer(self, customer_title: str) -> Customer: return self.customer_controller.get_tenant_customer_using_get(customer_title=customer_title) @@ -479,7 +482,8 @@ def get_devices_by_entity_group_id(self, entity_group_id: EntityGroupId, page_si sort_order=sort_order) def get_devices_by_ids(self, device_ids: list) -> List[Device]: - return self.device_controller.get_devices_by_ids_using_get(device_ids=str(device_ids)) + device_ids = ','.join(device_ids) + return self.device_controller.get_devices_by_ids_using_get(device_ids=device_ids) def get_user_devices(self, page_size: int, page: int, type: Optional[str] = None,text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None,) -> PageDataDevice: @@ -554,9 +558,11 @@ def get_converter_by_id(self, converter_id: ConverterId) -> Converter: return self.converter_controller.get_converter_by_id_using_get(converter_id=converter_id) def get_converters_by_ids(self, converter_ids: list) -> List[Converter]: - return self.converter_controller.get_converters_by_ids_using_get(converter_ids=str(converter_ids)) + converter_ids = ','.join(converter_ids) + return self.converter_controller.get_converters_by_ids_using_get(converter_ids=converter_ids) - def get_converters(self, page_size: int, page: int, is_edge_template: Optional[bool], text_search: Optional[str] = None, sort_property: Optional[str] = None, + def get_converters(self, page_size: int, page: int, is_edge_template: Optional[bool] = None, + text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None) -> PageDataConverter: return self.converter_controller.get_converters_using_get(page_size=page_size, page=page, is_edge_template=is_edge_template, @@ -693,7 +699,8 @@ def get_entity_views_by_entity_group_id(self, entity_group_id: EntityGroupId, pa sort_property=sort_property, sort_order=sort_order) def get_entity_views_by_ids(self, entity_view_ids: list) -> List[EntityView]: - return self.entity_view_controller.get_entity_views_by_ids_using_get(entity_view_ids=str(entity_view_ids)) + entity_view_ids = ','.join(entity_view_ids) + return self.entity_view_controller.get_entity_views_by_ids_using_get(entity_view_ids=entity_view_ids) def save_entity_view(self, body: Optional[EntityView] = None) -> EntityView: return self.entity_view_controller.save_entity_view_using_post(body=body) @@ -842,7 +849,8 @@ def mobile_login(self, pkg_name: str) -> str: def terms_of_use_accepted(self, ) -> bool: return self.sign_up_controller.terms_of_use_accepted_using_get() - def get_device_profiles_by_ids(self, device_profile_ids: str) -> List[DeviceProfileInfo]: + def get_device_profiles_by_ids(self, device_profile_ids: list) -> List[DeviceProfileInfo]: + device_profile_ids = ','.join(device_profile_ids) return self.device_profile_controller.get_device_profiles_by_ids_using_get( device_profile_ids=device_profile_ids) @@ -1094,19 +1102,20 @@ def get_max_datapoints_limit(self, ) -> int: return self.dashboard_controller.get_max_datapoints_limit_using_get() def get_dashboards_by_ids(self, dashboard_ids: list) -> List[DashboardInfo]: - return self.dashboard_controller.get_dashboards_by_ids_using_get(dashboard_ids=str(dashboard_ids)) + dashboard_ids = ','.join(dashboard_ids) + return self.dashboard_controller.get_dashboards_by_ids_using_get(dashboard_ids=dashboard_ids) def get_customer_home_dashboard_info(self, ) -> HomeDashboardInfo: return self.dashboard_controller.get_customer_home_dashboard_info_using_get() - def get_tenant_dashboards(self, page_size: int, page: int, mobile: Optional[bool], text_search: Optional[str] = None, sort_property: Optional[str] = None, + def get_tenant_dashboards(self, page_size: int, page: int, mobile: Optional[bool] = None, text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None) -> PageDataDashboardInfo: return self.dashboard_controller.get_tenant_dashboards_using_get(page_size=page_size, page=page, mobile=mobile, text_search=text_search, sort_property=sort_property, sort_order=sort_order) - def get_user_dashboards(self, page_size: int, page: int, mobile: Optional[bool], text_search: Optional[str] = None, sort_property: Optional[str] = None, + def get_user_dashboards(self, page_size: int, page: int, mobile: Optional[bool] = None, text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None, operation: Optional[str] = None, user_id: Optional[str] = None) -> PageDataDashboardInfo: user_id = self.get_id(user_id) return self.dashboard_controller.get_user_dashboards_using_get(page_size=page_size, page=page, mobile=mobile, @@ -1191,7 +1200,8 @@ def get_role_by_id(self, role_id: RoleId) -> Role: return self.role_controller.get_role_by_id_using_get(role_id=role_id) def get_roles_by_ids(self, role_ids: list) -> List[Role]: - return self.role_controller.get_roles_by_ids_using_get(role_ids=str(role_ids)) + role_ids = ','.join(role_ids) + return self.role_controller.get_roles_by_ids_using_get(role_ids=role_ids) def get_roles(self, page_size: int, page: int, type: Optional[str] = None,text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None,) -> PageDataRole: return self.role_controller.get_roles_using_get(page_size=page_size, page=page, type=type, @@ -1460,7 +1470,8 @@ def get_entity_group_by_owner_and_name_and_type(self, owner_type: str, owner_id: group_name=group_name) def get_entity_groups_by_ids(self, entity_group_ids: list) -> List[EntityGroup]: - return self.entity_group_controller.get_entity_groups_by_ids_using_get(entity_group_ids=str(entity_group_ids)) + entity_group_ids = ','.join(entity_group_ids) + return self.entity_group_controller.get_entity_groups_by_ids_using_get(entity_group_ids=entity_group_ids) def get_entity_groups_by_owner_and_type(self, owner_type: str, owner_id: UserId, group_type: str) -> List[EntityGroupInfo]: owner_id = self.get_id(owner_id) @@ -1483,7 +1494,7 @@ def get_group_entity(self, entity_group_id: EntityGroupId, entity_id: EntityId) return self.entity_group_controller.get_group_entity_using_get(entity_group_id=entity_group_id, entity_id=entity_id) - def get_owners(self, page_size: int, page: int,text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None,) -> PageDataContactBasedobject: + def get_owners(self, page_size: int, page: int, text_search: Optional[str] = None, sort_property: Optional[str] = None, sort_order: Optional[str] = None,) -> PageDataContactBasedobject: return self.entity_group_controller.get_owners_using_get(page_size=page_size, page=page, text_search=text_search, sort_property=sort_property, sort_order=sort_order) diff --git a/test/tests.py b/test/tests.py index e69de29b..c1d6e885 100644 --- a/test/tests.py +++ b/test/tests.py @@ -0,0 +1,730 @@ +import unittest + +from tb_rest_client.rest_client_pe import * + + +class TBClientPETests(unittest.TestCase): + client = None + + @classmethod + def setUpClass(cls) -> None: + # ThingsBoard REST API URL + url = "https://thingsboard.cloud" + + # Default Tenant Administrator credentials + username = "***" + password = "***" + + with RestClientPE(url) as cls.client: + cls.client.login(username, password) + + +class TelemetryControllerTests(TBClientPETests): + device = None + device_profile_id = None + + @classmethod + def setUpClass(cls) -> None: + super(TelemetryControllerTests, cls).setUpClass() + cls.device_profile_id = list(filter(lambda x: x.type == 'DEFAULT', cls.client.get_device_profiles(10, 0).data))[ + 0] + + cls.device = Device(name='Test', type='default', + device_profile_id=cls.device_profile_id.id) + cls.device = cls.client.save_device(cls.device) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_device(cls.device.id) + + def test_get_latest_timeseries(self): + self.assertIsInstance( + self.client.get_latest_timeseries(self.device.id), dict) + + def test_get_timeseries(self): + self.assertIsInstance( + self.client.get_timeseries(self.device.id, 'string_read3', + 164999693900, 168999693900), dict) + + def test_get_attributes_by_scope(self): + self.assertIsInstance( + self.client.get_attributes_by_scope(self.device.id, + 'SHARED_SCOPE'), list) + + def test_get_attributes(self): + self.assertIsInstance(self.client.get_attributes(self.device.id), + list) + + def test_delete_entity_timeseries(self): + self.assertIsInstance( + self.client.delete_entity_timeseries(self.device.id, + 'combination', + delete_all_data_for_keys=True), bytes) + + def test_save_entity_telemetry(self): + self.assertEqual( + self.client.save_entity_telemetry(self.device.id, 'ANY', + body={"ts": 1634712287000, + "values": {"temperature": 26, "humidity": 87}}), b'') + + def test_save_entity_telemetry_with_ttl(self): + self.assertEqual( + self.client.save_entity_telemetry_with_ttl(self.device.id, + 'ANY', body={"temperature": 26, "humidity": 87}, + ttl=100), b'') + + def test_get_timeseries_keys(self): + self.assertIsInstance( + self.client.get_timeseries_keys(self.device_profile_id.id), + list) + + def test_get_attribute_keys_by_scope(self): + self.assertIsInstance( + self.client.get_attribute_keys_by_scope(self.device.id, + 'SHARED_SCOPE'), list) + + def test_get_attribute_keys(self): + self.assertIsInstance( + self.client.get_attribute_keys(self.device.id), list) + + def test_save_entity_attributes_v2(self): + self.assertEqual( + self.client.save_entity_attributes_v2(self.device.id, + 'SHARED_SCOPE', {'shared1': 12}), b'') + + def test_delete_entity_attributes(self): + self.assertEqual( + self.client.delete_entity_attributes(self.device.id, + 'SHARED_SCOPE', 'shared1'), b'') + + def test_save_entity_attributes_v1(self): + self.assertEqual( + self.client.save_entity_attributes_v1(self.device.id, + 'SHARED_SCOPE', {'shared1': 12}), b'') + + def test_delete_device_attributes(self): + self.assertEqual( + self.client.delete_device_attributes(self.device.id, + 'SHARED_SCOPE', 'shared1'), b'') + + def test_save_device_attributes(self): + self.assertEqual(self.client.save_device_attributes(self.device.id, + 'SHARED_SCOPE', {'shared1': 12}), b'') + + +class DeviceControllerTest(TBClientPETests): + device = None + device_profile_id = None + + @classmethod + def setUpClass(cls) -> None: + super(DeviceControllerTest, cls).setUpClass() + cls.device_profile_id = list(filter(lambda x: x.type == 'DEFAULT', cls.client.get_device_profiles(10, 0).data))[ + 0] + + cls.device = Device(name='Test', type='default', + device_profile_id=cls.device_profile_id.id) + cls.device = cls.client.save_device(cls.device) + cls.cred = cls.client.get_device_credentials_by_device_id(cls.device.id) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_device(cls.device.id) + + def test_get_user_devices(self): + devices = self.client.get_user_devices(10, 0) + self.assertIsInstance(devices, PageDataDevice) + + def test_get_tenant_devices(self): + self.assertIsInstance(self.client.get_tenant_devices(10, 0), PageDataDevice) + sleep(1) + + def test_get_tenant_device(self): + self.assertIsInstance(self.client.get_tenant_device(self.device.name), Device) + + def test_assign_device_to_tenant(self): + tenant_id = self.client.get_user().tenant_id + self.assertIsInstance(self.client.assign_device_to_tenant(tenant_id, self.device.id), Device) + + def test_count_by_device_profile_and_empty_ota_package(self): + self.assertIsInstance( + self.client.count_by_device_profile_and_empty_ota_package('FIRMWARE', self.device_profile_id.id), int) + sleep(1) + + def test_get_devices_by_ids(self): + self.assertIsInstance( + self.client.get_devices_by_ids([self.device.id.id]), list) + + def test_get_device_types(self): + self.assertIsInstance(self.client.get_device_types(), list) + + def test_get_device_credentials_by_device_id(self): + self.assertIsInstance( + self.client.get_device_credentials_by_device_id(self.device.id), + DeviceCredentials) + + def test_update_device_credentials(self): + self.assertIsInstance(self.client.update_device_credentials( + DeviceCredentials(self.cred.id, + device_id=self.device.id, + credentials_id=self.cred.credentials_id, credentials_type='ACCESS_TOKEN', + credentials_value='fffadsfsdgsfddsfdddsdfsf')), DeviceCredentials) + + def test_get_device_by_id(self): + self.assertIsInstance(self.client.get_device_by_id(self.device.id), Device) + + def test_re_claim_device(self): + self.assertEqual(self.client.re_claim_device(self.device.name), b'') + + def test_get_customer_devices(self): + customer = self.client.get_customers(10, 0).data[0] + self.assertIsInstance( + self.client.get_customer_devices(customer.id, 10, 0), + PageDataDevice) + + def test_count_by_device_group_and_empty_ota_package(self): + entity_group = self.client.get_entity_groups_by_type('DEVICE')[0] + ota_package = self.client.get_ota_packages(10, 0).data[0] + self.assertIsInstance( + self.client.count_by_device_group_and_empty_ota_package('FIRMWARE', ota_package.id, entity_group.id), int) + + def test_get_devices_by_entity_group_id(self): + entity_group = self.client.get_entity_groups_by_type('DEVICE')[0] + self.assertIsInstance( + self.client.get_devices_by_entity_group_id(entity_group.id, 10, 0), PageDataDevice) + + def test_save_device_with_credentials(self): + test_device = Device(name='Test 1', type='default', device_profile_id=self.device_profile_id.id) + test_device = self.client.save_device_with_credentials( + SaveDeviceWithCredentialsRequest(test_device, DeviceCredentials(credentials_type='ACCESS_TOKEN', + credentials_id='sdfsdfsdfsdfsdfsdf'))) + self.assertIsInstance(test_device, Device) + self.client.delete_device(test_device.id) + + +class AssetControllerTests(TBClientPETests): + test_asset = None + test_entity_group = None + + @classmethod + def setUpClass(cls) -> None: + super(AssetControllerTests, cls).setUpClass() + + cls.test_entity_group = cls.client.get_entity_groups_by_type('ASSET')[0] + + cls.test_asset = Asset(name="Test Asset", type="building") + cls.test_asset = cls.client.save_asset(body=cls.test_asset, + entity_group_id=cls.test_entity_group.id) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_asset(cls.test_asset.id) + + def test_get_user_assets(self): + self.assertIsInstance(self.client.get_user_assets(10, 0), PageDataAsset) + + def test_get_tenant_assets(self): + self.assertIsInstance(self.client.get_tenant_assets(10, 0), PageDataAsset) + + def test_get_tenant_asset(self): + self.assertIsInstance(self.client.get_tenant_asset(self.test_asset.name), Asset) + + def test_get_assets_by_entity_group_id(self): + entity_group = self.client.get_entity_groups_by_type('ASSET')[0] + self.assertIsInstance( + self.client.get_assets_by_entity_group_id(entity_group.id, 10, 0), PageDataAsset) + + def test_get_customer_assets(self): + customer = self.client.get_customers(10, 0).data[0] + self.assertIsInstance(self.client.get_customer_assets(customer.id, 10, 0), PageDataAsset) + + def test_get_assets_by_ids(self): + self.assertIsInstance(self.client.get_assets_by_ids([self.test_asset.id.id]), list) + + def test_get_asset_types(self): + self.assertIsInstance(self.client.get_asset_types(), list) + + def test_get_asset_by_id(self): + self.assertIsInstance(self.client.get_asset_by_id(self.test_asset.id), Asset) + + +class EntityGroupControllerTests(TBClientPETests): + test_entity_group = None + test_asset = None + + @classmethod + def setUpClass(cls) -> None: + super(EntityGroupControllerTests, cls).setUpClass() + cls.test_entity_group = EntityGroup(name='Test 1', type='ASSET') + cls.test_entity_group = cls.client.save_entity_group(cls.test_entity_group) + + cls.test_asset = cls.client.get_tenant_assets(10, 0).data[0] + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_entity_group(cls.test_entity_group.id) + + def test_get_entity_groups_by_type(self): + self.assertIsInstance(self.client.get_entity_groups_by_type('DEVICE'), list) + + def test_get_entity_group_by_owner_and_name_and_type(self): + customer = self.client.get_customers(10, 0).data[0] + self.assertIsInstance( + self.client.get_entity_group_by_owner_and_name_and_type('CUSTOMER', customer.id, 'ASSET', 'All'), + EntityGroupInfo) + + def test_get_entity_groups_by_owner_and_type(self): + customer = self.client.get_customers(10, 0).data[0] + self.assertIsInstance(self.client.get_entity_groups_by_owner_and_type('CUSTOMER', customer.id, 'ASSET'), list) + + def test_get_entity_groups_for_entity(self): + self.assertIsInstance(self.client.get_entity_groups_for_entity(self.test_asset.id), list) + + def test_get_entity_groups_by_ids(self): + self.assertIsInstance(self.client.get_entity_groups_by_ids([self.test_entity_group.id.id]), list) + + def test_make_entity_group_public(self): + self.assertEqual(self.client.make_entity_group_public(self.test_entity_group.id), None) + + def test_make_entity_group_private(self): + self.client.make_entity_group_public(self.test_entity_group.id) + self.assertEqual( + self.client.make_entity_group_private(self.test_entity_group.id), None) + + def test_remove_entities_from_entity_group(self): + self.client.add_entities_to_entity_group(self.test_entity_group.id, + [self.test_asset.id.id]) + self.assertEqual(self.client.remove_entities_from_entity_group( + self.test_entity_group.id, [self.test_asset.id.id]), + None) + + def test_add_entities_to_entity_group(self): + self.assertEqual( + self.client.add_entities_to_entity_group(self.test_entity_group.id, + [self.test_asset.id.id]), None) + + def test_get_entity_group_by_id(self): + self.assertIsInstance( + self.client.get_entity_group_by_id(self.test_entity_group.id), + EntityGroupInfo) + + def test_get_owners(self): + self.assertIsInstance(self.client.get_owners(1, 0), PageDataContactBasedobject) + + def test_share_entity_group_to_child_owner_user_group(self): + self.assertEqual(self.client.share_entity_group_to_child_owner_user_group( + self.test_entity_group.id, + EntityId('4ff7a2b0-edfd-11eb-91fd-1f8899a6f9b3', 'USER'), + RoleId('29b466c0-43ab-11ec-b286-536c9e21a8b1', 'CUSTOMER')), None) + + @unittest.skip('ThingsBoard json naming bug') + def test_get_entities(self): + self.assertIsInstance( + self.client.get_entities(EntityGroupId('4fe07130-edfd-11eb-91fd-1f8899a6f9b3', 'ASSET'), 1, 0), + PageDataShortEntityView) + + @unittest.skip('ThingsBoard json naming bug') + def test_get_group_entity(self): + self.assertIsInstance( + self.client.get_group_entity(EntityGroupId('4fe07130-edfd-11eb-91fd-1f8899a6f9b3', 'ASSET'), + EntityId('7731eb20-1894-11ed-b864-31da2039250b', 'ASSET')), ShortEntityView) + + +class CustomerControllerTests(TBClientPETests): + test_customer = None + + @classmethod + def setUpClass(cls) -> None: + super(CustomerControllerTests, cls).setUpClass() + cls.test_customer = Customer(name='Test from test', title='Test from test') + cls.test_customer = cls.client.save_customer(body=cls.test_customer) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_customer(cls.test_customer.id) + + def test_get_user_customers(self): + self.assertIsInstance(self.client.get_user_customers(10, 0), PageDataCustomer) + + def test_get_tenant_customer(self): + self.assertIsInstance(self.client.get_tenant_customer('Public'), Customer) + + def test_get_customers_by_entity_group_id(self): + entity_group = self.client.get_entity_groups_by_type('CUSTOMER')[0] + self.assertIsInstance(self.client.get_customers_by_entity_group_id(entity_group.id, 10, 0), PageDataCustomer) + + def test_get_customers(self): + self.assertIsInstance(self.client.get_customers(10, 0), PageDataCustomer) + + def test_get_customer_title_by_id(self): + self.assertIsInstance( + self.client.get_customer_title_by_id(self.test_customer.id), str) + + def test_get_short_customer_info_by_id(self): + self.assertIsInstance(self.client.get_short_customer_info_by_id(self.test_customer.id), dict) + + def test_get_customer_by_id(self): + self.assertIsInstance(self.client.get_customer_by_id(self.test_customer.id), Customer) + + +class DashboardControllerTests(TBClientPETests): + test_dashboard = None + + @classmethod + def setUpClass(cls) -> None: + super(DashboardControllerTests, cls).setUpClass() + cls.test_dashboard = Dashboard(name='Test from test', title='Test from test') + cls.client.save_dashboard(body=cls.test_dashboard) + cls.test_dashboard = list(filter(lambda x: x.name == cls.test_dashboard.name, + cls.client.get_user_dashboards(10, 0).data))[0] + cls.client.set_tenant_home_dashboard_info( + HomeDashboardInfo(cls.test_dashboard.id, hide_dashboard_toolbar=False)) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_dashboard(cls.test_dashboard.id) + + def test_get_user_dashboards(self): + self.assertIsInstance(self.client.get_user_dashboards(10, 0), PageDataDashboardInfo) + + def test_get_tenant_dashboards(self): + self.assertIsInstance(self.client.get_tenant_dashboards(10, 0), PageDataDashboardInfo) + + def test_get_tenant_home_dashboard_info(self): + self.assertIsInstance(self.client.get_tenant_home_dashboard_info(), HomeDashboardInfo) + + def test_set_tenant_home_dashboard_info(self): + self.assertEqual(self.client.set_tenant_home_dashboard_info( + HomeDashboardInfo(self.test_dashboard.id, hide_dashboard_toolbar=False)), None) + + def test_export_group_dashboards(self): + entity_group = self.client.get_entity_groups_by_type('DASHBOARD')[0] + self.assertIsInstance(self.client.export_group_dashboards(entity_group.id, 1), list) + + def test_get_dashboards_by_entity_group_id(self): + entity_group = self.client.get_entity_groups_by_type('DASHBOARD')[0] + self.assertIsInstance(self.client.get_dashboards_by_entity_group_id(entity_group.id, 10, 0), + PageDataDashboardInfo) + + def test_get_dashboards_by_ids(self): + self.assertIsInstance(self.client.get_dashboards_by_ids([self.test_dashboard.id.id]), list) + + def test_get_server_time(self): + self.assertIsInstance(self.client.get_server_time(), int) + + def test_get_max_datapoints_limit(self): + self.assertIsInstance(self.client.get_max_datapoints_limit(), int) + + def test_get_dashboard_info_by_id(self): + self.assertIsInstance( + self.client.get_dashboard_info_by_id(self.test_dashboard.id), + DashboardInfo) + + def test_get_home_dashboard_info(self): + self.assertIsInstance(self.client.get_home_dashboard_info(), HomeDashboardInfo) + + def test_get_home_dashboard(self): + self.assertIsInstance(self.client.get_home_dashboard(), HomeDashboard) + + def test_get_dashboard_by_id(self): + self.assertIsInstance( + self.client.get_dashboard_by_id(self.test_dashboard.id), Dashboard) + + +class ConverterControllerTests(TBClientPETests): + test_converter = None + + @classmethod + def setUpClass(cls) -> None: + super(ConverterControllerTests, cls).setUpClass() + cls.test_converter = Converter(name='Test', type='UPLINK', configuration={ + "decoder": "// Decode an uplink message from a buffer\n// payload - array of bytes\n// metadata - key/value object\n\n/** Decoder **/\n\n// decode payload to string\nvar payloadStr = decodeToString(payload);\n\n// decode payload to JSON\n// var data = decodeToJson(payload);\n\nvar deviceName = 'Device A';\nvar deviceType = 'thermostat';\nvar customerName = 'customer';\nvar groupName = 'thermostat devices';\n// use assetName and assetType instead of deviceName and deviceType\n// to automatically create assets instead of devices.\n// var assetName = 'Asset A';\n// var assetType = 'building';\n\n// Result object with device/asset attributes/telemetry data\nvar result = {\n// Use deviceName and deviceType or assetName and assetType, but not both.\n deviceName: deviceName,\n deviceType: deviceType,\n// assetName: assetName,\n// assetType: assetType,\n customerName: customerName,\n groupName: groupName,\n attributes: {\n model: 'Model A',\n serialNumber: 'SN111',\n integrationName: metadata['integrationName']\n },\n telemetry: {\n temperature: 42,\n humidity: 80,\n rawData: payloadStr\n }\n};\n\n/** Helper functions **/\n\nfunction decodeToString(payload) {\n return String.fromCharCode.apply(String, payload);\n}\n\nfunction decodeToJson(payload) {\n // covert payload to string.\n var str = decodeToString(payload);\n\n // parse string to JSON\n var data = JSON.parse(str);\n return data;\n}\n\nreturn result;", + "encoder": None + }) + cls.test_converter = cls.client.save_converter(cls.test_converter) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_converter(cls.test_converter.id) + + def test_get_converters(self): + self.assertIsInstance(self.client.get_converters(10, 0), PageDataConverter) + + def test_get_converters_by_ids(self): + self.assertIsInstance(self.client.get_converters_by_ids([self.test_converter.id.id]), list) + + def test_get_latest_converter_debug_input(self): + self.assertIsInstance(self.client.get_latest_converter_debug_input( + self.test_converter.id), bytes) + + def test_get_converter_by_id(self): + self.assertIsInstance(self.client.get_converter_by_id(self.test_converter.id), Converter) + + def test_test_up_link_converter(self): + self.assertIsInstance(self.client.test_up_link_converter({ + "metadata": { + }, + "payload": "ewogICAgImRhdGEiOiAiZGF0YSIKfQ==", + "decoder": "// Decode an uplink message from a buffer\n// payload - array of bytes\n// metadata - key/value object\n\n/** Decoder **/\n\n// decode payload to string\nvar payloadStr = decodeToString(payload);\n\n// decode payload to JSON\n// var data = decodeToJson(payload);\n\nvar deviceName = 'Device A';\nvar deviceType = 'thermostat';\nvar customerName = 'customer';\nvar groupName = 'thermostat devices';\n// use assetName and assetType instead of deviceName and deviceType\n// to automatically create assets instead of devices.\n// var assetName = 'Asset A';\n// var assetType = 'building';\n\n// Result object with device/asset attributes/telemetry data\nvar result = {\n// Use deviceName and deviceType or assetName and assetType, but not both.\n deviceName: deviceName,\n deviceType: deviceType,\n// assetName: assetName,\n// assetType: assetType,\n customerName: customerName,\n groupName: groupName,\n attributes: {\n model: 'Model A',\n serialNumber: 'SN111',\n integrationName: metadata['integrationName']\n },\n telemetry: {\n temperature: 42,\n humidity: 80,\n rawData: payloadStr\n }\n};\n\n/** Helper functions **/\n\nfunction decodeToString(payload) {\n return String.fromCharCode.apply(String, payload);\n}\n\nfunction decodeToJson(payload) {\n // covert payload to string.\n var str = decodeToString(payload);\n\n // parse string to JSON\n var data = JSON.parse(str);\n return data;\n}\n\nreturn result;" + }), dict) + + def test_test_down_link_converter(self): + self.assertIsInstance(self.client.test_down_link_converter({ + "metadata": { + "data": "40" + }, + "msg": "{\n \"temp\": 42,\n \"humidity\": 77\n}", + "msgType": "POST_TELEMETRY_REQUEST", + "integrationMetadata": { + "integrationName": "Integration" + }, + "encoder": "// Encode downlink data from incoming Rule Engine message\n\n// msg - JSON message payload downlink message json\n// msgType - type of message, for ex. 'ATTRIBUTES_UPDATED', 'POST_TELEMETRY_REQUEST', etc.\n// metadata - list of key-value pairs with additional data about the message\n// integrationMetadata - list of key-value pairs with additional data defined in Integration executing this converter\n\n/** Encoder **/\n\nvar data = {};\n\n// Process data from incoming message and metadata\n\ndata.tempValue = msg.temp;\ndata.humValue = msg.humidity;\n\ndata.devSerialNumber = metadata['ss_serialNumber'];\n\n// Result object with encoded downlink payload\nvar result = {\n\n // downlink data content type: JSON, TEXT or BINARY (base64 format)\n contentType: \"JSON\",\n\n // downlink data\n data: JSON.stringify(data),\n\n // Optional metadata object presented in key/value format\n metadata: {\n topic: metadata['deviceType']+'/'+metadata['deviceName']+'/upload'\n }\n\n};\n\nreturn result;" + }), dict) + + +class AlarmControllerTests(TBClientPETests): + test_alarm = None + device = None + device_profile_id = None + + @classmethod + def setUpClass(cls) -> None: + super(AlarmControllerTests, cls).setUpClass() + cls.device_profile_id = list(filter(lambda x: x.type == 'DEFAULT', cls.client.get_device_profiles(10, 0).data))[ + 0] + + cls.device = Device(name='Test', type='default', + device_profile_id=cls.device_profile_id.id) + cls.device = cls.client.save_device(cls.device) + + cls.test_alarm = Alarm(name='Test', type='default', + originator=cls.device.id, + severity='CRITICAL', status='CLEARED_UNACK') + cls.test_alarm = cls.client.save_alarm(cls.test_alarm) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_alarm(cls.test_alarm.id) + cls.client.delete_device(cls.device.id) + + def test_get_all_alarms(self): + self.assertIsInstance(self.client.get_all_alarms(10, 0), PageDataAlarmInfo) + + def test_get_alarm_info_by_id(self): + self.assertIsInstance(self.client.get_alarm_info_by_id(self.test_alarm.id), AlarmInfo) + + def test_get_highest_alarm_severity(self): + self.assertIsInstance( + self.client.get_highest_alarm_severity(self.device.id), str) + + def test_get_alarms(self): + self.assertIsInstance(self.client.get_alarms(self.device.id, 10, 0), + PageDataAlarmInfo) + + def test_clear_alarm(self): + self.assertEqual(self.client.clear_alarm(self.test_alarm.id), None) + + def test_ack_alarm(self): + self.assertEqual(self.client.ack_alarm(self.test_alarm.id), None) + + def test_get_alarm_by_id(self): + self.assertIsInstance(self.client.get_alarm_by_id(self.test_alarm.id), Alarm) + + +class DeviceProfileControllerTests(TBClientPETests): + test_device_profile = None + + @classmethod + def setUpClass(cls) -> None: + super(DeviceProfileControllerTests, cls).setUpClass() + cls.test_device_profile = DeviceProfile(name='Test', type='DEFAULT', transport_type='MQTT', + provision_type='ALLOW_CREATE_NEW_DEVICES', + profile_data=DeviceProfileData( + configuration={"type": "DEFAULT"}, transport_configuration={ + "type": "MQTT", + "deviceTelemetryTopic": "v1/devices/me/telemetry", + "deviceAttributesTopic": "v1/devices/me/attributes", + "transportPayloadTypeConfiguration": { + "transportPayloadType": "PROTOBUF", + "deviceTelemetryProtoSchema": "syntax =\"proto3\";\npackage telemetry;\n\nmessage SensorDataReading {\n\n optional double temperature = 1;\n optional double humidity = 2;\n InnerObject innerObject = 3;\n\n message InnerObject {\n optional string key1 = 1;\n optional bool key2 = 2;\n optional double key3 = 3;\n optional int32 key4 = 4;\n optional string key5 = 5;\n }\n}", + "deviceAttributesProtoSchema": "syntax =\"proto3\";\npackage attributes;\n\nmessage SensorConfiguration {\n optional string firmwareVersion = 1;\n optional string serialNumber = 2;\n}", + "deviceRpcRequestProtoSchema": "syntax =\"proto3\";\npackage rpc;\n\nmessage RpcRequestMsg {\n optional string method = 1;\n optional int32 requestId = 2;\n optional string params = 3;\n}", + "deviceRpcResponseProtoSchema": "syntax =\"proto3\";\npackage rpc;\n\nmessage RpcResponseMsg {\n optional string payload = 1;\n}" + } + })) + cls.test_device_profile = cls.client.save_device_profile(cls.test_device_profile) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_device_profile(cls.test_device_profile.id) + + def test_get_device_profiles(self): + self.assertIsInstance(self.client.get_device_profiles(10, 0), PageDataDeviceProfile) + + def test_get_device_profile_infos(self): + self.assertIsInstance(self.client.get_device_profile_infos(10, 0), PageDataDeviceProfileInfo) + + def test_get_device_profiles_by_ids(self): + self.assertIsInstance(self.client.get_device_profiles_by_ids([self.test_device_profile.id.id]), list) + + def test_get_default_device_profile_info(self): + self.assertIsInstance(self.client.get_default_device_profile_info(), DeviceProfileInfo) + + def test_get_device_profile_info_by_id(self): + self.assertIsInstance(self.client.get_device_profile_info_by_id(self.test_device_profile.id), DeviceProfileInfo) + + def test_get_device_profile_by_id(self): + self.assertIsInstance(self.client.get_device_profile_by_id(self.test_device_profile.id), DeviceProfile) + + +class EntityRelationControllerTests(TBClientPETests): + test_relation = None + test_asset = None + test_device = None + device_profile_id = None + entity_group = None + + @classmethod + def setUpClass(cls) -> None: + super(EntityRelationControllerTests, cls).setUpClass() + + cls.device_profile_id = list(filter(lambda x: x.type == 'DEFAULT', cls.client.get_device_profiles(10, 0).data))[ + 0] + + cls.test_device = Device(name='Test from test', type='default', + device_profile_id=cls.device_profile_id.id) + cls.test_device = cls.client.save_device(cls.test_device) + + cls.entity_group = cls.client.get_entity_groups_by_type('ASSET')[0] + cls.test_asset = Asset(name="Test Asset", type="building") + cls.test_asset = cls.client.save_asset(body=cls.test_asset, + entity_group_id=cls.entity_group.id) + + cls.test_relation = EntityRelation(_from=cls.test_asset.id, to=cls.test_device.id, type="Contains") + cls.client.save_relation(cls.test_relation) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_relation(from_id=cls.test_asset.id, to_id=cls.test_device.id, relation_type='Contains') + cls.client.delete_asset(cls.test_asset.id) + cls.client.delete_device(cls.test_device.id) + + def test_find_info_by_to(self): + self.assertIsInstance(self.client.find_info_by_to(self.test_device.id, 'DEVICE'), list) + + def find_info_by_from(self): + self.assertIsInstance(self.client.find_info_by_from(self.test_asset.id), list) + + def test_find_by_to(self): + self.assertIsInstance(self.client.find_by_to(self.test_device.id, 'Contains'), list) + + def test_find_by_from(self): + self.assertIsInstance(self.client.find_by_from(self.test_asset.id, 'Contains'), list) + + def test_get_relation(self): + self.assertIsInstance(self.client.get_relation(self.test_asset.id, 'Contains', self.test_device.id), + EntityRelation) + + +class EntityViewControllerTests(TBClientPETests): + test_entity_view = None + device = None + device_profile_id = None + + @classmethod + def setUpClass(cls) -> None: + super(EntityViewControllerTests, cls).setUpClass() + cls.device_profile_id = list(filter(lambda x: x.type == 'DEFAULT', cls.client.get_device_profiles(10, 0).data))[ + 0] + + cls.device = Device(name='Test', type='default', + device_profile_id=cls.device_profile_id.id) + cls.device = cls.client.save_device(cls.device) + + cls.test_entity_view = EntityView(name='Test', type='default', + entity_id=cls.device.id, + keys=TelemetryEntityView(timeseries=['temp'], + attributes=AttributesEntityView(cs=['fff'], + sh=['shared'], + ss=['active']))) + cls.test_entity_view = cls.client.save_entity_view(cls.test_entity_view) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_entity_view(cls.test_entity_view.id) + cls.client.delete_device(cls.device.id) + + def test_get_user_entity_views(self): + self.assertIsInstance(self.client.get_user_entity_views(10, 0), PageDataEntityView) + + def test_get_tenant_entity_views(self): + self.assertIsInstance(self.client.get_tenant_entity_views(10, 0), PageDataEntityView) + + def test_get_tenant_entity_view(self): + self.assertIsInstance(self.client.get_tenant_entity_view(self.test_entity_view.name), EntityView) + + def test_get_entity_views_by_ids(self): + self.assertIsInstance(self.client.get_entity_views_by_ids([self.test_entity_view.id.id]), list) + + def test_get_entity_view_types(self): + self.assertIsInstance(self.client.get_entity_view_types(), list) + + def test_get_entity_view_by_id(self): + self.assertIsInstance(self.client.get_entity_view_by_id(self.test_entity_view.id), EntityView) + + def test_get_entity_views_by_entity_group_id(self): + entity_group = self.client.get_entity_groups_by_type('ENTITY_VIEW')[0] + self.assertIsInstance(self.client.get_entity_views_by_entity_group_id(entity_group.id, 10, 0), + PageDataEntityView) + + def test_get_customer_entity_views(self): + customer = self.client.get_customers(10, 0).data[0] + self.assertIsInstance( + self.client.get_customer_entity_views(customer.id, 10, + 0), PageDataEntityView) + + +class RoleControllerTests(TBClientPETests): + test_role = None + + @classmethod + def setUpClass(cls) -> None: + super(RoleControllerTests, cls).setUpClass() + cls.test_role = Role(name='Test', type='GENERIC', permissions={ + "ALL": [ + "READ", + "RPC_CALL", + "READ_CREDENTIALS", + "READ_ATTRIBUTES", + "READ_TELEMETRY" + ], + "DEVICE": [ + "ALL" + ], + "PROFILE": [ + "ALL" + ] + }) + cls.test_role = cls.client.save_role(cls.test_role) + + @classmethod + def tearDownClass(cls) -> None: + cls.client.delete_role(cls.test_role.id) + + def test_get_roles_by_ids(self): + self.assertIsInstance(self.client.get_roles_by_ids([self.test_role.id.id]), list) + + def test_get_roles(self): + self.assertIsInstance(self.client.get_roles(10, 0), PageDataRole) + + def test_get_role_by_id(self): + self.assertIsInstance(self.client.get_role_by_id(self.test_role.id), Role) + + +class UserPermissionsControllerTests(TBClientPETests): + def test_get_allowed_permissions(self): + self.assertIsInstance(self.client.get_allowed_permissions(), AllowedPermissionsInfo) + + +if __name__ == '__main__': + unittest.main(warnings='ignore')