# madbot_cli.discover

*module*

Find what an instance offers, before writing a deposit file.

The plugins of the instance, the parameters each one expects, and the
connections the account already has. Everything is read from the API: the
plugins publish the JSON Schema of their shared parameters, of their
credentials and of their settings, and this module reads those schemas
generically, with no case for a given plugin. Nothing is written in madbot.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1-1)

## madbot_cli.discover.DATA_PLUGIN

*attribute* · *module attribute*

```python
DATA_PLUGIN = 'data_plugin'
```

The type of a plugin that is a source of data.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L30-30)

## madbot_cli.discover.DESCRIPTION_WIDTH

*attribute* · *module attribute*

```python
DESCRIPTION_WIDTH = 100
```

The longest description shown on one line.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L52-52)

## madbot_cli.discover.FORMAT_NAMES

*attribute* · *module attribute*

```python
FORMAT_NAMES = {'date': 'a date, YYYY-MM-DD', 'date-time': 'a date and time, YYYY-MM-DDThh:mm:ss'}
```

How a format of a value is called on screen.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1485-1488)

## madbot_cli.discover.INTERNAL_TYPES

*attribute* · *module attribute*

```python
INTERNAL_TYPES = frozenset({'connection_plugin', 'madbot_plugin', 'metadata_field_definition_plugin_with_standard_mapping'})
```

The types of plugin internal to madbot, not shown.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L43-49)

## madbot_cli.discover.KIND_NAMES

*attribute* · *module attribute*

```python
KIND_NAMES = {'string': 'a text', 'number': 'a number', 'integer': 'a whole number', 'boolean': 'true or false', 'array': 'a list', 'object': 'an object'}
```

How the type of a value is called on screen.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1475-1482)

## madbot_cli.discover.LONG_LIST

*attribute* · *module attribute*

```python
LONG_LIST = 30
```

The most values of a field written on screen; --search narrows the others.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L58-58)

## madbot_cli.discover.MANY_CHOICES

*attribute* · *module attribute*

```python
MANY_CHOICES = 10
```

Beyond this number of values, each value is shown with its title only.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L54-54)

## madbot_cli.discover.MAX_REF_DEPTH

*attribute* · *module attribute*

```python
MAX_REF_DEPTH = 20
```

The most references followed one inside another, to stop on a loop.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L60-60)

## madbot_cli.discover.MULTILINE

*attribute* · *module attribute*

```python
MULTILINE = 'multi'
```

The format of a value that spans several lines, such as an SSH key.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L56-56)

## madbot_cli.discover.SUBMISSION_PLUGIN

*attribute* · *module attribute*

```python
SUBMISSION_PLUGIN = 'submission_plugin'
```

The type of a plugin that is a repository.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L32-32)

## madbot_cli.discover.TYPE_NAMES

*attribute* · *module attribute*

```python
TYPE_NAMES = {DATA_PLUGIN: 'data source', SUBMISSION_PLUGIN: 'repository', 'metadata_plugin': 'metadata', 'metadata_field_definition_plugin': 'metadata fields'}
```

How a type of plugin is called on screen, in this order; another type keeps
its own name.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L34-39)

## madbot_cli.discover.Write

*attribute* · *module attribute*

```python
Write = Callable[[str], None]
```

Writes a line.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L27-27)

## madbot_cli.discover.choice_matches

*function*

```python
def choice_matches(choice: Mapping, text: str) -> bool
```

Tell whether a value, or a form, contains a text, whatever the case.

**Parameters**

- `choice` (`mapping`) — A value of `choices_of`, or a form of `variants_of`.
- `text` (`str`) — The text searched.

**Returns**

- (`bool`) — True when its value, title or description contains the text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L829-850)

## madbot_cli.discover.choices_of

*function*

```python
def choices_of(schema: Mapping) -> list[dict]
```

List the values a schema allows, when it allows only a few.

**Parameters**

- `schema` (`mapping`) — A JSON Schema.

**Returns**

- (`list of dict`) — Each value with its ``title`` and ``description`` when the schema gives them: the constants of ``oneOf`` or ``anyOf``, or the ``enum``. Empty when the schema allows any value.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L67-94)

## madbot_cli.discover.connection_block

*function*

```python
def connection_block(described: Mapping) -> dict
```

Give the part of a source or a repository that names its connection.

