nextlayer-sdk-python 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nextlayer-sdk-python
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Client utilities to interact with next layer public APIs
5
5
  Author: Wolfgang Powisch
6
6
  Author-email: wolfgang.powisch@nextlayer.at
@@ -23,8 +23,8 @@ Client utilities to interact with next layer public APIs.
23
23
 
24
24
  ## Configuration
25
25
 
26
- The module will use a YAML Config file in , where it also needs to **write** to, to store
27
- and update the obtained Tokens and their expiry (similar like `kubctl` does with kubeconfig).
26
+ The module will use a YAML Config file to read it's configuration and also **writes** to it,
27
+ to store obtained Tokens and their expiry (similar like `kubctl` does with kubeconfig).
28
28
 
29
29
  _Example `~/.nextlayer-sdk/auth.nlcustomers.yml`:_
30
30
 
@@ -44,7 +44,7 @@ Except for `username`, all settings are optional, but if no `password` is
44
44
  supplied in config, the password will be asked interactively (if STDIN is a TTY) !
45
45
 
46
46
  Alternatively the username can be suppled in the `NEXTLAYERSDK_USERNAME` environment
47
- variable or directly passed to the `NlAuth` cosntructor.
47
+ variable or directly passed to the `NlAuth` constructor.
48
48
 
49
49
  Alternatively the password can be suppliend in the `NEXTLAYERSDK_PASSWORD` environment
50
50
  variable.
@@ -63,6 +63,7 @@ rsp = requests.get(
63
63
  "https://portal.nextlayer.at/apis/v1/users/self",
64
64
  headers={"Authorization": "Bearer " + access_token},
65
65
  )
66
+ print(rsp.json())
66
67
  ```
67
68
 
68
69
  You need to call the `.get_access_token()` Method **every time** you make API-Calls,
@@ -77,8 +78,23 @@ from nextlayer.sdk.auth_httpx import NlHttpxAuth
77
78
 
78
79
  client = httpx.Client(
79
80
  timeout=httpx.Timeout(30.0),
80
- base_url=f"{base_url}/api/v2",
81
+ base_url=f"https://portal.nextlayer.at/apis/v1",
81
82
  auth=NlHttpxAuth(),
82
83
  )
84
+ print(client.get("/users/self").json())
85
+ ```
86
+
87
+ ## Usage fron commandline
88
+
89
+ The package also installs a commandline utility `nextlayer-auth` which takes care
90
+ of obtaining an access token and printing out a proper `Authorization:` header.
91
+
92
+ ```bash
93
+ curl -H "`nextlayer-auth`" https://portal.nextlayer.at/apis/v1/users/self
94
+ ```
95
+
96
+ It can also be used to "logout" by cleaning up tokens in the yaml file with:
97
+ ```
98
+ nextlayer-auth clear
83
99
  ```
84
100
 
@@ -4,8 +4,8 @@ Client utilities to interact with next layer public APIs.
4
4
 
5
5
  ## Configuration
6
6
 
7
- The module will use a YAML Config file in , where it also needs to **write** to, to store
8
- and update the obtained Tokens and their expiry (similar like `kubctl` does with kubeconfig).
7
+ The module will use a YAML Config file to read it's configuration and also **writes** to it,
8
+ to store obtained Tokens and their expiry (similar like `kubctl` does with kubeconfig).
9
9
 
10
10
  _Example `~/.nextlayer-sdk/auth.nlcustomers.yml`:_
11
11
 
@@ -25,7 +25,7 @@ Except for `username`, all settings are optional, but if no `password` is
25
25
  supplied in config, the password will be asked interactively (if STDIN is a TTY) !
26
26
 
27
27
  Alternatively the username can be suppled in the `NEXTLAYERSDK_USERNAME` environment
28
- variable or directly passed to the `NlAuth` cosntructor.
28
+ variable or directly passed to the `NlAuth` constructor.
29
29
 
30
30
  Alternatively the password can be suppliend in the `NEXTLAYERSDK_PASSWORD` environment
31
31
  variable.
@@ -44,6 +44,7 @@ rsp = requests.get(
44
44
  "https://portal.nextlayer.at/apis/v1/users/self",
45
45
  headers={"Authorization": "Bearer " + access_token},
46
46
  )
47
+ print(rsp.json())
47
48
  ```
48
49
 
49
50
  You need to call the `.get_access_token()` Method **every time** you make API-Calls,
@@ -58,7 +59,22 @@ from nextlayer.sdk.auth_httpx import NlHttpxAuth
58
59
 
59
60
  client = httpx.Client(
60
61
  timeout=httpx.Timeout(30.0),
61
- base_url=f"{base_url}/api/v2",
62
+ base_url=f"https://portal.nextlayer.at/apis/v1",
62
63
  auth=NlHttpxAuth(),
63
64
  )
65
+ print(client.get("/users/self").json())
66
+ ```
67
+
68
+ ## Usage fron commandline
69
+
70
+ The package also installs a commandline utility `nextlayer-auth` which takes care
71
+ of obtaining an access token and printing out a proper `Authorization:` header.
72
+
73
+ ```bash
74
+ curl -H "`nextlayer-auth`" https://portal.nextlayer.at/apis/v1/users/self
75
+ ```
76
+
77
+ It can also be used to "logout" by cleaning up tokens in the yaml file with:
78
+ ```
79
+ nextlayer-auth clear
64
80
  ```
@@ -3,7 +3,7 @@ name = "nextlayer-sdk-python"
3
3
  packages = [
4
4
  { include = "nextlayer", from="src" }
5
5
  ]
6
- version = "v1.0.1"
6
+ version = "v1.0.2"
7
7
  description = "Client utilities to interact with next layer public APIs"
8
8
  readme = "README.md"
9
9
  authors = ["Wolfgang Powisch <wolfgang.powisch@nextlayer.at>"]
@@ -1,2 +1,2 @@
1
1
  # do not edit this version line, it will be updated in CI-Pipeline!
2
- __version__ = "v1.0.1"
2
+ __version__ = "v1.0.2"