Skip to content

Commit

Permalink
Restructure startup functionalities
Browse files Browse the repository at this point in the history
Move JavaScript for swagger page into a dedicated file
  • Loading branch information
dormant-user committed Jan 6, 2025
1 parent 61501b2 commit 64ad6ef
Show file tree
Hide file tree
Showing 17 changed files with 482 additions and 262 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,35 @@ pyninja start
> _By default, `PyNinja` will look for a `.env` file in the current working directory._
</details>
**Basic API**
- **APIKEY** - API Key for authentication.
- **SWAGGER_UI_PARAMETERS** - Dictionary of parameters to be included in the Swagger UI.
- **NINJA_HOST** - Hostname for the API server.
- **NINJA_PORT** - Port number for the API server.

**Functional improvements**
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

**Remote execution and FileIO**
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.

**Monitoring UI**
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **MAX_CONNECTIONS** - Maximum number of monitoring sessions allowed in parallel.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **PROCESSES** - List of process names to include in the monitor page.
- **SERVICES** - List of service names to include in the monitor page.
- **SMART_LIB** - Library path for S.M.A.R.T metrics using [PyUdisk].
- **GPU_LIB** - GPU library filepath to use for monitoring.
- **DISK_LIB** - Disk library filepath to use for monitoring.
- **SERVICE_LIB** - Memory library filepath to use for monitoring.
- **PROCESSOR_LIB** - Processor library filepath to use for monitoring.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

⚠️ Enabling remote execution can be extremely risky and a major security threat.
So use **caution** and set the **API_SECRET** to a strong value.
Expand Down
11 changes: 10 additions & 1 deletion doc_gen/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ PyNinja - Main

.. automodule:: pyninja.main

====

.. automodule:: pyninja.startup

PyNinja - Executors
===================

Expand Down Expand Up @@ -123,13 +127,18 @@ Models

====

.. autoclass:: pyninja.modules.models.FileIO(BaseModel)
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. autoclass:: pyninja.modules.models.EnvConfig(BaseModel)
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. automodule:: pyninja.modules.models
:exclude-members: RoutingHandler, ServiceStatus, Architecture, Session, WSSession, RateLimit, EnvConfig, session, ws_session, env, database, architecture
:exclude-members: RoutingHandler, ServiceStatus, Architecture, Session, WSSession, RateLimit, FileIO, EnvConfig, session, ws_session, env, database, architecture

