Uploading NPL code
This section explains how to deploy NPL application code to NOUMENA Cloud.
You have various tools to deploy NPL sources:
Deployment tool | Project code in GitHub Codespace | Project code on local machine |
---|---|---|
Portal (zip upload) | ✅ | |
Command line (NPL CLI) | ✅ | ✅ |
VS Code NPL-Dev plugin | ✅ | ✅ |
IntelliJ NPL-Dev plugin | ✅ |
If you are new to NPL and NOUMENA Cloud, or if you are starting your project from scratch, start with a readily usable NPL example in GitHub Codespaces or on your local machine.
If you already have NPL source code, jump to section Checking NPL source structure.
Starting from an example
Use the example NPL code provided by the npl-init
repository to get a quick start with NPL and NOUMENA Cloud.
Several options are available to you, depending on where you want to keep the example code, for inspection and upload to NOUMENA Cloud:
- Choose Codespaces if you do not want to install nor copy anything on your machine (requires a GitHub account with Codespaces access).
- If you prefer to work on your machine, create a local copy of the example project using the NPL CLI or zip file download.
- Open the
npl-init
repository page - Log into GitHub if not already done
- At the top right of the npl-init repository page, click
Use this template
- Select
Open in a Codespace
. The Codespace will take a few seconds to open
Among other things, your Codespace comes pre-configured with
- the NPL CLI, which allows deployment from the Codespace console
- the NPL-Dev plugin for VS Code, which allows deployment from the Codespace GUI
Browse the NPL source code in the Codespace File panel, and proceed directly to upload NPL with the NPL CLI or with the VS Code NPL-Dev plugin.
To learn more about developing NPL in GitHub Codespaces, check out this starter tutorial.
- If not already done, install the NPL CLI
-
In a terminal window, create a copy of the standard NPL example project with:
npl init --projectDir my-project
This command will create a new directory called my-project
containing the example NPL package, with the
appropriate structure for upload to NOUMENA Cloud in the api/src/main
subfolder.
From there, you can proceed directly to upload using the NOUMENA Cloud Portal UI, the NPL CLI, or an IDE NPL-Dev plugin.
- Download the
npl-init
project as zip file - Unzip the file on your machine.
The unzipped folder contains the example NPL package, with the appropriate structure
for upload to NOUMENA Cloud in the api/src/main
subfolder.
From there, you can proceed directly to upload using the NOUMENA Cloud Portal UI, the NPL CLI, or an IDE NPL-Dev plugin.
To find our more about the example code, check out the Creating a new NPL project tutorial.
Checking NPL source structure
Your NPL sources should have the following elements for inclusion in a deployment to NOUMENA Cloud:
.
└── <npl module sources directory> (e.g. api/src/main)
├── migration.yml
├── npl (see comment about naming below)
│ ├── <npl package> (e.g. greetings)
│ │ ├── <npl source file> (e.g. hello.npl)
│ │ └── <npl source file> (e.g. bye.npl)
│ └── <npl package>
│ └── <npl source file>
└── rules (see comment about naming below)
└── rules.yml (optional)
Key files and folders in the structure are:
migration.yml
: Migration descriptor file to manage application code migrations, required for any deploymentnpl
: NPL sources, required for any deploymentrules.yml
: Party Automation descriptor file to enable the automatic creation of parties using the attributes in the user's authorization token (optional)
The naming of the npl
directory and rules.yml
file and their path relative to the migration.yml
file must match
the values used in the migration.yml
file. The npl
directory can be named e.g. npl-1.2.3
(versioning pattern in
case of migrations) or another name of your choice, but the migration.yml
file must refer to the same name in the
changeset to be applied. Refer to the
Migration descriptor documentation for details.
Uploading NPL sources
Option 1: Upload NPL from the NOUMENA Cloud Portal
Using the NOUMENA Cloud Portal, you can manually upload NPL sources stored on your local machine.
-
Create a zip archive of the NPL sources folder containing the
migration.yml
file, the.npl
files and the (optional) party automation rules file (e.g. zip folderapi/src/main
in thenpl-init
example project) -
Navigate to the application in the NOUMENA Cloud Portal
-
Select
Upload package
from the top-right corner. If you have previously deployed NPL sources, select...
next to the date of last deployment appearing top right, thenUpdate package
If you are deploying NPL source code again to the same application, make sure to clear the existing package first or implement a migration for the changes to take effect.
To clear NPL sources from the app, go to the
Settings
tab in your application view, then selectClear package
and confirm withProceed
. Then proceed withUpload package
as described above. -
Browse to select the zip file created in step 1, and click
Upload
-
Wait for deployment to complete (indicated by a success message)
Option 2: Upload NPL with the NPL CLI
Whether you are working in GitHub Codespaces or on your local machine, you can use the NPL CLI to upload NPL sources.
-
If not already done, install the NPL CLI
-
Authenticate with NOUMENA Cloud to connect your NPL CLI to your NOUMENA Cloud account:
npl cloud login
Follow the authentication prompts to complete the login process. This will store your authentication credentials locally for future deployments.
-
From the root of your project (e.g.
npl-init
ormy-project
if you started from the NPL starter example above), deploy your NPL source code to NOUMENA Cloud with:npl cloud deploy npl \ --tenant YOUR_TENANT_SLUG \ --app YOUR_APPLICATION_SLUG \ --migration api/src/main/migration.yml
Replace
YOUR_TENANT_SLUG
with your tenant slug andYOUR_APPLICATION_SLUG
with your application slug from your NOUMENA Cloud portal. Adjust the path to your migration file as needed. In the absence of--migration
parameter, this defaults to the directory from which the command is executed.If you are deploying NPL source code again to the same application, make sure to clear the existing package first or implement a migration for the changes to take effect. To clear NPL sources from the app, run:
npl cloud clear \ --tenant YOUR_TENANT_SLUG \ --app YOUR_APPLICATION_SLUG
Option 3: Upload NPL with the VS Code NPL-Dev plugin
For developers working in VS Code, Cursor, or GitHub Codespaces, direct deployment is supported.
-
If not already done, install the NPL-Dev plugin for VS Code
-
Open your project in VS Code (e.g.
npl-init
ormy-project
if you started from the NPL starter example above) -
In the VS Code sidebar, select the NOUMENA icon to open the NOUMENA Cloud panel
-
Click
Sign in to NOUMENA Cloud
, provide your NOUMENA Cloud credentials in the browser window, and selectYes
when prompted toGrant Access to PaaS
-
The NOUMENA Cloud panel of your VS Code editor should now display your NOUMENA Cloud tenants and applications. If not, click the refresh icon
-
Hover or click on your target application, select
Deploy application
, thenNPL Backend
in the action menuIf you are deploying NPL source code again to the same application, make sure to clear the existing package first or implement a migration for the changes to take effect.
To clear NPL sources from the app, select the
Clear deployed NPL application
next to your application in the NOUMENA Cloud panel. -
Wait for deployment to complete (indicated by a success message in the VS Code notification area)
Option 4: Upload NPL with the IntelliJ NPL-Dev plugin
For developers working in IntelliJ IDE, direct deployment is supported.
-
If not already done, install the NPL-Dev plugin for IntelliJ IDEA
-
Open your project in IntelliJ (e.g.
npl-init
ormy-project
if you started from theNPL starter example above)
-
In the top-right corner of IntelliJ, select
Current File
>Edit Configurations
-
Choose
Add new configuration
>Deploy to PaaS
-
Configure the deployment with:
- Name: "Deploy"
- Server base URL: https://portal.noumena.cloud
- Application ID: Found on the settings tab of your app in the NOUMENA Cloud Portal
- Username: Your NOUMENA Cloud email address
- Password: Your NOUMENA Cloud password
- Source path: The absolute path to the main directory containing the
migration.yml
file - Delete existing application and data before deployment: Check this option to remove any previous deployments and protocol instance.
You need to select the
Delete existing application and data
option or write a migration for changes to deployed NPL code to take effect. -
Click
Ok
to save the configuration -
In the top-right corner of IntelliJ, click
Run Deploy
-
Wait for deployment to complete (indicated by a success message in the IntelliJ console)
Verification
Once deployment completes, you'll see the status change in the NOUMENA Cloud Portal. You can also navigate to the Services tab of the application and visit the Swagger UI to check that the NPL code has been deployed successfully.
Next Steps
Now that your NPL application is deployed, continue to Creating users in Keycloak to set up authentication for your application.