Source code for

# This is the CLIENT-side abstraction for an invocable.
# If you are implementing a package, see: steamship.invocable.server.App

from __future__ import annotations

from typing import Any, Optional, Type

from pydantic import BaseModel, Field

from steamship.base.client import Client
from steamship.base.model import CamelModel
from steamship.base.request import CreateRequest, GetRequest, IdentifierRequest, UpdateRequest
from import Manifest

[docs] class PackageCreateRequest(CreateRequest): is_public: bool = False fetch_if_exists = False profile: Optional[Manifest] = None
[docs] class PackageUpdateRequest(UpdateRequest): id: Optional[str] = None handle: Optional[str] = None description: Optional[str] = None profile: Optional[Manifest] = None readme: Optional[str] = None
[docs] class Package(CamelModel): client: Client = Field(None, exclude=True) id: str = None handle: str = None user_id: str = None profile: Optional[Manifest] = None description: Optional[str] = None readme: Optional[str] = None is_public: bool = False
[docs] @classmethod def parse_obj(cls: Type[BaseModel], obj: Any) -> BaseModel: # TODO (enias): This needs to be solved at the engine side obj = obj["package"] if "package" in obj else obj return super().parse_obj(obj)
[docs] @staticmethod def create( client: Client, handle: str = None, profile: Manifest = None, is_public=False, fetch_if_exists=False, ) -> Package: req = PackageCreateRequest( handle=handle, profile=profile, is_public=is_public, fetch_if_exists=fetch_if_exists ) return"package/create", payload=req, expect=Package)
[docs] @staticmethod def get(client: Client, handle: str) -> Package: return"package/get", GetRequest(handle=handle), expect=Package)
[docs] def update(self, client: Client) -> Package: return "package/update", PackageUpdateRequest(, description=self.description, profile=self.profile, readme=self.readme ), expect=Package, )
[docs] def delete(self) -> Package: """Delete this package. If this package is public and another user has created an instance of it, this method will throw an error and the package will not be deleted. Deleting the package will delete any versions and instances of it that you have created.""" return "package/delete", IdentifierRequest(, expect=Package, )