Package: dhi-platform
MIKE Cloud Platform SDK for PythonWhat is MIKE Cloud Platform SDK for Python?MIKE Cloud Platform SDK for Python allows you to programmatically access MIKE Cloud Platform from Python.
It also includes set of CLI tools to manipulate data and access services in MIKE Cloud Platform.Here is a small example:pltcfglogin--login
pltprjcreate--name"My project"pltprjlsSeethe documentationfor more examples.MIKE Cloud Platform SDK for Python is in development; some features are missing and there could be even bugs :-oRequirementsYou need Python 3.8 or later.
In Ubuntu, Mint and Debian you can install Python 3 like this:$ sudo apt-get install python3 python3-pip python3-wheel python3-cffi python3-cryptography python3-greenlet python3-gevent python3-yamlIn Alpine:$ apk add --no-cache bash python3 py3-pip py3-wheel py3-cffi py3-cryptography py3-greenlet py3-gevent py3-yamlFor other Linux flavors, macOS and Windows, packages are available athttps://www.python.org/getit/Quick startMIKE Cloud Platform SDK for Python and additional packages are installed using pip:$ pip install -U dhi-platformIf you want to run the latest stable version of the code, you can install from git:$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML
$ pip install -U git+https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py@masterOr if you want to run the latest development (unstable) version of the code from git:$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML
$ pip install -U git+https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py@developManual installation: get files from mike-platform-sdk-py repository (https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py). Add "src" directory to PYTHONPATH and "bin" directory to PATH. Install additional packages: azure-identity, azure-storage-blob, signalrcore, signalr-async and PyYAML:$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAMLNow, if Python on your system is configured properly (else see
"Troubleshooting" below) you can try CLI commands.
Please note that this example will try to use interactive authentication.
It opens a browser to interactively authenticate a user onWindowsoperating systems
or it authenticates users through the device code flow onLinuxsystems:plt
pltcfg
pltcfglogin-h
pltcfglogin--login
pltprjcreate--name"My project"pltprjls-v# switch to DEV environmentpltcfglogin--login-edev
pltprjls-v# back to PROD environmentpltprjls-v-eprodHow to authenticate in PythonWhen creating MIKE Cloud Platform clients in Python, you must provide credentials. There are two ways to do that:Using open api keyProvided you know your customer ID and that  you have a valid api key assigned to a project, you can create an identity and provide that to clients. Open API key for the MIKE CLoud Platform can be requested throughmike@dhigroup.comand assigned to projects using Data Admin UI application.Example:fromdhi.platform.authenticationimportApiKeyIdentityfromdhi.platform.metadataimportMetadataClientkey="<api key uuid>"identity=ApiKeyIdentity(apikey=key)client=MetadataClient(identity=identity)If you want to target a different environment than production, provide the optionalenvironmentparameter.Using interactive user loginIf you are an onboarded user, you can login interactively in a web browser.Example:fromdhi.platform.authenticationimportInteractiveIdentityfromdhi.platform.metadataimportMetadataClientidentity=InteractiveIdentity()client=MetadataClient(identity=identity)If you want to target a different environment than production, provide the optionalenvironmentparameter.
If you want to use account from the last login, useforcelogin=False(optional, default isforcelogin=True):identity=InteractiveIdentity(environment="test",forcelogin=False)Web site and documentationDocumentation and additional information is available at the web site:https://develop.mike-cloud.comOr you can jump straight to the documentation:https://develop.mike-cloud.com/docs/TroubleshootingDepending on your configuration, you may have to runpiplike this:$ pip install --no-deps -U dhi-platformThis doesn't automatically install the appropriate version of
azure-identity, azure-storage-blob, signalrcore, signalr-async and PyYAML.
You can install them manually:$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAMLIf thepltcommand isn't found after installation: Afterpip install, thepltscript and
dependencies, will be installed to system-dependent locations.
Sometimes the script directory will not
be inPATH, and you have to add the target directory toPATHmanually or create a symbolic link to the script.  In particular, on
macOS, the script may be installed under/Library/Frameworks:/Library/Frameworks/Python.framework/Versions/<version>/binIn Windows, the script is generally installed in\PythonNN\Scripts. So, type check a program like this (replace\Python38with your Python installation path):C:\>\Python38\python \Python38\Scripts\plt ...Working withvirtualenvIf you are usingvirtualenv,
make sure you are running a python3 environment. Installing viapip3in a v2 environment will not configure the environment to run installed
modules from the command line.$ pip install -U virtualenv
$ python3 -m virtualenv envDevelopment statusMIKE Cloud Platform SDK for Python is beta software.ChangelogIssue trackerLicenseMIKE Cloud Platform SDK for Python is licensed under the terms of the MIT License (see the file
LICENSE).