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 custom port support for protect archiver #73

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions protect_archiver/cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
required=True,
help="IP address or hostname of the UniFi Protect Server",
)
@click.option(
"--port",
default=Config.PORT,
show_default=True,
required=False,
help="The port of the UniFi Protect Server",
)
@click.option(
"--not-unifi-os",
is_flag=True,
Expand Down Expand Up @@ -147,6 +154,7 @@
def download(
dest,
address,
port,
not_unifi_os,
username,
password,
Expand Down Expand Up @@ -174,6 +182,7 @@ def download(

client = ProtectClient(
address=address,
port=port,
not_unifi_os=not_unifi_os,
username=username,
password=password,
Expand Down
9 changes: 9 additions & 0 deletions protect_archiver/cli/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
required=True,
help="IP address or hostname of the UniFi Protect Server",
)
@click.option(
"--port",
default=Config.PORT,
show_default=True,
required=False,
help="The port of the UniFi Protect Server",
)
@click.option(
"--not-unifi-os",
is_flag=True,
Expand Down Expand Up @@ -143,6 +150,7 @@
def events(
dest,
address,
port,
not_unifi_os,
username,
password,
Expand All @@ -160,6 +168,7 @@ def events(
):
client = ProtectClient(
address=address,
port=port,
not_unifi_os=not_unifi_os,
username=username,
password=password,
Expand Down
10 changes: 10 additions & 0 deletions protect_archiver/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from protect_archiver.cli.base import cli
from protect_archiver.client import ProtectClient
from protect_archiver.config import Config
from protect_archiver.sync import ProtectSync
from protect_archiver.utils import print_download_stats

Expand All @@ -19,6 +20,13 @@
required=True,
help="CloudKey IP address or hostname",
)
@click.option(
"--port",
default=Config.PORT,
show_default=True,
required=False,
help="CloudKey port number",
)
@click.option(
"--not-unifi-os",
is_flag=True,
Expand Down Expand Up @@ -71,6 +79,7 @@
def sync(
dest,
address,
port,
not_unifi_os,
username,
password,
Expand All @@ -90,6 +99,7 @@ def sync(

client = ProtectClient(
address=address,
port=port,
not_unifi_os=not_unifi_os,
username=username,
password=password,
Expand Down
4 changes: 2 additions & 2 deletions protect_archiver/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ProtectClient:
def __init__(
self,
address: str = Config.ADDRESS,
port: int = Config.PORT,
protocol: str = Config.PROTOCOL,
username: str = Config.USERNAME,
password: str = Config.PASSWORD,
Expand All @@ -27,6 +28,7 @@ def __init__(
):
self.protocol = protocol
self.address = address
self.port = port if port is not None else 7443 if not_unifi_os else 443
self.not_unifi_os = not_unifi_os
self.username = username
self.password = password
Expand All @@ -51,7 +53,6 @@ def __init__(
self._api_token = None

if not_unifi_os:
self.port = 7443
self.base_path = "/api"
self.session = LegacyClient(
self.protocol,
Expand All @@ -62,7 +63,6 @@ def __init__(
self.verify_ssl,
)
else:
self.port = 443
self.session = UniFiOSClient(
self.protocol,
self.address,
Expand Down
1 change: 1 addition & 0 deletions protect_archiver/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def __init__(self):
pass

ADDRESS: str = "unifi"
PORT: int = 443
PROTOCOL: str = "https"
USERNAME: str = "ubnt"
PASSWORD: str = None
Expand Down