From 9b4365b92f87d410122c9952988c2117afb7f0a0 Mon Sep 17 00:00:00 2001 From: Vignesh Rao Date: Mon, 30 Sep 2024 04:25:57 -0500 Subject: [PATCH] Restructure code - phase 3 --- doc_gen/index.rst | 108 +- docs/README.html | 2 +- docs/_sources/index.rst.txt | 108 +- docs/genindex.html | 444 ++++--- docs/index.html | 1387 ++++++++++++--------- docs/objects.inv | Bin 1695 -> 1794 bytes docs/py-modindex.html | 46 +- docs/searchindex.js | 2 +- pyninja/executors/routes.py | 4 +- pyninja/features/{processor.py => cpu.py} | 0 pyninja/monitor/routes.py | 4 +- release_notes.rst | 62 +- 12 files changed, 1225 insertions(+), 942 deletions(-) rename pyninja/features/{processor.py => cpu.py} (100%) diff --git a/doc_gen/index.rst b/doc_gen/index.rst index b68163f..fa1e4d8 100644 --- a/doc_gen/index.rst +++ b/doc_gen/index.rst @@ -17,137 +17,135 @@ PyNinja - Main .. automodule:: pyninja.main -Authenticator -============= -.. automodule:: pyninja.auth +PyNinja - Executors +=================== -Routes -====== +API Authenticator +----------------- +.. automodule:: pyninja.executors.auth -.. automodule:: pyninja.routes +Database +-------- +.. automodule:: pyninja.executors.database -Monitors -======== +API Routes +---------- +.. automodule:: pyninja.executors.routes -Docker +Squire ------ +.. automodule:: pyninja.executors.squire -.. automodule:: pyninja.dockerized +PyNinja - Features +================== + +CPU +--- +.. automodule:: pyninja.features.cpu + +Disks +----- +.. automodule:: pyninja.features.disks + +Docker +------ +.. automodule:: pyninja.features.dockerized GPU --- +.. automodule:: pyninja.features.gpu -.. automodule:: pyninja.gpu +Operations +---------- +.. automodule:: pyninja.features.operations Process ------- - -.. automodule:: pyninja.process +.. automodule:: pyninja.features.process Service ------- +.. automodule:: pyninja.features.service -.. automodule:: pyninja.service - -Operations -========== - -.. automodule:: pyninja.operations - -Database -======== - -.. automodule:: pyninja.database - -RateLimiter -=========== - -.. automodule:: pyninja.rate_limit +PyNinja - Modules +================= Exceptions -========== - -.. automodule:: pyninja.exceptions +---------- +.. automodule:: pyninja.modules.exceptions Models -====== - -.. autoclass:: pyninja.models.Payload(BaseModel) +------ +.. autoclass:: pyninja.modules.models.Payload(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ServiceStatus(BaseModel) +.. autoclass:: pyninja.modules.models.ServiceStatus(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.DiskLib(BaseModel) +.. autoclass:: pyninja.modules.models.DiskLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ServiceLib(BaseModel) +.. autoclass:: pyninja.modules.models.ServiceLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ProcessorLib(BaseModel) +.. autoclass:: pyninja.modules.models.ProcessorLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.Session(BaseModel) +.. autoclass:: pyninja.modules.models.Session(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.RateLimit(BaseModel) +.. autoclass:: pyninja.modules.models.RateLimit(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.EnvConfig(BaseModel) +.. autoclass:: pyninja.modules.models.EnvConfig(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. automodule:: pyninja.models +.. automodule:: pyninja.modules.models :exclude-members: Payload, ServiceStatus, DiskLib, ServiceLib, ProcessorLib, EnvConfig, Session, RateLimit, env, database -Squire -====== +RateLimit +--------- +.. automodule:: pyninja.modules.rate_limit -.. automodule:: pyninja.squire +Secure +--------- +.. automodule:: pyninja.modules.secure PyNinja - Monitor ================= Authenticator ------------- - .. automodule:: pyninja.monitor.authenticator Configuration ------------- - .. automodule:: pyninja.monitor.config Resources --------- - .. automodule:: pyninja.monitor.resources Routes ------ - .. automodule:: pyninja.monitor.routes -Secure ------- - -.. automodule:: pyninja.monitor.secure - Indices and tables ================== diff --git a/docs/README.html b/docs/README.html index d4e8039..c77ad6e 100644 --- a/docs/README.html +++ b/docs/README.html @@ -4,7 +4,7 @@ - + PyNinja — PyNinja documentation diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt index b68163f..fa1e4d8 100644 --- a/docs/_sources/index.rst.txt +++ b/docs/_sources/index.rst.txt @@ -17,137 +17,135 @@ PyNinja - Main .. automodule:: pyninja.main -Authenticator -============= -.. automodule:: pyninja.auth +PyNinja - Executors +=================== -Routes -====== +API Authenticator +----------------- +.. automodule:: pyninja.executors.auth -.. automodule:: pyninja.routes +Database +-------- +.. automodule:: pyninja.executors.database -Monitors -======== +API Routes +---------- +.. automodule:: pyninja.executors.routes -Docker +Squire ------ +.. automodule:: pyninja.executors.squire -.. automodule:: pyninja.dockerized +PyNinja - Features +================== + +CPU +--- +.. automodule:: pyninja.features.cpu + +Disks +----- +.. automodule:: pyninja.features.disks + +Docker +------ +.. automodule:: pyninja.features.dockerized GPU --- +.. automodule:: pyninja.features.gpu -.. automodule:: pyninja.gpu +Operations +---------- +.. automodule:: pyninja.features.operations Process ------- - -.. automodule:: pyninja.process +.. automodule:: pyninja.features.process Service ------- +.. automodule:: pyninja.features.service -.. automodule:: pyninja.service - -Operations -========== - -.. automodule:: pyninja.operations - -Database -======== - -.. automodule:: pyninja.database - -RateLimiter -=========== - -.. automodule:: pyninja.rate_limit +PyNinja - Modules +================= Exceptions -========== - -.. automodule:: pyninja.exceptions +---------- +.. automodule:: pyninja.modules.exceptions Models -====== - -.. autoclass:: pyninja.models.Payload(BaseModel) +------ +.. autoclass:: pyninja.modules.models.Payload(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ServiceStatus(BaseModel) +.. autoclass:: pyninja.modules.models.ServiceStatus(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.DiskLib(BaseModel) +.. autoclass:: pyninja.modules.models.DiskLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ServiceLib(BaseModel) +.. autoclass:: pyninja.modules.models.ServiceLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.ProcessorLib(BaseModel) +.. autoclass:: pyninja.modules.models.ProcessorLib(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.Session(BaseModel) +.. autoclass:: pyninja.modules.models.Session(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.RateLimit(BaseModel) +.. autoclass:: pyninja.modules.models.RateLimit(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. autoclass:: pyninja.models.EnvConfig(BaseModel) +.. autoclass:: pyninja.modules.models.EnvConfig(BaseModel) :exclude-members: _abc_impl, model_config, model_fields, model_computed_fields ==== -.. automodule:: pyninja.models +.. automodule:: pyninja.modules.models :exclude-members: Payload, ServiceStatus, DiskLib, ServiceLib, ProcessorLib, EnvConfig, Session, RateLimit, env, database -Squire -====== +RateLimit +--------- +.. automodule:: pyninja.modules.rate_limit -.. automodule:: pyninja.squire +Secure +--------- +.. automodule:: pyninja.modules.secure PyNinja - Monitor ================= Authenticator ------------- - .. automodule:: pyninja.monitor.authenticator Configuration ------------- - .. automodule:: pyninja.monitor.config Resources --------- - .. automodule:: pyninja.monitor.resources Routes ------ - .. automodule:: pyninja.monitor.routes -Secure ------- - -.. automodule:: pyninja.monitor.secure - Indices and tables ================== diff --git a/docs/genindex.html b/docs/genindex.html index 6b948eb..f06c777 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -68,37 +68,57 @@

Index

_

A

@@ -106,11 +126,11 @@

A

B

@@ -118,19 +138,19 @@

B

C

@@ -138,33 +158,33 @@

C

D

@@ -172,19 +192,19 @@

D

E

@@ -216,87 +236,95 @@

G

@@ -304,17 +332,17 @@

G

H

@@ -322,15 +350,17 @@

H

I

@@ -338,7 +368,7 @@

I

K

@@ -346,25 +376,25 @@

K

L

@@ -457,11 +491,11 @@

M

N

@@ -469,152 +503,168 @@

N

P

@@ -625,29 +675,29 @@

R

  • - pyninja.monitor.authenticator + pyninja.features.gpu
  • - pyninja.monitor.config + pyninja.features.operations
  • - pyninja.monitor.resources + pyninja.features.process
  • - pyninja.monitor.routes + pyninja.features.service
  • - pyninja.monitor.secure + pyninja.main
  • - pyninja.operations + pyninja.modules.exceptions
  • - pyninja.process + pyninja.modules.models
  • - pyninja.rate_limit + pyninja.modules.rate_limit
  • - pyninja.routes + pyninja.modules.secure
  • - pyninja.service + pyninja.monitor.authenticator
  • - pyninja.squire + pyninja.monitor.config
  • +
  • + pyninja.monitor.resources + +
  • +
  • + pyninja.monitor.routes + +
@@ -655,33 +705,33 @@

R

S

diff --git a/docs/index.html b/docs/index.html index 7a93596..c3c2fb9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ - + Welcome to PyNinja’s documentation! — PyNinja documentation @@ -86,7 +86,7 @@

Welcome to PyNinja’s documentation!
-async pyninja.main.redirect_exception_handler(request: Request, exception: RedirectException) JSONResponse
+async pyninja.main.redirect_exception_handler(request: Request, exception: RedirectException) JSONResponse

Custom exception handler to handle redirect.

Parameters:
@@ -130,16 +130,18 @@

Welcome to PyNinja’s documentation! -

Authenticator

+
+

PyNinja - Executors

+
+

API Authenticator

-
-pyninja.auth.EPOCH()
+
+pyninja.executors.auth.EPOCH()
-
-async pyninja.auth.forbidden(request: Request) None
+
+async pyninja.executors.auth.forbidden(request: Request) None

Validates if a request is part of the forbidden list.

Parameters:
@@ -147,7 +149,7 @@

Welcome to PyNinja’s documentation!Raises:
@@ -155,8 +157,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.auth.level_1(request: Request, apikey: HTTPAuthorizationCredentials) None
+
+async pyninja.executors.auth.level_1(request: Request, apikey: HTTPAuthorizationCredentials) None

Validates the auth request using HTTPBearer.

Parameters:
@@ -167,7 +169,7 @@

Welcome to PyNinja’s documentation!Raises:
@@ -176,8 +178,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.auth.level_2(request: Request, apikey: HTTPAuthorizationCredentials, token: str) None
+
+async pyninja.executors.auth.level_2(request: Request, apikey: HTTPAuthorizationCredentials, token: str) None

Validates the auth request using HTTPBearer and additionally a secure token.

Parameters:
@@ -189,7 +191,7 @@

Welcome to PyNinja’s documentation!Raises:
@@ -198,8 +200,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.auth.incrementer(attempt: int) int
+
+async pyninja.executors.auth.incrementer(attempt: int) int

Increments block time for a host address based on the number of failed login attempts.

Parameters:
@@ -215,8 +217,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.auth.handle_auth_error(request: Request) None
+
+async pyninja.executors.auth.handle_auth_error(request: Request) None

Handle authentication errors from the filebrowser API.

Parameters:
@@ -226,11 +228,56 @@

Welcome to PyNinja’s documentation! -

Routes

+
+

Database

-
-async pyninja.routes.get_ip_address(request: Request, public: bool = False, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+pyninja.executors.database.get_record(host: str) int | None
+

Gets blocked epoch time for a particular host.

+
+
Parameters:
+

host – Host address.

+
+
Returns:
+

Returns the epoch time until when the host address should be blocked.

+
+
Return type:
+

int

+
+
+
+ +
+
+pyninja.executors.database.put_record(host: str, block_until: int) None
+

Inserts blocked epoch time for a particular host.

+
+
Parameters:
+
    +
  • host – Host address.

  • +
  • block_until – Epoch time until when the host address should be blocked.

  • +
+
+
+
+ +
+
+pyninja.executors.database.remove_record(host: str) None
+

Deletes all records related to the host address.

+
+
Parameters:
+

host – Host address.

+
+
+
+ +
+
+

API Routes

+
+
+async pyninja.executors.routes.get_ip_address(request: Request, public: bool = False, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get local and public IP address of the device.

Args:

@@ -248,8 +295,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_cpu_utilization(request: Request, interval: int | float = 2, per_cpu: bool = True, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_cpu_utilization(request: Request, interval: int | float = 2, per_cpu: bool = True, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get the CPU utilization.

Args:

@@ -268,8 +315,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_memory_utilization(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_memory_utilization(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get memory utilization.

Args:

@@ -286,8 +333,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_cpu_load_avg(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_cpu_load_avg(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get the number of processes in the system run queue averaged over the last 1, 5, and 15 minutes respectively.

Args:

@@ -304,8 +351,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_disk_utilization(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_disk_utilization(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get disk utilization.

Args:

@@ -322,8 +369,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_all_disks(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_all_disks(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get all disks attached to the host device.

Args:

@@ -340,8 +387,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.run_command(request: Request, payload: Payload, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer), token: Optional[str] = Header(None))
+
+async pyninja.executors.routes.run_command(request: Request, payload: Payload, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer), token: Optional[str] = Header(None))

API function to run a command on host machine.

Args:

@@ -360,8 +407,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_process_status(request: Request, process_name: str, cpu_interval: Union[int, float] = 1, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_process_status(request: Request, process_name: str, cpu_interval: Union[int, float] = 1, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to monitor a process.

Args:

@@ -380,8 +427,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_service_status(request: Request, service_name: str, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_service_status(request: Request, service_name: str, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to monitor a service.

Args:

@@ -399,8 +446,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_docker_containers(request: Request, container_name: str = None, get_all: bool = False, get_running: bool = False, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_docker_containers(request: Request, container_name: str = None, get_all: bool = False, get_running: bool = False, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to get docker containers’ information.

Args:

@@ -420,8 +467,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_docker_images(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_docker_images(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to get docker images’ information.

Args:

@@ -438,8 +485,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_docker_volumes(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_docker_volumes(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to get docker volumes’ information.

Args:

@@ -456,8 +503,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_docker_stats(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_docker_stats(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

Get docker-stats for all running containers.

Args:

@@ -474,8 +521,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.get_processor_name(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))
+
+async pyninja.executors.routes.get_processor_name(request: Request, apikey: HTTPAuthorizationCredentials = Depends(HTTPBearer))

API function to get process information.

Args:

@@ -493,8 +540,8 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.docs() RedirectResponse
+
+async pyninja.executors.routes.docs() RedirectResponse

Redirect to docs page.

Returns:
@@ -507,22 +554,22 @@

Welcome to PyNinja’s documentation! -
-async pyninja.routes.health()
+
+async pyninja.executors.routes.health()

Health check for PyNinja.

Returns:

Returns a health check response with status code 200.

Return type:
-

APIResponse

+

APIResponse

-
-pyninja.routes.get_all_routes(dependencies: List[Depends]) List[APIRoute]
+
+pyninja.executors.routes.get_all_routes(dependencies: List[Depends]) List[APIRoute]

Get all the routes to be added for the API server.

Parameters:
@@ -538,20 +585,92 @@

Welcome to PyNinja’s documentation! -

Monitors

-
-

Docker

+
+

Squire

-
-pyninja.dockerized.get_container_status(name: str = None) str | None
-

Get container status by name.

+
+pyninja.executors.squire.public_ip_address() str
+

Gets public IP address of the host using different endpoints.

+
+
Returns:
+

Public IP address.

+
+
Return type:
+

str

+
+
+
+ +
+
+pyninja.executors.squire.private_ip_address() str | None
+

Uses a simple check on network id to see if it is connected to local host or not.

+
+
Returns:
+

Private IP address of host machine.

+
+
Return type:
+

str

+
+
+
+ +
+
+pyninja.executors.squire.format_nos(input_: float) int | float
+

Removes .0 float values.

Parameters:
-

name – Name of the container or image used to run the container.

+

input_ – Strings or integers with .0 at the end.

Returns:
-

Container status as a string.

+

Int if found, else returns the received float value.

+
+
Return type:
+

int | float

+
+
+
+ +
+
+pyninja.executors.squire.format_timedelta(td: timedelta) str
+

Converts timedelta to human-readable format by constructing a formatted string based on non-zero values.

+
+
Parameters:
+

td – Timedelta object.

+
+
+
+

See also

+

Always limits the output to a maximum of two identifiers.

+
+

Examples

+
    +
  • 3 days and 1 hour

  • +
  • 1 hour and 11 minutes

  • +
  • 5 minutes and 23 seconds

  • +
+
+
Returns:
+

Human-readable format of timedelta.

+
+
Return type:
+

str

+
+
+
+ +
+
+pyninja.executors.squire.size_converter(byte_size: int | float) str
+

Gets the current memory consumed and converts it to human friendly format.

+
+
Parameters:
+

byte_size – Receives byte size as argument.

+
+
Returns:
+

Converted understandable size.

Return type:

str

@@ -560,105 +679,191 @@

Monitors -
-pyninja.dockerized.get_running_containers() Generator[Dict[str, str]]
-

Get running containers.

+
+pyninja.executors.squire.process_command(command: str, timeout: Union[int, float]) Dict[str, List[str]]
+

Process the requested command.

-
Yields:
-

Dict[str, str] – Yields a dictionary of running containers with the corresponding metrics.

+
Parameters:
+
    +
  • command – Command as string.

  • +
  • timeout – Timeout for the command.

  • +
+
+
Returns:
+

Returns the result with stdout and stderr as key-value pairs.

+
+
Return type:
+

Dict[str, List[str]]

-
-pyninja.dockerized.get_all_containers() Optional[List[Dict[str, str]]]
-

Get all containers and their metrics.

+
+pyninja.executors.squire.envfile_loader(filename: str | os.PathLike) EnvConfig
+

Loads environment variables based on filetypes.

+
+
Parameters:
+

filename – Filename from where env vars have to be loaded.

+
+
Returns:
+

Returns a reference to the EnvConfig object.

+
+
Return type:
+

EnvConfig

+
+
+
+ +
+
+pyninja.executors.squire.load_env(**kwargs) EnvConfig
+

Merge env vars from env_file with kwargs, giving priority to kwargs.

+
+

See also

+

This function allows env vars to be loaded partially from .env files and partially through kwargs.

+
Returns:
-

Returns a list of all the containers and their stats.

+

Returns a reference to the EnvConfig object.

Return type:
-

List[Dict[str, str]]

+

EnvConfig

-
-pyninja.dockerized.get_all_images() Optional[Dict[str, str]]
-

Get all docker images.

+
+pyninja.executors.squire.keygen() str
+

Generate session token from secrets module, so that users are forced to log in when the server restarts.

Returns:
-

Returns a dictionary with image stats.

+

Returns a URL safe 64-bit token.

Return type:
-

Dict[str, str]

+

str

-
-pyninja.dockerized.get_all_volumes() Optional[Dict[str, str]]
-

Get all docker volumes.

+
+pyninja.executors.squire.dynamic_numbers(string: str) int | float | None
+

Convert strings to integer or float dynamically.

+
+
Parameters:
+

string – Number in string format.

+
+
Returns:
+

Integer or float value.

+
+
Return type:
+

int | float

+
+
+
+ +
+
+
+

PyNinja - Features

+
+

CPU

+
+
+pyninja.features.cpu._darwin(lib_path: Path) str
+

Get processor information for macOS.

+
+
Parameters:
+

lib_path – Path to the library executable.

+
+
+
+ +
+
+pyninja.features.cpu._linux(lib_path: Path) str
+

Get processor information for Linux.

+
+
Parameters:
+

lib_path – Path to the library file.

+
+
+
+ +
+
+pyninja.features.cpu._windows(lib_path: Path) str
+

Get processor information for Windows.

+
+
Parameters:
+

lib_path – Path to the library file.

+
+
+
+ +
+
+pyninja.features.cpu.get_name() str | None
+

Get processor information for the host operating system.

Returns:
-

Returns a dictionary with list of volume objects.

+

Returns the processor information as a string.

Return type:
-

Dict[str, str]

+

str

-
-

GPU

+
+

Disks

-
-pyninja.gpu._darwin(lib_path) Optional[List[Dict[str, str]]]
-

Get GPU model and vendor information for Linux operating system.

+
+pyninja.features.disks.get_partitions_for_disk(device_id: str) List[str]
+

Use psutil to find partitions for a given device.

Parameters:
-

lib_path – Library path to get GPU information.

+

device_id

Returns:
-

Returns a list of GPU model and vendor information.

+

Returns the list of partitions in a disk.

Return type:
-

List[Dict[str, str]]

+

List[str]

-
-pyninja.gpu._linux(lib_path) Optional[List[Dict[str, str]]]
-

Get GPU model and vendor information for Linux operating system.

+
+pyninja.features.disks.parse_size(size_str) str
+

Convert size string with units to a standard size in bytes.

Parameters:
-

lib_path – Library path to get GPU information.

+

size_str – Size with unit as string.

Returns:
-

Returns a list of GPU model and vendor information.

+

Returns the parsed size as string with units attached.

Return type:
-

List[Dict[str, str]]

+

str

-
-pyninja.gpu._windows(lib_path: Path) Optional[List[Dict[str, str]]]
-

Get GPU model and vendor information for Windows operating system.

+
+pyninja.features.disks._linux(lib_path: Path) List[Dict[str, str]]
+

Get disks attached to Linux devices.

Parameters:
-

lib_path – Library path to get GPU information.

+

lib_path – Returns the library path for disk information.

Returns:
-

Returns a list of GPU model and vendor information.

+

Returns disks information for Linux distros.

Return type:

List[Dict[str, str]]

@@ -667,155 +872,227 @@

Monitors -
-pyninja.gpu.get_names() List[Dict[str, str]]
-

Get list of GPU model and vendor information based on the operating system.

+
+pyninja.features.disks.is_physical_disk(lib_path: Path, device_id: str) bool
+

Check if the disk is a physical disk using diskutil info.

+
+
Parameters:
+
    +
  • lib_path – Library path to get disk info.

  • +
  • device_id – Device mount ID.

  • +
+
+
Returns:
+

Boolean to indicate virtual or physical

+
+
Return type:
+

bool

+
+

-
-
-

Process

-
-pyninja.process.get_process_status(process_name: str, cpu_interval: int) List[Dict[str, int | float | str | bool]]
-

Get process information by name.

+
+pyninja.features.disks._darwin(lib_path: Path) List[Dict[str, str]]
+

Get disks attached to macOS devices.

Parameters:
-
    -
  • process_name – Name of the process.

  • -
  • cpu_interval – CPU interval to get the CPU performance.

  • -
+

lib_path – Returns the library path for disk information.

Returns:
-

Returns a list of performance report for each process hosting the given process name.

+

Returns disks information for macOS devices.

Return type:
-

List[Dict[str, int | float | str | bool]]

+

List[Dict[str, str]]

-
-pyninja.process.get_performance(process: Process, cpu_interval: int) Dict[str, int | float | str | bool]
-

Checks process performance by monitoring CPU utilization, number of threads and open files.

+
+pyninja.features.disks._reformat_windows(data: Dict[str, str | int | float]) Dict[str, str]
+

Reformats each drive’s information for Windows OS.

Parameters:
-
    -
  • process – Process object.

  • -
  • cpu_interval – CPU interval to get the CPU performance.

  • -
+

data – Data as a dictionary.

Returns:
-

Returns the process metrics as key-value pairs.

+

Returns a dictionary of key-value pairs.

Return type:
-

Dict[str, int | float | str | bool]

+

Dict[str, str]

-
-
-

Service

-
-pyninja.service.running(service_name: str) ServiceStatus
-

Constructs an ServiceStatus object with a status code.

+
+pyninja.features.disks._windows(lib_path: Path) List[Dict[str, str]]
+

Get disks attached to Windows devices.

Parameters:
-

service_name – Name of the service.

+

lib_path – Returns the library path for disk information.

Returns:
-

Returns a reference to the ServiceStatus object.

+

Returns disks information for Windows machines.

Return type:
-

ServiceStatus

+

List[Dict[str, str]]

-
-pyninja.service.stopped(service_name: str) ServiceStatus
-

Constructs an ServiceStatus object with a status code 501.

+
+pyninja.features.disks.get_all_disks() List[Dict[str, str]]
+

OS-agnostic function to get all disks connected to the host system.

+
+ +
+
+

Docker

+
+
+pyninja.features.dockerized.get_container_status(name: str = None) str | None
+

Get container status by name.

Parameters:
-

service_name – Name of the service.

+

name – Name of the container or image used to run the container.

Returns:
-

Returns a reference to the ServiceStatus object.

+

Container status as a string.

Return type:
-

ServiceStatus

+

str

-
-pyninja.service.unknown(service_name) ServiceStatus
-

Constructs an ServiceStatus object with a status code 503.

+
+pyninja.features.dockerized.get_running_containers() Generator[Dict[str, str]]
+

Get running containers.

+
+
Yields:
+

Dict[str, str] – Yields a dictionary of running containers with the corresponding metrics.

+
+
+
+ +
+
+pyninja.features.dockerized.get_all_containers() Optional[List[Dict[str, str]]]
+

Get all containers and their metrics.

+
+
Returns:
+

Returns a list of all the containers and their stats.

+
+
Return type:
+

List[Dict[str, str]]

+
+
+
+ +
+
+pyninja.features.dockerized.get_all_images() Optional[Dict[str, str]]
+

Get all docker images.

+
+
Returns:
+

Returns a dictionary with image stats.

+
+
Return type:
+

Dict[str, str]

+
+
+
+ +
+
+pyninja.features.dockerized.get_all_volumes() Optional[Dict[str, str]]
+

Get all docker volumes.

+
+
Returns:
+

Returns a dictionary with list of volume objects.

+
+
Return type:
+

Dict[str, str]

+
+
+
+ +
+
+

GPU

+
+
+pyninja.features.gpu._darwin(lib_path) Optional[List[Dict[str, str]]]
+

Get GPU model and vendor information for Linux operating system.

Parameters:
-

service_name – Name of the service.

+

lib_path – Library path to get GPU information.

Returns:
-

Returns a reference to the ServiceStatus object.

+

Returns a list of GPU model and vendor information.

Return type:
-

ServiceStatus

+

List[Dict[str, str]]

-
-pyninja.service.unavailable(service_name: str) ServiceStatus
-

Constructs an ServiceStatus object with a status code 404.

+
+pyninja.features.gpu._linux(lib_path) Optional[List[Dict[str, str]]]
+

Get GPU model and vendor information for Linux operating system.

Parameters:
-

service_name – Name of the service.

+

lib_path – Library path to get GPU information.

Returns:
-

Returns a reference to the ServiceStatus object.

+

Returns a list of GPU model and vendor information.

Return type:
-

ServiceStatus

+

List[Dict[str, str]]

-
-pyninja.service.get_service_status(service_name: str) ServiceStatus
-

Get service status by name.

+
+pyninja.features.gpu._windows(lib_path: Path) Optional[List[Dict[str, str]]]
+

Get GPU model and vendor information for Windows operating system.

Parameters:
-

service_name – Name of the service.

+

lib_path – Library path to get GPU information.

Returns:
-

Returns an instance of the ServiceStatus object.

+

Returns a list of GPU model and vendor information.

Return type:
-

ServiceStatus

+

List[Dict[str, str]]

+
+
+pyninja.features.gpu.get_names() List[Dict[str, str]]
+

Get list of GPU model and vendor information based on the operating system.

+
+
-
-
-

Operations

+
+

Operations

-
-pyninja.operations.default(name: str)
+
+pyninja.features.operations.default(name: str)

Default values for processes and services.

-
-pyninja.operations.get_process_info(proc: Process, process_name: str = None) Dict[str, Union[str, int]]
+
+pyninja.features.operations.get_process_info(proc: Process, process_name: str = None) Dict[str, Union[str, int]]

Get process information.

Parameters:
@@ -834,8 +1111,8 @@

Monitors -
-async pyninja.operations.process_monitor(executor: ThreadPoolExecutor) List[Dict[str, str]]
+
+async pyninja.features.operations.process_monitor(executor: ThreadPoolExecutor) List[Dict[str, str]]

Function to monitor processes and return their usage statistics.

See also

@@ -858,8 +1135,8 @@

Monitors -
-async pyninja.operations.service_monitor(executor: ThreadPoolExecutor) List[Dict[str, str]]
+
+async pyninja.features.operations.service_monitor(executor: ThreadPoolExecutor) List[Dict[str, str]]

Function to monitor services and return their usage statistics.

See also

@@ -883,139 +1160,202 @@

Monitors -
-pyninja.operations.get_service_pid(service_name: str) Optional[int]
+
+pyninja.features.operations.get_service_pid(service_name: str) Optional[int]

Retrieve the PID of a service depending on the OS.

-
-pyninja.operations.get_service_pid_linux(service_name: str) Optional[int]
-

Get the PID of a service on Linux.

+
+pyninja.features.operations.get_service_pid_linux(service_name: str) Optional[int]
+

Get the PID of a service on Linux.

+
+
Parameters:
+

service_name – Name of the service.

+
+
Returns:
+

Returns the PID of the service.

+
+
Return type:
+

Optional[int]

+
+
+
+ +
+
+pyninja.features.operations.get_service_pid_macos(service_name: str) Optional[int]
+

Get the PID of a service on macOS.

+
+
Parameters:
+

service_name – Name of the service.

+
+
Returns:
+

Returns the PID of the service.

+
+
Return type:
+

Optional[int]

+
+
+
+ +
+
+pyninja.features.operations.get_service_pid_windows(service_name: str) Optional[int]
+

Get the PID of a service on Windows.

+
+
Parameters:
+

service_name – Name of the service.

+
+
Returns:
+

Returns the PID of the service.

+
+
Return type:
+

Optional[int]

+
+
+
+ +
+
+

Process

+
+
+pyninja.features.process.get_process_status(process_name: str, cpu_interval: int) List[Dict[str, int | float | str | bool]]
+

Get process information by name.

Parameters:
-

service_name – Name of the service.

+
    +
  • process_name – Name of the process.

  • +
  • cpu_interval – CPU interval to get the CPU performance.

  • +
Returns:
-

Returns the PID of the service.

+

Returns a list of performance report for each process hosting the given process name.

Return type:
-

Optional[int]

+

List[Dict[str, int | float | str | bool]]

-
-pyninja.operations.get_service_pid_macos(service_name: str) Optional[int]
-

Get the PID of a service on macOS.

+
+pyninja.features.process.get_performance(process: Process, cpu_interval: int) Dict[str, int | float | str | bool]
+

Checks process performance by monitoring CPU utilization, number of threads and open files.

Parameters:
-

service_name – Name of the service.

+
    +
  • process – Process object.

  • +
  • cpu_interval – CPU interval to get the CPU performance.

  • +
Returns:
-

Returns the PID of the service.

+

Returns the process metrics as key-value pairs.

Return type:
-

Optional[int]

+

Dict[str, int | float | str | bool]

+
+
+

Service

-
-pyninja.operations.get_service_pid_windows(service_name: str) Optional[int]
-

Get the PID of a service on Windows.

+
+pyninja.features.service.running(service_name: str) ServiceStatus
+

Constructs an ServiceStatus object with a status code.

Parameters:

service_name – Name of the service.

Returns:
-

Returns the PID of the service.

+

Returns a reference to the ServiceStatus object.

Return type:
-

Optional[int]

+

ServiceStatus

-
-
-

Database

-
-pyninja.database.get_record(host: str) int | None
-

Gets blocked epoch time for a particular host.

+
+pyninja.features.service.stopped(service_name: str) ServiceStatus
+

Constructs an ServiceStatus object with a status code 501.

Parameters:
-

host – Host address.

+

service_name – Name of the service.

Returns:
-

Returns the epoch time until when the host address should be blocked.

+

Returns a reference to the ServiceStatus object.

Return type:
-

int

+

ServiceStatus

-
-pyninja.database.put_record(host: str, block_until: int) None
-

Inserts blocked epoch time for a particular host.

+
+pyninja.features.service.unknown(service_name) ServiceStatus
+

Constructs an ServiceStatus object with a status code 503.

Parameters:
-
    -
  • host – Host address.

  • -
  • block_until – Epoch time until when the host address should be blocked.

  • -
+

service_name – Name of the service.

+
+
Returns:
+

Returns a reference to the ServiceStatus object.

+
+
Return type:
+

ServiceStatus

-
-pyninja.database.remove_record(host: str) None
-

Deletes all records related to the host address.

+
+pyninja.features.service.unavailable(service_name: str) ServiceStatus
+

Constructs an ServiceStatus object with a status code 404.

Parameters:
-

host – Host address.

+

service_name – Name of the service.

+
+
Returns:
+

Returns a reference to the ServiceStatus object.

+
+
Return type:
+

ServiceStatus

-
-
-

RateLimiter

-
-
-class pyninja.rate_limit.RateLimiter(rps: RateLimit)
-

Object that implements the RateLimiter functionality.

-
>>> RateLimiter
-
-
-
-
-init(request: Request) None
-

Checks if the number of calls exceeds the rate limit for the given identifier.

+
+
+pyninja.features.service.get_service_status(service_name: str) ServiceStatus
+

Get service status by name.

Parameters:
-

request – The incoming request object.

+

service_name – Name of the service.

-
Raises:
-

429 – Too many requests.

+
Returns:
+

Returns an instance of the ServiceStatus object.

+
+
Return type:
+

ServiceStatus

-
-
-
-

Exceptions

+
+
+

PyNinja - Modules

+
+

Exceptions

-
-exception pyninja.exceptions.APIResponse(status_code: int, detail: Any = None, headers: Optional[Dict[str, str]] = None)
+
+exception pyninja.modules.exceptions.APIResponse(status_code: int, detail: Any = None, headers: Optional[Dict[str, str]] = None)

Custom HTTPException from FastAPI to wrap an API response.

>>> APIResponse
 
@@ -1023,8 +1363,8 @@

Monitors -
-exception pyninja.exceptions.UnSupportedOS
+
+exception pyninja.modules.exceptions.UnSupportedOS

Custom exception class for unsupported OS.

>>> UnSupportedOS
 
@@ -1032,8 +1372,8 @@

Monitors -
-exception pyninja.exceptions.RedirectException(location: str, detail: Optional[str] = '')
+
+exception pyninja.modules.exceptions.RedirectException(location: str, detail: Optional[str] = '')

Custom RedirectException raised within the API since HTTPException doesn’t support returning HTML content.

>>> RedirectException
 
@@ -1051,8 +1391,8 @@

Monitors -
-exception pyninja.exceptions.SessionError(detail: Optional[str] = '')
+
+exception pyninja.modules.exceptions.SessionError(detail: Optional[str] = '')

Custom exception class for session errors.

>>> SessionError
 
@@ -1060,8 +1400,8 @@

Monitors -
-pyninja.exceptions.raise_os_error(operating_system: str) NoReturn
+
+pyninja.modules.exceptions.raise_os_error(operating_system: str) NoReturn

Raises a custom exception for unsupported OS.

Parameters:
@@ -1075,277 +1415,277 @@

Monitors -

Models

+

Models

-
-class pyninja.models.Payload(BaseModel)
+
+class pyninja.modules.models.Payload(BaseModel)

BaseModel that handles input data for Payload.

>>> Payload
 
-
-command: str
+
+command: str
-
-timeout: Union[int, float]
+
+timeout: Union[int, float]

-
-class pyninja.models.ServiceStatus(BaseModel)
+
+class pyninja.modules.models.ServiceStatus(BaseModel)

Object to load service status with a status code and description.

>>> ServiceStatus
 
-
-status_code: int
+
+status_code: int
-
-description: str
+
+description: str

-
-class pyninja.models.DiskLib(BaseModel)
+
+class pyninja.modules.models.DiskLib(BaseModel)

Default disks library dedicated to each supported operating system.

>>> DiskLib
 
-
-linux: Path
+
+linux: Path
-
-darwin: Path
+
+darwin: Path
-
-windows: Path
+
+windows: Path

-
-class pyninja.models.ServiceLib(BaseModel)
+
+class pyninja.modules.models.ServiceLib(BaseModel)

Default service library dedicated to each supported operating system.

>>> ServiceLib
 
-
-linux: Path
+
+linux: Path
-
-darwin: Path
+
+darwin: Path
-
-windows: Path
+
+windows: Path

-
-class pyninja.models.ProcessorLib(BaseModel)
+
+class pyninja.modules.models.ProcessorLib(BaseModel)

Default processor library dedicated to each supported operating system.

>>> ProcessorLib
 
-
-linux: Path
+
+linux: Path
-
-darwin: Path
+
+darwin: Path
-
-windows: Path
+
+windows: Path

-
-class pyninja.models.Session(BaseModel)
+
+class pyninja.modules.models.Session(BaseModel)

Object to store session information.

>>> Session
 
-
-auth_counter: Dict[str, int]
+
+auth_counter: Dict[str, int]
-
-forbid: Set[str]
+
+forbid: Set[str]
-
-info: Dict[str, str]
+
+info: Dict[str, str]
-
-rps: Dict[str, int]
+
+rps: Dict[str, int]
-
-allowed_origins: Set[str]
+
+allowed_origins: Set[str]

-
-class pyninja.models.RateLimit(BaseModel)
+
+class pyninja.modules.models.RateLimit(BaseModel)

Object to store the rate limit settings.

>>> RateLimit
 
-
-max_requests: int
+
+max_requests: int
-
-seconds: int
+
+seconds: int

-
-class pyninja.models.EnvConfig(BaseModel)
+
+class pyninja.modules.models.EnvConfig(BaseModel)

Object to load environment variables.

>>> EnvConfig
 
-
-apikey: str
+
+apikey: str
-
-ninja_host: str
+
+ninja_host: str
-
-ninja_port: int
+
+ninja_port: int
-
-remote_execution: bool
+
+remote_execution: bool
-
-api_secret: str | None
+
+api_secret: str | None
-
-monitor_username: str | None
+
+monitor_username: str | None
-
-monitor_password: str | None
+
+monitor_password: str | None
-
-monitor_session: int
+
+monitor_session: int
-
-max_connections: int
+
+max_connections: int
-
-processes: List[str]
+
+processes: List[str]
-
-services: List[str]
+
+services: List[str]
-
-gpu_lib: Path
+
+gpu_lib: Path
-
-disk_lib: Path
+
+disk_lib: Path
-
-service_lib: Path
+
+service_lib: Path
-
-processor_lib: Path
+
+processor_lib: Path
-
-database: str
+
+database: str
-
-rate_limit: Union[RateLimit, List[RateLimit]]
+
+rate_limit: Union[RateLimit, List[RateLimit]]
-
-log_config: Optional[Union[Dict[str, Any], Path]]
+
+log_config: Optional[Union[Dict[str, Any], Path]]
-
-classmethod parse_api_secret(value: str | None) str | None
+
+classmethod parse_api_secret(value: str | None) str | None

Parse API secret to validate complexity.

Parameters:
@@ -1361,8 +1701,8 @@

Models

-
-classmethod from_env_file(env_file: Path) EnvConfig
+
+classmethod from_env_file(env_file: Path) EnvConfig

Create Settings instance from environment file.

Parameters:
@@ -1372,23 +1712,23 @@

Models

Loads the EnvConfig model.

Return type:
-

EnvConfig

+

EnvConfig

-
-class Config
+
+class Config

Extra configuration for EnvConfig object.

-
-extra = 'ignore'
+
+extra = 'ignore'
-
-hide_input_in_errors = True
+
+hide_input_in_errors = True
@@ -1396,9 +1736,9 @@

Models


-
-
-pyninja.models.complexity_checker(secret: str) None
+
+
+pyninja.modules.models.complexity_checker(secret: str) None

Verifies the strength of a secret.

See also

@@ -1419,47 +1759,47 @@

Models

-
-class pyninja.models.GPULib(*, linux: Path = '/usr/bin/lspci', darwin: Path = '/usr/sbin/system_profiler', windows: Path = 'C:\\Windows\\System32\\wbem\\wmic.exe')
+
+class pyninja.modules.models.GPULib(*, linux: Path = '/usr/bin/lspci', darwin: Path = '/usr/sbin/system_profiler', windows: Path = 'C:\\Windows\\System32\\wbem\\wmic.exe')

Default GPU library dedicated to each supported operating system.

>>> GPULib
 
-
-linux: Path
+
+linux: Path
-
-darwin: Path
+
+darwin: Path
-
-windows: Path
+
+windows: Path
-
-_abc_impl = <_abc._abc_data object>
+
+_abc_impl = <_abc._abc_data object>
-
-model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

-
-model_config: ClassVar[ConfigDict] = {}
+
+model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

-
-model_fields: ClassVar[dict[str, FieldInfo]] = {'darwin': FieldInfo(annotation=Path, required=False, default='/usr/sbin/system_profiler', metadata=[PathType(path_type='file')]), 'linux': FieldInfo(annotation=Path, required=False, default='/usr/bin/lspci', metadata=[PathType(path_type='file')]), 'windows': FieldInfo(annotation=Path, required=False, default='C:\\Windows\\System32\\wbem\\wmic.exe', metadata=[PathType(path_type='file')])}
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'darwin': FieldInfo(annotation=Path, required=False, default='/usr/sbin/system_profiler', metadata=[PathType(path_type='file')]), 'linux': FieldInfo(annotation=Path, required=False, default='/usr/bin/lspci', metadata=[PathType(path_type='file')]), 'windows': FieldInfo(annotation=Path, required=False, default='C:\\Windows\\System32\\wbem\\wmic.exe', metadata=[PathType(path_type='file')])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

@@ -1468,42 +1808,42 @@

Models

-
-class pyninja.models.WSSession(*, invalid: Dict[str, int] = {}, client_auth: Dict[str, Dict[str, int]] = {})
+
+class pyninja.modules.models.WSSession(*, invalid: Dict[str, int] = {}, client_auth: Dict[str, Dict[str, int]] = {})

Object to store websocket session information.

>>> WSSession
 
-
-invalid: Dict[str, int]
+
+invalid: Dict[str, int]
-
-client_auth: Dict[str, Dict[str, int]]
+
+client_auth: Dict[str, Dict[str, int]]
-
-_abc_impl = <_abc._abc_data object>
+
+_abc_impl = <_abc._abc_data object>
-
-model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

-
-model_config: ClassVar[ConfigDict] = {}
+
+model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

-
-model_fields: ClassVar[dict[str, FieldInfo]] = {'client_auth': FieldInfo(annotation=Dict[str, Dict[str, int]], required=False, default={}), 'invalid': FieldInfo(annotation=Dict[str, int], required=False, default={})}
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'client_auth': FieldInfo(annotation=Dict[str, Dict[str, int]], required=False, default={}), 'invalid': FieldInfo(annotation=Dict[str, int], required=False, default={})}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

@@ -1512,8 +1852,8 @@

Models

-
-pyninja.models.get_library(library: Union[Type[ServiceLib], Type[ProcessorLib], Type[DiskLib], Type[GPULib]]) Path
+
+pyninja.modules.models.get_library(library: Union[Type[ServiceLib], Type[ProcessorLib], Type[DiskLib], Type[GPULib]]) Path

Get service/processor/disk library filepath for the host operating system.

Parameters:
@@ -1529,15 +1869,15 @@

Models

-
-class pyninja.models.Database(datastore: Union[Path, str], timeout: int = 10)
+
+class pyninja.modules.models.Database(datastore: Union[Path, str], timeout: int = 10)

Creates a connection to the Database using sqlite3.

>>> Database
 
-
-create_table(table_name: str, columns: Union[List[str], Tuple[str]]) None
+
+create_table(table_name: str, columns: Union[List[str], Tuple[str]]) None

Creates the table with the required columns.

Parameters:
@@ -1552,191 +1892,71 @@

Models

-
-

Squire

-
-
-pyninja.squire.public_ip_address() str
-

Gets public IP address of the host using different endpoints.

-
-
Returns:
-

Public IP address.

-
-
Return type:
-

str

-
-
-
- -
-
-pyninja.squire.private_ip_address() str | None
-

Uses a simple check on network id to see if it is connected to local host or not.

-
-
Returns:
-

Private IP address of host machine.

-
-
Return type:
-

str

-
-
-
- -
-
-pyninja.squire.format_nos(input_: float) int | float
-

Removes .0 float values.

-
-
Parameters:
-

input_ – Strings or integers with .0 at the end.

-
-
Returns:
-

Int if found, else returns the received float value.

-
-
Return type:
-

int | float

-
-
-
- -
-
-pyninja.squire.format_timedelta(td: timedelta) str
-

Converts timedelta to human-readable format by constructing a formatted string based on non-zero values.

-
-
Parameters:
-

td – Timedelta object.

-
-
-
-

See also

-

Always limits the output to a maximum of two identifiers.

+
+

RateLimit

+
+
+class pyninja.modules.rate_limit.RateLimiter(rps: RateLimit)
+

Object that implements the RateLimiter functionality.

+
>>> RateLimiter
+
-

Examples

-
    -
  • 3 days and 1 hour

  • -
  • 1 hour and 11 minutes

  • -
  • 5 minutes and 23 seconds

  • -
+
+
+init(request: Request) None
+

Checks if the number of calls exceeds the rate limit for the given identifier.

-
Returns:
-

Human-readable format of timedelta.

+
Parameters:
+

request – The incoming request object.

-
Return type:
-

str

+
Raises:
+

429 – Too many requests.

-
-
-pyninja.squire.size_converter(byte_size: int | float) str
-

Gets the current memory consumed and converts it to human friendly format.

-
-
Parameters:
-

byte_size – Receives byte size as argument.

-
-
Returns:
-

Converted understandable size.

-
-
Return type:
-

str

-
-
+
+
+

Secure

-
-pyninja.squire.process_command(command: str, timeout: Union[int, float]) Dict[str, List[str]]
-

Process the requested command.

-
-
Parameters:
-
    -
  • command – Command as string.

  • -
  • timeout – Timeout for the command.

  • -
-
-
Returns:
-

Returns the result with stdout and stderr as key-value pairs.

-
-
Return type:
-

Dict[str, List[str]]

-
-
+
+async pyninja.modules.secure.calculate_hash(value: Any) str
+

Generate hash value for the given payload.

-
-pyninja.squire.envfile_loader(filename: str | os.PathLike) EnvConfig
-

Loads environment variables based on filetypes.

-
-
Parameters:
-

filename – Filename from where env vars have to be loaded.

-
-
Returns:
-

Returns a reference to the EnvConfig object.

-
-
Return type:
-

EnvConfig

-
-
+
+async pyninja.modules.secure.base64_encode(value: Any) str
+

Base64 encode the given payload.

-
-pyninja.squire.load_env(**kwargs) EnvConfig
-

Merge env vars from env_file with kwargs, giving priority to kwargs.

-
-

See also

-

This function allows env vars to be loaded partially from .env files and partially through kwargs.

-
-
-
Returns:
-

Returns a reference to the EnvConfig object.

-
-
Return type:
-

EnvConfig

-
-
+
+async pyninja.modules.secure.base64_decode(value: Any) str
+

Base64 decode the given payload.

-
-pyninja.squire.keygen() str
-

Generate session token from secrets module, so that users are forced to log in when the server restarts.

-
-
Returns:
-

Returns a URL safe 64-bit token.

-
-
Return type:
-

str

-
-
+
+async pyninja.modules.secure.hex_decode(value: Any) str
+

Convert hex value to a string.

-
-pyninja.squire.dynamic_numbers(string: str) int | float | None
-

Convert strings to integer or float dynamically.

-
-
Parameters:
-

string – Number in string format.

-
-
Returns:
-

Integer or float value.

-
-
Return type:
-

int | float

-
-
+
+async pyninja.modules.secure.hex_encode(value: str)
+

Convert string value to hex.

+

PyNinja - Monitor

-
-

Authenticator

-
+
+

Authenticator

+
async pyninja.monitor.authenticator.failed_auth_counter(host) None

Keeps track of failed login attempts from each host, and redirects if failed for 3 or more times.

@@ -1805,7 +2025,7 @@

Authenticator
-async pyninja.monitor.authenticator.session_error(request: Request, error: SessionError) HTMLResponse
+async pyninja.monitor.authenticator.session_error(request: Request, error: SessionError) HTMLResponse

Renders the session error page.

Parameters:
@@ -1837,7 +2057,7 @@

AuthenticatorRaises:
@@ -1964,9 +2184,9 @@

Authenticator -

Routes

-
+
+

Routes

+
async pyninja.monitor.routes.error_endpoint(request: Request) HTMLResponse

Error endpoint for the monitoring page.

@@ -2048,39 +2268,6 @@

Routes

-
-
-

Secure

-
-
-async pyninja.monitor.secure.calculate_hash(value: Any) str
-

Generate hash value for the given payload.

-
- -
-
-async pyninja.monitor.secure.base64_encode(value: Any) str
-

Base64 encode the given payload.

-
- -
-
-async pyninja.monitor.secure.base64_decode(value: Any) str
-

Base64 decode the given payload.

-
- -
-
-async pyninja.monitor.secure.hex_decode(value: Any) str
-

Convert hex value to a string.

-
- -
-
-async pyninja.monitor.secure.hex_encode(value: str)
-

Convert string value to hex.

-
-
@@ -2104,27 +2291,35 @@

Table of Contents

  • Welcome to PyNinja’s documentation!
  • PyNinja - Main
  • -
  • Authenticator
  • -
  • Routes
  • -
  • Monitors
      -
    • Docker
    • -
    • GPU
    • -
    • Process
    • -
    • Service
    • +
    • PyNinja - Executors
    • -
    • Operations
    • -
    • Database
    • -
    • RateLimiter
    • -
    • Exceptions
    • +
    • PyNinja - Features +
    • +
    • PyNinja - Modules +
    • PyNinja - Monitor
    • Indices and tables
    • diff --git a/docs/objects.inv b/docs/objects.inv index 50d67fc1386576fb6de91f960424adbfbecf5d6c..d47d5d472a50626984cce5acd245c01886a8d893 100644 GIT binary patch delta 1696 zcmV;R24DG~4T27kc7L0}j@vd6hVT0nF52q~O;PlaTaYZ;07+x45#&hFMK`g(nm4n;|}lg-u~>J+c7|06jZ&WuJ%+Z$#6;uRc0biq1b@h;B{xN-b`_t<7rhQUa-K{^o{v*nFoe@D-T1Vd8qxse)J z{LH{P>qr!3go6f50GeLI0W^D2p#3FRD|z5s?t!#rlenrOFbBdqNgcmxyJ7^|-X4HR zakdNKNoGjWN?PG*qYn1tS~IEqLn-655F$jh9n+Re#t(HNrVC1|FMLqbNzp1xp{#fS z$AmS3D+A7#vwu{>YgmBe0}l&e4pw(f(R@_PxRefj38cZZ==z0rt#wx5bOsZ3z8qv7 zGrWNUkOy~A0?KBz2d-1HB#2#S(2bi06IU+5f9{l{Mf@bKWRLb!f|;(_5)RQw0dv?X z%(^kyc9gOoZK0d4qB08 zVJhEhbdKWLc=ZKhs6K$Zx}w?v9!MOs!t|5j;pei7N$wt%$se#{TAA)h5#o5#K6-*Q zhNJ7F*({w)ja&;2LZXdEEyYTs)WLXOX$Bi9C1OIY_5`8jE~u#T3>P%ONG#=9yYIac zT+<;q8Gnzt43Ar`e5g54CrO?(t7oI;7G}?}atgEOI9V0d_dxT)vPy>U(J=Yr1vTAV zH7z>U(^PB-E>o?Y@U>zMa&58yZr$O<@QGc3z3EYrEjR4vN$hTxOXtV=mC8Lyl z6ZQ>g45dW154LSV64jmI2d*^VY9JFHjD5T^7&knH?JI2_FHfBX@Z$OrDhCp)cM%vI z1+-DXQhU{9KyXjpl|eI2-B*tKOYnTkFH7M% ztWBnVR0(hRneD9)%aCI3DotI`|DUjL$PC=o@y-M{x0T6tr}HqtoS$GAghw7`stYNa*rkg6?pCir)Y2Q zF;c#p0%e|6X6aBPIQZOw52e$*L=Cl8iW~w-_i3a(!A#cnqEv+w3AfXkQz@|4kOHj%jxTbE*3A13m@hy~Ia({fyDw$VY zoQ9(cJrjF~PyHxOwxMr}g|g$W&(mMl|Cx=tllYXD(gLn@=BEMZJ}T>83o~Jt^@h`> zu!;?m-+pBhrU-kz{VoY$$OOT)=ybHlp8Gusv4>;H8lpUJ0Ye912_65_ac7I%H3>{ym94f8`1B25FYadjJp~lvFR$u)o%-GH;2MrNB zF72#AL}r0gyPj!Vt4z)*E@ygC5@Heq?r2LG2{Dwyu~pYc(j<4_ZRZ4d!sKV|{3>+| z_@@cPDG*;YewyQZAE03vjGYo>Qp4LtW;D*`!rB>}+}Hjuh1GD%Fn>zQ)~f8?Nr>T4 z6eI9M8Dr|-7C|0i>*JnYJD2;rS8v|mt$dI#(HB;?FIMTB;fmF||1%D9gF$xC4cBSD z1s$)PzD?J@jUR7LmyNiyD?Wk7;tE#5PT+t4{>QKI!Y=-wo#7pgA8v5VpBSs{Z>Jv; q?0xcc7K}9j@vd6$M5?TF52q~-J<9rw;)-x0g}epMUW#wi({Kzie&iV zwR7rg^!55A9g>nPXBS-!m76T{_vhDeh8)VCwA6p`hR3j9+0(1eh^S!o^Ga#~$7UZo z^<#N={nP6D%1(+mx9g8@{z%X^>NZHDS2t7aN%^gD8z}^60)MmTS}0)YnSpc05m>2P z2Oa1D6iUGX6uTi4zsw^94}8Nt5C(fdnjHk@pfyg=>S}DP1abV#0cfmgAHd14AShiN zq1;KX6l;wRTxxKhTJID&h%KaE6-K z>vwnHEk0&59e@9sQ)6=nLZZEd+mRwm+=KV{a67Db8vRM%M{A7>AU@vHamS?xW<15+ z>}({AG?s3d;Oz%01SVr5*8rrjd+=t{^7mc z5GpJ{b2dF5f|HvVU^Y8iAsw9<SfKC#r&@Ztd8y*j6wr}vYWb}*9Rqz}TS;0fX9aY0OB$d|j>f%J z)hKlQn12*Bv}1s-k}+Ba03Mu^8Dp>At z18}+2$aZF(X>mxQdV+fa9Mc8n>QY=$vXj+=kq!W;0Y_+KSYRM%7YEtGlFsxJ#1Z{{ z{fQJLOZkTJO^fFTt7>Yiim*Le5ny{V|3cr=VSlIrfi4o1@Qak_e(pkGK?|z(3Tu8+ zhKu=g-2)AdS%-Vds@j?$J1~*Bz}Ca+CfVkcsQfeK5z;H&274n5NQ!6D7-^@!xy z>EKHQA8M;bFM@VWwaWYAdPtLXW~!!Yf>%t`gsz&Vp1&V+7om`NI%jQO1`v?m3nLHNN0&1{(Mg! z=n<)nvuA-;Nzj1}`Rf`9sSjLH2l|YEhq(Jxj2?Qw)u?Gl>V$%$3@6s^A>|?|Nt2x3 z!400{?lhOn$A-LCa293DLrJ;K&b>Utmw!`x8yIfhMS9DXU(lRp%ki)&*thGsR&ECx z^1i$^=0U;|sgkNBCb-4h4L~=U7MUHtF^$%?TO)mTM~87i-%}M1w@Ym+|_lV zS4issj#g5afdg-%>yJ3Z#*b{dez1{Qz@Iu)HlgHd^L<3V!thIU{K*IC7@ne?Y=5hj zI&Qy9i~81Fj5a|BH~V!nl))yiG6q^$BgwNY;nl~LoUinv451O+{*orO2=E{7pstN{3bfXfc7>)=7%bP!!RNaLEQEuihGpRFMe1^^mh_ZQn;h6M1hzAupD;rG?QN1t5;5v6W z3NU;rk?wWs$a7OkXxiVT>>J~UT@@UIRPrkiv$uE?KHp+35-6J(>SrBK6@MrnxICo^ zo2aKS>EoCQE-m9ixPIxA&<;A|PK!pqYUw}0anCbca*^=CQC8Hx2d=`Ngt(~LB(wc8 z*Ef&gH+rJFa|7Rh=tP5jFxCRCZ%x$vfam$)Qws|Cpv~hL0d>Y8#f9kv$AF{zos0KK7e~M<8*iX`t66?l@H<-y64sP&8ob~C06UxpGo)% z$2)Vm94-M+spRmslzo>Tug=AKxk-u7pl~o?70e*~@8AFU6&8%?TQ%G4mw&iI8-J!Q ud%7O}C}JPV@+h@V{(S*kpKt@DFKG|lwfjr3yerIo`G1WO^Xfm@_d#Qi2NyyB diff --git a/docs/py-modindex.html b/docs/py-modindex.html index 380ed31..e9ecf3e 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -61,92 +61,102 @@

      Python Module Index

          - pyninja.auth + pyninja.executors.auth     - pyninja.database + pyninja.executors.database     - pyninja.dockerized + pyninja.executors.routes     - pyninja.exceptions + pyninja.executors.squire     - pyninja.gpu + pyninja.features.cpu     - pyninja.main + pyninja.features.disks     - pyninja.models + pyninja.features.dockerized     - pyninja.monitor.authenticator + pyninja.features.gpu     - pyninja.monitor.config + pyninja.features.operations     - pyninja.monitor.resources + pyninja.features.process     - pyninja.monitor.routes + pyninja.features.service + + + +     + pyninja.main     - pyninja.monitor.secure + pyninja.modules.exceptions     - pyninja.operations + pyninja.modules.models     - pyninja.process + pyninja.modules.rate_limit     - pyninja.rate_limit + pyninja.modules.secure     - pyninja.routes + pyninja.monitor.authenticator     - pyninja.service + pyninja.monitor.config     - pyninja.squire + pyninja.monitor.resources + + + +     + pyninja.monitor.routes diff --git a/docs/searchindex.js b/docs/searchindex.js index 152df98..a10bd11 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyNinja", "Welcome to PyNinja\u2019s documentation!"], "terms": {"lightweight": 0, "o": [0, 1], "agnost": 0, "servic": 0, "monitor": 0, "api": [0, 1], "platform": 0, "support": [0, 1], "deploy": 0, "recommend": 0, "instal": [0, 1], "python": 0, "3": [0, 1], "10": [0, 1], "11": [0, 1], "us": [0, 1], "dedic": [0, 1], "virtual": [0, 1], "m": 0, "pip": 0, "initi": 0, "id": [0, 1], "import": 0, "__name__": 0, "__main__": 0, "start": [0, 1], "cli": 0, "help": 0, "usag": [0, 1], "instruct": 0, "sourc": 0, "from": [0, 1], "an": [0, 1], "env": [0, 1], "file": [0, 1], "By": 0, "default": [0, 1], "look": 0, "current": [0, 1], "work": [0, 1], "directori": 0, "apikei": [0, 1], "kei": [0, 1], "authent": 0, "ninja": 0, "_": 0, "host": [0, 1], "hostnam": [0, 1], "server": [0, 1], "port": [0, 1], "number": [0, 1], "remot": [0, 1], "execut": [0, 1], "boolean": [0, 1], "flag": [0, 1], "enabl": [0, 1], "secret": [0, 1], "access": [0, 1], "run": [0, 1], "command": [0, 1], "usernam": [0, 1], "page": [0, 1], "password": [0, 1], "session": [0, 1], "timeout": [0, 1], "max": [0, 1], "connect": [0, 1], "maximum": [0, 1], "allow": [0, 1], "parallel": 0, "process": 0, "list": [0, 1], "name": [0, 1], "includ": [0, 1], "gpu": 0, "lib": 0, "librari": [0, 1], "filepath": [0, 1], "disk": [0, 1], "memori": [0, 1], "processor": [0, 1], "databas": 0, "store": [0, 1], "auth": [0, 1], "handl": [0, 1], "error": [0, 1], "rate": [0, 1], "limit": [0, 1], "dictionari": [0, 1], "max_request": [0, 1], "second": [0, 1], "appli": [0, 1], "log": [0, 1], "config": [0, 1], "configur": 0, "path": [0, 1], "can": [0, 1], "extrem": 0, "riski": 0, "major": 0, "secur": 0, "threat": 0, "so": [0, 1], "caution": 0, "set": [0, 1], "strong": [0, 1], "valu": [0, 1], "refer": [0, 1], "sampl": 0, "exampl": [0, 1], "docstr": 0, "format": [0, 1], "googl": 0, "style": 0, "convent": 0, "pep": 0, "8": 0, "isort": 0, "requir": [0, 1], "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": [0, 1], "pre": 0, "commit": 0, "ensur": 0, "pytest": 0, "gener": [0, 1], "valid": [0, 1], "hyperlink": 0, "all": [0, 1], "markdown": 0, "wiki": 0, "sphinx": 0, "5": [0, 1], "1": [0, 1], "recommonmark": 0, "http": [0, 1], "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "kick": 1, "off": 1, "environ": 1, "variabl": 1, "code": 1, "standard": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "get_desc": 1, "remote_flag": 1, "bool": 1, "monitor_flag": 1, "str": 1, "construct": 1, "detail": 1, "descript": 1, "doc": 1, "paramet": 1, "state": 1, "return": 1, "string": 1, "type": 1, "async": 1, "redirect_exception_handl": 1, "request": 1, "redirectexcept": 1, "jsonrespons": 1, "custom": 1, "handler": 1, "redirect": 1, "take": 1, "object": 1, "argument": 1, "inherit": 1, "statu": 1, "cooki": 1, "kwarg": 1, "none": 1, "starter": 1, "function": 1, "which": 1, "uvicorn": 1, "trigger": 1, "keyword": 1, "env_fil": 1, "load": 1, "ninja_host": 1, "ninja_port": 1, "remote_execut": 1, "api_secret": 1, "monitor_usernam": 1, "monitor_password": 1, "monitor_sess": 1, "service_manag": 1, "manag": 1, "rate_limit": 1, "log_config": 1, "dict": 1, "yaml": 1, "yml": 1, "json": 1, "ini": 1, "epoch": 1, "forbidden": 1, "i": 1, "part": 1, "fastapi": 1, "rais": 1, "apirespons": 1, "403": 1, "If": 1, "address": 1, "level_1": 1, "httpauthorizationcredenti": 1, "httpbearer": 1, "author": 1, "header": 1, "token": 1, "basic": 1, "401": 1, "invalid": 1, "level_2": 1, "addition": 1, "addit": 1, "critic": 1, "increment": 1, "attempt": 1, "int": 1, "block": 1, "time": 1, "base": 1, "fail": 1, "login": 1, "appropri": 1, "minut": 1, "handle_auth_error": 1, "filebrows": 1, "The": 1, "incom": 1, "get_ip_address": 1, "public": 1, "fals": 1, "depend": 1, "get": 1, "local": 1, "ip": 1, "devic": 1, "arg": 1, "httpstatu": 1, "privat": 1, "respons": 1, "get_cpu_util": 1, "interv": 1, "float": 1, "2": 1, "per_cpu": 1, "true": 1, "cpu": 1, "util": 1, "each": 1, "get_memory_util": 1, "get_cpu_load_avg": 1, "system": 1, "queue": 1, "averag": 1, "over": 1, "last": 1, "15": 1, "respect": 1, "get_disk_util": 1, "get_all_disk": 1, "attach": 1, "run_command": 1, "payload": 1, "option": 1, "machin": 1, "receiv": 1, "bodi": 1, "get_process_statu": 1, "process_nam": 1, "cpu_interv": 1, "union": 1, "check": 1, "get_service_statu": 1, "service_nam": 1, "get_docker_contain": 1, "container_nam": 1, "get_al": 1, "get_run": 1, "contain": 1, "inform": 1, "get_docker_imag": 1, "imag": 1, "get_docker_volum": 1, "volum": 1, "get_docker_stat": 1, "stat": 1, "get_processor_nam": 1, "redirectrespons": 1, "user": 1, "health": 1, "200": 1, "get_all_rout": 1, "apirout": 1, "ad": 1, "get_container_statu": 1, "get_running_contain": 1, "yield": 1, "correspond": 1, "metric": 1, "get_all_contain": 1, "get_all_imag": 1, "get_all_volum": 1, "_darwin": 1, "lib_path": 1, "vendor": 1, "linux": 1, "_linux": 1, "_window": 1, "window": 1, "get_nam": 1, "perform": 1, "report": 1, "given": 1, "get_perform": 1, "thread": 1, "open": 1, "pair": 1, "servicestatu": 1, "stop": 1, "501": 1, "unknown": 1, "503": 1, "unavail": 1, "404": 1, "instanc": 1, "get_process_info": 1, "proc": 1, "psutil": 1, "statist": 1, "process_monitor": 1, "executor": 1, "threadpoolexecutor": 1, "case": 1, "sensit": 1, "maco": 1, "top": 1, "grep": 1, "task": 1, "service_monitor": 1, "ar": 1, "follow": 1, "right": 1, "launchctl": 1, "systemctl": 1, "show": 1, "properti": 1, "mainpid": 1, "sc": 1, "queri": 1, "get_service_pid": 1, "retriev": 1, "pid": 1, "get_service_pid_linux": 1, "get_service_pid_maco": 1, "get_service_pid_window": 1, "get_record": 1, "particular": 1, "until": 1, "when": 1, "should": 1, "put_record": 1, "block_until": 1, "insert": 1, "remove_record": 1, "delet": 1, "record": 1, "relat": 1, "class": 1, "rp": 1, "implement": 1, "init": 1, "call": 1, "exce": 1, "identifi": 1, "429": 1, "too": 1, "mani": 1, "status_cod": 1, "ani": 1, "httpexcept": 1, "wrap": 1, "unsupportedo": 1, "unsupport": 1, "locat": 1, "within": 1, "sinc": 1, "doesn": 1, "html": 1, "demand": 1, "where": 1, "solut": 1, "There": 1, "altern": 1, "our": 1, "javascript": 1, "thi": 1, "wai": 1, "come": 1, "handi": 1, "unexpect": 1, "scenario": 1, "tiangolo": 1, "com": 1, "tutori": 1, "sessionerror": 1, "raise_os_error": 1, "operating_system": 1, "noreturn": 1, "validationerror": 1, "overridden": 1, "pydant": 1, "basemodel": 1, "input": 1, "data": 1, "disklib": 1, "darwin": 1, "servicelib": 1, "processorlib": 1, "auth_count": 1, "forbid": 1, "info": 1, "allowed_origin": 1, "envconfig": 1, "max_connect": 1, "gpu_lib": 1, "disk_lib": 1, "service_lib": 1, "processor_lib": 1, "classmethod": 1, "parse_api_secret": 1, "pars": 1, "complex": 1, "from_env_fil": 1, "creat": 1, "extra": 1, "ignor": 1, "hide_input_in_error": 1, "complexity_check": 1, "verifi": 1, "strength": 1, "A": 1, "consid": 1, "least": 1, "ha": 1, "32": 1, "charact": 1, "digit": 1, "symbol": 1, "uppercas": 1, "letter": 1, "lowercas": 1, "assertionerror": 1, "abov": 1, "condit": 1, "match": 1, "gpulib": 1, "usr": 1, "bin": 1, "lspci": 1, "sbin": 1, "system_profil": 1, "c": 1, "system32": 1, "wbem": 1, "wmic": 1, "ex": 1, "_abc_impl": 1, "_abc": 1, "_abc_data": 1, "model_computed_field": 1, "classvar": 1, "computedfieldinfo": 1, "comput": 1, "field": 1, "model_config": 1, "configdict": 1, "conform": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "metadata": 1, "pathtyp": 1, "path_typ": 1, "about": 1, "defin": 1, "map": 1, "replac": 1, "__fields__": 1, "v1": 1, "wssession": 1, "client_auth": 1, "websocket": 1, "get_librari": 1, "referenc": 1, "datastor": 1, "sqlite3": 1, "create_t": 1, "table_nam": 1, "column": 1, "tupl": 1, "public_ip_address": 1, "differ": 1, "endpoint": 1, "private_ip_address": 1, "simpl": 1, "network": 1, "see": 1, "format_no": 1, "input_": 1, "remov": 1, "0": 1, "integ": 1, "end": 1, "found": 1, "els": 1, "format_timedelta": 1, "td": 1, "timedelta": 1, "convert": 1, "human": 1, "readabl": 1, "non": 1, "zero": 1, "alwai": 1, "output": 1, "two": 1, "dai": 1, "hour": 1, "23": 1, "size_convert": 1, "byte_s": 1, "consum": 1, "friendli": 1, "byte": 1, "size": 1, "understand": 1, "process_command": 1, "result": 1, "stdout": 1, "stderr": 1, "envfile_load": 1, "filenam": 1, "pathlik": 1, "filetyp": 1, "var": 1, "have": 1, "load_env": 1, "merg": 1, "give": 1, "prioriti": 1, "partial": 1, "through": 1, "keygen": 1, "modul": 1, "forc": 1, "restart": 1, "url": 1, "safe": 1, "64": 1, "bit": 1, "dynamic_numb": 1, "dynam": 1, "failed_auth_count": 1, "keep": 1, "track": 1, "more": 1, "raise_error": 1, "unauthor": 1, "bad": 1, "credenti": 1, "extract_credenti": 1, "extract": 1, "decod": 1, "befor": 1, "verify_login": 1, "generate_cooki": 1, "auth_payload": 1, "timestamp": 1, "session_error": 1, "htmlrespons": 1, "render": 1, "messag": 1, "templat": 1, "jinja2": 1, "validate_sess": 1, "cookie_str": 1, "summari": 1, "clear_sess": 1, "clear": 1, "get_expiri": 1, "lease_start": 1, "lease_dur": 1, "expiri": 1, "datetim": 1, "ag": 1, "wa": 1, "made": 1, "date": 1, "gmt": 1, "map_docker_stat": 1, "json_data": 1, "get_cpu_perc": 1, "percentag": 1, "asynchron": 1, "get_system_metr": 1, "swap": 1, "nest": 1, "system_resourc": 1, "gather": 1, "error_endpoint": 1, "logout_endpoint": 1, "out": 1, "login_endpoint": 1, "session_token": 1, "redirect_url": 1, "monitor_endpoint": 1, "ui": 1, "after": 1, "websocket_endpoint": 1, "fetch": 1, "live": 1, "calculate_hash": 1, "hash": 1, "base64_encod": 1, "base64": 1, "encod": 1, "base64_decod": 1, "hex_decod": 1, "hex": 1, "hex_encod": 1, "index": 1, "search": 1}, "objects": {"pyninja": [[1, 0, 0, "-", "auth"], [1, 0, 0, "-", "database"], [1, 0, 0, "-", "dockerized"], [1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "gpu"], [1, 0, 0, "-", "main"], [1, 0, 0, "-", "models"], [1, 0, 0, "-", "operations"], [1, 0, 0, "-", "process"], [1, 0, 0, "-", "rate_limit"], [1, 0, 0, "-", "routes"], [1, 0, 0, "-", "service"], [1, 0, 0, "-", "squire"]], "pyninja.auth": [[1, 1, 1, "", "EPOCH"], [1, 1, 1, "", "forbidden"], [1, 1, 1, "", "handle_auth_error"], [1, 1, 1, "", "incrementer"], [1, 1, 1, "", "level_1"], [1, 1, 1, "", "level_2"]], "pyninja.database": [[1, 1, 1, "", "get_record"], [1, 1, 1, "", "put_record"], [1, 1, 1, "", "remove_record"]], "pyninja.dockerized": [[1, 1, 1, "", "get_all_containers"], [1, 1, 1, "", "get_all_images"], [1, 1, 1, "", "get_all_volumes"], [1, 1, 1, "", "get_container_status"], [1, 1, 1, "", "get_running_containers"]], "pyninja.exceptions": [[1, 2, 1, "", "APIResponse"], [1, 2, 1, "", "RedirectException"], [1, 2, 1, "", "SessionError"], [1, 2, 1, "", "UnSupportedOS"], [1, 1, 1, "", "raise_os_error"]], "pyninja.gpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_names"]], "pyninja.main": [[1, 1, 1, "", "get_desc"], [1, 1, 1, "", "redirect_exception_handler"], [1, 1, 1, "", "start"]], "pyninja.models": [[1, 3, 1, "", "Database"], [1, 3, 1, "", "DiskLib"], [1, 3, 1, "", "EnvConfig"], [1, 3, 1, "", "GPULib"], [1, 3, 1, "", "Payload"], [1, 3, 1, "", "ProcessorLib"], [1, 3, 1, "", "RateLimit"], [1, 3, 1, "", "ServiceLib"], [1, 3, 1, "", "ServiceStatus"], [1, 3, 1, "", "Session"], [1, 3, 1, "", "WSSession"], [1, 1, 1, "", "complexity_checker"], [1, 1, 1, "", "get_library"]], "pyninja.models.Database": [[1, 4, 1, "", "create_table"]], "pyninja.models.DiskLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.models.EnvConfig": [[1, 3, 1, "", "Config"], [1, 5, 1, "", "api_secret"], [1, 5, 1, "", "apikey"], [1, 5, 1, "", "database"], [1, 5, 1, "", "disk_lib"], [1, 4, 1, "", "from_env_file"], [1, 5, 1, "", "gpu_lib"], [1, 5, 1, "", "log_config"], [1, 5, 1, "", "max_connections"], [1, 5, 1, "", "monitor_password"], [1, 5, 1, "", "monitor_session"], [1, 5, 1, "", "monitor_username"], [1, 5, 1, "", "ninja_host"], [1, 5, 1, "", "ninja_port"], [1, 4, 1, "", "parse_api_secret"], [1, 5, 1, "", "processes"], [1, 5, 1, "", "processor_lib"], [1, 5, 1, "", "rate_limit"], [1, 5, 1, "", "remote_execution"], [1, 5, 1, "", "service_lib"], [1, 5, 1, "", "services"]], "pyninja.models.EnvConfig.Config": [[1, 5, 1, "", "extra"], [1, 5, 1, "", "hide_input_in_errors"]], "pyninja.models.GPULib": [[1, 5, 1, "", "_abc_impl"], [1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "model_computed_fields"], [1, 5, 1, "", "model_config"], [1, 5, 1, "", "model_fields"], [1, 5, 1, "", "windows"]], "pyninja.models.Payload": [[1, 5, 1, "", "command"], [1, 5, 1, "", "timeout"]], "pyninja.models.ProcessorLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.models.RateLimit": [[1, 5, 1, "", "max_requests"], [1, 5, 1, "", "seconds"]], "pyninja.models.ServiceLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.models.ServiceStatus": [[1, 5, 1, "", "description"], [1, 5, 1, "", "status_code"]], "pyninja.models.Session": [[1, 5, 1, "", "allowed_origins"], [1, 5, 1, "", "auth_counter"], [1, 5, 1, "", "forbid"], [1, 5, 1, "", "info"], [1, 5, 1, "", "rps"]], "pyninja.models.WSSession": [[1, 5, 1, "", "_abc_impl"], [1, 5, 1, "", "client_auth"], [1, 5, 1, "", "invalid"], [1, 5, 1, "", "model_computed_fields"], [1, 5, 1, "", "model_config"], [1, 5, 1, "", "model_fields"]], "pyninja.monitor": [[1, 0, 0, "-", "authenticator"], [1, 0, 0, "-", "config"], [1, 0, 0, "-", "resources"], [1, 0, 0, "-", "routes"], [1, 0, 0, "-", "secure"]], "pyninja.monitor.authenticator": [[1, 1, 1, "", "extract_credentials"], [1, 1, 1, "", "failed_auth_counter"], [1, 1, 1, "", "generate_cookie"], [1, 1, 1, "", "raise_error"], [1, 1, 1, "", "session_error"], [1, 1, 1, "", "validate_session"], [1, 1, 1, "", "verify_login"]], "pyninja.monitor.config": [[1, 1, 1, "", "clear_session"], [1, 1, 1, "", "get_expiry"]], "pyninja.monitor.resources": [[1, 1, 1, "", "get_cpu_percent"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_system_metrics"], [1, 1, 1, "", "map_docker_stats"], [1, 1, 1, "", "system_resources"]], "pyninja.monitor.routes": [[1, 1, 1, "", "error_endpoint"], [1, 1, 1, "", "login_endpoint"], [1, 1, 1, "", "logout_endpoint"], [1, 1, 1, "", "monitor_endpoint"], [1, 1, 1, "", "websocket_endpoint"]], "pyninja.monitor.secure": [[1, 1, 1, "", "base64_decode"], [1, 1, 1, "", "base64_encode"], [1, 1, 1, "", "calculate_hash"], [1, 1, 1, "", "hex_decode"], [1, 1, 1, "", "hex_encode"]], "pyninja.operations": [[1, 1, 1, "", "default"], [1, 1, 1, "", "get_process_info"], [1, 1, 1, "", "get_service_pid"], [1, 1, 1, "", "get_service_pid_linux"], [1, 1, 1, "", "get_service_pid_macos"], [1, 1, 1, "", "get_service_pid_windows"], [1, 1, 1, "", "process_monitor"], [1, 1, 1, "", "service_monitor"]], "pyninja.process": [[1, 1, 1, "", "get_performance"], [1, 1, 1, "", "get_process_status"]], "pyninja.rate_limit": [[1, 3, 1, "", "RateLimiter"]], "pyninja.rate_limit.RateLimiter": [[1, 4, 1, "", "init"]], "pyninja.routes": [[1, 1, 1, "", "docs"], [1, 1, 1, "", "get_all_disks"], [1, 1, 1, "", "get_all_routes"], [1, 1, 1, "", "get_cpu_load_avg"], [1, 1, 1, "", "get_cpu_utilization"], [1, 1, 1, "", "get_disk_utilization"], [1, 1, 1, "", "get_docker_containers"], [1, 1, 1, "", "get_docker_images"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_docker_volumes"], [1, 1, 1, "", "get_ip_address"], [1, 1, 1, "", "get_memory_utilization"], [1, 1, 1, "", "get_process_status"], [1, 1, 1, "", "get_processor_name"], [1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "health"], [1, 1, 1, "", "run_command"]], "pyninja.service": [[1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "running"], [1, 1, 1, "", "stopped"], [1, 1, 1, "", "unavailable"], [1, 1, 1, "", "unknown"]], "pyninja.squire": [[1, 1, 1, "", "dynamic_numbers"], [1, 1, 1, "", "envfile_loader"], [1, 1, 1, "", "format_nos"], [1, 1, 1, "", "format_timedelta"], [1, 1, 1, "", "keygen"], [1, 1, 1, "", "load_env"], [1, 1, 1, "", "private_ip_address"], [1, 1, 1, "", "process_command"], [1, 1, 1, "", "public_ip_address"], [1, 1, 1, "", "size_converter"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:exception", "3": "py:class", "4": "py:method", "5": "py:attribute"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "exception", "Python exception"], "3": ["py", "class", "Python class"], "4": ["py", "method", "Python method"], "5": ["py", "attribute", "Python attribute"]}, "titleterms": {"pyninja": [0, 1], "kick": 0, "off": 0, "environ": 0, "variabl": 0, "code": 0, "standard": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "content": 1, "main": 1, "authent": 1, "rout": 1, "monitor": 1, "docker": 1, "gpu": 1, "process": 1, "servic": 1, "oper": 1, "databas": 1, "ratelimit": 1, "except": 1, "model": 1, "squir": 1, "configur": 1, "resourc": 1, "secur": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file +Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyNinja", "Welcome to PyNinja\u2019s documentation!"], "terms": {"lightweight": 0, "o": [0, 1], "agnost": [0, 1], "servic": 0, "monitor": 0, "api": 0, "platform": 0, "support": [0, 1], "deploy": 0, "recommend": 0, "instal": [0, 1], "python": 0, "3": [0, 1], "10": [0, 1], "11": [0, 1], "us": [0, 1], "dedic": [0, 1], "virtual": [0, 1], "m": 0, "pip": 0, "initi": 0, "id": [0, 1], "import": 0, "__name__": 0, "__main__": 0, "start": [0, 1], "cli": 0, "help": 0, "usag": [0, 1], "instruct": 0, "sourc": 0, "from": [0, 1], "an": [0, 1], "env": [0, 1], "file": [0, 1], "By": 0, "default": [0, 1], "look": 0, "current": [0, 1], "work": [0, 1], "directori": 0, "apikei": [0, 1], "kei": [0, 1], "authent": 0, "ninja": 0, "_": 0, "host": [0, 1], "hostnam": [0, 1], "server": [0, 1], "port": [0, 1], "number": [0, 1], "remot": [0, 1], "execut": [0, 1], "boolean": [0, 1], "flag": [0, 1], "enabl": [0, 1], "secret": [0, 1], "access": [0, 1], "run": [0, 1], "command": [0, 1], "usernam": [0, 1], "page": [0, 1], "password": [0, 1], "session": [0, 1], "timeout": [0, 1], "max": [0, 1], "connect": [0, 1], "maximum": [0, 1], "allow": [0, 1], "parallel": 0, "process": 0, "list": [0, 1], "name": [0, 1], "includ": [0, 1], "gpu": 0, "lib": 0, "librari": [0, 1], "filepath": [0, 1], "disk": 0, "memori": [0, 1], "processor": [0, 1], "databas": 0, "store": [0, 1], "auth": [0, 1], "handl": [0, 1], "error": [0, 1], "rate": [0, 1], "limit": [0, 1], "dictionari": [0, 1], "max_request": [0, 1], "second": [0, 1], "appli": [0, 1], "log": [0, 1], "config": [0, 1], "configur": 0, "path": [0, 1], "can": [0, 1], "extrem": 0, "riski": 0, "major": 0, "secur": 0, "threat": 0, "so": [0, 1], "caution": 0, "set": [0, 1], "strong": [0, 1], "valu": [0, 1], "refer": [0, 1], "sampl": 0, "exampl": [0, 1], "docstr": 0, "format": [0, 1], "googl": 0, "style": 0, "convent": 0, "pep": 0, "8": 0, "isort": 0, "requir": [0, 1], "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": [0, 1], "pre": 0, "commit": 0, "ensur": 0, "pytest": 0, "gener": [0, 1], "valid": [0, 1], "hyperlink": 0, "all": [0, 1], "markdown": 0, "wiki": 0, "sphinx": 0, "5": [0, 1], "1": [0, 1], "recommonmark": 0, "http": [0, 1], "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "kick": 1, "off": 1, "environ": 1, "variabl": 1, "code": 1, "standard": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "get_desc": 1, "remote_flag": 1, "bool": 1, "monitor_flag": 1, "str": 1, "construct": 1, "detail": 1, "descript": 1, "doc": 1, "paramet": 1, "state": 1, "return": 1, "string": 1, "type": 1, "async": 1, "redirect_exception_handl": 1, "request": 1, "redirectexcept": 1, "jsonrespons": 1, "custom": 1, "handler": 1, "redirect": 1, "take": 1, "object": 1, "argument": 1, "inherit": 1, "statu": 1, "cooki": 1, "kwarg": 1, "none": 1, "starter": 1, "function": 1, "which": 1, "uvicorn": 1, "trigger": 1, "keyword": 1, "env_fil": 1, "load": 1, "ninja_host": 1, "ninja_port": 1, "remote_execut": 1, "api_secret": 1, "monitor_usernam": 1, "monitor_password": 1, "monitor_sess": 1, "service_manag": 1, "manag": 1, "rate_limit": 1, "log_config": 1, "dict": 1, "yaml": 1, "yml": 1, "json": 1, "ini": 1, "epoch": 1, "forbidden": 1, "i": 1, "part": 1, "fastapi": 1, "rais": 1, "apirespons": 1, "403": 1, "If": 1, "address": 1, "level_1": 1, "httpauthorizationcredenti": 1, "httpbearer": 1, "author": 1, "header": 1, "token": 1, "basic": 1, "401": 1, "invalid": 1, "level_2": 1, "addition": 1, "addit": 1, "critic": 1, "increment": 1, "attempt": 1, "int": 1, "block": 1, "time": 1, "base": 1, "fail": 1, "login": 1, "appropri": 1, "minut": 1, "handle_auth_error": 1, "filebrows": 1, "The": 1, "incom": 1, "get_record": 1, "get": 1, "particular": 1, "until": 1, "when": 1, "should": 1, "put_record": 1, "block_until": 1, "insert": 1, "remove_record": 1, "delet": 1, "record": 1, "relat": 1, "get_ip_address": 1, "public": 1, "fals": 1, "depend": 1, "local": 1, "ip": 1, "devic": 1, "arg": 1, "httpstatu": 1, "privat": 1, "respons": 1, "get_cpu_util": 1, "interv": 1, "float": 1, "2": 1, "per_cpu": 1, "true": 1, "util": 1, "each": 1, "get_memory_util": 1, "get_cpu_load_avg": 1, "system": 1, "queue": 1, "averag": 1, "over": 1, "last": 1, "15": 1, "respect": 1, "get_disk_util": 1, "get_all_disk": 1, "attach": 1, "run_command": 1, "payload": 1, "option": 1, "machin": 1, "receiv": 1, "bodi": 1, "get_process_statu": 1, "process_nam": 1, "cpu_interv": 1, "union": 1, "check": 1, "get_service_statu": 1, "service_nam": 1, "get_docker_contain": 1, "container_nam": 1, "get_al": 1, "get_run": 1, "contain": 1, "inform": 1, "get_docker_imag": 1, "imag": 1, "get_docker_volum": 1, "volum": 1, "get_docker_stat": 1, "stat": 1, "get_processor_nam": 1, "redirectrespons": 1, "user": 1, "health": 1, "200": 1, "get_all_rout": 1, "apirout": 1, "ad": 1, "public_ip_address": 1, "differ": 1, "endpoint": 1, "private_ip_address": 1, "simpl": 1, "network": 1, "see": 1, "format_no": 1, "input_": 1, "remov": 1, "0": 1, "integ": 1, "end": 1, "found": 1, "els": 1, "format_timedelta": 1, "td": 1, "timedelta": 1, "convert": 1, "human": 1, "readabl": 1, "non": 1, "zero": 1, "alwai": 1, "output": 1, "two": 1, "identifi": 1, "dai": 1, "hour": 1, "23": 1, "size_convert": 1, "byte_s": 1, "consum": 1, "friendli": 1, "byte": 1, "size": 1, "understand": 1, "process_command": 1, "result": 1, "stdout": 1, "stderr": 1, "pair": 1, "envfile_load": 1, "filenam": 1, "pathlik": 1, "envconfig": 1, "filetyp": 1, "where": 1, "var": 1, "have": 1, "load_env": 1, "merg": 1, "give": 1, "prioriti": 1, "thi": 1, "partial": 1, "through": 1, "keygen": 1, "ar": 1, "forc": 1, "restart": 1, "url": 1, "safe": 1, "64": 1, "bit": 1, "dynamic_numb": 1, "dynam": 1, "_darwin": 1, "lib_path": 1, "maco": 1, "_linux": 1, "linux": 1, "_window": 1, "window": 1, "get_nam": 1, "get_partitions_for_disk": 1, "device_id": 1, "psutil": 1, "find": 1, "partit": 1, "given": 1, "parse_s": 1, "size_str": 1, "unit": 1, "pars": 1, "distro": 1, "is_physical_disk": 1, "physic": 1, "diskutil": 1, "info": 1, "mount": 1, "_reformat_window": 1, "data": 1, "reformat": 1, "drive": 1, "get_container_statu": 1, "get_running_contain": 1, "yield": 1, "correspond": 1, "metric": 1, "get_all_contain": 1, "get_all_imag": 1, "get_all_volum": 1, "vendor": 1, "get_process_info": 1, "proc": 1, "statist": 1, "process_monitor": 1, "threadpoolexecutor": 1, "case": 1, "sensit": 1, "top": 1, "grep": 1, "task": 1, "service_monitor": 1, "follow": 1, "right": 1, "launchctl": 1, "systemctl": 1, "show": 1, "properti": 1, "mainpid": 1, "sc": 1, "queri": 1, "get_service_pid": 1, "retriev": 1, "pid": 1, "get_service_pid_linux": 1, "get_service_pid_maco": 1, "get_service_pid_window": 1, "perform": 1, "report": 1, "get_perform": 1, "thread": 1, "open": 1, "servicestatu": 1, "stop": 1, "501": 1, "unknown": 1, "503": 1, "unavail": 1, "404": 1, "instanc": 1, "status_cod": 1, "ani": 1, "httpexcept": 1, "wrap": 1, "unsupportedo": 1, "class": 1, "unsupport": 1, "locat": 1, "within": 1, "sinc": 1, "doesn": 1, "html": 1, "demand": 1, "solut": 1, "There": 1, "altern": 1, "our": 1, "javascript": 1, "wai": 1, "come": 1, "handi": 1, "mani": 1, "unexpect": 1, "scenario": 1, "tiangolo": 1, "com": 1, "tutori": 1, "sessionerror": 1, "raise_os_error": 1, "operating_system": 1, "noreturn": 1, "validationerror": 1, "overridden": 1, "pydant": 1, "basemodel": 1, "input": 1, "disklib": 1, "darwin": 1, "servicelib": 1, "processorlib": 1, "auth_count": 1, "forbid": 1, "rp": 1, "allowed_origin": 1, "max_connect": 1, "gpu_lib": 1, "disk_lib": 1, "service_lib": 1, "processor_lib": 1, "classmethod": 1, "parse_api_secret": 1, "complex": 1, "from_env_fil": 1, "creat": 1, "extra": 1, "ignor": 1, "hide_input_in_error": 1, "complexity_check": 1, "verifi": 1, "strength": 1, "A": 1, "consid": 1, "least": 1, "ha": 1, "32": 1, "charact": 1, "digit": 1, "symbol": 1, "uppercas": 1, "letter": 1, "lowercas": 1, "assertionerror": 1, "abov": 1, "condit": 1, "match": 1, "gpulib": 1, "usr": 1, "bin": 1, "lspci": 1, "sbin": 1, "system_profil": 1, "c": 1, "system32": 1, "wbem": 1, "wmic": 1, "ex": 1, "_abc_impl": 1, "_abc": 1, "_abc_data": 1, "model_computed_field": 1, "classvar": 1, "computedfieldinfo": 1, "comput": 1, "field": 1, "model_config": 1, "configdict": 1, "conform": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "metadata": 1, "pathtyp": 1, "path_typ": 1, "about": 1, "defin": 1, "map": 1, "replac": 1, "__fields__": 1, "v1": 1, "wssession": 1, "client_auth": 1, "websocket": 1, "get_librari": 1, "referenc": 1, "datastor": 1, "sqlite3": 1, "create_t": 1, "table_nam": 1, "column": 1, "tupl": 1, "implement": 1, "init": 1, "call": 1, "exce": 1, "429": 1, "too": 1, "calculate_hash": 1, "hash": 1, "base64_encod": 1, "base64": 1, "encod": 1, "base64_decod": 1, "decod": 1, "hex_decod": 1, "hex": 1, "hex_encod": 1, "failed_auth_count": 1, "keep": 1, "track": 1, "more": 1, "raise_error": 1, "unauthor": 1, "bad": 1, "credenti": 1, "extract_credenti": 1, "extract": 1, "befor": 1, "verify_login": 1, "generate_cooki": 1, "auth_payload": 1, "timestamp": 1, "session_error": 1, "htmlrespons": 1, "render": 1, "messag": 1, "templat": 1, "jinja2": 1, "validate_sess": 1, "cookie_str": 1, "summari": 1, "clear_sess": 1, "clear": 1, "get_expiri": 1, "lease_start": 1, "lease_dur": 1, "expiri": 1, "datetim": 1, "ag": 1, "wa": 1, "made": 1, "date": 1, "gmt": 1, "map_docker_stat": 1, "json_data": 1, "get_cpu_perc": 1, "percentag": 1, "asynchron": 1, "get_system_metr": 1, "swap": 1, "nest": 1, "system_resourc": 1, "gather": 1, "error_endpoint": 1, "logout_endpoint": 1, "out": 1, "login_endpoint": 1, "session_token": 1, "redirect_url": 1, "monitor_endpoint": 1, "ui": 1, "after": 1, "websocket_endpoint": 1, "fetch": 1, "live": 1, "index": 1, "search": 1}, "objects": {"pyninja.executors": [[1, 0, 0, "-", "auth"], [1, 0, 0, "-", "database"], [1, 0, 0, "-", "routes"], [1, 0, 0, "-", "squire"]], "pyninja.executors.auth": [[1, 1, 1, "", "EPOCH"], [1, 1, 1, "", "forbidden"], [1, 1, 1, "", "handle_auth_error"], [1, 1, 1, "", "incrementer"], [1, 1, 1, "", "level_1"], [1, 1, 1, "", "level_2"]], "pyninja.executors.database": [[1, 1, 1, "", "get_record"], [1, 1, 1, "", "put_record"], [1, 1, 1, "", "remove_record"]], "pyninja.executors.routes": [[1, 1, 1, "", "docs"], [1, 1, 1, "", "get_all_disks"], [1, 1, 1, "", "get_all_routes"], [1, 1, 1, "", "get_cpu_load_avg"], [1, 1, 1, "", "get_cpu_utilization"], [1, 1, 1, "", "get_disk_utilization"], [1, 1, 1, "", "get_docker_containers"], [1, 1, 1, "", "get_docker_images"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_docker_volumes"], [1, 1, 1, "", "get_ip_address"], [1, 1, 1, "", "get_memory_utilization"], [1, 1, 1, "", "get_process_status"], [1, 1, 1, "", "get_processor_name"], [1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "health"], [1, 1, 1, "", "run_command"]], "pyninja.executors.squire": [[1, 1, 1, "", "dynamic_numbers"], [1, 1, 1, "", "envfile_loader"], [1, 1, 1, "", "format_nos"], [1, 1, 1, "", "format_timedelta"], [1, 1, 1, "", "keygen"], [1, 1, 1, "", "load_env"], [1, 1, 1, "", "private_ip_address"], [1, 1, 1, "", "process_command"], [1, 1, 1, "", "public_ip_address"], [1, 1, 1, "", "size_converter"]], "pyninja.features": [[1, 0, 0, "-", "cpu"], [1, 0, 0, "-", "disks"], [1, 0, 0, "-", "dockerized"], [1, 0, 0, "-", "gpu"], [1, 0, 0, "-", "operations"], [1, 0, 0, "-", "process"], [1, 0, 0, "-", "service"]], "pyninja.features.cpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_name"]], "pyninja.features.disks": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_reformat_windows"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_all_disks"], [1, 1, 1, "", "get_partitions_for_disk"], [1, 1, 1, "", "is_physical_disk"], [1, 1, 1, "", "parse_size"]], "pyninja.features.dockerized": [[1, 1, 1, "", "get_all_containers"], [1, 1, 1, "", "get_all_images"], [1, 1, 1, "", "get_all_volumes"], [1, 1, 1, "", "get_container_status"], [1, 1, 1, "", "get_running_containers"]], "pyninja.features.gpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_names"]], "pyninja.features.operations": [[1, 1, 1, "", "default"], [1, 1, 1, "", "get_process_info"], [1, 1, 1, "", "get_service_pid"], [1, 1, 1, "", "get_service_pid_linux"], [1, 1, 1, "", "get_service_pid_macos"], [1, 1, 1, "", "get_service_pid_windows"], [1, 1, 1, "", "process_monitor"], [1, 1, 1, "", "service_monitor"]], "pyninja.features.process": [[1, 1, 1, "", "get_performance"], [1, 1, 1, "", "get_process_status"]], "pyninja.features.service": [[1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "running"], [1, 1, 1, "", "stopped"], [1, 1, 1, "", "unavailable"], [1, 1, 1, "", "unknown"]], "pyninja": [[1, 0, 0, "-", "main"]], "pyninja.main": [[1, 1, 1, "", "get_desc"], [1, 1, 1, "", "redirect_exception_handler"], [1, 1, 1, "", "start"]], "pyninja.modules": [[1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "models"], [1, 0, 0, "-", "rate_limit"], [1, 0, 0, "-", "secure"]], "pyninja.modules.exceptions": [[1, 2, 1, "", "APIResponse"], [1, 2, 1, "", "RedirectException"], [1, 2, 1, "", "SessionError"], [1, 2, 1, "", "UnSupportedOS"], [1, 1, 1, "", "raise_os_error"]], "pyninja.modules.models": [[1, 3, 1, "", "Database"], [1, 3, 1, "", "DiskLib"], [1, 3, 1, "", "EnvConfig"], [1, 3, 1, "", "GPULib"], [1, 3, 1, "", "Payload"], [1, 3, 1, "", "ProcessorLib"], [1, 3, 1, "", "RateLimit"], [1, 3, 1, "", "ServiceLib"], [1, 3, 1, "", "ServiceStatus"], [1, 3, 1, "", "Session"], [1, 3, 1, "", "WSSession"], [1, 1, 1, "", "complexity_checker"], [1, 1, 1, "", "get_library"]], "pyninja.modules.models.Database": [[1, 4, 1, "", "create_table"]], "pyninja.modules.models.DiskLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.modules.models.EnvConfig": [[1, 3, 1, "", "Config"], [1, 5, 1, "", "api_secret"], [1, 5, 1, "", "apikey"], [1, 5, 1, "", "database"], [1, 5, 1, "", "disk_lib"], [1, 4, 1, "", "from_env_file"], [1, 5, 1, "", "gpu_lib"], [1, 5, 1, "", "log_config"], [1, 5, 1, "", "max_connections"], [1, 5, 1, "", "monitor_password"], [1, 5, 1, "", "monitor_session"], [1, 5, 1, "", "monitor_username"], [1, 5, 1, "", "ninja_host"], [1, 5, 1, "", "ninja_port"], [1, 4, 1, "", "parse_api_secret"], [1, 5, 1, "", "processes"], [1, 5, 1, "", "processor_lib"], [1, 5, 1, "", "rate_limit"], [1, 5, 1, "", "remote_execution"], [1, 5, 1, "", "service_lib"], [1, 5, 1, "", "services"]], "pyninja.modules.models.EnvConfig.Config": [[1, 5, 1, "", "extra"], [1, 5, 1, "", "hide_input_in_errors"]], "pyninja.modules.models.GPULib": [[1, 5, 1, "", "_abc_impl"], [1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "model_computed_fields"], [1, 5, 1, "", "model_config"], [1, 5, 1, "", "model_fields"], [1, 5, 1, "", "windows"]], "pyninja.modules.models.Payload": [[1, 5, 1, "", "command"], [1, 5, 1, "", "timeout"]], "pyninja.modules.models.ProcessorLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.modules.models.RateLimit": [[1, 5, 1, "", "max_requests"], [1, 5, 1, "", "seconds"]], "pyninja.modules.models.ServiceLib": [[1, 5, 1, "", "darwin"], [1, 5, 1, "", "linux"], [1, 5, 1, "", "windows"]], "pyninja.modules.models.ServiceStatus": [[1, 5, 1, "", "description"], [1, 5, 1, "", "status_code"]], "pyninja.modules.models.Session": [[1, 5, 1, "", "allowed_origins"], [1, 5, 1, "", "auth_counter"], [1, 5, 1, "", "forbid"], [1, 5, 1, "", "info"], [1, 5, 1, "", "rps"]], "pyninja.modules.models.WSSession": [[1, 5, 1, "", "_abc_impl"], [1, 5, 1, "", "client_auth"], [1, 5, 1, "", "invalid"], [1, 5, 1, "", "model_computed_fields"], [1, 5, 1, "", "model_config"], [1, 5, 1, "", "model_fields"]], "pyninja.modules.rate_limit": [[1, 3, 1, "", "RateLimiter"]], "pyninja.modules.rate_limit.RateLimiter": [[1, 4, 1, "", "init"]], "pyninja.modules.secure": [[1, 1, 1, "", "base64_decode"], [1, 1, 1, "", "base64_encode"], [1, 1, 1, "", "calculate_hash"], [1, 1, 1, "", "hex_decode"], [1, 1, 1, "", "hex_encode"]], "pyninja.monitor": [[1, 0, 0, "-", "authenticator"], [1, 0, 0, "-", "config"], [1, 0, 0, "-", "resources"], [1, 0, 0, "-", "routes"]], "pyninja.monitor.authenticator": [[1, 1, 1, "", "extract_credentials"], [1, 1, 1, "", "failed_auth_counter"], [1, 1, 1, "", "generate_cookie"], [1, 1, 1, "", "raise_error"], [1, 1, 1, "", "session_error"], [1, 1, 1, "", "validate_session"], [1, 1, 1, "", "verify_login"]], "pyninja.monitor.config": [[1, 1, 1, "", "clear_session"], [1, 1, 1, "", "get_expiry"]], "pyninja.monitor.resources": [[1, 1, 1, "", "get_cpu_percent"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_system_metrics"], [1, 1, 1, "", "map_docker_stats"], [1, 1, 1, "", "system_resources"]], "pyninja.monitor.routes": [[1, 1, 1, "", "error_endpoint"], [1, 1, 1, "", "login_endpoint"], [1, 1, 1, "", "logout_endpoint"], [1, 1, 1, "", "monitor_endpoint"], [1, 1, 1, "", "websocket_endpoint"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:exception", "3": "py:class", "4": "py:method", "5": "py:attribute"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "exception", "Python exception"], "3": ["py", "class", "Python class"], "4": ["py", "method", "Python method"], "5": ["py", "attribute", "Python attribute"]}, "titleterms": {"pyninja": [0, 1], "kick": 0, "off": 0, "environ": 0, "variabl": 0, "code": 0, "standard": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "content": 1, "main": 1, "executor": 1, "api": 1, "authent": 1, "databas": 1, "rout": 1, "squir": 1, "featur": 1, "cpu": 1, "disk": 1, "docker": 1, "gpu": 1, "oper": 1, "process": 1, "servic": 1, "modul": 1, "except": 1, "model": 1, "ratelimit": 1, "secur": 1, "monitor": 1, "configur": 1, "resourc": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file diff --git a/pyninja/executors/routes.py b/pyninja/executors/routes.py index 4c487ed..a3eb13c 100644 --- a/pyninja/executors/routes.py +++ b/pyninja/executors/routes.py @@ -12,7 +12,7 @@ from pydantic import PositiveFloat, PositiveInt from pyninja.executors import auth, squire -from pyninja.features import disks, dockerized, process, processor, service +from pyninja.features import cpu, disks, dockerized, process, service from pyninja.modules import exceptions, models from pyninja.monitor import resources @@ -419,7 +419,7 @@ async def get_processor_name( Raises the HTTPStatus object with a status code and detail as response. """ await auth.level_1(request, apikey) - if processor_info := processor.get_name(): + if processor_info := cpu.get_name(): raise exceptions.APIResponse( status_code=HTTPStatus.OK.real, detail=processor_info ) diff --git a/pyninja/features/processor.py b/pyninja/features/cpu.py similarity index 100% rename from pyninja/features/processor.py rename to pyninja/features/cpu.py diff --git a/pyninja/monitor/routes.py b/pyninja/monitor/routes.py index 9bd996b..8e10e38 100644 --- a/pyninja/monitor/routes.py +++ b/pyninja/monitor/routes.py @@ -14,7 +14,7 @@ from pyninja import monitor, version from pyninja.executors import squire -from pyninja.features import disks, gpu, processor +from pyninja.features import cpu, disks, gpu from pyninja.modules import exceptions, models LOGGER = logging.getLogger("uvicorn.default") @@ -140,7 +140,7 @@ async def monitor_endpoint(request: Request, session_token: str = Cookie(None)): sys_info_basic["GPU"] = ", ".join( [gpu_info.get("model") for gpu_info in gpu_names] ) - if processor_name := processor.get_name(): + if processor_name := cpu.get_name(): LOGGER.info("Processor: %s", processor_name) sys_info_basic["CPU"] = processor_name sys_info_mem_storage = { diff --git a/release_notes.rst b/release_notes.rst index 67f4fda..28fb395 100644 --- a/release_notes.rst +++ b/release_notes.rst @@ -1,62 +1,94 @@ Release Notes ============= +v0.1.1 (09/29/2024) +------------------- +- Include services/processes metrics to monitoring page +- Filter PIDs from docker stats +- Remove overall code redundancies in the UI +- Convert collapsible sections of top level information in tables +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.1.0...v0.1.1 + v0.1.1-dev (09/29/2024) ----------------------- -- Release `v0.1.1-dev` +- Relese `dev` version for `0.1.1` +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.1.0...v0.1.1-dev v0.1.0 (09/29/2024) ------------------- -- Release `v0.1.0` +- Include `docker stats` in monitoring page +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.9...v0.1.0 v0.1.0-alpha (09/16/2024) ------------------------- -- Release `v0.1.0-alpha` +- Alpha version for docker stats +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.9...v0.1.0-alpha v0.0.9 (09/16/2024) ------------------- -- Release `v0.0.9` +- Includes disks information in the monitoring page +- Restructured monitoring page with dedicated div container for each category of system information +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.8...v0.0.9 v0.0.8 (09/10/2024) ------------------- -- Release `v0.0.8` +- Includes an option to get CPU load average via API calls and monitoring page UI +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.7...v0.0.8 v0.0.7 (09/09/2024) ------------------- -- Release `v0.0.7` +- Includes a new feature to monitor disk utilization and get process name +- Bug fix on uncaught errors during server shutdown +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.6...v0.0.7 v0.0.6 (09/09/2024) ------------------- -- Release `v0.0.6` +- Includes an option to limit maximum number of WebSocket sessions +- Includes a logout functionality for the monitoring page +- Uses bearer auth for the monitoring page +- Redefines progress bars with newer color schemes +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.5...v0.0.6 v0.0.6a (09/07/2024) -------------------- -- Release `v0.0.6a` +- Includes an option to limit max number of concurrent sessions for monitoring page +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.5...v0.0.6a v0.0.5 (09/07/2024) ------------------- -- Release `v0.0.5` +- Packs an entirely new UI and authentication mechanism for monitoring tool +- Includes speed, stability and security improvements for monitoring feature +- Adds night mode option for monitoring UI +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.4...v0.0.5 v0.0.4 (09/06/2024) ------------------- -- Include an option to monitor system resources via websockets +- Includes an option to monitor system resources via `WebSockets` +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.3...v0.0.4 v0.0.3 (08/16/2024) ------------------- -- Release `v0.0.3` +- Allows env vars to be sourced from both ``env_file`` and ``kwargs`` +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.2...v0.0.3 v0.0.2 (08/16/2024) ------------------- -- Release `v0.0.2` +- Includes added support for custom log configuration +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.1...v0.0.2 v0.0.1 (08/11/2024) ------------------- -- Release `v0.0.1` +- Includes a process monitor and remote command execution functionality +- Security improvements including brute force protection and rate limiting +- Accepts ``JSON`` and ``YAML`` files for env config +- Supports custom worker count for ``uvicorn`` server +- Allows custom logging using ``logging.ini`` +- Includes an option to set the ``apikey`` via commandline +- **Full Changelog**: https://github.com/thevickypedia/PyNinja/compare/v0.0.0...v0.0.1 v0.0.0 (08/11/2024) ------------------- -- Implement concurrency for validating process health -- Update logger names across the module and README.md +- Release first stable version 0.0.0-a (08/10/2024) --------------------