aio-kong 3.0.0__tar.gz → 3.3.1__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,4 +1,4 @@
1
- Copyright (c) 2022 Quantmind
1
+ Copyright (c) 2023 Quantmind
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification,
4
4
  are permitted provided that the following conditions are met:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aio-kong
3
- Version: 3.0.0
3
+ Version: 3.3.1
4
4
  Summary: Asynchronous Kong Client
5
5
  License: BSD-3-Clause
6
6
  Author: Luca
@@ -17,9 +17,6 @@ Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: 3
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
20
  Classifier: Topic :: Software Development
24
21
  Classifier: Topic :: Software Development :: Libraries
25
22
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
@@ -37,11 +34,11 @@ Description-Content-Type: text/markdown
37
34
  [![PyPI version](https://badge.fury.io/py/aio-kong.svg)](https://badge.fury.io/py/aio-kong)
38
35
  [![Python versions](https://img.shields.io/pypi/pyversions/aio-kong.svg)](https://pypi.org/project/aio-kong)
39
36
  [![Build](https://github.com/quantmind/aio-kong/workflows/build/badge.svg)](https://github.com/quantmind/aio-kong/actions?query=workflow%3Abuild)
40
- [![codecov](https://codecov.io/gh/quantmind/aio-kong/branch/master/graph/badge.svg)](https://codecov.io/gh/quantmind/aio-kong)
37
+ [![codecov](https://codecov.io/gh/quantmind/aio-kong/branch/main/graph/badge.svg?token=JF5L0PEkW6)](https://codecov.io/gh/quantmind/aio-kong)
41
38
  [![Downloads](https://img.shields.io/pypi/dd/aio-kong.svg)](https://pypi.org/project/aio-kong/)
42
39
 
43
40
 
44
- Tested with [kong][] v3.1
41
+ Tested with [kong][] v3.3
45
42
 
46
43
  ## Installation & Testing
47
44
 
@@ -1,3 +1,3 @@
1
1
  """Asynchronous Kong client"""
2
2
 
3
- __version__ = "3.0.0"
3
+ __version__ = "3.3.1"
@@ -15,7 +15,6 @@ def auth_factory(consumer: Consumer, auth_type: str) -> ConsumerAuth:
15
15
 
16
16
 
17
17
  class ConsumerAuth(CrudComponent):
18
-
19
18
  unique_field: str = ""
20
19
 
21
20
  @property
@@ -54,7 +54,7 @@ class Kong:
54
54
  __str__ = __repr__
55
55
 
56
56
  @property
57
- def cli(self) -> "Kong":
57
+ def cli(self) -> Kong:
58
58
  return self
59
59
 
60
60
  async def close(self) -> None:
File without changes
@@ -1,4 +1,3 @@
1
- from itertools import zip_longest
2
1
  from typing import cast
3
2
 
4
3
  from .components import UUID, CrudComponent, JsonType
@@ -19,26 +18,27 @@ class Routes(CrudComponent):
19
18
  await route.plugins.delete_all()
20
19
  return await super().delete(id_)
21
20
 
22
- async def apply_json(self, data: JsonType, clear: bool = True) -> list:
21
+ async def apply_json(self, data: JsonType, clear: bool = True) -> list[dict]:
23
22
  if not isinstance(data, list):
24
23
  data = [data]
25
24
  routes = await self.get_list()
25
+ route_map = {r.name: r for r in routes}
26
26
  result = []
27
- for entry, route in zip_longest(data, routes):
28
- if not entry:
29
- if route and clear:
30
- await self.delete(route.id)
31
- continue
27
+ for entry in data:
28
+ name = entry.get("name")
29
+ route = route_map.pop(name, None) if name else None
32
30
  entry = entry.copy()
33
31
  plugins = entry.pop("plugins", [])
34
32
  as_list("hosts", entry)
35
33
  as_list("paths", entry)
36
34
  as_list("methods", entry)
37
- if not route:
38
- entity = await self.create(**entry)
39
- else:
40
- entity = await self.update(route.id, **entry)
35
+ if route:
36
+ await self.delete(route.id)
37
+ entity = await self.create(**entry)
41
38
  route = cast(KongEntityWithPlugins, entity)
42
39
  route.data["plugins"] = await route.plugins.apply_json(plugins)
43
40
  result.append(route.data)
41
+ if clear:
42
+ for route in route_map.values():
43
+ await self.delete(route.id)
44
44
  return result
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "aio-kong"
3
- version = "3.0.0"
3
+ version = "3.3.1"
4
4
  description = "Asynchronous Kong Client"
5
5
  authors = ["Luca <luca@quantmind.com>"]
6
6
  license = "BSD-3-Clause"
@@ -37,20 +37,38 @@ aiohttp = "^3.8.1"
37
37
  click = "^8.1.3"
38
38
  PyYAML = "^6.0"
39
39
 
40
- [tool.poetry.dev-dependencies]
41
- black = "^22.6.0"
40
+ [tool.poetry.group.dev.dependencies]
41
+ black = "^23.3.0"
42
42
  isort = "^5.10.1"
43
- mypy = "^0.991"
43
+ mypy = "^1.4.0"
44
44
  pytest = "^7.1.2"
45
45
  pytest-cov = "^4.0.0"
46
- flake8 = "^6.0.0"
47
- flake8-blind-except = "^0.2.0"
48
- codecov = "^2.1.12"
49
- coverage = "^6.2"
50
- python-dotenv = "^0.21.0"
51
- pytest-asyncio = "^0.20.1"
46
+ python-dotenv = "^1.0.0"
47
+ pytest-asyncio = "^0.21.0"
52
48
  types-PyYAML = "^6.0.11"
49
+ ruff = "^0.0.274"
53
50
 
54
51
  [build-system]
55
52
  requires = ["poetry-core>=1.0.0"]
56
53
  build-backend = "poetry.core.masonry.api"
54
+
55
+
56
+ [tool.pytest.ini_options]
57
+ asyncio_mode = "auto"
58
+ testpaths = [
59
+ "tests"
60
+ ]
61
+
62
+
63
+ [tool.isort]
64
+ profile = "black"
65
+
66
+ [tool.ruff]
67
+ select = ["E", "F"]
68
+ line-length = 88
69
+
70
+ [tool.mypy]
71
+ disallow_untyped_calls = true
72
+ warn_return_any = false
73
+ disallow_untyped_defs = true
74
+ warn_no_return = true
@@ -3,11 +3,11 @@
3
3
  [![PyPI version](https://badge.fury.io/py/aio-kong.svg)](https://badge.fury.io/py/aio-kong)
4
4
  [![Python versions](https://img.shields.io/pypi/pyversions/aio-kong.svg)](https://pypi.org/project/aio-kong)
5
5
  [![Build](https://github.com/quantmind/aio-kong/workflows/build/badge.svg)](https://github.com/quantmind/aio-kong/actions?query=workflow%3Abuild)
6
- [![codecov](https://codecov.io/gh/quantmind/aio-kong/branch/master/graph/badge.svg)](https://codecov.io/gh/quantmind/aio-kong)
6
+ [![codecov](https://codecov.io/gh/quantmind/aio-kong/branch/main/graph/badge.svg?token=JF5L0PEkW6)](https://codecov.io/gh/quantmind/aio-kong)
7
7
  [![Downloads](https://img.shields.io/pypi/dd/aio-kong.svg)](https://pypi.org/project/aio-kong/)
8
8
 
9
9
 
10
- Tested with [kong][] v3.1
10
+ Tested with [kong][] v3.3
11
11
 
12
12
  ## Installation & Testing
13
13
 
aio_kong-3.0.0/setup.py DELETED
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['kong']
6
-
7
- package_data = \
8
- {'': ['*']}
9
-
10
- install_requires = \
11
- ['PyYAML>=6.0,<7.0', 'aiohttp>=3.8.1,<4.0.0', 'click>=8.1.3,<9.0.0']
12
-
13
- setup_kwargs = {
14
- 'name': 'aio-kong',
15
- 'version': '3.0.0',
16
- 'description': 'Asynchronous Kong Client',
17
- 'long_description': '# Async Python Client for Kong\n\n[![PyPI version](https://badge.fury.io/py/aio-kong.svg)](https://badge.fury.io/py/aio-kong)\n[![Python versions](https://img.shields.io/pypi/pyversions/aio-kong.svg)](https://pypi.org/project/aio-kong)\n[![Build](https://github.com/quantmind/aio-kong/workflows/build/badge.svg)](https://github.com/quantmind/aio-kong/actions?query=workflow%3Abuild)\n[![codecov](https://codecov.io/gh/quantmind/aio-kong/branch/master/graph/badge.svg)](https://codecov.io/gh/quantmind/aio-kong)\n[![Downloads](https://img.shields.io/pypi/dd/aio-kong.svg)](https://pypi.org/project/aio-kong/)\n\n\nTested with [kong][] v3.1\n\n## Installation & Testing\n\nTo install the package\n\n```\npip install aio-kong\n```\n\nTo run tests, clone and\n\n```\nmake test\n```\n\n:warning: If you don\'t have Kong or postgres running locally, run the services first\n\n```bash\nmake services\n```\n\ntest certificates were generated using the command\n\n```\nopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj \'/CN=localhost\'\n```\n\n## Client\n\nThe client can be imported via\n\n```python\nfrom kong.client import Kong\n```\n\nIn a coroutine:\n\n```python\nasync with Kong() as cli:\n services = await cli.services.get_list()\n print(json.dumps([s.data for s in services], indent=2))\n```\n\nBy default the url is obtained from the "KONG_ADMIN_URL" environment variable which defaults to http://127.0.0.1:8001.\n\nThe client has handlers for all Kong objects\n\n- [cli.services](./kong/services.py) CRUD operations on services\n- [cli.routes](./kong/routes.py) CRUD operations on routes\n- [cli.plugins](./kong/plugins.py) CRUD operations on plugins\n- [cli.consumers](./kong/consumers.py) CRUD operations on consumers\n- [cli.certificates](./kong/certificates.py) CRUD operations on TLS certificates\n- [cli.snis](./kong/snis.py) CRUD operations on SNIs\n- `cli.acls` To list all ACLs\n\n### Apply a configuration\n\nThe client allow to apply a configuration object to kong:\n\n```python\nawait cli.apply_json(config)\n```\n\n## Command line tool\n\nThe library install the `kongfig` command line tool for uploading kong configuration files.\n\n```\nkongfig --yaml config.yaml\n```\n\n[kong]: https://github.com/Kong/kong\n',
18
- 'author': 'Luca',
19
- 'author_email': 'luca@quantmind.com',
20
- 'maintainer': 'None',
21
- 'maintainer_email': 'None',
22
- 'url': 'None',
23
- 'packages': packages,
24
- 'package_data': package_data,
25
- 'install_requires': install_requires,
26
- 'python_requires': '>=3.10,<4.0',
27
- }
28
-
29
-
30
- setup(**setup_kwargs)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes