Skip to content

Commit

Permalink
fix: Remove ok, msg from PurgeImage mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Feb 11, 2025
1 parent 7a29b8b commit 6c6e3f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
5 changes: 1 addition & 4 deletions docs/manager/graphql-reference/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2362,14 +2362,11 @@ type ForgetImage {

"""Added in 25.3.0."""
type PurgeImageById {

Check notice on line 2364 in docs/manager/graphql-reference/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'PurgeImageById' was added

Type 'PurgeImageById' was added
ok: Boolean
msg: String
image: ImageNode
}

"""Added in 25.3.0."""
type PurgeImage {

Check notice on line 2369 in docs/manager/graphql-reference/schema.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector

Type 'PurgeImage' was added

Type 'PurgeImage' was added
ok: Boolean
msg: String
image: ImageNode
}

Expand Down
14 changes: 6 additions & 8 deletions src/ai/backend/manager/models/gql_models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ai.backend.logging import BraceStyleAdapter
from ai.backend.manager.models.container_registry import ContainerRegistryRow, ContainerRegistryType

from ...api.exceptions import ImageNotFound, ObjectNotFound
from ...api.exceptions import GenericForbidden, ImageNotFound, ObjectNotFound
from ...defs import DEFAULT_IMAGE_ARCH
from ..base import batch_multiresult_in_scalar_stream, set_if_set
from ..gql_relay import AsyncNode
Expand Down Expand Up @@ -568,6 +568,8 @@ async def mutate(


class PurgeImage(graphene.Mutation):
"""Added in 25.3.0."""

allowed_roles = (
UserRole.SUPERADMIN,
UserRole.ADMIN,
Expand All @@ -578,8 +580,6 @@ class Arguments:
reference = graphene.String(required=True)
architecture = graphene.String(default_value=DEFAULT_IMAGE_ARCH)

ok = graphene.Boolean()
msg = graphene.String()
image = graphene.Field(ImageNode)

@staticmethod
Expand Down Expand Up @@ -611,7 +611,7 @@ async def mutate(
):
return PurgeImage(ok=False, msg="Forbidden")
await session.delete(image_row)
return PurgeImage(ok=True, msg="", image=ImageNode.from_row(image_row))
return PurgeImage(image=ImageNode.from_row(image_row))


class PurgeImageById(graphene.Mutation):
Expand All @@ -626,8 +626,6 @@ class PurgeImageById(graphene.Mutation):
class Arguments:
image_id = graphene.String(required=True)

ok = graphene.Boolean()
msg = graphene.String()
image = graphene.Field(ImageNode)

@staticmethod
Expand Down Expand Up @@ -661,9 +659,9 @@ async def mutate(
not customized_image_owner
or customized_image_owner != f"user:{ctx.user['uuid']}"
):
return PurgeImageById(ok=False, msg="Forbidden")
raise GenericForbidden("Image is not owned by your account.")
await session.delete(image_row)
return PurgeImageById(ok=True, msg="", image=ImageNode.from_row(image_row))
return PurgeImageById(image=ImageNode.from_row(image_row))


class UntagImageFromRegistry(graphene.Mutation):
Expand Down

0 comments on commit 6c6e3f2

Please sign in to comment.