Building a client

Import an LMCTL client module into Python, and then use it to write Python code that works with the orchestration component:

To build the LMCTL client module, use client_Builder, as shown in the following example.

from lmctl.client import client_builder

cp4na_client = client_builder().address('https://cp4na-ishtar.example.com').client_credentials_auth('LmClient', 'admin').build()

You can use client_Builder to configure the following types of authentication:

# Zen Authentication (CP4NA 2.2+ on OCP)
cp4na_client = client_builder().address('https://cp4na-ishtar.example.com').zen_api_key_auth(username='MyUser', api_key='MyKey', zen_auth_address='https:/cpd-lifecycle-manager.apps.example.com//icp4d-api/v1/authorize').build()

# Client Credentials (environments without Zen)
cp4na_client = client_builder().address('https://cp4na-ishtar.example.com').client_credentials_auth(client_id='LmClient', client_secret='admin').build()

# UI Username/Password (environments without Zen)
cp4na_client = client_builder().address('https://cp4na-ishtar.example.com').legacy_user_pass_auth(username='almadmin', password='mypass', legacy_auth_address='https://cp4na-nimrod.example.com').build()

# Client based Username/Password (environments without Zen)
cp4na_client = client_builder().address('https://cp4na-ishtar.example.com').legacy_user_pass_auth(client_id='LmClient', client_secret='admin', username='almadmin', password='mypass').build()