Skip to content

Commit

Permalink
feat: new crud
Browse files Browse the repository at this point in the history
  • Loading branch information
Haivilo committed Dec 15, 2023
1 parent 819e01a commit b47cd78
Show file tree
Hide file tree
Showing 9 changed files with 682 additions and 526 deletions.
1 change: 0 additions & 1 deletion src/bentoml/_internal/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .base import CloudClient as CloudClient
from .bentocloud import BentoCloudClient as BentoCloudClient
from .deployment import Resource as Resource
from .yatai import YataiClient as YataiClient
10 changes: 9 additions & 1 deletion src/bentoml/_internal/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .schemas.schemasv1 import UpdateDeploymentSchema
from .schemas.schemasv1 import UserSchema
from .schemas.schemasv2 import CreateDeploymentSchema as CreateDeploymentSchemaV2
from .schemas.schemasv2 import UpdateDeploymentSchema as UpdateDeploymentSchemaV2
from .schemas.utils import schema_from_json
from .schemas.utils import schema_from_object
from .schemas.utils import schema_to_json
Expand Down Expand Up @@ -530,11 +531,18 @@ def create_deployment(
self, create_schema: CreateDeploymentSchemaV2
) -> DeploymentSchema | None:
url = urljoin(self.endpoint, "/api/v2/deployments")
print(schema_to_json(create_schema))
resp = self.session.post(url, data=schema_to_json(create_schema))
self._check_resp(resp)
return schema_from_json(resp.text, DeploymentSchema)

def update_deployment(
self, deployment_name: str, update_schema: UpdateDeploymentSchemaV2
) -> DeploymentSchema | None:
url = urljoin(self.endpoint, f"/api/v2/deployments/{deployment_name}")
resp = self.session.post(url, data=schema_to_json(update_schema))
self._check_resp(resp)
return schema_from_json(resp.text, DeploymentSchema)


class RestApiClient:
def __init__(self, endpoint: str, api_token: str) -> None:
Expand Down
Loading

0 comments on commit b47cd78

Please sign in to comment.