Skip to content

Commit

Permalink
trying to add get_client function again
Browse files Browse the repository at this point in the history
  • Loading branch information
KatHellg committed Nov 26, 2024
1 parent 18cba87 commit 4149c3e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions fedn/cli/client_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ def list_clients(ctx, protocol: str, host: str, port: str, token: str = None, n_
except requests.exceptions.ConnectionError:
click.echo(f"Error: Could not connect to {url}")

@click.option("-p", "--protocol", required=False, default=CONTROLLER_DEFAULTS["protocol"], help="Communication protocol of controller (api)")
@click.option("-H", "--host", required=False, default=CONTROLLER_DEFAULTS["host"], help="Hostname of controller (api)")
@click.option("-P", "--port", required=False, default=CONTROLLER_DEFAULTS["port"], help="Port of controller (api)")
@click.option("-t", "--token", required=False, help="Authentication token")
@click.option("-id", "--id", required=True, help="Client ID")
@client_cmd.command("get")
@click.pass_context
def get_client(ctx, protocol: str, host: str, port: str, token: str = None, id: str = None):
"""Return:
------
- result: client with given id
"""
url = get_api_url(protocol=protocol, host=host, port=port, endpoint="clients")
headers = {}


_token = get_token(token)

if _token:
headers["Authorization"] = _token

if id:
url = f"{url}{id}"


click.echo(f"\nRetrieving client: {url}\n")
click.echo(f"Headers: {headers}")
try:
response = requests.get(url, headers=headers)
print_response(response, "client", id)
except requests.exceptions.ConnectionError:
click.echo(f"Error: Could not connect to {url}")


@client_cmd.command("start-v1")
@click.option("-d", "--discoverhost", required=False, help="Hostname for discovery services(reducer).")
Expand Down

0 comments on commit 4149c3e

Please sign in to comment.