once again

This commit is contained in:
Inex Code 2022-06-24 19:28:58 +03:00
parent 766edc657a
commit 6ca723867e
6 changed files with 50 additions and 44 deletions

View file

@ -23,7 +23,7 @@ from selfprivacy_api.migrations import run_migrations
from selfprivacy_api.utils.auth import is_token_valid
from selfprivacy_api.graphql import schema
from selfprivacy_api.graphql.query import schema
swagger_blueprint = get_swaggerui_blueprint(
"/api/docs", "/api/swagger.json", config={"app_name": "SelfPrivacy API"}

View file

@ -1,27 +0,0 @@
"""GraphQL API for SelfPrivacy."""
# pylint: disable=too-few-public-methods
import typing
import strawberry
from selfprivacy_api.graphql.queries.api import ApiDevice, ApiRecoveryKeyStatus
from selfprivacy_api.graphql.queries.system import System
from selfprivacy_api.resolvers.api import get_api_version, get_devices, get_recovery_key_status
@strawberry.type
class Api:
"""API access status"""
version: str = strawberry.field(resolver=get_api_version)
devices: typing.List[ApiDevice] = strawberry.field(resolver=get_devices)
recovery_key: ApiRecoveryKeyStatus = strawberry.field(resolver=get_recovery_key_status)
@strawberry.type
class Query:
"""Root schema for queries"""
system: System
@strawberry.field
def api(self) -> Api:
"""API access status"""
return Api()
schema = strawberry.Schema(query=Query)

View file

@ -1,22 +1,15 @@
"""API access status"""
# pylint: disable=too-few-public-methods
import datetime
import typing
import strawberry
from selfprivacy_api.graphql.queries.api_fields import ApiDevice, ApiRecoveryKeyStatus
from selfprivacy_api.resolvers.api import get_api_version, get_devices, get_recovery_key_status
@strawberry.type
class ApiDevice:
"""A single device with SelfPrivacy app installed"""
name: str
creation_date: datetime.datetime
is_caller: bool
@strawberry.type
class ApiRecoveryKeyStatus:
"""Recovery key status"""
exists: bool
valid: bool
creation_date: typing.Optional[datetime.datetime]
expiration_date: typing.Optional[datetime.datetime]
uses_left: typing.Optional[int]
class Api:
"""API access status"""
version: str = strawberry.field(resolver=get_api_version)
devices: typing.List[ApiDevice] = strawberry.field(resolver=get_devices)
recovery_key: ApiRecoveryKeyStatus = strawberry.field(resolver=get_recovery_key_status)

View file

@ -0,0 +1,22 @@
"""API access status"""
# pylint: disable=too-few-public-methods
import datetime
import typing
import strawberry
@strawberry.type
class ApiDevice:
"""A single device with SelfPrivacy app installed"""
name: str
creation_date: datetime.datetime
is_caller: bool
@strawberry.type
class ApiRecoveryKeyStatus:
"""Recovery key status"""
exists: bool
valid: bool
creation_date: typing.Optional[datetime.datetime]
expiration_date: typing.Optional[datetime.datetime]
uses_left: typing.Optional[int]

View file

@ -0,0 +1,18 @@
"""GraphQL API for SelfPrivacy."""
# pylint: disable=too-few-public-methods
import typing
import strawberry
from selfprivacy_api.graphql.queries.api import Api
from selfprivacy_api.graphql.queries.system import System
@strawberry.type
class Query:
"""Root schema for queries"""
system: System
@strawberry.field
def api(self) -> Api:
"""API access status"""
return Api()
schema = strawberry.Schema(query=Query)

View file

@ -3,7 +3,7 @@ import datetime
import typing
from flask import request
from selfprivacy_api.graphql.queries.api import ApiDevice, ApiRecoveryKeyStatus
from selfprivacy_api.graphql.queries.api_fields import ApiDevice, ApiRecoveryKeyStatus
from selfprivacy_api.utils.auth import (
get_recovery_token_status,