**Parameters**

- `described` (`mapping`) — A plugin, as `describe_plugin` gives it.

**Returns**

- (`dict`) — Its ``plugin``, ``shared_params`` and ``credentials_env``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L606-626)

## madbot_cli.discover.credential_examples

*function*

```python
def credential_examples(params: list[Mapping]) -> list[dict]
```

Give an example of the credentials for each form they may take.

**Parameters**

- `params` (`list of mapping`) — The private parameters of a plugin.

**Returns**

- (`list of dict`) — Each example with ``forms``, the titles of the forms it follows, ``value``, the JSON object to put in the environment variable, and ``jq``, a command writing that object when a value spans several lines (an SSH key, whose line breaks JSON writes escaped), else None.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L408-442)

## madbot_cli.discover.describe

*function*

```python
def describe(schema: Mapping, key: str | None = None) -> dict
```

Describe what a schema asks for.

**Parameters**

- `schema` (`mapping`) — A JSON Schema.
- `key` (`str`) (default: `None`) — The key the value goes under.

**Returns**

- (`dict`) — Its ``key``, ``title``, ``description``, ``type``, ``format``, the ``pattern`` a text must match and the ``pattern_message`` explaining it, its fixed value (``const``), the values it allows (``choices``), the forms of an object (``variants``), the parts of an object (``params``) and what each item of a list is (``items``, else None).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L148-186)

## madbot_cli.discover.describe_field

*function*

```python
def describe_field(client: Client, slug: str, *, source: str | None = None, search: str | None = None) -> dict
```

Describe what a metadata field accepts, with an example to paste.

**Parameters**

- `client` (`Client`) — The client.
- `slug` (`str`) — The slug of the field.
- `source` (`str`) (default: `None`) — The source of the field, when several fields share the slug.
- `search` (`str`) (default: `None`) — Keep only the values that contain this text, whatever the case.

**Returns**

- (`dict`) — The field (``slug``, ``name``, ``description``, ``source``, ``kind``: a field of madbot or of a plugin, ``level``: its level outside any submission), what its ``value`` is (as `describe` gives it), the ``search`` and the number of values and forms that ``match`` it (None without a search, or when the field has no list), and an ``example`` value (None when no value matches the search).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1104-1154)

## madbot_cli.discover.describe_plugin

*function*

```python
def describe_plugin(client: Client, reference: str) -> dict
```

Describe what a plugin asks for in a deposit file.

**Parameters**

- `client` (`Client`) — The client.
- `reference` (`str`) — The slug or the identifier of the plugin.

**Returns**

- (`dict`) — The plugin (``slug``, ``name``, ``types``, ``description``), its ``shared`` parameters, its ``private`` ones (the credentials), its ``settings`` when it is a repository, ``public`` when it reads public data without credentials, the ``credentials_env`` the example names, the ``credentials`` examples and the ``example`` blocks to paste in the file.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L551-603)

## madbot_cli.discover.env_name

*function*

```python
def env_name(slug: str) -> str
```

Name the environment variable of the credentials of a plugin.

**Parameters**

- `slug` (`str`) — The slug of the plugin.

**Returns**

- (`str`) — Such as ``SSHFS_CREDENTIALS``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L388-405)

## madbot_cli.discover.example_blocks

*function*

```python
def example_blocks(described: Mapping) -> dict
```

Give the blocks of a deposit file that use a plugin.

**Parameters**

- `described` (`mapping`) — A plugin, as `describe_plugin` gives it.

**Returns**

- (`dict`) — ``sources``, the top-level block of a source, when the plugin is a source of data; ``repository``, the block of a submission, when it is a repository.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L647-676)

## madbot_cli.discover.example_object

*function*

```python
def example_object(params: Iterable[Mapping]) -> dict
```

Give an example object, with every required part and every fixed value.

**Parameters**

- `params` (`iterable of mapping`) — The parts of the object, as `params_of` gives them.

**Returns**

- (`dict`) — Each part by its key.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L262-280)

## madbot_cli.discover.example_of

*function*

```python
def example_of(param: Mapping, variant: int = 0) -> Any
```

Give an example value of a parameter, with placeholders to replace.

A value to choose stays a placeholder: the example never picks one, such
as a production server, for the reader.

**Parameters**

