Reusing Connections
## Overview
Modules represent functions in the backend (e.g. Customers, Accounts, Users). When those functions reside on the same backend, Modules use the same connection details.
Instead of cloning the connection details by value for every different Module, Connection objects can be created that are referenced by every module in the same backend. Note that modifying the Connection profile will apply to all the modules using this Connection profile.
## Connection Profile
* A Connection object can contain multiple Profiles (Default + Profiles).
* A user can Create/Edit/Delete a Connection and its Profiles.
* Connection Name
* Connection Description
* Connection Attachments
* Referring Modules
* For a Connection created with a Default Profile, the user may:
* Add a Profile
* Edit the Profile
* Delete the Profile (except from the Default)
## Create a Connection
1. Select **Connections** from the menu.
<Image align="center" width="100px" src="https://files.readme.io/91efb5e-Connections_menu.png" />
<Image align="center" width="00px" src="https://files.readme.io/982fde8-Connections_menu.png" />
2. Press **+ Create Connection**.
<Image align="center" src="https://files.readme.io/d4a2990-Create_Connection.png" />
3. The **Create New Connection** window opens.
<Image align="center" width="300px" src="https://files.readme.io/409ab63-Create_New_Connection_Type.png" />
<Image align="center" width="1px" src="https://files.readme.io/749b740-Create_New_Connection_Type.png" />
4. Type a **Connection Name** and select a **Backend Type** from the list. Press the **Create Connection** button to create the connection with a default profile.
<Image align="center" width="400px" src="https://files.readme.io/503ae1b-Create_New_Connection_Type_Profile.png" />
5. The new connection appears on the **Connections** page.
<Image align="center" src="https://files.readme.io/c4f9007-New_Connection.png" />
6. To add or edit a Connection Profile, click on the Connection icon:
<Image align="center" src="https://files.readme.io/1b1524d-New_Connection_Edit.png" />
7. The default Connection Profile is displayed:
<Image align="center" src="https://files.readme.io/4cb5ad0-Default_Connection_Profile.png" />
8. To edit the default profile, press the edit icon .
9. To add a profile, press **+ Add profile**. Enter a **Profile name** and edit the **Connection Profile Details**. Then press the **Create** button.
<Image align="center" src="https://files.readme.io/422fb0c-Create_Connection_Profile.png" />
10. The new Connection Profile is displayed.
* You may enter a description for the new profile by pressing the **Description**  icon.
* To delete the profile, press the  icon.
* To test the profile, press the test  icon.
* Note that the new profile inherits fields that are not modified from the default profile.
<Image align="center" src="https://files.readme.io/1b66802-New_Connection_Profile.png" />
<Image align="center" width="0px" src="https://files.readme.io/117cc9c-New_Connection_Profile.png" />
11. Note that if you try to edit an existing profile, you will be prompted to confirm.
<Image align="center" width="300px" src="https://files.readme.io/c6eeb22-Connection_profile_warning.png" />
## Connections List
The **Connections** page displays the list of connections with the following properties:
* Connection name
* Connection description
* Backend Type
* Last update
* Last updater
* Profiles list
* Referring Modules list
## Using Connections
### With New Module
1. On the **Modules** page, press **+ Create Module**.
<Image align="center" src="https://files.readme.io/cb5d4e3-Create_Module.png" />
2. The **Select Connector** page is displayed.
<Image align="center" src="https://files.readme.io/85b5103-Create_Module_Select_Connector_1.png" />
3. Use the **Filter** to select the backend type.
<Image align="center" src="https://files.readme.io/67df4b1-Create_Module_Select_Connector_2.png" />
4. Select one of the connector backend types by clicking on it.
<Image align="center" src="https://files.readme.io/48efa90-Create_Module_Select_Connector_3.png" />
5. Press the **Create Module from the Connector** button. Type the new **Module Name**. To use an existing Connection, choose **Select Connection** and select from the list of available connections..
<Image align="center" src="https://files.readme.io/5a0d089-Create_Module_Select_Connector_6.png" />
6. Press the **Done** button to save the new module.
7. The new module appears on the **Modules** page.
<Image align="center" src="https://files.readme.io/f808e58-Create_Module_Select_Connector_7.png" />
### With Existing Module
1. On the **Modules** page, click on the Module to select.
<Image align="center" src="https://files.readme.io/d1ea4a3-Select_Module_1.png" />
2. Click on the  icon adjacent to the module name and select **Change connection** from the dropdown menu.
<Image align="center" src="https://files.readme.io/bf2aa96-Select_Module_2.png" />
3. On the **Change Connection references** page, select a connection from the existing connections and press **Replace**.
<Image align="center" src="https://files.readme.io/0d3d797-Select_Module_3.png" />
4. A confirmation window opens. Press the **Apply** button to replace the connection.
<Image align="center" className="border" style={{ border: "true" }} src="https://files.readme.io/bdad96d-Select_Module_4.png" />
5. The module is displayed with the selected connection indicated by the  icon next to the connection name.
<Image align="center" src="https://files.readme.io/be8b28c-Select_Module_5.png" />
## Using Connections in the CLI
### Commands
#### ol list connections
Usage: ol list connections [OPTIONS]
Display OL-HUB connections list
Options: --verbose Enables verbose mode --verbose-debug Enables debug mode --verbose-trace Enables trace mode -l, --limit INT The total number of connections to return in the command's output -o, --offset INT An offset to specify where to start paginating -f, --filter TEXT RegEx filter by connections names -h, --help Show this message and exit
**Example**
The command output includes the connection **Id**, **Name**, **Connector Type** and **Description**.
C:\WINDOWS\system32>ol list connections
DONE
Id Name Connector Type Description
a1ec7302-d17f-4ec2-a0da-8b0a05e0a117 demo-account-default-connection oracle_db Auto-generated connection for module demo-account 8ced1e55-fbce-4773-bfae-087ed9e19a36 m-as400-screens-default-connection as400Screens Auto-generated connection for module m-as400-screens 30b4d357-0407-464a-a586-e1437890032c as400-screens-default-connection as400Screens Auto-generated connection for module as400-screens 0129e054-0712-48c3-885a-ce1f073d7404 as400 as400Rpc as400 b23c9289-2057-4d0c-90af-9f3f904aad41 as400-pcml as400Rpc
#### ol create module MODULE\_NAME --connector `<connector type>`
Example:
ol create module as400-cobol --connector as400-cobol
The new module is created with the default connector type and default profile.
## Linking Connections between the CLI and the OL Hub
The Connection is an OL Hub object. It does not exist in the CLI until the Module is pushed to the Hub.
Therefore, if you create a Module in the CLI, it behaves as follows:
* Running the **ol test connection** command in the CLI will store the connection details in the profile (no Hub connection yet).
* When you push the module to the Hub, it will create a new Connection for the profile/s or use the Hub Module Connection if it already exists.
* If you link an existing Connection to the Module, then the Module Connection and its profiles are copied to the module.json. When you push the Module to the Hub, it will use the Module Connection that you've linked.
Updated 1 day ago