Payloads
--------
Expand Down
25 changes: 18 additions & 7 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,39 @@ <h2>Environment Variables<a class="headerlink" href="#environment-variables" tit
<summary><strong>Sourcing environment variables from an env file</strong></summary><blockquote>
<div><p><em>By default, <code class="docutils literal notranslate"><span class="pre">PyNinja</span></code> will look for a <code class="docutils literal notranslate"><span class="pre">.env</span></code> file in the current working directory.</em></p>
</div></blockquote>
</details><ul class="simple">
</details><p><strong>Basic API</strong></p>
<ul class="simple">
<li><p><strong>APIKEY</strong> - API Key for authentication.</p></li>
<li><p><strong>SWAGGER_UI_PARAMETERS</strong> - Dictionary of parameters to be included in the Swagger UI.</p></li>
<li><p><strong>NINJA_HOST</strong> - Hostname for the API server.</p></li>
<li><p><strong>NINJA_PORT</strong> - Port number for the API server.</p></li>
</ul>
<p><strong>Functional improvements</strong></p>
<ul class="simple">
<li><p><strong>RATE_LIMIT</strong> - List of dictionaries with <code class="docutils literal notranslate"><span class="pre">max_requests</span></code> and <code class="docutils literal notranslate"><span class="pre">seconds</span></code> to apply as rate limit.</p></li>
<li><p><strong>LOG_CONFIG</strong> - Logging configuration file path.</p></li>
</ul>
<p><strong>Remote execution and FileIO</strong></p>
<ul class="simple">
<li><p><strong>REMOTE_EXECUTION</strong> - Boolean flag to enable remote execution.</p></li>
<li><p><strong>API_SECRET</strong> - Secret access key for running commands on server remotely.</p></li>
<li><p><strong>DISK_REPORT</strong> - Boolean flag to enable disk report feature using <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>UDISK_LIB</strong> - Udisk library for Linux machines to use <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>DATABASE</strong> - FilePath to store the auth database that handles the authentication errors.</p></li>
</ul>
<p><strong>Monitoring UI</strong></p>
<ul class="simple">
<li><p><strong>MONITOR_USERNAME</strong> - Username to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_PASSWORD</strong> - Password to authenticate the monitoring page.</p></li>
<li><p><strong>MONITOR_SESSION</strong> - Session timeout for the monitoring page.</p></li>
<li><p><strong>NO_AUTH</strong> - Boolean flag to host monitoring page without authentication.</p></li>
<li><p><strong>DISK_REPORT</strong> - Boolean flag to enable disk report feature using <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>MAX_CONNECTIONS</strong> - Maximum number of monitoring sessions allowed in parallel.</p></li>
<li><p><strong>NO_AUTH</strong> - Boolean flag to host monitoring page without authentication.</p></li>
<li><p><strong>PROCESSES</strong> - List of process names to include in the monitor page.</p></li>
<li><p><strong>SERVICES</strong> - List of service names to include in the monitor page.</p></li>
<li><p><strong>SMART_LIB</strong> - Library path for S.M.A.R.T metrics using <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a>.</p></li>
<li><p><strong>GPU_LIB</strong> - GPU library filepath to use for monitoring.</p></li>
<li><p><strong>DISK_LIB</strong> - Disk library filepath to use for monitoring.</p></li>
<li><p><strong>SERVICE_LIB</strong> - Memory library filepath to use for monitoring.</p></li>
<li><p><strong>PROCESSOR_LIB</strong> - Processor library filepath to use for monitoring.</p></li>
<li><p><strong>DATABASE</strong> - FilePath to store the auth database that handles the authentication errors.</p></li>
<li><p><strong>RATE_LIMIT</strong> - List of dictionaries with <code class="docutils literal notranslate"><span class="pre">max_requests</span></code> and <code class="docutils literal notranslate"><span class="pre">seconds</span></code> to apply as rate limit.</p></li>
<li><p><strong>LOG_CONFIG</strong> - Logging configuration file path.</p></li>
</ul>
<p>⚠️ Enabling remote execution can be extremely risky and a major security threat.
So use <strong>caution</strong> and set the <strong>API_SECRET</strong> to a strong value.</p>
Expand Down
20 changes: 14 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,35 @@ pyninja start
> _By default, `PyNinja` will look for a `.env` file in the current working directory._
</details>
**Basic API**
- **APIKEY** - API Key for authentication.
- **SWAGGER_UI_PARAMETERS** - Dictionary of parameters to be included in the Swagger UI.
- **NINJA_HOST** - Hostname for the API server.
- **NINJA_PORT** - Port number for the API server.

**Functional improvements**
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

**Remote execution and FileIO**
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.

**Monitoring UI**
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **MAX_CONNECTIONS** - Maximum number of monitoring sessions allowed in parallel.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **PROCESSES** - List of process names to include in the monitor page.
- **SERVICES** - List of service names to include in the monitor page.
- **SMART_LIB** - Library path for S.M.A.R.T metrics using [PyUdisk].
- **GPU_LIB** - GPU library filepath to use for monitoring.
- **DISK_LIB** - Disk library filepath to use for monitoring.
- **SERVICE_LIB** - Memory library filepath to use for monitoring.
- **PROCESSOR_LIB** - Processor library filepath to use for monitoring.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

⚠️ Enabling remote execution can be extremely risky and a major security threat.
So use **caution** and set the **API_SECRET** to a strong value.
Expand Down
20 changes: 14 additions & 6 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,35 @@ pyninja start
> _By default, `PyNinja` will look for a `.env` file in the current working directory._
</details>

**Basic API**
- **APIKEY** - API Key for authentication.
- **SWAGGER_UI_PARAMETERS** - Dictionary of parameters to be included in the Swagger UI.
- **NINJA_HOST** - Hostname for the API server.
- **NINJA_PORT** - Port number for the API server.

**Functional improvements**
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

**Remote execution and FileIO**
- **REMOTE_EXECUTION** - Boolean flag to enable remote execution.
- **API_SECRET** - Secret access key for running commands on server remotely.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **UDISK_LIB** - Udisk library for Linux machines to use [PyUdisk].
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.

