averbis / averbis-python-api

Conveniently access the REST API of Averbis products using Python
Apache License 2.0
12 stars 4 forks source link

Streamlining Client constructor behavior #24

Open DavidHuebner opened 3 years ago

DavidHuebner commented 3 years ago

Is your feature request related to a problem? Please describe.

@nadre reported that he experienced an unexpected behavior when initializing the Client class together with a profile saved in the client-settings.json. He used the following command to initialize the client:

Client("my-server", api_token = "XYZ"). 

where my-server was an entry in the client-settings.json that had an API token which differed from the API token that was passed as an argument to Client. In that case, the API token from the client-settings currently prevails. No warning is currently printed in that case.

He also remarked that the parameter username is used inconsistently in the rest_client and should be changed to user.

Describe the solution you'd like

  1. I would say that parameters which are provided explicitly to the constructor overwrite those from the client-settings.json. This should be the case for the parameters api_token and verify_ssl.
  2. If an API token is provided together with a username and a password, then the given API token should be taken and the username and password should be ignored. A warning should be printed that the username and password are not used.
  3. If a username and password are provided, then a new API token should be generated even if one is already defined in the client-settings.json. In that case, we should overwrite the entry in the client-settings.json with the new API token.
  4. If any parameter is overwritten (or set multiple times), a warning should be printed.
  5. The parameter name for username should be changed to user in Client.
nadre commented 3 years ago
  1. yes
  2. yes
  3. yes but no overrides, use a warning instead
  4. yes, answered in 3.
  5. yes

Additionally:

  1. Loading settings info from should be debug and loading profile info should appear