Skip to content

Billing api sdk

Source code in unicboard_billing_sdk/billing_api_sdk.py
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
class BillingApiSdk:

    def __init__(self, api_billing_url: str, api_token: str) -> None:
        """
        This function initializes the class with the billing API URL and the API token.

        Args:
          api_billing_url (str): The URL of the API Billing endpoint.
          api_token (str): The API token you received from the billing system.
        """
        self._api_billing_url = api_billing_url
        self._api_token = api_token

    def get_device_list_info(
        self,
        resource_type: Optional[ResourceTypeEnum],
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        filters: Optional[List[Dict[str, Any]]] = None,
        sorts: Optional[List[Tuple[str, str]]] = None,
    ) -> GetDeviceListInfoResponse:
        """
        It makes a GET request to the `/api/v1/devices/info` endpoint, and returns the response as a
        `GetDeviceListInfoResponse` object
        Args:
         resource_type (Optional[str]): filter by resource type - use ResourceTypeEnum for choose value
         limit (Optional[int]): The maximum number of devices to return.
         offset (Optional[int]): The offset of the first device to return.
         filters (Optional[List[Dict[str, Any]]]): A list of dictionaries, each of which contains a key and a value.
         The key is the name of the field to filter on, and the value is the value to filter on.
         sorts (Optional[List[Tuple[str, str]]]): A list of tuples, where each tuple is a field name and a sort direction.

        Returns:
            A list of devices.

        [GetDeviceListInfoResponse](GetDeviceListInfoResponse.md)
        """

        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {
            "resource_type": resource_type.value if resource_type is not None else None,
            "filter": filters,
            "sort": sorts,
        }
        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/info',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_list_info_structure(response.json())

    def get_device_list_by_id_info(self, device_ids: List[UUID]) -> GetDeviceListInfoResponse:
        """
        It takes a list of device IDs and returns a list of device info objects

        Args:
          device_ids (List[UUID]): List[UUID]

        Returns:
          A list of devices.
        [GetDeviceListInfoResponse](GetDeviceListInfoResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}

        device_ids_str = [str(device_id) for device_id in device_ids]
        response = requests.post(
            f'{self._api_billing_url}/'
            f'api/v1/devices/info',
            headers=auth_header,
            json={'device_ids': device_ids_str},
        )
        response.raise_for_status()
        return get_device_list_info_structure(response.json())

    def get_device_info(self, device_id: UUID) -> GetDeviceInfoResponse:
        """
        > This function takes a device ID and returns a `GetDeviceInfoResponse` object

        Args:
          device_id (UUID): The UUID of the device you want to get information about.

        Returns:
          A GetDeviceInfoResponse object. Status of payload information in device list)
        [GetDeviceInfoResponse](GetDeviceInfoResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/info',
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_info_structure(response.json())

    def get_device_value(
            self,
            devices_id: List[UUID],
            period_from: datetime,
            iteration_interval: IntervalSelectValue = IntervalSelectValue.day,
            period_to: datetime = None,
            end_of_day: bool = True,
    ) -> GetDeviceValueResponse:
        """
        It gets the value of a device

        Args:
          devices_id (List[UUID]): List[UUID] - list of device IDs
          period_from (datetime): The start of the period for which you want to get the data.
          period_to (datetime): datetime = None
          iteration_interval (IntervalSelectValue): = IntervalSelectValue.day  iteration interval
          end_of_day (bool): = True Show values of the end of day

        Returns:
          GetDeviceValueResponse: response about device value
        [GetDeviceValueResponse](GetDeviceValueResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {
            "period_from": period_from,
            "period_to": period_to,
            "end_of_day": end_of_day,
            "iteration_interval": iteration_interval.value,
        }
        devices_id = [str(device_id) for device_id in devices_id]

        response = requests.post(
            f'{self._api_billing_url}/'
            f'api/v1/devices/values',
            params=query_params,
            headers=auth_header,
            json={"devices_id": devices_id},
        )
        response.raise_for_status()
        return get_device_value_structure(response.json())

    def get_device_battery_level(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceBatteryLevelResponse:
        """
        It gets the battery level value of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices battery level value to return.
          offset (Optional[int]): The offset of the first device battery level value to return.

        Returns:
          GetDeviceBatteryLevelResponse: response about device battery level value
        [GetDeviceBatteryLevelResponse](GetDeviceBatteryLevelResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/battery-level',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_battery_level_structure(response.json())

    def get_device_clock(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceClockResponse:
        """
        It gets the clock data of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices clock data value to return.
          offset (Optional[int]): The offset of the first device clock data value to return.

        Returns:
          GetDeviceClockResponse: response about device clock data
        [GetDeviceClockResponse](GetDeviceClockResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/clocks',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_clock_structure(response.json())

    def get_device_event(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceEventResponse:
        """
        It gets events of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices events value to return.
          offset (Optional[int]): The offset of the first device events value to return.

        Returns:
          GetDeviceEventResponse: response about device events
        [GetDeviceEventResponse](GetDeviceEventResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/events',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_event_structure(response.json())

    def get_device_profile(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceProfileResponse:
        """
        It gets the time profiles of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices time profiles value to return.
          offset (Optional[int]): The offset of the first device time profiles value to return.

        Returns:
          GetDeviceProfileResponse: response about device time profiles
        [GetDeviceProfileResponse](GetDeviceProfileResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/profiles',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_profile_structure(response.json())

    def get_device_temperature(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceTemperatureResponse:
        """
        It gets the temperature info of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices time profiles value to return.
          offset (Optional[int]): The offset of the first device time profiles value to return.

        Returns:
          GetDeviceTemperatureResponse: response about device temperature info
        [GetDeviceTemperatureResponse](GetDeviceTemperatureResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/temperatures',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_temperature_structure(response.json())

    def get_device_uptime(
        self,
        device_id: UUID,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> GetDeviceUptimeResponse:
        """
        It gets the temperature info of device

        Args:
          device_id (UUID): The UUID of the device you want to get information about.
          limit (Optional[int]): The maximum number of devices time profiles value to return.
          offset (Optional[int]): The offset of the first device time profiles value to return.

        Returns:
          GetDeviceTemperatureResponse: response about device temperature info
        [GetDeviceTemperatureResponse](GetDeviceTemperatureResponse.md)
        """
        auth_header = {'Authorization': f'Bearer {self._api_token}'}
        query_params: Dict[str, Any] = {}

        if limit is not None:
            query_params['limit'] = limit
        if offset is not None:
            query_params['offset'] = offset

        response = requests.get(
            f'{self._api_billing_url}/'
            f'api/v1/devices/{str(device_id)}/uptimes',
            params=query_params,
            headers=auth_header,
        )
        response.raise_for_status()
        return get_device_temperature_structure(response.json())

__init__(api_billing_url, api_token)

This function initializes the class with the billing API URL and the API token.

Parameters:

Name Type Description Default
api_billing_url str

The URL of the API Billing endpoint.

required
api_token str

The API token you received from the billing system.

required
Source code in unicboard_billing_sdk/billing_api_sdk.py
19
20
21
22
23
24
25
26
27
28
def __init__(self, api_billing_url: str, api_token: str) -> None:
    """
    This function initializes the class with the billing API URL and the API token.

    Args:
      api_billing_url (str): The URL of the API Billing endpoint.
      api_token (str): The API token you received from the billing system.
    """
    self._api_billing_url = api_billing_url
    self._api_token = api_token

get_device_battery_level(device_id, limit=None, offset=None)

It gets the battery level value of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices battery level value to return.

None
offset Optional[int]

The offset of the first device battery level value to return.

None

Returns:

Name Type Description
GetDeviceBatteryLevelResponse GetDeviceBatteryLevelResponse

response about device battery level value

GetDeviceBatteryLevelResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def get_device_battery_level(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceBatteryLevelResponse:
    """
    It gets the battery level value of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices battery level value to return.
      offset (Optional[int]): The offset of the first device battery level value to return.

    Returns:
      GetDeviceBatteryLevelResponse: response about device battery level value
    [GetDeviceBatteryLevelResponse](GetDeviceBatteryLevelResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/battery-level',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_battery_level_structure(response.json())

get_device_clock(device_id, limit=None, offset=None)

It gets the clock data of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices clock data value to return.

None
offset Optional[int]

The offset of the first device clock data value to return.

None

Returns:

Name Type Description
GetDeviceClockResponse GetDeviceClockResponse

response about device clock data

GetDeviceClockResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def get_device_clock(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceClockResponse:
    """
    It gets the clock data of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices clock data value to return.
      offset (Optional[int]): The offset of the first device clock data value to return.

    Returns:
      GetDeviceClockResponse: response about device clock data
    [GetDeviceClockResponse](GetDeviceClockResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/clocks',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_clock_structure(response.json())

get_device_event(device_id, limit=None, offset=None)

It gets events of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices events value to return.

None
offset Optional[int]

The offset of the first device events value to return.

None

Returns:

Name Type Description
GetDeviceEventResponse GetDeviceEventResponse

response about device events

GetDeviceEventResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
def get_device_event(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceEventResponse:
    """
    It gets events of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices events value to return.
      offset (Optional[int]): The offset of the first device events value to return.

    Returns:
      GetDeviceEventResponse: response about device events
    [GetDeviceEventResponse](GetDeviceEventResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/events',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_event_structure(response.json())

get_device_info(device_id)

This function takes a device ID and returns a GetDeviceInfoResponse object

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required

Returns:

Type Description
GetDeviceInfoResponse

A GetDeviceInfoResponse object. Status of payload information in device list)

GetDeviceInfoResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def get_device_info(self, device_id: UUID) -> GetDeviceInfoResponse:
    """
    > This function takes a device ID and returns a `GetDeviceInfoResponse` object

    Args:
      device_id (UUID): The UUID of the device you want to get information about.

    Returns:
      A GetDeviceInfoResponse object. Status of payload information in device list)
    [GetDeviceInfoResponse](GetDeviceInfoResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/info',
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_info_structure(response.json())

get_device_list_by_id_info(device_ids)

It takes a list of device IDs and returns a list of device info objects

Parameters:

Name Type Description Default
device_ids List[UUID]

List[UUID]

required

Returns:

Type Description
GetDeviceListInfoResponse

A list of devices.

GetDeviceListInfoResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def get_device_list_by_id_info(self, device_ids: List[UUID]) -> GetDeviceListInfoResponse:
    """
    It takes a list of device IDs and returns a list of device info objects

    Args:
      device_ids (List[UUID]): List[UUID]

    Returns:
      A list of devices.
    [GetDeviceListInfoResponse](GetDeviceListInfoResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}

    device_ids_str = [str(device_id) for device_id in device_ids]
    response = requests.post(
        f'{self._api_billing_url}/'
        f'api/v1/devices/info',
        headers=auth_header,
        json={'device_ids': device_ids_str},
    )
    response.raise_for_status()
    return get_device_list_info_structure(response.json())

get_device_list_info(resource_type, limit=None, offset=None, filters=None, sorts=None)

It makes a GET request to the /api/v1/devices/info endpoint, and returns the response as a GetDeviceListInfoResponse object Args: resource_type (Optional[str]): filter by resource type - use ResourceTypeEnum for choose value limit (Optional[int]): The maximum number of devices to return. offset (Optional[int]): The offset of the first device to return. filters (Optional[List[Dict[str, Any]]]): A list of dictionaries, each of which contains a key and a value. The key is the name of the field to filter on, and the value is the value to filter on. sorts (Optional[List[Tuple[str, str]]]): A list of tuples, where each tuple is a field name and a sort direction.

Returns:

Type Description
GetDeviceListInfoResponse

A list of devices.

GetDeviceListInfoResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def get_device_list_info(
    self,
    resource_type: Optional[ResourceTypeEnum],
    limit: Optional[int] = None,
    offset: Optional[int] = None,
    filters: Optional[List[Dict[str, Any]]] = None,
    sorts: Optional[List[Tuple[str, str]]] = None,
) -> GetDeviceListInfoResponse:
    """
    It makes a GET request to the `/api/v1/devices/info` endpoint, and returns the response as a
    `GetDeviceListInfoResponse` object
    Args:
     resource_type (Optional[str]): filter by resource type - use ResourceTypeEnum for choose value
     limit (Optional[int]): The maximum number of devices to return.
     offset (Optional[int]): The offset of the first device to return.
     filters (Optional[List[Dict[str, Any]]]): A list of dictionaries, each of which contains a key and a value.
     The key is the name of the field to filter on, and the value is the value to filter on.
     sorts (Optional[List[Tuple[str, str]]]): A list of tuples, where each tuple is a field name and a sort direction.

    Returns:
        A list of devices.

    [GetDeviceListInfoResponse](GetDeviceListInfoResponse.md)
    """

    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {
        "resource_type": resource_type.value if resource_type is not None else None,
        "filter": filters,
        "sort": sorts,
    }
    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/info',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_list_info_structure(response.json())

get_device_profile(device_id, limit=None, offset=None)

It gets the time profiles of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices time profiles value to return.

None
offset Optional[int]

The offset of the first device time profiles value to return.

None

Returns:

Name Type Description
GetDeviceProfileResponse GetDeviceProfileResponse

response about device time profiles

GetDeviceProfileResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
def get_device_profile(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceProfileResponse:
    """
    It gets the time profiles of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices time profiles value to return.
      offset (Optional[int]): The offset of the first device time profiles value to return.

    Returns:
      GetDeviceProfileResponse: response about device time profiles
    [GetDeviceProfileResponse](GetDeviceProfileResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/profiles',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_profile_structure(response.json())

get_device_temperature(device_id, limit=None, offset=None)

It gets the temperature info of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices time profiles value to return.

None
offset Optional[int]

The offset of the first device time profiles value to return.

None

Returns:

Name Type Description
GetDeviceTemperatureResponse GetDeviceTemperatureResponse

response about device temperature info

GetDeviceTemperatureResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
def get_device_temperature(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceTemperatureResponse:
    """
    It gets the temperature info of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices time profiles value to return.
      offset (Optional[int]): The offset of the first device time profiles value to return.

    Returns:
      GetDeviceTemperatureResponse: response about device temperature info
    [GetDeviceTemperatureResponse](GetDeviceTemperatureResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/temperatures',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_temperature_structure(response.json())

get_device_uptime(device_id, limit=None, offset=None)

It gets the temperature info of device

Parameters:

Name Type Description Default
device_id UUID

The UUID of the device you want to get information about.

required
limit Optional[int]

The maximum number of devices time profiles value to return.

None
offset Optional[int]

The offset of the first device time profiles value to return.

None

Returns:

Name Type Description
GetDeviceTemperatureResponse GetDeviceUptimeResponse

response about device temperature info

GetDeviceTemperatureResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
def get_device_uptime(
    self,
    device_id: UUID,
    limit: Optional[int] = None,
    offset: Optional[int] = None,
) -> GetDeviceUptimeResponse:
    """
    It gets the temperature info of device

    Args:
      device_id (UUID): The UUID of the device you want to get information about.
      limit (Optional[int]): The maximum number of devices time profiles value to return.
      offset (Optional[int]): The offset of the first device time profiles value to return.

    Returns:
      GetDeviceTemperatureResponse: response about device temperature info
    [GetDeviceTemperatureResponse](GetDeviceTemperatureResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {}

    if limit is not None:
        query_params['limit'] = limit
    if offset is not None:
        query_params['offset'] = offset

    response = requests.get(
        f'{self._api_billing_url}/'
        f'api/v1/devices/{str(device_id)}/uptimes',
        params=query_params,
        headers=auth_header,
    )
    response.raise_for_status()
    return get_device_temperature_structure(response.json())

get_device_value(devices_id, period_from, iteration_interval=IntervalSelectValue.day, period_to=None, end_of_day=True)

It gets the value of a device

Parameters:

Name Type Description Default
devices_id List[UUID]

List[UUID] - list of device IDs

required
period_from datetime

The start of the period for which you want to get the data.

required
period_to datetime

datetime = None

None
iteration_interval IntervalSelectValue

= IntervalSelectValue.day iteration interval

day
end_of_day bool

= True Show values of the end of day

True

Returns:

Name Type Description
GetDeviceValueResponse GetDeviceValueResponse

response about device value

GetDeviceValueResponse

Source code in unicboard_billing_sdk/billing_api_sdk.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def get_device_value(
        self,
        devices_id: List[UUID],
        period_from: datetime,
        iteration_interval: IntervalSelectValue = IntervalSelectValue.day,
        period_to: datetime = None,
        end_of_day: bool = True,
) -> GetDeviceValueResponse:
    """
    It gets the value of a device

    Args:
      devices_id (List[UUID]): List[UUID] - list of device IDs
      period_from (datetime): The start of the period for which you want to get the data.
      period_to (datetime): datetime = None
      iteration_interval (IntervalSelectValue): = IntervalSelectValue.day  iteration interval
      end_of_day (bool): = True Show values of the end of day

    Returns:
      GetDeviceValueResponse: response about device value
    [GetDeviceValueResponse](GetDeviceValueResponse.md)
    """
    auth_header = {'Authorization': f'Bearer {self._api_token}'}
    query_params: Dict[str, Any] = {
        "period_from": period_from,
        "period_to": period_to,
        "end_of_day": end_of_day,
        "iteration_interval": iteration_interval.value,
    }
    devices_id = [str(device_id) for device_id in devices_id]

    response = requests.post(
        f'{self._api_billing_url}/'
        f'api/v1/devices/values',
        params=query_params,
        headers=auth_header,
        json={"devices_id": devices_id},
    )
    response.raise_for_status()
    return get_device_value_structure(response.json())