# plugins_api.base

*module*

Base plugin classes.

This module contains the core plugin classes that define the plugin architecture.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L1-1)

## plugins_api.base.ConnectionPlugin

*class*

```python
class ConnectionPlugin(MadbotPlugin)
```

Bases: `plugins_api.base.MadbotPlugin`

Abstract class for connection plugins.

A connection plugin is a plugin that can be instantiated and used to connect to a specific service.
A connection plugin thus has public and private parameters to establish the connection to the service.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L179-289)

### plugins_api.base.ConnectionPlugin.close

*method*

```python
def close() -> None
```

Release connection resources (optional).

Plugins that hold long-lived connections (e.g. SSH, persistent HTTP
sessions) may override this method to close the underlying connection
and release file descriptors. Callers (e.g. core) should call
``close()`` when done with the plugin instance.

The base implementation does nothing. Plugins that do not need to
release resources need not override it.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L232-244)

### plugins_api.base.ConnectionPlugin.get_connection_fields

*method* · *abstract* · *classmethod*

```python
def get_connection_fields() -> tuple[list[ConnectionField], list[ConnectionField]]
```

Retrieve the connection fields for the connection plugin.

**Returns**

- (`tuple[list[ConnectionField], list[ConnectionField]]`) — ``(shared_fields, private_fields)``. Shared fields are instance-level (URL, host). Private fields are per-user secrets (token, password).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L201-217)

### plugins_api.base.ConnectionPlugin.get_instance_name

*method* · *abstract*

```python
def get_instance_name() -> str
```

Return the instance name of the connection plugin.

**Returns**

- (`str`) — Instance name.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L188-199)

### plugins_api.base.ConnectionPlugin.get_shared_parameters

*method* · *abstract*

```python
def get_shared_parameters() -> dict[str, Any]
```

Return all shared parameters in a cleaned form.

**Returns**

- (`dict`) — Shared parameters cleaned.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L219-230)

### plugins_api.base.ConnectionPlugin.is_sandbox

*method* · *classmethod*

```python
def is_sandbox(shared_parameters: dict[str, Any]) -> bool
```

Return whether the shared parameters are for a sandbox connection or not.

**Parameters**

- `shared_parameters` (`dict`) — The shared parameters to check.

**Returns**

- (`bool`) — Plugin is sandbox.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L246-263)

### plugins_api.base.ConnectionPlugin.on_before_store_credentials

*method* · *classmethod*

```python
def on_before_store_credentials(shared_params: dict, private_params: dict) -> dict
```

Hook called just before writing credentials to the Vault.
Allows the plugin to transform/enrich the private_params.
By default, returns the params unchanged.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L265-276)

### plugins_api.base.ConnectionPlugin.on_delete_credentials

*method* · *classmethod*

```python
def on_delete_credentials(shared_params: dict, vault_secret: dict) -> None
```

Hook called just before deleting credentials from the Vault.
Allows the plugin to perform cleanup on the remote server side.
By default, does nothing.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L278-289)

### plugins_api.base.ConnectionPlugin.get_author

*method* · *abstract* · *classmethod*

```python
def get_author() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return plugin author.

**Returns**

- (`str`) — Plugin author.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L77-89)

### plugins_api.base.ConnectionPlugin.get_color

*method* · *abstract* · *classmethod*

```python
def get_color() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the color of the plugin.

Typically a hex value such as ``"#3B82F6"``.

**Returns**

- (`str`) — Plugin color.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L108-122)

### plugins_api.base.ConnectionPlugin.get_description

*method* · *abstract* · *classmethod*

```python
def get_description() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return plugin description.

**Returns**

- (`str`) — Plugin description.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L63-75)

### plugins_api.base.ConnectionPlugin.get_id

*method* · *classmethod*

```python
def get_id() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the unique identifier of the plugin.

**Returns**

- (`str`) — Unique identifier in the format 'module.class'.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L19-30)

### plugins_api.base.ConnectionPlugin.get_logo

*method* · *abstract* · *classmethod*

```python
def get_logo() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the static path of the plugin logo.

Path is relative to the plugin package static files.
Example: ``"images/ena.png"``.

**Returns**

- (`str`) — Plugin logo static path.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L91-106)

### plugins_api.base.ConnectionPlugin.get_name

*method* · *abstract* · *classmethod*

```python
def get_name() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the plugin name.

**Returns**

- (`str`) — Plugin name.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L32-44)

### plugins_api.base.ConnectionPlugin.get_slug

*method* · *abstract* · *classmethod*

