mrok 0.2.2__py3-none-any.whl → 0.2.3__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.
- mrok/controller/app.py +8 -2
- mrok/controller/routes/extensions.py +21 -7
- mrok/controller/routes/instances.py +5 -1
- mrok/controller/schemas.py +13 -1
- mrok/ziti/api.py +1 -1
- {mrok-0.2.2.dist-info → mrok-0.2.3.dist-info}/METADATA +1 -1
- {mrok-0.2.2.dist-info → mrok-0.2.3.dist-info}/RECORD +10 -10
- {mrok-0.2.2.dist-info → mrok-0.2.3.dist-info}/WHEEL +0 -0
- {mrok-0.2.2.dist-info → mrok-0.2.3.dist-info}/entry_points.txt +0 -0
- {mrok-0.2.2.dist-info → mrok-0.2.3.dist-info}/licenses/LICENSE.txt +0 -0
mrok/controller/app.py
CHANGED
|
@@ -51,9 +51,15 @@ def setup_app():
|
|
|
51
51
|
|
|
52
52
|
# TODO: Add healthcheck
|
|
53
53
|
app.include_router(
|
|
54
|
-
extensions_router,
|
|
54
|
+
extensions_router,
|
|
55
|
+
prefix="/extensions",
|
|
56
|
+
dependencies=[Depends(authenticate)],
|
|
57
|
+
)
|
|
58
|
+
app.include_router(
|
|
59
|
+
instances_router,
|
|
60
|
+
prefix="/instances",
|
|
61
|
+
dependencies=[Depends(authenticate)],
|
|
55
62
|
)
|
|
56
|
-
app.include_router(instances_router, prefix="/instances", dependencies=[Depends(authenticate)])
|
|
57
63
|
|
|
58
64
|
settings = get_settings()
|
|
59
65
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import Annotated
|
|
2
|
+
from typing import Annotated, Literal
|
|
3
3
|
|
|
4
4
|
from fastapi import APIRouter, Body, HTTPException, status
|
|
5
5
|
|
|
@@ -116,8 +116,26 @@ async def create_extension(
|
|
|
116
116
|
async def get_extension_by_id_or_extension_id(
|
|
117
117
|
mgmt_api: ZitiManagementAPI,
|
|
118
118
|
id_or_extension_id: str,
|
|
119
|
+
with_instances: Literal["none", "online", "offline"] = "none",
|
|
119
120
|
):
|
|
120
|
-
|
|
121
|
+
extension = await fetch_extension_or_404(mgmt_api, id_or_extension_id)
|
|
122
|
+
|
|
123
|
+
if with_instances == "none":
|
|
124
|
+
return ExtensionRead(**extension)
|
|
125
|
+
|
|
126
|
+
instances = list(
|
|
127
|
+
filter(
|
|
128
|
+
lambda ir: ir.status == with_instances,
|
|
129
|
+
[
|
|
130
|
+
InstanceRead(**identity)
|
|
131
|
+
async for identity in mgmt_api.identities(
|
|
132
|
+
{"filter": f'tags.{MROK_SERVICE_TAG_NAME} = "{extension["name"]}"'}
|
|
133
|
+
)
|
|
134
|
+
],
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return ExtensionRead(**extension, instances=instances)
|
|
121
139
|
|
|
122
140
|
|
|
123
141
|
@router.delete(
|
|
@@ -272,11 +290,7 @@ async def get_instance_by_id_or_instance_id(
|
|
|
272
290
|
id_or_instance_id: str,
|
|
273
291
|
):
|
|
274
292
|
identity = await fetch_instance_or_404(mgmt_api, id_or_extension_id, id_or_instance_id)
|
|
275
|
-
return InstanceRead(
|
|
276
|
-
id=identity["id"],
|
|
277
|
-
name=identity["name"],
|
|
278
|
-
tags=identity["tags"],
|
|
279
|
-
)
|
|
293
|
+
return InstanceRead(**identity)
|
|
280
294
|
|
|
281
295
|
|
|
282
296
|
@router.delete(
|
|
@@ -6,6 +6,7 @@ from mrok.controller.dependencies import ZitiManagementAPI
|
|
|
6
6
|
from mrok.controller.openapi import examples
|
|
7
7
|
from mrok.controller.pagination import LimitOffsetPage, paginate
|
|
8
8
|
from mrok.controller.schemas import InstanceRead
|
|
9
|
+
from mrok.ziti.constants import MROK_IDENTITY_TYPE_TAG_NAME, MROK_IDENTITY_TYPE_TAG_VALUE_INSTANCE
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger("mrok.controller")
|
|
11
12
|
|
|
@@ -68,4 +69,7 @@ async def get_instance_by_id_or_instance_id(
|
|
|
68
69
|
async def get_instances(
|
|
69
70
|
mgmt_api: ZitiManagementAPI,
|
|
70
71
|
):
|
|
71
|
-
|
|
72
|
+
params = {
|
|
73
|
+
"filter": f'tags.{MROK_IDENTITY_TYPE_TAG_NAME}="{MROK_IDENTITY_TYPE_TAG_VALUE_INSTANCE}"'
|
|
74
|
+
}
|
|
75
|
+
return await paginate(mgmt_api, "/identities", InstanceRead, extra_params=params)
|
mrok/controller/schemas.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
from
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated, Any, Literal
|
|
2
4
|
|
|
3
5
|
from pydantic import (
|
|
4
6
|
BaseModel,
|
|
@@ -34,6 +36,7 @@ class ExtensionBase(BaseSchema):
|
|
|
34
36
|
|
|
35
37
|
class ExtensionRead(BaseSchema, IdSchema):
|
|
36
38
|
name: str
|
|
39
|
+
instances: list[InstanceRead] | None = None
|
|
37
40
|
|
|
38
41
|
@computed_field
|
|
39
42
|
def extension(self) -> dict:
|
|
@@ -51,6 +54,11 @@ class InstanceBase(BaseSchema):
|
|
|
51
54
|
class InstanceRead(BaseSchema, IdSchema):
|
|
52
55
|
name: str
|
|
53
56
|
identity: dict[str, Any] | None = None
|
|
57
|
+
has_edge_router_connection: bool | None = Field(
|
|
58
|
+
False,
|
|
59
|
+
alias="hasEdgeRouterConnection",
|
|
60
|
+
exclude=True,
|
|
61
|
+
)
|
|
54
62
|
|
|
55
63
|
@computed_field
|
|
56
64
|
def instance(self) -> dict:
|
|
@@ -62,6 +70,10 @@ class InstanceRead(BaseSchema, IdSchema):
|
|
|
62
70
|
_, extension_id = self.name.split(".", 1)
|
|
63
71
|
return {"id": extension_id.upper()}
|
|
64
72
|
|
|
73
|
+
@computed_field
|
|
74
|
+
def status(self) -> Literal["online", "offline"]:
|
|
75
|
+
return "online" if bool(self.has_edge_router_connection) else "offline"
|
|
76
|
+
|
|
65
77
|
|
|
66
78
|
class InstanceCreate(InstanceBase):
|
|
67
79
|
pass
|
mrok/ziti/api.py
CHANGED
|
@@ -397,7 +397,7 @@ class ZitiManagementAPI(BaseZitiAPI):
|
|
|
397
397
|
async def search_config_type(self, id_or_name: str) -> dict[str, Any] | None:
|
|
398
398
|
return await self.search_by_id_or_name("/config-types", id_or_name)
|
|
399
399
|
|
|
400
|
-
async def delete_config_type(self, config_type_id: str) ->
|
|
400
|
+
async def delete_config_type(self, config_type_id: str) -> None:
|
|
401
401
|
return await self.delete("/config-types", config_type_id)
|
|
402
402
|
|
|
403
403
|
async def get_identity(self, identity_id: str) -> dict[str, Any]:
|
|
@@ -31,10 +31,10 @@ mrok/cli/commands/controller/__init__.py,sha256=2xw-YVN0akiLiuGUU3XbYyZZ0ugOjQ6X
|
|
|
31
31
|
mrok/cli/commands/controller/openapi.py,sha256=QLjVao9UkB2vBaGkFi_q_jrlg4Np4ldMRwDIJsrJ7A8,1175
|
|
32
32
|
mrok/cli/commands/controller/run.py,sha256=osyjssb81xNMYZLPb6dfPR4W_BQlCxKDfvl-BIhG_1A,2460
|
|
33
33
|
mrok/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
mrok/controller/app.py,sha256=
|
|
34
|
+
mrok/controller/app.py,sha256=XxCIB7N1YE52vSYfvGW2UPgEEOZ9jxDMe2l9D2SfXi8,1866
|
|
35
35
|
mrok/controller/auth.py,sha256=Kg94W8yNMs6TvUmLRYv1QeUjDy4qlGZ-_6OHa4KH1zg,2648
|
|
36
36
|
mrok/controller/pagination.py,sha256=raYpYa34q8Ckl4BXBOEdpWlKkFj6z7e6QLWr2HT7dzI,2187
|
|
37
|
-
mrok/controller/schemas.py,sha256=
|
|
37
|
+
mrok/controller/schemas.py,sha256=AaF8_bEwZTHM02apVEBAzlUb2t71zoxYaG-VHtPNeMk,1705
|
|
38
38
|
mrok/controller/dependencies/__init__.py,sha256=voewk6gjkA0OarL6HFmfT_RLqBns0Fpl-VIqK5xVAEI,202
|
|
39
39
|
mrok/controller/dependencies/conf.py,sha256=2Pa8fxJHkZ29q6UL-w6hUP_wr7WnNELfw5LlzWg1Tec,162
|
|
40
40
|
mrok/controller/dependencies/ziti.py,sha256=fYoxeJb4s6p2_3gxbExbFSRabjpvp_gZMBb3ocXZV3Y,702
|
|
@@ -42,8 +42,8 @@ mrok/controller/openapi/__init__.py,sha256=U1dw45w76CcoQagyqg_FXdMuJF3qJZZM6wG8T
|
|
|
42
42
|
mrok/controller/openapi/examples.py,sha256=ZI0BP7L6sI0z7Mq1I3uc2UrweGpzpPeGSIuf1bUKkgg,1419
|
|
43
43
|
mrok/controller/openapi/utils.py,sha256=Kn55ISAWlMJNwrJTum7iFrBvJvr81To76pCK8W-s79Q,1114
|
|
44
44
|
mrok/controller/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
-
mrok/controller/routes/extensions.py,sha256=
|
|
46
|
-
mrok/controller/routes/instances.py,sha256=
|
|
45
|
+
mrok/controller/routes/extensions.py,sha256=jd3OGsJ_ESLQbOJ1mkzU8F44QgPe3R23dIapkNjmYDY,9126
|
|
46
|
+
mrok/controller/routes/instances.py,sha256=v-fn_F6JHbDZ4YUNCIZzClgHp6aC1Eu5HB7k7qBG5pk,2202
|
|
47
47
|
mrok/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
48
|
mrok/http/config.py,sha256=k8mjvD3ninJn-v1t-co-GSa3upm4b70bWyk3fwdcOh8,2161
|
|
49
49
|
mrok/http/forwarder.py,sha256=mo-Z8B8Zg6kdDX-lWEiptRv-9kJU9cEdmg6gt6eF0cc,11374
|
|
@@ -52,15 +52,15 @@ mrok/http/master.py,sha256=TwU78yE_GQecogBs_PDpl3gY7_jWYNIRNaAXRzi0rvY,4152
|
|
|
52
52
|
mrok/http/protocol.py,sha256=ap8jbLUvgbAH81ZJZCBkQiYR7mkV_eL3rpfwEkoE8sU,392
|
|
53
53
|
mrok/http/server.py,sha256=Mj7C85fc-DXp-WTBWaOd7ag808oliLmFBH5bf-G2FHg,370
|
|
54
54
|
mrok/ziti/__init__.py,sha256=20OWMiexRhOovZOX19zlX87-V78QyWnEnSZfyAftUdE,263
|
|
55
|
-
mrok/ziti/api.py,sha256=
|
|
55
|
+
mrok/ziti/api.py,sha256=KvGiT9d4oSgC3JbFWLDQyuHcLX2HuZJoJ8nHmWtCDkY,16154
|
|
56
56
|
mrok/ziti/bootstrap.py,sha256=QIDhlkIxPW2QRuumFq2D1WDbD003P5f3z24pAUsyeBI,2696
|
|
57
57
|
mrok/ziti/constants.py,sha256=Urq1X3bCBQZfw8NbnEa1pqmY4oq1wmzkwPfzam3kbTw,339
|
|
58
58
|
mrok/ziti/errors.py,sha256=yYCbVDwktnR0AYduqtynIjo73K3HOhIrwA_vQimvEd4,368
|
|
59
59
|
mrok/ziti/identities.py,sha256=oE_3j6Y4xCr6uKNdprW55bxGsyKnmJt-MrxrylB2Ey4,5388
|
|
60
60
|
mrok/ziti/pki.py,sha256=o2tySqHC8-7bvFuI2Tqxg9vX6H6ZSxWxfP_9x29e19M,1954
|
|
61
61
|
mrok/ziti/services.py,sha256=JnznLTHNZjgbFwnBtv7y2XIp4NiQxLVawwP9EfWdVuM,3208
|
|
62
|
-
mrok-0.2.
|
|
63
|
-
mrok-0.2.
|
|
64
|
-
mrok-0.2.
|
|
65
|
-
mrok-0.2.
|
|
66
|
-
mrok-0.2.
|
|
62
|
+
mrok-0.2.3.dist-info/METADATA,sha256=HCW-FucwR1yddkxR12eUY63wEXxTiaeNlEIMKpORVUo,15546
|
|
63
|
+
mrok-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
64
|
+
mrok-0.2.3.dist-info/entry_points.txt,sha256=tloXwvU1uJicBJR2h-8HoVclPgwJWDwuREMHN8Zq-nU,38
|
|
65
|
+
mrok-0.2.3.dist-info/licenses/LICENSE.txt,sha256=6PaICaoA3yNsZKLv5G6OKqSfLSoX7MakYqTDgJoTCBs,11346
|
|
66
|
+
mrok-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|