lswapi 0.5.0__tar.gz → 0.5.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.
- {lswapi-0.5.0/lswapi.egg-info → lswapi-0.5.2}/PKG-INFO +8 -20
- {lswapi-0.5.0 → lswapi-0.5.2}/pyproject.toml +29 -33
- lswapi-0.5.2/src/lswapi/__init__.py +2 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/aio/client.py +6 -2
- lswapi-0.5.0/.version +0 -1
- lswapi-0.5.0/PKG-INFO +0 -114
- lswapi-0.5.0/lswapi.egg-info/SOURCES.txt +0 -22
- lswapi-0.5.0/lswapi.egg-info/dependency_links.txt +0 -1
- lswapi-0.5.0/lswapi.egg-info/entry_points.txt +0 -2
- lswapi-0.5.0/lswapi.egg-info/requires.txt +0 -17
- lswapi-0.5.0/lswapi.egg-info/top_level.txt +0 -1
- lswapi-0.5.0/setup.cfg +0 -4
- lswapi-0.5.0/src/lswapi/__init__.py +0 -9
- lswapi-0.5.0/tests/test_aio.py +0 -23
- lswapi-0.5.0/tests/test_lswapi.py +0 -7
- lswapi-0.5.0/tests/test_requests.py +0 -16
- {lswapi-0.5.0 → lswapi-0.5.2}/LICENSE.txt +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/README.md +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/aio/__init__.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/aio/middleware.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/aio/oauth.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/httpie.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/requests/__init__.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/requests/oauth.py +0 -0
- {lswapi-0.5.0 → lswapi-0.5.2}/src/lswapi/requests/session.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: lswapi
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: a python client library for easy leaseweb api access
|
|
5
|
-
Author-email: Nico Di Rocco <n.dirocco@global.leaseweb.com>
|
|
6
5
|
License: Apache-2.0
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Author: Nico Di Rocco
|
|
7
|
+
Author-email: n.dirocco@global.leaseweb.com
|
|
8
|
+
Requires-Python: >= 3.9
|
|
9
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
10
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
11
11
|
Classifier: Operating System :: Unix
|
|
@@ -17,22 +17,9 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
19
|
Classifier: Topic :: Utilities
|
|
20
|
-
|
|
20
|
+
Project-URL: Homepage, http://developer.leaseweb.com
|
|
21
|
+
Project-URL: Issues, https://github.com/nrocco/lswapi
|
|
21
22
|
Description-Content-Type: text/markdown
|
|
22
|
-
License-File: LICENSE.txt
|
|
23
|
-
Provides-Extra: develop
|
|
24
|
-
Requires-Dist: flake8; extra == "develop"
|
|
25
|
-
Requires-Dist: pytest; extra == "develop"
|
|
26
|
-
Requires-Dist: pytest-cov; extra == "develop"
|
|
27
|
-
Requires-Dist: requests-mock; extra == "develop"
|
|
28
|
-
Requires-Dist: twine; extra == "develop"
|
|
29
|
-
Provides-Extra: httpie
|
|
30
|
-
Requires-Dist: httpie; extra == "httpie"
|
|
31
|
-
Provides-Extra: requests
|
|
32
|
-
Requires-Dist: requests; extra == "requests"
|
|
33
|
-
Provides-Extra: aio
|
|
34
|
-
Requires-Dist: aiodns; extra == "aio"
|
|
35
|
-
Requires-Dist: aiohttp; extra == "aio"
|
|
36
23
|
|
|
37
24
|
# lswapi (beta)
|
|
38
25
|
|
|
@@ -112,3 +99,4 @@ Contribute
|
|
|
112
99
|
4. Make sure that tests pass (`make test`)
|
|
113
100
|
5. Push to the branch (`git push origin my-new-feature`)
|
|
114
101
|
6. Create new Pull Request
|
|
102
|
+
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lswapi"
|
|
3
|
-
|
|
3
|
+
version = "0.5.2"
|
|
4
4
|
description = "a python client library for easy leaseweb api access"
|
|
5
|
-
readme = "README.md"
|
|
6
5
|
authors = [
|
|
7
|
-
{
|
|
6
|
+
{name = "Nico Di Rocco",email = "n.dirocco@global.leaseweb.com"}
|
|
8
7
|
]
|
|
9
|
-
license = {text="Apache-2.0"}
|
|
10
|
-
requires-python = ">= 3.9"
|
|
11
8
|
classifiers = [
|
|
12
9
|
"Development Status :: 5 - Production/Stable",
|
|
13
10
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
@@ -21,47 +18,46 @@ classifiers = [
|
|
|
21
18
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
19
|
"Topic :: Utilities"
|
|
23
20
|
]
|
|
21
|
+
license = "Apache-2.0"
|
|
22
|
+
readme = "README.md"
|
|
23
|
+
requires-python = ">= 3.9"
|
|
24
|
+
dependencies = [
|
|
25
|
+
]
|
|
24
26
|
|
|
25
27
|
[project.urls]
|
|
26
28
|
Homepage = "http://developer.leaseweb.com"
|
|
27
29
|
Issues = "https://github.com/nrocco/lswapi"
|
|
28
30
|
|
|
29
|
-
[project.optional-dependencies]
|
|
30
|
-
develop = [
|
|
31
|
-
"flake8",
|
|
32
|
-
"pytest",
|
|
33
|
-
"pytest-cov",
|
|
34
|
-
"requests-mock",
|
|
35
|
-
"twine",
|
|
36
|
-
]
|
|
37
|
-
httpie = [
|
|
38
|
-
"httpie",
|
|
39
|
-
]
|
|
40
|
-
requests = [
|
|
41
|
-
"requests",
|
|
42
|
-
]
|
|
43
|
-
aio = [
|
|
44
|
-
"aiodns",
|
|
45
|
-
"aiohttp",
|
|
46
|
-
]
|
|
47
31
|
|
|
48
32
|
[project.entry-points."httpie.plugins.auth.v1"]
|
|
49
33
|
httpie_lswapi = "lswapi.httpie:ApiAuthPlugin"
|
|
50
34
|
|
|
35
|
+
|
|
51
36
|
[build-system]
|
|
52
|
-
requires = [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
38
|
+
build-backend = "poetry.core.masonry.api"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
[tool.poetry.group.dev.dependencies]
|
|
42
|
+
flake8 = "^7.3.0"
|
|
43
|
+
pytest = "^8.4.1"
|
|
44
|
+
pytest-cov = "^6.2.1"
|
|
45
|
+
requests-mock = "^1.12.1"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
[tool.poetry.group.httpie.dependencies]
|
|
49
|
+
httpie = "^3.2.4"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
[tool.poetry.group.requests.dependencies]
|
|
53
|
+
requests = "^2.32.4"
|
|
54
|
+
|
|
56
55
|
|
|
57
|
-
[tool.
|
|
58
|
-
|
|
56
|
+
[tool.poetry.group.aio.dependencies]
|
|
57
|
+
aiodns = "^3.5.0"
|
|
58
|
+
aiohttp = "^3.12.15"
|
|
59
59
|
|
|
60
|
-
[tool.setuptools.dynamic]
|
|
61
|
-
version = {file = ".version"}
|
|
62
60
|
|
|
63
61
|
[tool.pytest.ini_options]
|
|
64
62
|
testpaths = ["tests"]
|
|
65
63
|
|
|
66
|
-
[tool.distutils.egg_info]
|
|
67
|
-
egg_base = "."
|
|
@@ -4,7 +4,8 @@ from aiohttp import ClientSession
|
|
|
4
4
|
class LeasewebHttpClient:
|
|
5
5
|
def __init__(self, *args, middlewares: list[callable] = [], **kwargs):
|
|
6
6
|
self.middlewares = middlewares
|
|
7
|
-
self.
|
|
7
|
+
self.__create_session = lambda: ClientSession(*args, **kwargs)
|
|
8
|
+
self.session = None
|
|
8
9
|
|
|
9
10
|
async def _run_middlewares(self, method, url, next_func, **kwargs):
|
|
10
11
|
async def middleware_chain(index, method, url, **kwargs):
|
|
@@ -16,6 +17,8 @@ class LeasewebHttpClient:
|
|
|
16
17
|
return await middleware_chain(0, method, url, **kwargs)
|
|
17
18
|
|
|
18
19
|
async def _request(self, method, url, **kwargs):
|
|
20
|
+
if not self.session:
|
|
21
|
+
self.session = self.__create_session()
|
|
19
22
|
return await self.session.request(method, url, **kwargs)
|
|
20
23
|
|
|
21
24
|
async def request(self, method, url, **kwargs):
|
|
@@ -37,7 +40,8 @@ class LeasewebHttpClient:
|
|
|
37
40
|
return await self.request("DELETE", url, **kwargs)
|
|
38
41
|
|
|
39
42
|
async def close(self):
|
|
40
|
-
|
|
43
|
+
if self.session:
|
|
44
|
+
await self.session.close()
|
|
41
45
|
|
|
42
46
|
async def __aenter__(self):
|
|
43
47
|
return self
|
lswapi-0.5.0/.version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.5.0
|
lswapi-0.5.0/PKG-INFO
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: lswapi
|
|
3
|
-
Version: 0.5.0
|
|
4
|
-
Summary: a python client library for easy leaseweb api access
|
|
5
|
-
Author-email: Nico Di Rocco <n.dirocco@global.leaseweb.com>
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Project-URL: Homepage, http://developer.leaseweb.com
|
|
8
|
-
Project-URL: Issues, https://github.com/nrocco/lswapi
|
|
9
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
11
|
-
Classifier: Operating System :: Unix
|
|
12
|
-
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
-
Classifier: Topic :: Utilities
|
|
20
|
-
Requires-Python: >=3.9
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
License-File: LICENSE.txt
|
|
23
|
-
Provides-Extra: develop
|
|
24
|
-
Requires-Dist: flake8; extra == "develop"
|
|
25
|
-
Requires-Dist: pytest; extra == "develop"
|
|
26
|
-
Requires-Dist: pytest-cov; extra == "develop"
|
|
27
|
-
Requires-Dist: requests-mock; extra == "develop"
|
|
28
|
-
Requires-Dist: twine; extra == "develop"
|
|
29
|
-
Provides-Extra: httpie
|
|
30
|
-
Requires-Dist: httpie; extra == "httpie"
|
|
31
|
-
Provides-Extra: requests
|
|
32
|
-
Requires-Dist: requests; extra == "requests"
|
|
33
|
-
Provides-Extra: aio
|
|
34
|
-
Requires-Dist: aiodns; extra == "aio"
|
|
35
|
-
Requires-Dist: aiohttp; extra == "aio"
|
|
36
|
-
|
|
37
|
-
# lswapi (beta)
|
|
38
|
-
|
|
39
|
-
[](https://github.com/nrocco/lswapi/actions)
|
|
40
|
-
|
|
41
|
-
Python module to talk to Leaseweb's API.
|
|
42
|
-
|
|
43
|
-
For more information refer to the documentation available at
|
|
44
|
-
[http://developer.leaseweb.com]
|
|
45
|
-
|
|
46
|
-
This module contains two api clients:
|
|
47
|
-
|
|
48
|
-
1. One is based on the `requests` module.
|
|
49
|
-
2. The second one is based on the `aiohttp` module for asyncio support.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## Installation
|
|
53
|
-
|
|
54
|
-
Install the module using pip. This will not install `requests` or `aiohttp`.
|
|
55
|
-
|
|
56
|
-
pip install lswapi
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
You can install optional depencies, such as `aiohttp`:
|
|
60
|
-
|
|
61
|
-
pip install 'lswapi[aio]'
|
|
62
|
-
|
|
63
|
-
Or if you prefer to use `requests`:
|
|
64
|
-
|
|
65
|
-
pip install 'lswapi[requests]'
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Using requests
|
|
72
|
-
|
|
73
|
-
The `lswapi.requests.get_leaseweb_api` function creates an instance of the Leaseweb Api
|
|
74
|
-
object with the `X-Lsw-Auth` key. You can provide the api key as an argument
|
|
75
|
-
to `get_leaseweb_api`
|
|
76
|
-
|
|
77
|
-
$ python
|
|
78
|
-
>>> from lswapi.requests import get_leaseweb_api
|
|
79
|
-
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
|
|
80
|
-
>>> response = client.get("/bareMetals/v2/servers")
|
|
81
|
-
>>> servers = response.json()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
or get `LSW_API_KEY` from an environment variable:
|
|
85
|
-
|
|
86
|
-
$ LSW_API_KEY=xxxx-xxxx-xxxxx python
|
|
87
|
-
>>> from lswapi.requests import get_leaseweb_api
|
|
88
|
-
>>> client = get_leaseweb_api()
|
|
89
|
-
>>> response = client.get("/bareMetals/v2/servers")
|
|
90
|
-
>>> servers = response.json()
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### Using aiohttp
|
|
94
|
-
|
|
95
|
-
The `lswapi.aio.get_leaseweb_api` function creates an instance of the Leaseweb Api
|
|
96
|
-
object with the `X-Lsw-Auth` key. You can provide the api key as an argument
|
|
97
|
-
to `get_leaseweb_api` or via the environment variable `LSW_API_KEY`:
|
|
98
|
-
|
|
99
|
-
$ python -m asyncio
|
|
100
|
-
>>> from lswapi.aio import get_leaseweb_api
|
|
101
|
-
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
|
|
102
|
-
>>> response = await client.get("/bareMetals/v2/servers")
|
|
103
|
-
>>> servers = await response.json()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Contribute
|
|
107
|
-
----------
|
|
108
|
-
|
|
109
|
-
1. Fork it
|
|
110
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
111
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
112
|
-
4. Make sure that tests pass (`make test`)
|
|
113
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
|
114
|
-
6. Create new Pull Request
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
.version
|
|
2
|
-
LICENSE.txt
|
|
3
|
-
README.md
|
|
4
|
-
pyproject.toml
|
|
5
|
-
lswapi.egg-info/PKG-INFO
|
|
6
|
-
lswapi.egg-info/SOURCES.txt
|
|
7
|
-
lswapi.egg-info/dependency_links.txt
|
|
8
|
-
lswapi.egg-info/entry_points.txt
|
|
9
|
-
lswapi.egg-info/requires.txt
|
|
10
|
-
lswapi.egg-info/top_level.txt
|
|
11
|
-
src/lswapi/__init__.py
|
|
12
|
-
src/lswapi/httpie.py
|
|
13
|
-
src/lswapi/aio/__init__.py
|
|
14
|
-
src/lswapi/aio/client.py
|
|
15
|
-
src/lswapi/aio/middleware.py
|
|
16
|
-
src/lswapi/aio/oauth.py
|
|
17
|
-
src/lswapi/requests/__init__.py
|
|
18
|
-
src/lswapi/requests/oauth.py
|
|
19
|
-
src/lswapi/requests/session.py
|
|
20
|
-
tests/test_aio.py
|
|
21
|
-
tests/test_lswapi.py
|
|
22
|
-
tests/test_requests.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
lswapi
|
lswapi-0.5.0/setup.cfg
DELETED
lswapi-0.5.0/tests/test_aio.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
from lswapi.aio import get_leaseweb_api
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_get_with_nothing():
|
|
8
|
-
async def fuubar():
|
|
9
|
-
with pytest.raises(Exception):
|
|
10
|
-
get_leaseweb_api()
|
|
11
|
-
asyncio.run(fuubar())
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def test_get_with_api_key():
|
|
15
|
-
async def fuubar():
|
|
16
|
-
assert get_leaseweb_api(api_key="xxx")
|
|
17
|
-
asyncio.run(fuubar())
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_get_with_oauth():
|
|
21
|
-
async def fuubar():
|
|
22
|
-
assert get_leaseweb_api(client_id="xxx", client_secret="yyy")
|
|
23
|
-
asyncio.run(fuubar())
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from lswapi.requests import get_leaseweb_api
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_get_with_nothing():
|
|
7
|
-
with pytest.raises(Exception):
|
|
8
|
-
get_leaseweb_api()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_get_with_api_key():
|
|
12
|
-
assert get_leaseweb_api(api_key="xxx")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_get_with_oauth():
|
|
16
|
-
assert get_leaseweb_api(client_id="xxx", client_secret="yyy")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|