mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-20 11:19:15 +00:00
once again
This commit is contained in:
parent
766edc657a
commit
6ca723867e
|
@ -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"}
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
||||
|
|
22
selfprivacy_api/graphql/queries/api_fields.py
Normal file
22
selfprivacy_api/graphql/queries/api_fields.py
Normal 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]
|
18
selfprivacy_api/graphql/query.py
Normal file
18
selfprivacy_api/graphql/query.py
Normal 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)
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue