Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add timeout arg #330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading