aio-kong 3.7.1__py3-none-any.whl → 3.7.2__py3-none-any.whl

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: aio-kong
3
- Version: 3.7.1
3
+ Version: 3.7.2
4
4
  Summary: Asynchronous Kong Client
5
5
  License: BSD-3-Clause
6
6
  Author: Luca Sbardella
@@ -113,5 +113,13 @@ and to run the cli tool, you can use the following command:
113
113
  kongfig --help
114
114
  ```
115
115
 
116
+
117
+ ## Environment variables
118
+
119
+ The client uses the following environment variables:
120
+
121
+ * `KONG_ADMIN_URL`: The URL of the Kong admin API. Defaults to `http://127.0.0.1:8001`.
122
+ * `KONG_ADMIN_SSL`: Whether to use SSL validation for the Kong admin API. Defaults to `true`.
123
+
116
124
  [kong]: https://github.com/Kong/kong
117
125
 
@@ -1,9 +1,9 @@
1
- kong/__init__.py,sha256=XBw4jTdRI9AISqosZ32-Z6cawhimVjvwj8AmcgCW0rs,54
1
+ kong/__init__.py,sha256=_bttf2nr5Tpq7nT_IWzoyaYbwcnddQgYHfInF1gHjZY,54
2
2
  kong/acls.py,sha256=1HR66CKp6SVOmtauXOnj77moLMeHfL7gsfBRwlbJK1U,127
3
3
  kong/auths.py,sha256=1aNSQ6Sw5rjh8lbJppH9GOXVMG6KL7-bO4P75MsFKJU,2337
4
4
  kong/certificates.py,sha256=7QYS0BLg5QKyjdi1dUDGErXBZHQK4ARv_iYFluXX3RM,275
5
- kong/cli.py,sha256=9_HiFC2FxhNpCufkg86E00k1nKjorp4O8Bss6ZmLdx8,5649
6
- kong/client.py,sha256=T8cTcpCMZ4Lm_BFta56sFintV3vqgQFr5_4kwUi7LDc,4010
5
+ kong/cli.py,sha256=7ZUbTH64P_vFmEMgeg3s8RnwK7naFWXlebvpR91x5JA,5934
6
+ kong/client.py,sha256=t06vRnqif86FbYfjKnZOEPyCFs7o56cX40GvEQDd0mg,4383
7
7
  kong/components.py,sha256=ZT3bSsfFzKOH-ipXFDFAsMCjWydqqCGsakbhB26CBfM,5471
8
8
  kong/consumers.py,sha256=SDR9W6zY3PAIq_iC0EOSKbn0lyTl4C7WbsyM7MA7hLs,2715
9
9
  kong/plugins.py,sha256=GmuL-EnrpHeZEzv0bjDvXE0oTtG3DYWpGi0AZHMmY7E,2730
@@ -12,8 +12,8 @@ kong/routes.py,sha256=e1n5hIIirwkAVacbFnJ_C1AwQN_IC10gISyXU8ex-g0,1493
12
12
  kong/services.py,sha256=fVArH4m7DfTfgBD7n1OGUArE-P6ZNJUP_zPPM1sBNRo,2616
13
13
  kong/snis.py,sha256=QxjHFUtMGvlBcfCdiye5hQ9n8D1PRSQQThqaB-OekLI,716
14
14
  kong/utils.py,sha256=Uoe5DRclN-t1DX8AvwgidYn8GMMvLUXVjMgzqs6mUAE,932
