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