This commit is contained in:
inexcode 2022-08-13 03:39:37 +04:00
parent 79bc2668e1
commit d8a8b2ec29
4 changed files with 10 additions and 10 deletions

View file

@ -33,7 +33,10 @@ class StorageVolume:
model: typing.Optional[str]
serial: typing.Optional[str]
type: str
usages: list["StorageUsageInterface"] = strawberry.field(resolver=get_usages)
@strawberry.field
def usages(self) -> list["StorageUsageInterface"]:
"""Get usages of a volume"""
return get_usages(self)
@strawberry.interface
@ -79,7 +82,6 @@ def get_storage_usage(root: "Service") -> ServiceStorageUsage:
@strawberry.type
class Service:
storage_usage: ServiceStorageUsage = strawberry.field(resolver=get_storage_usage)
id: str
display_name: str
description: str
@ -90,7 +92,10 @@ class Service:
status: ServiceStatusEnum
url: typing.Optional[str]
dns_records: typing.Optional[typing.List[DnsRecord]]
@strawberry.field
def storage_usage(self) -> ServiceStorageUsage:
"""Get storage usage for a service"""
return get_storage_usage(self)
def service_to_graphql_service(service: ServiceInterface) -> Service:
"""Convert service to graphql service"""

View file

@ -2,15 +2,10 @@
# pylint: disable=too-few-public-methods
import typing
import strawberry
from selfprivacy_api.graphql.common_types.service import (
ServiceStorageUsage,
service_to_graphql_service,
get_volume_by_id,
)
from selfprivacy_api.graphql.common_types.service import (
StorageVolume,
)
from selfprivacy_api.services import get_services_by_location
from selfprivacy_api.utils.block_devices import BlockDevices

View file

@ -6,7 +6,7 @@ from selfprivacy_api.graphql import IsAuthenticated
from selfprivacy_api.graphql.mutations.api_mutations import ApiMutations
from selfprivacy_api.graphql.mutations.mutation_interface import GenericMutationReturn
from selfprivacy_api.graphql.mutations.ssh_mutations import SshMutations
from selfprivacy_api.graphql.mutations.storage_mutation import StorageMutations
from selfprivacy_api.graphql.mutations.storage_mutations import StorageMutations
from selfprivacy_api.graphql.mutations.system_mutations import SystemMutations
from selfprivacy_api.graphql.queries.api_queries import Api