# leia-api-sdk
Leia API

This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: 1.0.0
- Package version: 1.0.5
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen

## Requirements.

Python 2.7 and 3.4+

## Installation & Usage
### pip install

If the python package is hosted on Github, you can install directly from Github

```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)

Then import the package:
```python
import leiaapi.generated 
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import leiaapi.generated
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python
from __future__ import print_function
import time
import leiaapi.generated
from leiaapi.generated.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
body = NULL # object | The prediction that should be associated to document in this annotation, in free form json
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_type = leiaapi.generated.AnnotationTypes() # AnnotationTypes | The type of the annotation
document_id = 'document_id_example' # str | The id of the document to annotate
name = 'name_example' # str | The name of the annotation (for information purposes only) (optional)
tags = ['tags_example'] # list[str] | The tags of the annotation (optional)

try:
    # Creates an annotation
    api_response = api_instance.create_annotation(body, token, annotation_type, document_id, name=name, tags=tags)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AnnotationApi->create_annotation: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | The id of the annotation (for information purposes only)

try:
    # Deletes an annotation
    api_instance.delete_annotation(token, annotation_id)
except ApiException as e:
    print("Exception when calling AnnotationApi->delete_annotation: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | The id of the annotation (for information purposes only)

try:
    # Retrieves an annotation
    api_response = api_instance.get_annotation(token, annotation_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AnnotationApi->get_annotation: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | If specified, filters the annotations id (optional)
annotation_type = leiaapi.generated.AnnotationTypes() # AnnotationTypes | If specified, filters the annotations by type (optional)
name = 'name_example' # str | If specified, filters the annotations by name (optional)
tags = ['tags_example'] # list[str] | If specified, filters the annotations by tag (optional)
document_id = 'document_id_example' # str | If specified, filters the annotations attached to a given document (optional)
created_after = '2013-10-20T19:20:30+01:00' # datetime | If specified, keeps only annotations created after given UTC timestamp (ISO 8601 format : yyyy-MM-ddThh:mm:ss) (optional)
created_before = '2013-10-20T19:20:30+01:00' # datetime | If specified, keeps only annotations created before given UTC timestamp (ISO 8601 format : yyyy-MM-ddThh:mm:ss) (optional)
offset = 56 # int | Number of the first annotation to send (pagination) (optional)
limit = 56 # int | Maximum number of annotation to send (pagination) (optional)

try:
    # Retrieves annotations (paginated)
    api_response = api_instance.get_annotations(token, annotation_id=annotation_id, annotation_type=annotation_type, name=name, tags=tags, document_id=document_id, created_after=created_after, created_before=created_before, offset=offset, limit=limit)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AnnotationApi->get_annotations: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | The id of the annotation
tag = 'tag_example' # str | The tag to add to the annotation

try:
    # Tags an annotation
    api_response = api_instance.tag_annotation(token, annotation_id, tag)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AnnotationApi->tag_annotation: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | The id of the annotation
tag = 'tag_example' # str | The tag to delete from the annotation

try:
    # Untags an annotation
    api_instance.untag_annotation(token, annotation_id, tag)
except ApiException as e:
    print("Exception when calling AnnotationApi->untag_annotation: %s\n" % e)

# create an instance of the API class
api_instance = leiaapi.generated.AnnotationApi(leiaapi.generated.ApiClient(configuration))
body = NULL # object | The new prediction that should be associated to document in this annotation, in free form json
token = 'token_example' # str | The login token obtained via GET /login/{api_key}
annotation_id = 'annotation_id_example' # str | The id of the annotation to modify
name = 'name_example' # str | The new name of the annotation (won't change if not set) (optional)

try:
    # Updates an annotation
    api_response = api_instance.update_annotation(body, token, annotation_id, name=name)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AnnotationApi->update_annotation: %s\n" % e)
```

## Documentation for API Endpoints

All URIs are relative to *https://api.leia.io/leia/1.0.0*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnnotationApi* | [**create_annotation**](docs/AnnotationApi.md#create_annotation) | **POST** /annotation/{document_id} | Creates an annotation
*AnnotationApi* | [**delete_annotation**](docs/AnnotationApi.md#delete_annotation) | **DELETE** /annotation/{annotation_id} | Deletes an annotation
*AnnotationApi* | [**get_annotation**](docs/AnnotationApi.md#get_annotation) | **GET** /annotation/{annotation_id} | Retrieves an annotation
*AnnotationApi* | [**get_annotations**](docs/AnnotationApi.md#get_annotations) | **GET** /annotation | Retrieves annotations (paginated)
*AnnotationApi* | [**tag_annotation**](docs/AnnotationApi.md#tag_annotation) | **POST** /annotation/{annotation_id}/tag/{tag} | Tags an annotation
*AnnotationApi* | [**untag_annotation**](docs/AnnotationApi.md#untag_annotation) | **DELETE** /annotation/{annotation_id}/tag/{tag} | Untags an annotation
*AnnotationApi* | [**update_annotation**](docs/AnnotationApi.md#update_annotation) | **PATCH** /annotation/{annotation_id} | Updates an annotation
*ApplicationApi* | [**login_application**](docs/ApplicationApi.md#login_application) | **GET** /login/{api_key} | (DEPRECATED) Logs into Leia API
*ApplicationApi* | [**login_application_post**](docs/ApplicationApi.md#login_application_post) | **POST** /login | Logs into Leia API
*ApplicationApi* | [**logout_application**](docs/ApplicationApi.md#logout_application) | **GET** /logout | Logs out from Leia API
*ApplicationApi* | [**who_am_i**](docs/ApplicationApi.md#who_am_i) | **GET** /whoami | Gets the currently connected application
*ApplicationAdminApi* | [**admin_create_application**](docs/ApplicationAdminApi.md#admin_create_application) | **POST** /admin/application | Adds a new application to the system (admin only)
*ApplicationAdminApi* | [**admin_delete_always_on_schedule**](docs/ApplicationAdminApi.md#admin_delete_always_on_schedule) | **DELETE** /admin/application/{application_id}/always_on_schedules/{always_on_schedule_id} | Removes a schedule from an application
*ApplicationAdminApi* | [**admin_delete_application**](docs/ApplicationAdminApi.md#admin_delete_application) | **DELETE** /admin/application/{application_id} | Deletes an application (admin only)
*ApplicationAdminApi* | [**admin_edit_application**](docs/ApplicationAdminApi.md#admin_edit_application) | **PATCH** /admin/application/{application_id} | Modifies an existing application in the system (admin only)
*ApplicationAdminApi* | [**admin_get_application**](docs/ApplicationAdminApi.md#admin_get_application) | **GET** /admin/application/{application_id} | Retrieves an application (admin only)
*ApplicationAdminApi* | [**admin_get_applications**](docs/ApplicationAdminApi.md#admin_get_applications) | **GET** /admin/application | Retrieves applications (admin only) (paginated)
*ApplicationAdminApi* | [**admin_reset_api_key**](docs/ApplicationAdminApi.md#admin_reset_api_key) | **POST** /admin/application/{application_id}/reset_api_key | Resets an API key (admin only)
*DocumentApi* | [**create_document**](docs/DocumentApi.md#create_document) | **POST** /document | Uploads a document to the Leia API
*DocumentApi* | [**delete_document**](docs/DocumentApi.md#delete_document) | **DELETE** /document/{document_id} | Deletes a document from Leia API
*DocumentApi* | [**edit_document**](docs/DocumentApi.md#edit_document) | **PATCH** /document/{document_id} | Updates a document in Leia API
*DocumentApi* | [**get_document**](docs/DocumentApi.md#get_document) | **GET** /document/{document_id} | Retrieves a document from Leia API
*DocumentApi* | [**get_document_contents**](docs/DocumentApi.md#get_document_contents) | **GET** /document/{document_id}/file_contents | Retrieves a document from Leia API
*DocumentApi* | [**get_documents**](docs/DocumentApi.md#get_documents) | **GET** /document | Retrieves documents from Leia API (paginated)
*DocumentApi* | [**get_documents_tags**](docs/DocumentApi.md#get_documents_tags) | **GET** /document/tag | Retrieves documents&#x27; tags from Leia API
*DocumentApi* | [**get_documents_zip**](docs/DocumentApi.md#get_documents_zip) | **GET** /document/zip | Retrieves documents from Leia API (paginated)
*DocumentApi* | [**tag_document**](docs/DocumentApi.md#tag_document) | **POST** /document/{document_id}/tag/{tag} | Tags a document
*DocumentApi* | [**transform_document_async**](docs/DocumentApi.md#transform_document_async) | **POST** /document/{document_ids}/transform/{output_type} | Asynchronously converts a document within Leia API
*DocumentApi* | [**untag_document**](docs/DocumentApi.md#untag_document) | **DELETE** /document/{document_id}/tag/{tag} | Untags an document
*DocumentAdminApi* | [**admin_create_document**](docs/DocumentAdminApi.md#admin_create_document) | **POST** /admin/{application_id}/document | Uploads a document to the Leia API (admin only)
*DocumentAdminApi* | [**admin_delete_document**](docs/DocumentAdminApi.md#admin_delete_document) | **DELETE** /admin/{application_id}/document/{document_id} | Deletes a document from Leia API (admin only)
*DocumentAdminApi* | [**admin_edit_document**](docs/DocumentAdminApi.md#admin_edit_document) | **PATCH** /admin/{application_id}/document/{document_id} | Updates a document in Leia API (admin only)
*DocumentAdminApi* | [**admin_get_document**](docs/DocumentAdminApi.md#admin_get_document) | **GET** /admin/{application_id}/document/{document_id} | Retrieves a document from Leia API (admin only)
*DocumentAdminApi* | [**admin_get_document_contents**](docs/DocumentAdminApi.md#admin_get_document_contents) | **GET** /admin/{application_id}/document/{document_id}/file_contents | Retrieves a document from Leia API (admin only)
*DocumentAdminApi* | [**admin_get_documents**](docs/DocumentAdminApi.md#admin_get_documents) | **GET** /admin/document | Retrieves documents from Leia API (admin only) (paginated)
*DocumentAdminApi* | [**admin_get_documents_tags**](docs/DocumentAdminApi.md#admin_get_documents_tags) | **GET** /admin/document/tag | Retrieves documents&#x27; tags from Leia API (admin only)
*DocumentAdminApi* | [**admin_get_documents_zip**](docs/DocumentAdminApi.md#admin_get_documents_zip) | **GET** /admin/document/zip | Retrieves documents from Leia API (admin only) (paginated)
*DocumentAdminApi* | [**admin_tag_document**](docs/DocumentAdminApi.md#admin_tag_document) | **POST** /admin/{application_id}/document/{document_id}/tag/{tag} | Tags a document (admin only)
*DocumentAdminApi* | [**admin_transform_document_async**](docs/DocumentAdminApi.md#admin_transform_document_async) | **POST** /admin/{application_id}/document/{document_ids}/transform/{output_type} | Asynchronously converts a document within Leia API (admin only)
*DocumentAdminApi* | [**admin_untag_document**](docs/DocumentAdminApi.md#admin_untag_document) | **DELETE** /admin/{application_id}/document/{document_id}/tag/{tag} | Untags an document (admin only)
*HealthApi* | [**health_check**](docs/HealthApi.md#health_check) | **GET** /health | Checks Leia API health
*JobApi* | [**cancel_job**](docs/JobApi.md#cancel_job) | **DELETE** /job/{job_id} | Cancels a job in Leia API
*JobApi* | [**create_conditional_job**](docs/JobApi.md#create_conditional_job) | **POST** /job/conditional/{execute_after_id} | Asynchronously and conditionaly applies model(s) on documents
*JobApi* | [**get_job**](docs/JobApi.md#get_job) | **GET** /job/{job_id} | Retrieves a job from Leia API
*JobApi* | [**get_job_statuses**](docs/JobApi.md#get_job_statuses) | **GET** /job/{job_ids}/status | Retrieves job statuses from Leia API
*JobApi* | [**get_jobs**](docs/JobApi.md#get_jobs) | **GET** /job | Retrieves jobs (paginated)
*JobApi* | [**start_job**](docs/JobApi.md#start_job) | **POST** /job/{job_id}/start | Starts a job in BLOCKED status within Leia API
*JobAdminApi* | [**admin_cancel_job**](docs/JobAdminApi.md#admin_cancel_job) | **DELETE** /admin/{submitter_id}/job/{job_id} | Cancels a job in Leia API (admin only)
*JobAdminApi* | [**admin_create_conditional_job**](docs/JobAdminApi.md#admin_create_conditional_job) | **POST** /admin/{application_id}/job/conditional/{execute_after_id} | Asynchronously and conditionaly applies model(s) on documents (admin only)
*JobAdminApi* | [**admin_get_job**](docs/JobAdminApi.md#admin_get_job) | **GET** /admin/{submitter_id}/job/{job_id} | Retrieves a job from Leia API (admin only)
*JobAdminApi* | [**admin_get_job_statuses**](docs/JobAdminApi.md#admin_get_job_statuses) | **GET** /admin/{submitter_id}/job/{job_ids}/status | Retrieves job statuses from Leia API (admin only)
*JobAdminApi* | [**admin_get_jobs**](docs/JobAdminApi.md#admin_get_jobs) | **GET** /admin/job | Retrieves jobs (admin only) (paginated)
*JobAdminApi* | [**admin_start_job**](docs/JobAdminApi.md#admin_start_job) | **POST** /admin/{submitter_id}/job/{job_id}/start | Starts a job in BLOCKED status within Leia API
*ModelApi* | [**apply_model_async**](docs/ModelApi.md#apply_model_async) | **POST** /model/{model_id}/apply/{document_ids} | Asynchronously applies a model on documents
*ModelApi* | [**get_model**](docs/ModelApi.md#get_model) | **GET** /model/{model_id} | Get a model
*ModelApi* | [**get_models**](docs/ModelApi.md#get_models) | **GET** /model | Lists models (paginated)
*ModelApi* | [**tag_model**](docs/ModelApi.md#tag_model) | **POST** /model/{model_id}/tag/{tag} | Tags a model
*ModelApi* | [**train_model_async**](docs/ModelApi.md#train_model_async) | **POST** /model/{model_module}/train/{documents_tag} | Asynchronously trains a model on documents (admin only)
*ModelApi* | [**untag_model**](docs/ModelApi.md#untag_model) | **DELETE** /model/{model_id}/tag/{tag} | Untags a model
*ModelAdminApi* | [**admin_apply_model_async**](docs/ModelAdminApi.md#admin_apply_model_async) | **POST** /admin/{application_id}/model/{model_id}/apply/{document_ids} | Asynchronously applies a model on documents (admin only)
*ModelAdminApi* | [**admin_create_model**](docs/ModelAdminApi.md#admin_create_model) | **POST** /admin/{application_id}/model | Adds a new model to the system (admin only)
*ModelAdminApi* | [**admin_delete_model**](docs/ModelAdminApi.md#admin_delete_model) | **DELETE** /admin/{application_id}/model/{model_id} | Deletes a model (admin only)
*ModelAdminApi* | [**admin_edit_model**](docs/ModelAdminApi.md#admin_edit_model) | **PATCH** /admin/{application_id}/model/{model_id} | Modifies an existing model in the system (admin only)
*ModelAdminApi* | [**admin_get_model**](docs/ModelAdminApi.md#admin_get_model) | **GET** /admin/{application_id}/model/{model_id} | Get a model (admin only)
*ModelAdminApi* | [**admin_get_model_contents**](docs/ModelAdminApi.md#admin_get_model_contents) | **GET** /admin/{application_id}/model/{model_id}/file_contents | Get a model (admin only)
*ModelAdminApi* | [**admin_get_models**](docs/ModelAdminApi.md#admin_get_models) | **GET** /admin/model | Lists models (admin only) (paginated))
*ModelAdminApi* | [**admin_tag_model**](docs/ModelAdminApi.md#admin_tag_model) | **POST** /admin/{application_id}/model/{model_id}/tag/{tag} | Tags a model (admin only)
*ModelAdminApi* | [**admin_train_model_async**](docs/ModelAdminApi.md#admin_train_model_async) | **POST** /admin/{application_id}/model/{model_module}/train/{documents_tag} | Asynchronously trains a model on documents (admin only)
*ModelAdminApi* | [**admin_untag_model**](docs/ModelAdminApi.md#admin_untag_model) | **DELETE** /admin/{application_id}/model/{model_id}/tag/{tag} | Untags a model (admin only)
*WorkerApi* | [**get_worker**](docs/WorkerApi.md#get_worker) | **GET** /worker/{job_type} | Retrieves worker information from Leia API
*WorkerApi* | [**get_workers**](docs/WorkerApi.md#get_workers) | **GET** /worker | Retrieves worker information from Leia API
*WorkerAdminApi* | [**kill_worker**](docs/WorkerAdminApi.md#kill_worker) | **DELETE** /worker/{job_type} | Kills a worker (admin only)

## Documentation For Models

 - [Annotation](docs/Annotation.md)
 - [AnnotationTypes](docs/AnnotationTypes.md)
 - [Application](docs/Application.md)
 - [ApplicationTypes](docs/ApplicationTypes.md)
 - [ApplyBody](docs/ApplyBody.md)
 - [Classification](docs/Classification.md)
 - [ConditionalBody](docs/ConditionalBody.md)
 - [Document](docs/Document.md)
 - [FormatTypes](docs/FormatTypes.md)
 - [Job](docs/Job.md)
 - [JobTypes](docs/JobTypes.md)
 - [LoginBody](docs/LoginBody.md)
 - [LoginToken](docs/LoginToken.md)
 - [Model](docs/Model.md)
 - [ModelInputTypes](docs/ModelInputTypes.md)
 - [ModelTypes](docs/ModelTypes.md)
 - [OneOfJobResult](docs/OneOfJobResult.md)
 - [ResultTypes](docs/ResultTypes.md)
 - [Speed](docs/Speed.md)
 - [Statuses](docs/Statuses.md)
 - [TrainBody](docs/TrainBody.md)
 - [TransformBody](docs/TransformBody.md)
 - [TransformTypes](docs/TransformTypes.md)
 - [Worker](docs/Worker.md)

## Documentation For Authorization

 All endpoints do not require authorization.


## Author

contact@leia.io
