-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Adding multiple manifest and linter
- Loading branch information
1 parent
667c179
commit ddcd3f1
Showing
17 changed files
with
199 additions
and
709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from fastapi import APIRouter, status, HTTPException | ||
from fastapi_versioning import version | ||
|
||
from app.manifest import ManifestManager | ||
from app.manifest.models import ManifestBase, Manifest | ||
|
||
# Creates Extension router | ||
manifest_router_v2 = APIRouter( | ||
prefix="/manifest", | ||
tags=["manifest"], | ||
responses={ | ||
status.HTTP_404_NOT_FOUND: {"description": "Not found"} | ||
}, | ||
) | ||
|
||
manager = ManifestManager.instance() | ||
|
||
# Endpoints | ||
|
||
@manifest_router_v2.get("/", status_code=status.HTTP_200_OK) | ||
@version(2, 0) | ||
async def list_manifest() -> list[Manifest]: | ||
return await manager.fetch() | ||
|
||
@manifest_router_v2.get("/{identifier}", status_code=status.HTTP_200_OK) | ||
@version(2, 0) | ||
async def get_manifest(identifier: str) -> Manifest: | ||
manifest = await manager.fetch_by_identifier(identifier) | ||
if not manifest: | ||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Manifest not found") | ||
|
||
return manifest | ||
|
||
@manifest_router_v2.post("/", status_code=status.HTTP_201_CREATED) | ||
@version(2, 0) | ||
async def create_manifest(body: ManifestBase) -> str: | ||
return await manager.add(body) | ||
|
||
@manifest_router_v2.put("/{identifier}", status_code=status.HTTP_204_NO_CONTENT) | ||
@version(2, 0) | ||
async def update_manifest(identifier: str, body: ManifestBase) -> None: | ||
await manager.update(identifier, body) | ||
|
||
@manifest_router_v2.delete("/{identifier}", status_code=status.HTTP_204_NO_CONTENT) | ||
@version(2, 0) | ||
async def delete_manifest(identifier: str) -> None: | ||
await manager.remove(identifier) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# This file is used to define general configurations for the app | ||
|
||
# Current running service name | ||
SERVICE_NAME = 'kraken' | ||
|
||
__all__ = ["SERVICE_NAME"] | ||
EXT_DEV_MANIFEST_URL = "https://raw.githubusercontent.com/bluerobotics/BlueOS-Extensions-Repository/gh-pages-dev/manifest.json" | ||
EXT_PROD_MANIFEST_URL = "https://bluerobotics.github.io/BlueOS-Extensions-Repository/manifest.json" | ||
|
||
__all__ = [ | ||
"SERVICE_NAME", "EXT_DEV_MANIFEST_URL", "EXT_PROD_MANIFEST_URL" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import aiodocker | ||
|
||
class DockerCtx(object): | ||
""" | ||
Context manager for Docker client. | ||
""" | ||
|
||
def __init__(self) -> None: | ||
self._client: aiodocker.Docker = aiodocker.Docker() | ||
|
||
async def __aenter__(self) -> aiodocker.Docker: | ||
return self._client | ||
|
||
async def __aexit__(self, exc_type, exc, tb) -> None: | ||
await self._client.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from pydantic import BaseModel | ||
|
||
class ContainerModel(BaseModel): | ||
name: str | ||
image: str | ||
image_id: str | ||
status: str | ||
|
||
class ContainerUsageModel(BaseModel): | ||
cpu: str | ||
memory: float | ||
disk: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from app.extension.extension import Extension | ||
from app.extension.model import ExtensionModel | ||
|
||
__all__ = ["Extension", "ExtensionModel"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.