Rename api_server2 module to apiserver
This commit is contained in:
@@ -6,9 +6,8 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from fastapi.security.http import HTTPBasic, HTTPBasicCredentials
|
||||
|
||||
from freqtrade.rpc.api_server2.api_models import AccessAndRefreshToken, AccessToken
|
||||
|
||||
from .deps import get_api_config
|
||||
from freqtrade.rpc.api_server.api_models import AccessAndRefreshToken, AccessToken
|
||||
from freqtrade.rpc.api_server.deps import get_api_config
|
||||
|
||||
|
||||
ALGORITHM = "HS256"
|
||||
@@ -45,7 +44,7 @@ def get_user_from_token(token, secret_key: str, token_type: str = "access"):
|
||||
return username
|
||||
|
||||
|
||||
def create_token(data: dict, secret_key: str, token_type: str = "access") -> str:
|
||||
def create_token(data: dict, secret_key: str, token_type: str = "access") -> bytes:
|
||||
to_encode = data.copy()
|
||||
if token_type == "access":
|
||||
expire = datetime.utcnow() + timedelta(minutes=15)
|
@@ -167,7 +167,7 @@ class DeleteTrade(BaseModel):
|
||||
|
||||
|
||||
class PlotConfig(BaseModel):
|
||||
main_plot: Optional[Dict[str, Any]]
|
||||
main_plot: Dict[str, Any]
|
||||
subplots: Optional[Dict[str, Any]]
|
||||
|
||||
|
@@ -83,7 +83,7 @@ def status(rpc: RPC = Depends(get_rpc)):
|
||||
|
||||
# TODO: Missing response model
|
||||
@router.get('/trades', tags=['info', 'trading'])
|
||||
def trades(limit: Optional[int] = 0, rpc: RPC = Depends(get_rpc)):
|
||||
def trades(limit: int = 0, rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_trade_history(limit)
|
||||
|
||||
|
||||
@@ -180,8 +180,8 @@ def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
|
||||
return RPC._rpc_analysed_history_full(config, pair, timeframe, timerange)
|
||||
|
||||
|
||||
@router.get('/plot_config', response_model=Union[Dict, PlotConfig], tags=['candle data'])
|
||||
def plot_config(rpc=Depends(get_rpc)):
|
||||
@router.get('/plot_config', response_model=Union[PlotConfig, Dict], tags=['candle data'])
|
||||
def plot_config(rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_plot_config()
|
||||
|
||||
|
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class ApiServer(RPCHandler):
|
||||
|
||||
_rpc: RPC = None
|
||||
_rpc: RPC
|
||||
_config: Dict[str, Any] = {}
|
||||
|
||||
def __init__(self, rpc: RPC, config: Dict[str, Any]) -> None:
|
@@ -34,7 +34,7 @@ class RPCManager:
|
||||
# Enable local rest api server for cmd line control
|
||||
if config.get('api_server', {}).get('enabled', False):
|
||||
logger.info('Enabling rpc.api_server')
|
||||
from freqtrade.rpc.api_server2 import ApiServer
|
||||
from freqtrade.rpc.api_server import ApiServer
|
||||
|
||||
self.registered_modules.append(ApiServer(self._rpc, config))
|
||||
|
||||
|
Reference in New Issue
Block a user