diff --git a/poetry.lock b/poetry.lock index 78745bb..b41ddc9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -188,7 +188,7 @@ version = "25.9.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.9" -groups = ["quality"] +groups = ["main", "quality"] files = [ {file = "black-25.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ce41ed2614b706fd55fd0b4a6909d06b5bab344ffbfadc6ef34ae50adba3d4f7"}, {file = "black-25.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2ab0ce111ef026790e9b13bd216fa7bc48edd934ffc4cbf78808b235793cbc92"}, @@ -1038,7 +1038,7 @@ version = "1.1.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.8" -groups = ["quality"] +groups = ["main", "quality"] files = [ {file = "mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505"}, {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"}, @@ -1127,7 +1127,7 @@ version = "25.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" -groups = ["examples", "quality", "tests"] +groups = ["main", "examples", "quality", "tests"] files = [ {file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"}, {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"}, @@ -1226,7 +1226,7 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" -groups = ["quality"] +groups = ["main", "quality"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -1363,7 +1363,7 @@ version = "4.4.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.9" -groups = ["quality", "tests"] +groups = ["main", "quality", "tests"] files = [ {file = "platformdirs-4.4.0-py3-none-any.whl", hash = "sha256:abd01743f24e5287cd7a5db3752faf1a2d65353f38ec26d98e25a6db65958c85"}, {file = "platformdirs-4.4.0.tar.gz", hash = "sha256:ca753cf4d81dc309bc67b0ea38fd15dc97bc30ce419a7f58d13eb3bf14c4febf"}, @@ -1857,7 +1857,7 @@ version = "0.1.10" description = "A Fast, spec compliant Python 3.12+ tokenizer that runs on older Pythons." optional = false python-versions = ">=3.8" -groups = ["quality"] +groups = ["main", "quality"] files = [ {file = "pytokens-0.1.10-py3-none-any.whl", hash = "sha256:db7b72284e480e69fb085d9f251f66b3d2df8b7166059261258ff35f50fb711b"}, {file = "pytokens-0.1.10.tar.gz", hash = "sha256:c9a4bfa0be1d26aebce03e6884ba454e842f186a59ea43a6d3b25af58223c044"}, @@ -2231,7 +2231,7 @@ version = "2.2.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" -groups = ["quality", "tests"] +groups = ["main", "quality", "tests"] markers = "python_version == \"3.10\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, @@ -2831,4 +2831,4 @@ pyarrow = ["pyarrow"] [metadata] lock-version = "2.1" python-versions = "^3.10" -content-hash = "394883338926938b8fca8e0feefa887251f11117b69f6ab902f0409686e26641" +content-hash = "3d3ebb33bcfa42854b82a80147fcfd055101d4a38485850a6720ac72f6ecb176" diff --git a/pyproject.toml b/pyproject.toml index e6d6063..fc9c08a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,7 @@ numpy = [ { version = ">=1.26.0", python = ">=3.12" }, ] pillow = "^11.1.0" +black = "^25.9.0" [tool.poetry.extras] pyarrow = ["pyarrow"] diff --git a/src/together/cli/api/endpoints.py b/src/together/cli/api/endpoints.py index 3b1da3f..25c3cd2 100644 --- a/src/together/cli/api/endpoints.py +++ b/src/together/cli/api/endpoints.py @@ -337,13 +337,30 @@ def delete(client: Together, endpoint_id: str) -> None: type=click.Choice(["dedicated", "serverless"]), help="Filter by endpoint type", ) +@click.option( + "--mine", + type=click.BOOL, + default=None, + help="true (only mine), default=all", +) +@click.option( + "--usage-type", + type=click.Choice(["on-demand", "reserved"]), + help="Filter by endpoint usage type", +) @click.pass_obj @handle_api_errors def list( - client: Together, json: bool, type: Literal["dedicated", "serverless"] | None + client: Together, + json: bool, + type: Literal["dedicated", "serverless"] | None, + usage_type: Literal["on-demand", "reserved"] | None, + mine: bool | None, ) -> None: """List all inference endpoints (includes both dedicated and serverless endpoints).""" - endpoints: List[ListEndpoint] = client.endpoints.list(type=type) + endpoints: List[ListEndpoint] = client.endpoints.list( + type=type, usage_type=usage_type, mine=mine + ) if not endpoints: click.echo("No dedicated endpoints found", err=True) diff --git a/src/together/resources/endpoints.py b/src/together/resources/endpoints.py index e40238a..993f73d 100644 --- a/src/together/resources/endpoints.py +++ b/src/together/resources/endpoints.py @@ -13,13 +13,18 @@ def __init__(self, client: TogetherClient) -> None: self._client = client def list( - self, type: Optional[Literal["dedicated", "serverless"]] = None + self, + type: Optional[Literal["dedicated", "serverless"]] = None, + usage_type: Optional[Literal["on-demand", "reserved"]] = None, + mine: Optional[bool] = None, ) -> List[ListEndpoint]: """ - List all endpoints, can be filtered by type. + List all endpoints, can be filtered by endpoint type and ownership. Args: - type (str, optional): Filter endpoints by type ("dedicated" or "serverless"). Defaults to None. + type (str, optional): Filter endpoints by endpoint type ("dedicated" or "serverless"). Defaults to None. + usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None. + mine (bool, optional): If True, return only endpoints owned by the caller. Defaults to None. Returns: List[ListEndpoint]: List of endpoint objects @@ -28,9 +33,20 @@ def list( client=self._client, ) - params = {} + params: Dict[ + str, + Union[ + Literal["dedicated", "serverless"], + Literal["on-demand", "reserved"], + bool, + ], + ] = {} if type is not None: params["type"] = type + if usage_type is not None: + params["usage_type"] = usage_type + if mine is not None: + params["mine"] = mine response, _, _ = requestor.request( options=TogetherRequest( @@ -263,13 +279,18 @@ def __init__(self, client: TogetherClient) -> None: self._client = client async def list( - self, type: Optional[Literal["dedicated", "serverless"]] = None + self, + type: Optional[Literal["dedicated", "serverless"]] = None, + usage_type: Optional[Literal["on-demand", "reserved"]] = None, + mine: Optional[bool] = None, ) -> List[ListEndpoint]: """ - List all endpoints, can be filtered by type. + List all endpoints, can be filtered by type and ownership. Args: type (str, optional): Filter endpoints by type ("dedicated" or "serverless"). Defaults to None. + usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None. + mine (bool, optional): If True, return only endpoints owned by the caller. Defaults to None. Returns: List[ListEndpoint]: List of endpoint objects @@ -278,9 +299,20 @@ async def list( client=self._client, ) - params = {} + params: Dict[ + str, + Union[ + Literal["dedicated", "serverless"], + Literal["on-demand", "reserved"], + bool, + ], + ] = {} if type is not None: params["type"] = type + if usage_type is not None: + params["usage_type"] = usage_type + if mine is not None: + params["mine"] = mine response, _, _ = await requestor.arequest( options=TogetherRequest(