**Monitoring UI**
- **MONITOR_USERNAME** - Username to authenticate the monitoring page.
- **MONITOR_PASSWORD** - Password to authenticate the monitoring page.
- **MONITOR_SESSION** - Session timeout for the monitoring page.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **DISK_REPORT** - Boolean flag to enable disk report feature using [PyUdisk].
- **MAX_CONNECTIONS** - Maximum number of monitoring sessions allowed in parallel.
- **NO_AUTH** - Boolean flag to host monitoring page without authentication.
- **PROCESSES** - List of process names to include in the monitor page.
- **SERVICES** - List of service names to include in the monitor page.
- **SMART_LIB** - Library path for S.M.A.R.T metrics using [PyUdisk].
- **GPU_LIB** - GPU library filepath to use for monitoring.
- **DISK_LIB** - Disk library filepath to use for monitoring.
- **SERVICE_LIB** - Memory library filepath to use for monitoring.
- **PROCESSOR_LIB** - Processor library filepath to use for monitoring.
- **DATABASE** - FilePath to store the auth database that handles the authentication errors.
- **RATE_LIMIT** - List of dictionaries with `max_requests` and `seconds` to apply as rate limit.
- **LOG_CONFIG** - Logging configuration file path.

⚠️ Enabling remote execution can be extremely risky and a major security threat.
So use **caution** and set the **API_SECRET** to a strong value.
Expand Down
11 changes: 10 additions & 1 deletion docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ PyNinja - Main

.. automodule:: pyninja.main

====

.. automodule:: pyninja.startup

PyNinja - Executors
===================

Expand Down Expand Up @@ -123,13 +127,18 @@ Models

====

.. autoclass:: pyninja.modules.models.FileIO(BaseModel)
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. autoclass:: pyninja.modules.models.EnvConfig(BaseModel)
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. automodule:: pyninja.modules.models
:exclude-members: RoutingHandler, ServiceStatus, Architecture, Session, WSSession, RateLimit, EnvConfig, session, ws_session, env, database, architecture
:exclude-members: RoutingHandler, ServiceStatus, Architecture, Session, WSSession, RateLimit, FileIO, EnvConfig, session, ws_session, env, database, architecture

Payloads
--------
Expand Down
35 changes: 25 additions & 10 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ <h2 id="C">C</h2>
<li><a href="index.html#pyninja.modules.models.Architecture.cpu">cpu (pyninja.modules.models.Architecture attribute)</a>
</li>
<li><a href="index.html#pyninja.modules.models.Database.create_table">create_table() (pyninja.modules.models.Database method)</a>
</li>
<li><a href="index.html#pyninja.main.custom_swagger_ui">custom_swagger_ui() (in module pyninja.main)</a>
</li>
</ul></td>
</tr></table>
Expand Down Expand Up @@ -175,6 +173,8 @@ <h2 id="D">D</h2>
<li><a href="index.html#pyninja.modules.enums.APIEndpoints.docs">docs (pyninja.modules.enums.APIEndpoints attribute)</a>
</li>
<li><a href="index.html#pyninja.main.docs">docs() (in module pyninja.main)</a>
</li>
<li><a href="index.html#pyninja.startup.docs_handler">docs_handler() (in module pyninja.startup)</a>
</li>
<li><a href="index.html#pyninja.executors.routers.docs_redirect">docs_redirect() (in module pyninja.executors.routers)</a>
</li>
Expand Down Expand Up @@ -215,6 +215,8 @@ <h2 id="F">F</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.monitor.authenticator.failed_auth_counter">failed_auth_counter() (in module pyninja.monitor.authenticator)</a>
</li>
<li><a href="index.html#pyninja.modules.models.FileIO">FileIO (class in pyninja.modules.models)</a>
</li>
<li><a href="index.html#pyninja.modules.payloads.GetFile.filepath">filepath (pyninja.modules.payloads.GetFile attribute)</a>
</li>
Expand All @@ -238,7 +240,7 @@ <h2 id="G">G</h2>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.monitor.authenticator.generate_cookie">generate_cookie() (in module pyninja.monitor.authenticator)</a>
</li>
<li><a href="index.html#pyninja.main.generate_hyperlink">generate_hyperlink() (in module pyninja.main)</a>
<li><a href="index.html#pyninja.startup.generate_hyperlink">generate_hyperlink() (in module pyninja.startup)</a>
</li>
<li><a href="index.html#pyninja.modules.enums.APIRouteType.get">get (pyninja.modules.enums.APIRouteType attribute)</a>
</li>
Expand Down Expand Up @@ -274,7 +276,7 @@ <h2 id="G">G</h2>
</li>
<li><a href="index.html#pyninja.routes.metrics.get_cpu_utilization">get_cpu_utilization() (in module pyninja.routes.metrics)</a>
</li>
<li><a href="index.html#pyninja.main.get_desc">get_desc() (in module pyninja.main)</a>
<li><a href="index.html#pyninja.startup.get_desc">get_desc() (in module pyninja.startup)</a>
</li>
<li><a href="index.html#pyninja.monitor.resources.get_disk_info">get_disk_info() (in module pyninja.monitor.resources)</a>
</li>
Expand Down Expand Up @@ -448,11 +450,13 @@ <h2 id="L">L</h2>
</li>
<li><a href="index.html#pyninja.modules.payloads.ListFiles">ListFiles (class in pyninja.modules.payloads)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.executors.squire.load_architecture">load_architecture() (in module pyninja.executors.squire)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.executors.squire.load_env">load_env() (in module pyninja.executors.squire)</a>
</li>
<li><a href="index.html#pyninja.modules.models.load_swagger_ui">load_swagger_ui() (in module pyninja.modules.models)</a>
</li>
<li><a href="index.html#pyninja.modules.models.EnvConfig.log_config">log_config (pyninja.modules.models.EnvConfig attribute)</a>
</li>
Expand Down Expand Up @@ -535,6 +539,8 @@ <h2 id="M">M</h2>
<li><a href="index.html#module-pyninja.routes.namespace">pyninja.routes.namespace</a>
</li>
<li><a href="index.html#module-pyninja.routes.orchestration">pyninja.routes.orchestration</a>
</li>
<li><a href="index.html#module-pyninja.startup">pyninja.startup</a>
</li>
</ul></li>
</ul></td>
Expand Down Expand Up @@ -788,6 +794,13 @@ <h2 id="P">P</h2>