- `param` (`mapping`) — A parameter, as `describe` gives it.
- `variant` (`int`) (default: `0`) — The form to follow, when the parameter has several.

**Returns**

- (`Any`) — The fixed value, an object of examples, or a placeholder.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L229-259)

## madbot_cli.discover.field_in_submission

*function*

```python
def field_in_submission(client: Client, deposit: Manifest, title: str, slug: str, environ: Mapping[str, str] | None = None) -> dict
```

Read the level and the values of a field in a submission of a deposit file.

The level comes from the submission, with its settings: a checklist may
make a field mandatory. The submission must have been prepared by apply.

**Parameters**

- `client` (`Client`) — The client.
- `deposit` (`Manifest`) — The deposit file.
- `title` (`str`) — The title of the submission, in the file.
- `slug` (`str`) — The slug of the field.
- `environ` (`mapping`) (default: `None`) — The environment holding the credentials; `os.environ` by default.

**Returns**

- (`dict`) — The ``submission`` and, for each type of metadata object that has the field (``types``): its ``type``, ``level``, the ``value`` all objects share (or None), the value of each object (``by_object``, by alias) and the objects still ``missing`` a mandatory value.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1044-1101)

## madbot_cli.discover.find_field

*function*

```python
def find_field(client: Client, slug: str, source: str | None = None) -> dict
```

Find a metadata field of the instance by its slug.

**Parameters**

- `client` (`Client`) — The client.
- `slug` (`str`) — The slug of the field, as a deposit file writes it.
- `source` (`str`) (default: `None`) — The source of the field (a plugin slug, or ``referential``), when several fields share the slug.

**Returns**

- (`dict`) — The field as the API returns it.

**Raises**

- `MadbotError` — When no field has this slug, giving those whose slug or name is
close; or when several have it and `source` does not choose.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L769-826)

## madbot_cli.discover.flatten

*function*

```python
def flatten(params: Iterable[Mapping]) -> list[dict]
```

Put the parameters a schema wraps in an object at the top.

A plugin publishes each connection parameter as an object holding that
parameter, the way the API checks ``{key: value}``.

**Parameters**

- `params` (`iterable of mapping`) — The parameters, one per schema of the plugin.

**Returns**

- (`list of dict`) — The parameters inside those objects.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L528-548)

## madbot_cli.discover.has_values

*function*

```python
def has_values(param: Mapping) -> bool
```

Tell whether a parameter has a list of values or forms, at any depth.

**Parameters**

- `param` (`mapping`) — A parameter, as `describe` gives it.

**Returns**

- (`bool`) — True when `--search` has something to narrow.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L932-951)

## madbot_cli.discover.head_of

*function*

```python
def head_of(param: Mapping) -> str
```

Write the head line of a parameter: its key, its flags and its description.

**Parameters**

- `param` (`mapping`) — The parameter, as `describe` gives it.

**Returns**

- (`str`) — Such as ``release_date (required, a date, YYYY-MM-DD)``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1310-1338)

## madbot_cli.discover.inline_refs

*function*

```python
def inline_refs(schema: Any, root: Mapping | None = None, depth: int = 0) -> Any
```

Put in place the definitions a schema points to inside itself.

The API resolves the references between schemas (``?ref=false``) but
keeps those to the ``$defs`` of the schema itself.

**Parameters**

- `schema` (`Any`) — A JSON Schema, or a part of it.
- `root` (`mapping`) (default: `None`) — The whole schema, holding the ``$defs``; `schema` by default.
- `depth` (`int`) (default: `0`) — How many references were followed, to stop on a loop.

**Returns**

- (`Any`) — The schema with each ``{"$ref": "#/$defs/…"}`` replaced by its definition.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L730-766)

## madbot_cli.discover.is_object

*function*

```python
def is_object(schema: Mapping) -> bool
```

Tell whether a schema describes an object with parts.

**Parameters**

- `schema` (`mapping`) — A JSON Schema.

**Returns**

- (`bool`) — True when it is of type object, or lists properties or required parts.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L129-145)

## madbot_cli.discover.jq_command

*function*

```python
def jq_command(value: Any, multiline: set[str]) -> str | None
```

Write a jq command that builds credentials holding a multi-line value.

**Parameters**

- `value` (`Any`) — The example of the credentials, as `credential_examples` builds it.
- `multiline` (`set of str`) — The keys of the values that span several lines.

