Merge pull request #14 from FreedomNetNL/feature/add-client-with-group

Feature: Add client with group
This commit is contained in:
Martin Raiber 2022-07-09 11:46:34 +02:00 committed by GitHub
commit 2f9c6697cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
urbackup_server_web_api_wrapper.egg-info/* urbackup_server_web_api_wrapper.egg-info/*
dist/urbackup-server-web-api-wrapper-*.zip dist/urbackup-server-web-api-wrapper-*.zip
urbackup_api/__pycache__/* urbackup_api/__pycache__/*
# IDE
.idea

View File

@ -4,9 +4,7 @@ from urllib.parse import urlparse
from urllib.parse import urlencode from urllib.parse import urlencode
from base64 import b64encode from base64 import b64encode
import hashlib import hashlib
import socket
import shutil import shutil
import os
import binascii import binascii
import logging import logging
from enum import Enum from enum import Enum
@ -220,12 +218,15 @@ class urbackup_server:
"os": e_installer_os.value "os": e_installer_os.value
}) })
def add_client(self, clientname): def add_client(self, clientname, groupname=None):
if not self.login(): if not self.login():
return None return None
ret = self._get_json("add_client", {"clientname": clientname}) data = {"clientname": clientname}
if groupname is not None:
data['group_name'] = groupname
ret = self._get_json("add_client", data)
if ret == None or "already_exists" in ret: if ret == None or "already_exists" in ret:
return None return None