15
- aio_kong-3.7.1.dist-info/LICENSE,sha256=hTYbUZ810IUK9Cr9n0_PpfL7rpjDPSC9_CaS2014bdg,1466
16
- aio_kong-3.7.1.dist-info/METADATA,sha256=it4SamLtWRNYUoSjVxDoW-b1NAzMRh-Mc1b0r_h5R_s,3249
17
- aio_kong-3.7.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
- aio_kong-3.7.1.dist-info/entry_points.txt,sha256=Wp_emFiShNNMtqwMxwwdo7qQDiLMxYqZwk9sP4YbEp4,41
19
- aio_kong-3.7.1.dist-info/RECORD,,
15
+ aio_kong-3.7.2.dist-info/LICENSE,sha256=hTYbUZ810IUK9Cr9n0_PpfL7rpjDPSC9_CaS2014bdg,1466
16
+ aio_kong-3.7.2.dist-info/METADATA,sha256=HnqLHnaRRPHtVdJpsQod4e4YirBtzUOnLI1rWYTwDfM,3513
17
+ aio_kong-3.7.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
18
+ aio_kong-3.7.2.dist-info/entry_points.txt,sha256=Wp_emFiShNNMtqwMxwwdo7qQDiLMxYqZwk9sP4YbEp4,41
19
+ aio_kong-3.7.2.dist-info/RECORD,,
kong/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Asynchronous Kong client"""
2
2
 
3
- __version__ = "3.7.1"
3
+ __version__ = "3.7.2"
kong/cli.py CHANGED
@@ -55,11 +55,12 @@ def ip() -> None:
55
55
 
56
56
 
57
57
  @kong.command()
58
+ @click.option("-d", "--delete", type=str, help="Delete a service by name")
58
59
  @admin_url
59
60
  @as_json
60
- def services(url: str, json: bool) -> None:
61
+ def services(delete: str, url: str, json: bool) -> None:
61
62
  "Display services"
62
- asyncio.run(_services(url, as_json=json))
63
+ asyncio.run(_services(url, as_json=json, delete=delete))
63
64
 
64
65
 
65
66
  @kong.command()
@@ -96,9 +97,13 @@ async def _yml(yaml: Any, clear: bool, url: str) -> None:
96
97
  raise click.ClickException(str(exc)) from None
97
98
 
98
99
 
99
- async def _services(url: str, as_json: bool = False) -> None:
100
+ async def _services(url: str, as_json: bool = False, delete: str | None = None) -> None:
100
101
  async with Kong(url=url) as cli:
101
102
  try:
103
+ if delete:
104
+ await cli.services.delete(delete)
105
+ click.echo(f"Service '{delete}' deleted.")
106
+ return
102
107
  services = await cli.services.get_full_list()
103
108
  except KongError as exc:
104
109
  raise click.ClickException(str(exc)) from None
kong/client.py CHANGED
@@ -22,28 +22,41 @@ DEFAULT_USER_AGENT = (
22
22
  f"python/{'.'.join(map(str, sys.version_info[:2]))} aio-kong/{__version__}"
23
23
  )
24
24
 
25
+ KONG_ADMIN_SSL = os.getenv("KONG_ADMIN_SSL", "true").strip().lower() in (
26
+ "true",
27
+ "1",
28
+ "yes",
29
+ )
30
+
25
31
 
26
32
  def default_admin_url() -> str:
27
33
  """Return the default Kong admin URL."""
28
34
  return os.getenv("KONG_ADMIN_URL", os.getenv("KONG_URL", "http://127.0.0.1:8001"))
29
35
 
30
36
 
37
+ def kong_request_kwargs(request_kwargs: dict | None = None) -> dict:
38
+ kwargs = request_kwargs or {}
39
+ if "ssl" not in kwargs and not KONG_ADMIN_SSL:
40
+ kwargs["ssl"] = False
41
+ return kwargs
42
+
43
+
31
44
  class Kong:
32
45
  """Kong client"""
33
46
 
34
- content_type: str = "application/json, text/*; q=0.5"
35
-
36
47
  def __init__(
37
48
  self,
38
49
  url: str | None = None,
39
50
  session: ClientSession | None = None,
40
51
  request_kwargs: dict | None = None,
41
52
  user_agent: str = DEFAULT_USER_AGENT,
53
+ content_type: str = "application/json, text/*; q=0.5",
42
54
  ) -> None:
43
55
  self.url = url or default_admin_url()
44
56
  self.session = session
45
57
  self.user_agent = user_agent
46
- self.request_kwargs = request_kwargs or {}
58
+ self.content_type = content_type
59
+ self.request_kwargs = kong_request_kwargs(request_kwargs)
47
60
  self.services = Services(self, Service)
48
61
  self.routes = Routes(self, Route)
49
62
  self.plugins = Plugins(self, Plugin)