**Returns**

- (`str or None`) — Such as ``jq -n --rawfile private_key '<file of private_key>' '{…}'``, or None when the example has no such value.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L487-525)

## madbot_cli.discover.jq_variable

*function*

```python
def jq_variable(key: str) -> str
```

Name the jq variable that holds a value read from a file.

**Parameters**

- `key` (`str`) — The key of the value.

**Returns**

- (`str`) — A name jq accepts, such as ``private_key``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L469-484)

## madbot_cli.discover.kind_of

*function*

```python
def kind_of(param: Mapping) -> str
```

Say what a value is, in a few words.

**Parameters**

- `param` (`mapping`) — A value, as `describe` gives it.

**Returns**

- (`str`) — Such as ``a text``, ``a date, YYYY-MM-DD``, ``one of these forms`` or ``a list, each item an object with these parts``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1492-1518)

## madbot_cli.discover.list_connections

*function*

```python
def list_connections(client: Client, workspace: str | None = None) -> list[dict]
```

List the connections of the account, by workspace.

Only the shared parameters are read: the API never returns credentials.

**Parameters**

- `client` (`Client`) — The client.
- `workspace` (`str`) (default: `None`) — The name, slug or identifier of one workspace; every workspace of the account by default.

**Returns**

- (`list of dict`) — Each connection with its ``workspace`` (name), ``name``, ``plugin`` (slug), ``shared_params``, ``connected``, whether the account has working credentials for it, and ``public``, whether it reads the public data of the source without them.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L682-724)

## madbot_cli.discover.list_plugins

*function*

```python
def list_plugins(client: Client) -> list[dict]
```

List the plugins of the instance.

**Parameters**

- `client` (`Client`) — The client.

**Returns**

- (`list of dict`) — Each plugin with its ``slug``, ``name``, ``types`` and ``description``, sorted by slug.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L309-335)

## madbot_cli.discover.multiline_keys

*function*

```python
def multiline_keys(params: Iterable[Mapping]) -> set[str]
```

Find the keys of the values that span several lines.

**Parameters**

- `params` (`iterable of mapping`) — Parameters, as `describe` gives them.

**Returns**

- (`set of str`) — The keys whose format is `MULTILINE`, at any depth and in any form.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L445-466)

## madbot_cli.discover.object_names

*function*

```python
def object_names(objects: Iterable[Mapping]) -> list[str]
```

Name each metadata object once, by its alias, or else its label.

**Parameters**

- `objects` (`iterable of mapping`) — The objects, with their ``alias`` and ``label``.

**Returns**

- (`list of str`) — One name per object, in order; a name two objects share is followed by its rank, so that no value hides another.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1019-1041)

## madbot_cli.discover.one_line

*function*

```python
def one_line(text: str | None, width: int = DESCRIPTION_WIDTH) -> str
```

Put a description on one line.

**Parameters**

- `text` (`str or None`) — The description.
- `width` (`int`) (default: `DESCRIPTION_WIDTH`) — The longest text kept.

**Returns**

- (`str`) — The text with its spaces collapsed, cut at `width`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1160-1177)

## madbot_cli.discover.params_of

*function*

```python
def params_of(schema: Mapping) -> list[dict]
```

Describe the properties of an object schema.

**Parameters**

- `schema` (`mapping`) — A JSON Schema of an object.

**Returns**

- (`list of dict`) — Each property as `describe` gives it, with ``required``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L189-207)

## madbot_cli.discover.part_example

*function*

```python
def part_example(part: Mapping) -> Any
```

Give an example value of a part of an object, as `value_example` does.

**Parameters**

- `part` (`mapping`) — The part, as `describe` gives it.

**Returns**

- (`Any`) — The example.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1002-1016)

## madbot_cli.discover.placeholder

*function*

```python
def placeholder(param: Mapping) -> str
```

Write the value to replace for a parameter.

**Parameters**

- `param` (`mapping`) — A parameter, as `describe` gives it.

**Returns**

- (`str`) — Such as ``<host>``, or ``<YYYY-MM-DD>`` for a date.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L210-226)

## madbot_cli.discover.read_schema

*function*

```python
def read_schema(client: Client, url: str) -> dict
```

Read a schema the API publishes.

**Parameters**

- `client` (`Client`) — The client.
- `url` (`str`) — Its address, as a plugin gives it.

