Metadata-Version: 2.3
Name: monkey-service-kit
Version: 2.5.0
Summary: A collection of functions and objects that help the Monkey team bootstrap, build, and maintain services
License: GPLv3
Author: Mike Salvatore
Author-email: mike.salvatore@akamai.com
Requires-Python: >=3.11, <4.0
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 3.11
Provides-Extra: api
Provides-Extra: psycopg
Requires-Dist: fastapi (>=0.115.6,<1.0.0) ; extra == "api"
Requires-Dist: loguru (>=0.7.3,<1.0)
Requires-Dist: monkey-types (>=1.0.0,<3.0.0)
Requires-Dist: psycopg (>=3.2.4,<4.0.0) ; extra == "psycopg"
Requires-Dist: pydantic-settings (>=2.7.1,<3.0)
Requires-Dist: pygments (>=2.19.1,<3.0.0)
Requires-Dist: python-ulid (>=3.0.0,<4.0.0) ; extra == "api"
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
Requires-Dist: uvicorn (>=0.34.0,<1.0.0) ; extra == "api"
Project-URL: Repository, https://github.com/guardicode/service-kit
Description-Content-Type: text/markdown

<!-- START_GENERAL_DOCS -->
# Service-Kit Documentation

![License](https://img.shields.io/github/license/guardicode/service-kit)


 📌 Service-Kit is a collection of functions and objects designed to help the
Monkey team bootstrap, build, and maintain various services efficiently.

## Features

- **Service Bootstrapping**: Provides templates and utilities to stand up
new services quickly.
- **Common Utilities**: Provides common utilities for logging, configuration,
and error handling.
- **Service Configuration**: Provides a base class for service
configuration that can be easily extended.
- **Testing Support**: Provides utilities for testing services.

### Submodules

- **api**: Provides components for setting up an API with FastAPI
- **base_model**: Provides a Pydantic BaseModel with extra features
- **configuration**: Provides models, types, and utilities for configuring a service
- **errors**: Enables exceptions using structured errors
- **logging**: Provides a logger that enables structured logging


## Getting started

### Installation

You can install Service-Kit using [poetry](https://python-poetry.org/):

```bash
$ poetry add monkey-service-kit
```

or by using pip:

```bash
$ pip install monkey-service-kit
```

#### Extras

Service-Kit contains some functionality that is only available if extras are
installed.

- `service_kit.logging.log_postgres_error()` is only available if Service-Kit
  is installed with the `[psycopg]` extra.
- `service_kit.api` is only available if Serivce-Kit is installed with the
  `[api]` extra.

When installing with Poetry, this looks like:

```bash
$ poetry add monkey-service-kit[api,psycopg]
```

or with pip:

```bash
$ pip install monkey-service-kit[api,psycopg]
```

### Usage

After installation, you can start using Service-Kit like any other Python package.
For a more detailed example and usage patterns, refer to the
`template_service.py` file included in the repository.

<!-- END_GENERAL_DOCS -->
<!-- START_DEV_DOCS -->
## Development

### Setting up your development environment

Run the following commands to install the necessary prerequisites:

```bash
$ pip install poetry pre-commit
$ poetry install --all-extras
$ pre-commit install -t pre-commit -t prepare-commit-msg
```

### Running unit tests

Run automated tests with:

```bash
$ poetry run pytest
```


#### Test coverage

To run automated tests with test coverage, run:

```bash
$ poetry run pytest --cov-report=html --cov=service-kit
$ firefox ./htmlcov/index.html
```

### Sphinx Documentation

The `docs` directory contains the needed file to automatically generate code documentation using Sphinx.

#### Configuration

To change the Sphinx configuration, change the attributes in `source/conf.py`.
The documentation uses `source/_static` to keep the custom media, stylesheets, js scripts etc.
`source/index.rst` is the main rst file in which the look of the index HTML page is defined.

#### Build

The make script generates the documentation using sphinx-build.
The generated documentation is stored in `build/html/`.

##### Linux

1. From `service-kit`, install python dependencies:

```bash
$ poetry install
```

1. Activate the python venv

```bash
$ poetry env activate
```

1. Generate the documentation:

```bash
$ cd docs
$ make html
```


##### Windows

1. From `service-kit`, install python dependencies:

```bash
$ poetry install
```

1. Activate the python venv

```bash
$ poetry env activate
```

1. Generate the documentation:

```bash
$ cd docs
$ make html
```


#### Deployment

To deploy the documentation locally, `build/html/index.html`
<!-- END_DEV_DOCS -->