```python
def get_slug() -> str
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the plugin slug.

Lowercase, no spaces (e.g. ``"ena"``, ``"omero"``).
Used as ``MetadataFieldID.source`` and as the schema source at reload.

**Returns**

- (`str`) — Plugin slug.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L46-61)

### plugins_api.base.ConnectionPlugin.get_status

*method* · *abstract* · *classmethod*

```python
def get_status() -> dict[str, PluginStatus]
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the maturity status of the plugin, keyed by capability type.

A plugin implementing several capability types at once (e.g. a class
inheriting from both `SubmissionPlugin` and
`MetadataFieldDefinitionPlugin`) must return one entry per type it
implements, using the same type strings as `get_types()`.

**Returns**

- (`dict[str, PluginStatus]`) — Mapping of plugin type (as returned by `get_types()`) to its maturity status.

**Examples**

A plugin implementing a single type:

```pycon
>>> print(self.get_status())
{"data_plugin": PluginStatus.PREVIEW}
```

A plugin implementing several types at once:

```pycon
>>> print(self.get_status())
{
    "submission_plugin": PluginStatus.STABLE,
    "metadata_field_definition_plugin": PluginStatus.STABLE,
}
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L124-157)

### plugins_api.base.ConnectionPlugin.get_types

*method* · *classmethod*

```python
def get_types() -> list[str]
```

Inherited from: `plugins_api.base.MadbotPlugin`

Return the list of the plugin types in snake_case.

**Returns**

- (`list`) — List of plugin types.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L159-176)

## plugins_api.base.MadbotPlugin

*class*

```python
class MadbotPlugin(ABC)
```

Bases: `ABC`

Abstract base class for all plugins, declaring basic functions of a plugin.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L15-176)

### plugins_api.base.MadbotPlugin.get_author

*method* · *abstract* · *classmethod*

```python
def get_author() -> str
```

Return plugin author.

**Returns**

- (`str`) — Plugin author.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L77-89)

### plugins_api.base.MadbotPlugin.get_color

*method* · *abstract* · *classmethod*

```python
def get_color() -> str
```

Return the color of the plugin.

Typically a hex value such as ``"#3B82F6"``.

**Returns**

- (`str`) — Plugin color.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L108-122)

### plugins_api.base.MadbotPlugin.get_description

*method* · *abstract* · *classmethod*

```python
def get_description() -> str
```

Return plugin description.

**Returns**

- (`str`) — Plugin description.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L63-75)

### plugins_api.base.MadbotPlugin.get_id

*method* · *classmethod*

```python
def get_id() -> str
```

Return the unique identifier of the plugin.

**Returns**

- (`str`) — Unique identifier in the format 'module.class'.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L19-30)

### plugins_api.base.MadbotPlugin.get_logo

*method* · *abstract* · *classmethod*

```python
def get_logo() -> str
```

Return the static path of the plugin logo.

Path is relative to the plugin package static files.
Example: ``"images/ena.png"``.

**Returns**

- (`str`) — Plugin logo static path.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L91-106)

### plugins_api.base.MadbotPlugin.get_name

*method* · *abstract* · *classmethod*

```python
def get_name() -> str
```

Return the plugin name.

**Returns**

- (`str`) — Plugin name.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L32-44)

### plugins_api.base.MadbotPlugin.get_slug

*method* · *abstract* · *classmethod*

```python
def get_slug() -> str
```

Return the plugin slug.

Lowercase, no spaces (e.g. ``"ena"``, ``"omero"``).
Used as ``MetadataFieldID.source`` and as the schema source at reload.

**Returns**

- (`str`) — Plugin slug.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L46-61)

### plugins_api.base.MadbotPlugin.get_status

*method* · *abstract* · *classmethod*

```python
def get_status() -> dict[str, PluginStatus]
```

Return the maturity status of the plugin, keyed by capability type.

A plugin implementing several capability types at once (e.g. a class
inheriting from both `SubmissionPlugin` and
`MetadataFieldDefinitionPlugin`) must return one entry per type it
implements, using the same type strings as `get_types()`.

**Returns**

- (`dict[str, PluginStatus]`) — Mapping of plugin type (as returned by `get_types()`) to its maturity status.

**Examples**

A plugin implementing a single type:

```pycon
>>> print(self.get_status())
{"data_plugin": PluginStatus.PREVIEW}
```

A plugin implementing several types at once:

```pycon
>>> print(self.get_status())
{
    "submission_plugin": PluginStatus.STABLE,
    "metadata_field_definition_plugin": PluginStatus.STABLE,
}
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L124-157)

### plugins_api.base.MadbotPlugin.get_types

*method* · *classmethod*

```python
def get_types() -> list[str]
```

Return the list of the plugin types in snake_case.

**Returns**

- (`list`) — List of plugin types.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/plugins-api-v2.0.1/plugin_api/plugins_api/base.py#L159-176)