<ul>
<li><a href="index.html#module-pyninja.routes.orchestration">module</a>
</li>
</ul></li>
<li>
pyninja.startup

<ul>
<li><a href="index.html#module-pyninja.startup">module</a>
</li>
</ul></li>
<li><a href="index.html#pyninja.monitor.resources.pyudisk_metrics">pyudisk_metrics() (in module pyninja.monitor.resources)</a>
Expand All @@ -808,7 +821,7 @@ <h2 id="R">R</h2>
</li>
<li><a href="index.html#pyninja.modules.rate_limit.RateLimiter">RateLimiter (class in pyninja.modules.rate_limit)</a>
</li>
<li><a href="index.html#pyninja.main.redirect_exception_handler">redirect_exception_handler() (in module pyninja.main)</a>
<li><a href="index.html#pyninja.startup.redirect_exception_handler">redirect_exception_handler() (in module pyninja.startup)</a>
</li>
<li><a href="index.html#pyninja.modules.exceptions.RedirectException">RedirectException</a>
</li>
Expand Down Expand Up @@ -878,10 +891,10 @@ <h2 id="S">S</h2>
</li>
<li><a href="index.html#pyninja.main.start">start() (in module pyninja.main)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.features.dockerized.start_container">start_container() (in module pyninja.features.dockerized)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pyninja.modules.enums.APIEndpoints.start_docker_container">start_docker_container (pyninja.modules.enums.APIEndpoints attribute)</a>
</li>
<li><a href="index.html#pyninja.routes.orchestration.start_docker_container">start_docker_container() (in module pyninja.routes.orchestration)</a>
Expand Down Expand Up @@ -912,7 +925,9 @@ <h2 id="S">S</h2>
</ul></li>
<li><a href="index.html#pyninja.features.service.stopped">stopped() (in module pyninja.features.service)</a>
</li>
<li><a href="index.html#pyninja.modules.models.EnvConfig.swagger_ui_configuration">swagger_ui_configuration (pyninja.modules.models.EnvConfig attribute)</a>
<li><a href="index.html#pyninja.modules.models.FileIO.swagger_ui">swagger_ui (pyninja.modules.models.FileIO attribute)</a>
</li>
<li><a href="index.html#pyninja.modules.models.EnvConfig.swagger_ui_parameters">swagger_ui_parameters (pyninja.modules.models.EnvConfig attribute)</a>
</li>
<li><a href="index.html#pyninja.monitor.resources.system_resources">system_resources() (in module pyninja.monitor.resources)</a>
</li>
Expand Down
Loading

0 comments on commit 64ad6ef

Please sign in to comment.