**Returns**

- (`dict`) — The schema.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L338-354)

## madbot_cli.discover.render_choices

*function*

```python
def render_choices(write: Write, choices: list[Mapping], pad: str, limit: int | None = None) -> None
```

Write the values a parameter allows, one per line.

**Parameters**

- `write` (`Write`) — Writes a line.
- `choices` (`list of mapping`) — The values, as `choices_of` gives them.
- `pad` (`str`) — The indentation of the parameter.
- `limit` (`int`) (default: `None`) — The most values written; every value by default.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1225-1254)

## madbot_cli.discover.render_connections

*function*

```python
def render_connections(write: Write, connections: list[Mapping]) -> None
```

Write the connections of the account, by workspace.

**Parameters**

- `write` (`Write`) — Writes a line.
- `connections` (`list of mapping`) — The connections, from `list_connections`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1438-1472)

## madbot_cli.discover.render_credentials

*function*

```python
def render_credentials(write: Write, described: Mapping) -> None
```

Write how to give the credentials of a plugin.

**Parameters**

- `write` (`Write`) — Writes a line.
- `described` (`mapping`) — The plugin, from `describe_plugin`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1412-1435)

## madbot_cli.discover.render_example

*function*

```python
def render_example(write: Write, where: str, block: Any) -> None
```

Write an example block of a deposit file.

**Parameters**

- `write` (`Write`) — Writes a line.
- `where` (`str`) — Where it goes in the file.
- `block` (`Any`) — The block, written as YAML.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1606-1622)

## madbot_cli.discover.render_field

*function*

```python
def render_field(write: Write, described: Mapping, within: Mapping | None = None) -> None
```

Write what a metadata field accepts, an example, and its place in a submission.

**Parameters**

- `write` (`Write`) — Writes a line.
- `described` (`mapping`) — The field, from `describe_field`.
- `within` (`mapping`) (default: `None`) — The field in a submission, from `field_in_submission`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1541-1603)

## madbot_cli.discover.render_items

*function*

```python
def render_items(write: Write, param: Mapping, depth: int, limit: int | None) -> None
```

Write what each item of a list holds, the list said once.

**Parameters**

- `write` (`Write`) — Writes a line.
- `param` (`mapping`) — The list, as `describe` gives it.
- `depth` (`int`) — How far the list is indented.
- `limit` (`int or None`) — The most values written for a list of values.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1341-1363)

## madbot_cli.discover.render_param

*function*

```python
def render_param(write: Write, param: Mapping, depth: int = 1, limit: int | None = None, *, body: bool = False) -> None
```

Write a parameter: its key, whether it is required, its values or forms.

**Parameters**

- `write` (`Write`) — Writes a line.
- `param` (`mapping`) — The parameter, as `describe` gives it.
- `depth` (`int`) (default: `1`) — How far it is indented.
- `limit` (`int`) (default: `None`) — The most values written for a list; every value by default.
- `body` (`bool`) (default: `False`) — Write what the parameter holds without its head line, for the item of a list, which the line of the list introduces.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1257-1307)

## madbot_cli.discover.render_plugin

*function*

```python
def render_plugin(write: Write, described: Mapping) -> None
```

Write what a plugin asks for, and the blocks to paste in a deposit file.

**Parameters**

- `write` (`Write`) — Writes a line.
- `described` (`mapping`) — The plugin, from `describe_plugin`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1366-1409)

## madbot_cli.discover.render_plugins

*function*

```python
def render_plugins(write: Write, plugins: list[Mapping]) -> None
```

Write the plugins of the instance, one per line.

**Parameters**

- `write` (`Write`) — Writes a line.
- `plugins` (`list of mapping`) — The plugins, from `list_plugins`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1200-1222)

## madbot_cli.discover.render_within

*function*

```python
def render_within(write: Write, within: Mapping) -> None
```

Write the level and the values of a field in a submission.

**Parameters**

- `write` (`Write`) — Writes a line.
- `within` (`mapping`) — The field in a submission, from `field_in_submission`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1625-1652)

## madbot_cli.discover.search_param

*function*

```python
def search_param(param: Mapping, text: str) -> tuple[dict, int]
```

Keep only the values of a parameter that contain a text, at any depth.

A form whose title or description contains the text keeps all its values;
another form is kept only when some of its values contain it.

