-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #547 from kbase/dev-aioarango
RE2022-266: Vendor aioarango
- Loading branch information
Showing
28 changed files
with
11,604 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016-2021 Joohwan Oh | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import aioarango.errno as errno # noqa: F401 | ||
from aioarango.client import ArangoClient # noqa: F401 | ||
from aioarango.exceptions import * # noqa: F401 F403 | ||
from aioarango.http import * # noqa: F401 F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from typing import Callable, Optional, TypeVar | ||
|
||
from aioarango.connection import Connection | ||
from aioarango.executor import ApiExecutor | ||
from aioarango.request import Request | ||
from aioarango.response import Response | ||
from aioarango.result import Result | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class ApiGroup: | ||
"""Base class for API groups. | ||
:param connection: HTTP connection. | ||
:param executor: API executor. | ||
""" | ||
|
||
def __init__(self, connection: Connection, executor: ApiExecutor) -> None: | ||
self._conn = connection | ||
self._executor = executor | ||
|
||
@property | ||
def conn(self) -> Connection: | ||
"""Return the HTTP connection. | ||
:return: HTTP connection. | ||
:rtype: aioarango.connection.BasicConnection | aioarango.connection.JwtConnection | | ||
aioarango.connection.JwtSuperuserConnection | ||
""" | ||
return self._conn | ||
|
||
@property | ||
def db_name(self) -> str: | ||
"""Return the name of the current database. | ||
:return: Database name. | ||
:rtype: str | ||
""" | ||
return self._conn.db_name | ||
|
||
@property | ||
def username(self) -> Optional[str]: | ||
"""Return the username. | ||
:returns: Username. | ||
:rtype: str | ||
""" | ||
return self._conn.username | ||
|
||
@property | ||
def context(self) -> str: | ||
"""Return the API execution context. | ||
:return: API execution context. Possible values are "default", "async", | ||
"batch" and "transaction". | ||
:rtype: str | ||
""" | ||
return self._executor.context | ||
|
||
async def _execute( | ||
self, request: Request, response_handler: Callable[[Response], T] | ||
) -> Result[T]: | ||
"""Execute an API. | ||
:param request: HTTP request. | ||
:type request: aioarango.request.Request | ||
:param response_handler: HTTP response handler. | ||
:type response_handler: callable | ||
:return: API execution result. | ||
""" | ||
return await self._executor.execute(request, response_handler) |
Oops, something went wrong.