README.md 2.45 KB
Newer Older
wuruchi's avatar
wuruchi committed
# Autosubmit API

wuruchi's avatar
wuruchi committed
# Table of Contents

Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
1. [Overview](#overview)
Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
2. [Installation](#installation)
3. [Configuration options](#configuration-options)
4. [How to run tests](#how-to-run-tests)
wuruchi's avatar
wuruchi committed

## Overview

wuruchi's avatar
wuruchi committed
Autosubmit API is a package that consumes the information generated by Autosubmit and serves it as an API.

wuruchi's avatar
wuruchi committed
Distribution: https://pypi.org/project/autosubmit-api/
Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
See the `openapi.json` specification and the repository wiki for more information.
wuruchi's avatar
wuruchi committed

wuruchi's avatar
wuruchi committed

Autosubmit API can be easily installed via pip
wuruchi's avatar
wuruchi committed

```sh
pip install autosubmit-api # >=4.0 (recommended)
wuruchi's avatar
wuruchi committed

Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
# Check installation and serving options
autosubmit_api start -h
```

Start the server:

```sh
autosubmit_api start
```
Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
## Configuration options

The Autosubmit API have some configuration options that can be modified by setting their specific environment variable before starting the server:

Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
- **`PROTECTION_LEVEL`**: Default `ALL`. Possible values `ALL`, `WRITEONLY`, `NONE`.
  - If set to `ALL`, all the endpoints will be protected by needing a valid token inside the `Authorization` header of the request.
  - If set to `WRITEONLY`, only a subset of the endpoints will be protected.
  - If set to `NONE`, none of the endpoints will be protected.
- **`SECRET_KEY`**: The secret key to encode the JWT tokens from the Authorization Module. **Important to be set up on production.**
- **`CAS_SERVER_URL`**: CAS Protocol server base URL to request a ticket and verify it. Used for `/v4` endpoints. `CAS_LOGIN_URL` and `CAS_VERIFY_URL` can be empty if this variable is set (the API will append the protocol URL subpaths).
- **`CAS_LOGIN_URL`**: CAS Protocol URL to request a ticket. Used for `/v3` endpoints.
- **`CAS_VERIFY_URL`**: CAS Protocol URL to verify a given ticket. Used for `/v3` endpoints.
- **`GITHUB_OAUTH_CLIENT_ID`**: Client ID of the Github Oauth app.
- **`GITHUB_OAUTH_CLIENT_SECRET`**: Secret key of the Github Oauth app.
- **`GITHUB_OAUTH_WHITELIST_ORGANIZATION`**: Used to use authorization based on the membership of a Github organization.
- **`GITHUB_OAUTH_WHITELIST_TEAM`**: Used to use authorization based on the membership of a Github team in an organization. `GITHUB_OAUTH_WHITELIST_ORGANIZATION` is required
## How to run tests

### Install pytest

```bash
pip install -e .[test]
### Run tests:

```bash
```

### Run tests with coverage HTML report:

```bash
Luiggi Tenorio Ku's avatar
Luiggi Tenorio Ku committed
pytest --cov=autosubmit_api --cov-config=.coveragerc --cov-report=html tests/
You will find the report in `htmlcov/index.html`