---
title: Charmhub | Deploy FINOS Legend Database Manager using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of FINOS Legend Database Manager as a Kubernetes
  Operator on any cloud.
url: https://charmhub.io/finos-legend-db-k8s/libraries/legend_database
---

# FINOS Legend Database Manager

[FINOS](https://charmhub.io/publisher/finos-charmers "View all packages from FINOS")

* [FINOS](https://charmhub.io/publisher/finos-charmers "View all packages from FINOS")

Platform:

stable 22

```
juju deploy finos-legend-db-k8s
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#drawer)

## charms.finos\_legend\_db\_k8s.v0.legend\_database

* [*Docstrings*Docstrings](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database)
  [*Code*Source code](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.finos_legend_db_k8s.v0.legend_database
    ```

    [Download legend\_database.py](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database/download)
  + *Last updated* 22 Oct 2021
  + *Revision* Library version 0.4

Module defining Legend DB consumer class and helpers.

---

Index

* [def get\_database\_connection\_from\_mongo\_data(
  mongodb\_consumer\_data,
  mongodb\_databases
  )](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#get_database_connection_from_mongo_data)
* [def set\_legend\_database\_creds\_in\_relation\_data(
  relation\_data,
  creds
  )](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#set_legend_database_creds_in_relation_data)
* [class LegendDatabaseConsumer](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#legenddatabaseconsumer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#legenddatabaseconsumer-__init__)
* + [def get\_legend\_database\_creds(
    self,
    relation\_id)](https://charmhub.io/finos-legend-db-k8s/libraries/legend_database#legenddatabaseconsumer-get_legend_database_creds)

#### def get\_database\_connection\_from\_mongo\_data(     mongodb\_consumer\_data,     mongodb\_databases )

Returns a dict with Mongo connection info for Legend components.

Arguments

mongodb\_consumer\_connection

connection data as returned by
charms.mongodb\_k8s.v0.mongodb.MongoConsumer.connection()
Should be a dict of the following structure: {
"username": "user",
"password": "pass",
"replica\_set\_uri": "Replica set URI with user/pass/login DB"
}

mongodb\_databases

List of database names as returned by
charms.mongodb\_k8s.v0.mongodb.MongoConsumer.databases()

Returns

Dictionary with the following structure:
{
"uri": "<replica set URI (with user/pass, no DB name)>",
"username": "<username>",
"password": "<password>",
"database": "<database name>"
}

Description

Output is compatible with `LegendDatabaseConsumer.get_legend_database_creds()`.

#### def set\_legend\_database\_creds\_in\_relation\_data(     relation\_data,     creds )

Set connection data for MongoDB from the provided relation data.

Arguments

relation\_data

Data of the relation to set the info into.

Returns

True if the provided creds are of a valid structure, else False.

#### class LegendDatabaseConsumer

Description

Class which facilitates reading Legend DB creds from relation data. None

Methods

LegendDatabaseConsumer.
\_\_init\_\_(

*self*

,
charm

,
relation\_name
)

LegendDatabaseConsumer.
get\_legend\_database\_creds(

*self*

,
relation\_id
)

Get connection data for MongoDB from the provided relation.

Description

Args:
relation\_id: ID of the relation to fetch data from.

Returns:
Dictionary with the following structure:
{
"uri": "<replica set URI (with user/pass, no DB name)>",
"username": "<username>",
"password": "<password>",
"database": "<database name>"
}

Raises:
TooManyRelatedAppsError if relation id is not provided and
multiple relation of the same name are present.
