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 cfe1da3
Show file tree
Hide file tree
Showing 19 changed files with 526 additions and 347 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
29 changes: 20 additions & 9 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

<title>PyNinja &#8212; PyNinja documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
Expand Down Expand Up @@ -71,7 +71,7 @@ <h2>Kick off<a class="headerlink" href="#kick-off" title="Permalink to this head
<div><p>For Linux machines, use <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pyninja[extra]</span></code> to include functionalities from <a class="reference external" href="https://github.com/thevickypedia/PyUdisk">PyUdisk</a> (S.M.A.R.T metrics)</p>
</div></blockquote>
<p><strong>Initiate - IDE</strong></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pyninja</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">pyninja</span>


<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
Expand All @@ -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
Loading

0 comments on commit cfe1da3

Please sign in to comment.