Skip to content

Commit

Permalink
add timeout arg
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen committed Jun 6, 2024
1 parent 3fa4f3f commit 0973fc1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client/pyroclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.

from typing import Dict
from typing import Dict, Optional
from urllib.parse import urljoin

import requests
Expand Down Expand Up @@ -71,17 +71,21 @@ def headers(self) -> Dict[str, str]:
return {"Authorization": f"Bearer {self.token}"}

# CAMERAS
def heartbeat(self) -> Response:
def heartbeat(self, timeout: Optional[float] = None) -> Response:
"""Update the last ping of the camera
>>> from pyroclient import Client
>>> api_client = Client("MY_CAM_TOKEN")
>>> response = api_client.heartbeat()
Args:
timeout: Optional timeout value for the request. If not provided, defaults to self.timeout.
Returns:
HTTP response containing the update device info
HTTP response containing the updated device info
"""
return requests.patch(self.routes["cameras-heartbeat"], headers=self.headers, timeout=self.timeout)
request_timeout = timeout if timeout is not None else self.timeout
return requests.patch(self.routes["cameras-heartbeat"], headers=self.headers, timeout=request_timeout)

# DETECTIONS
def create_detection(
Expand Down

0 comments on commit 0973fc1

Please sign in to comment.