**Parameters**

- `param` (`mapping`) — A parameter, as `describe` gives it.
- `text` (`str`) — The text searched, whatever the case.

**Returns**

- (`tuple of (dict, int)`) — The parameter with its lists narrowed, and how many values and forms contain the text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L853-902)

## madbot_cli.discover.search_params

*function*

```python
def search_params(params: Iterable[Mapping], text: str) -> tuple[list[dict], int]
```

Narrow the values of each parameter to those that contain a text.

A parameter none of whose values contains the text keeps them all: the
parts of one object go together, and the example takes one of them.

**Parameters**

- `params` (`iterable of mapping`) — Parameters, as `describe` gives them.
- `text` (`str`) — The text searched.

**Returns**

- (`tuple of (list of dict, int)`) — The parameters, and how many values and forms contain the text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L905-929)

## madbot_cli.discover.setting_of

*function*

```python
def setting_of(schema: Mapping, url: str) -> dict
```

Describe a setting of a repository from its schema.

A setting is mandatory when its schema says so with ``level``, as the web
application reads it, or when it gives the message of a missing value.
A mapping of messages under ``required`` is about the parts of an object
setting, not about the setting itself: it does not make it mandatory.

**Parameters**

- `schema` (`mapping`) — The schema of the setting.
- `url` (`str`) — The address of the schema, whose end is the key of the setting.

**Returns**

- (`dict`) — The setting as `describe` gives it, with ``required``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L357-385)

## madbot_cli.discover.source_key

*function*

```python
def source_key(slug: str) -> str
```

Give the key of a source in the example, from the slug of its plugin.

**Parameters**

- `slug` (`str`) — The slug of the plugin.

**Returns**

- (`str`) — A key the format accepts.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L629-644)

## madbot_cli.discover.type_names

*function*

```python
def type_names(plugin: Mapping) -> list[str]
```

Name the types of a plugin.

**Parameters**

- `plugin` (`mapping`) — A plugin as the API returns it.

**Returns**

- (`list of str`) — Such as ``data source`` or ``repository``, in the order of `TYPE_NAMES`, then a type madbot-cli does not know under its own name; the `INTERNAL_TYPES`, such as ``connection_plugin``, are left out.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L286-306)

## madbot_cli.discover.value_example

*function*

```python
def value_example(param: Mapping, *, required: bool = True, title: str | None = None) -> Any
```

Give an example value of a metadata field, with the values to choose left to fill.

Unlike `example_of`, a closed list in a required place gives its first
value, so that the example is valid as written. A value chosen among
others in a list, or in a part that may be left out, stays a ``<…>``
value: the example does not pick a type of data or a language for the
reader. A list narrowed to one value by ``--search`` gives that value;
a free text stays a placeholder to replace. Every part of an object is
written, required or not.

**Parameters**

- `param` (`mapping`) — The field, or a part of it, as `describe` gives it.
- `required` (`bool`) (default: `True`) — Whether the value must be given where it is: false for a part that may be left out, or an item of a list.
- `title` (`str`) (default: `None`) — The title of the place, for the placeholder of a value without one, such as the item of a list.

**Returns**

- (`Any`) — The example.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L954-999)

## madbot_cli.discover.value_head

*function*

```python
def value_head(value: Mapping) -> dict
```

Introduce a value without a key by what it is.

**Parameters**

- `value` (`mapping`) — A value, as `describe` gives it.

**Returns**

- (`dict`) — The value, titled by `kind_of`, which already says it is a date.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1521-1538)

## madbot_cli.discover.variants_of

*function*

```python
def variants_of(schema: Mapping) -> list[dict]
```

List the forms an object may take, such as a password or a key.

**Parameters**

- `schema` (`mapping`) — A JSON Schema.

**Returns**

- (`list of dict`) — Each form of ``oneOf`` or ``anyOf`` that is not a constant, with its ``title``, ``description``, ``params`` and, for a form that is not an object (such as a date or a year), the ``value`` it is, as `describe` gives it (None for an object).

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L97-126)

## madbot_cli.discover.yaml_text

*function*

```python
def yaml_text(value: Any) -> list[str]
```

Write a value as YAML lines.

**Parameters**

- `value` (`Any`) — The value.

**Returns**

- (`list of str`) — Its lines.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/discover.py#L1180-1197)
