Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/options.py: 82%
17 statements
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
1from typing import Optional, List
2from pydantic import BaseModel, Field
5def _dir_list(string) -> List[str]:
6 """Returns a list of directories from a comma separater list"""
7 folders = string.split(",")
8 folders = [s.strip() for s in folders]
9 return folders
12class ServerOptions(BaseModel):
13 """Options used to setup the Daiquiri server"""
15 resource_folders: Optional[List[str]] = Field(
16 default=[],
17 description="Server resources directories (first has priority)",
18 json_schema_extra=dict(argparse_type=_dir_list),
19 )
21 static_folder: str = Field(
22 default="static.default",
23 description="Actor implementors module",
24 )
26 static_resources_folder: Optional[str] = Field(
27 default=None,
28 description="Extra folder to override `static_folder/resources`",
29 json_schema_extra=dict(argparse_type=str),
30 )
32 hardware_folder: str = Field(
33 default="",
34 description="Hardware folder",
35 )
37 port: int = Field(
38 default=8080,
39 description="Web server port",
40 json_schema_extra=dict(argparse_flag="-p"),
41 )
43 save_spec_file: Optional[str] = Field(
44 default=None,
45 description="If defined, save the current API spec into the specified file, and exit",
46 json_schema_extra=dict(
47 argparse_name="--save-spec",
48 argparse_nargs="?",
49 argparse_flag="-s",
50 argparse_type=str,
51 ),
52 )
54 implementors: Optional[str] = Field(
55 default=None,
56 description="Actor implementors module",
57 json_schema_extra=dict(argparse_type=str),
58 )
60 ssl: Optional[bool] = Field(
61 default=None,
62 description="Enable the SSL protocol",
63 json_schema_extra=dict(argparse_type=bool),
64 )
66 ssl_cert: Optional[str] = Field(
67 default=None,
68 description="Location of the SSL certificat",
69 json_schema_extra=dict(argparse_type=str),
70 )
72 ssl_key: Optional[str] = Field(
73 default=None,
74 description="Location of the SSL key",
75 json_schema_extra=dict(argparse_type=str),
76 )