Managing Mambu Functions
  • 08 Aug 2024
  • 5 Minutes To Read
  • Dark
    Light
  • PDF

Managing Mambu Functions

  • Dark
    Light
  • PDF

Article summary

Once you have deployed your Mambu Functions you can manage them by deleting or updating them using the following commands. In most cases you will first need to list your deployed Functions to execute your commands on the right Function.

Listing deployed Mambu Functions

To see the Functions that you have already deployed to Mambu, run the command:

mambu functions list [--profile=PROFILE_NAME]

This will return a list of Functions that have been deployed, but they may not necessarily be bound to a product yet. See the Confirm that the Function has been deployed section for more on the flags and arguments that you can use in this command.

Updating a Mambu Function

To make an update to an already deployed Function you need to use the mambu functions update command, like so:

mambu functions update --functionDirectory=FUNCTION_DIRECTORY [--version=4] [--profile=PROFILE_NAME] [--functionName=FUNCTION_NAME]
ExampleDescriptionRequired
mambu functions updateThis part of the command is always required.YES
-d or --functionDirectoryThe local directory where your Mambu Function is located.YES
-n or --functionNameThe name of the Mambu Function, which can be changed when deploying your Function. The name can only contain letters, digits, and hyphens - and it can not be the same as a previously used name, unless you are updating a Function.NO
-v=1 or --version=3The default version is set to v1 if this flag is not used. For most cases, we recommend that you append a version number to your Function to keep track of versions that have been deployed.NO
-p or --profileThe profile flag allows you to use a different credentials profile, with a different Mambu API key and Mambu environment URL, for this command. If this is omitted, the default profile is used. For more information, see Using credentials profiles.NO
Please note
  • Version control for Mambu Functions that you create needs to be managed separately in your own systems (such as Git). It is not possible to pull deployed Functions from Mambu in order to update and redeploy them.
  • Ensure to run npm run build before updating the function.
  • Ensure not to update your function during End of the day batch job run as it might skew the results.

Deleting a Mambu Function

First list the Functions deployed to your Mambu environment to find the name of the Function you would like to delete. Functions that have already been bound to a product and are in use cannot be deleted.

The command to delete a Function from your Mambu environment is:

mambu functions delete --functionName=FUNCTION_NAME [--profile=PROFILE_NAME] [-y]
ExampleDescriptionRequired
mambu functions deleteThis part of the command is always required.YES
-n or --functionNameThe name of the Mambu Function. The name can only contain letters, digits, and hyphens - and it can not be the same as a previously used name unless you use the update flag.YES
-p or --profileThe profile flag allows you to use a different credentials profile, with a different Mambu API key and Mambu environment URL, for this command. If this is omitted, the default profile is used. For more information, see Using credentials profiles.NO
-y or --yesThis flag allows the command to complete without interrupting with the confirmation prompt.NO

A confirmation prompt will ask you to confirm that you would like to delete the Function. Type in Y to complete the action. After a 24-hour period the Function is fully deleted.

Retrieving Function logs

To retrieve the logs for a specific Function you can use the mambu functions logs command. You can only retrieve logs from the last two weeks.

mambu functions logs --functionName=FUNCTION_NAME [--profile=PROFILE_NAME] [--from=DATE_TIME_FROM] [--to=DATE_TIME_TO] [--limit=NUMBER] [--level=LOG_LEVEL] [--msgPattern=STRING_PATTERN] [--pretty] [--json]
ExampleDescriptionRequired
mambu functions logsThis part of the command is always required.YES
-n or --functionNameThe name of the Mambu Function. The name can only contain letters, digits, and hyphens - and it can not be the same as a previously used name unless you use the update flag.YES
-p or --profileThe profile flag allows you to use a different credentials profile, with a different Mambu API key and Mambu environment URL, for this command. If this is omitted, the default profile is used. For more information, see Using credentials profiles.NO
--from=DATE_TIME_FROMThe start of the time range in ISO 8601 format, for example: 2023-06-21T11:00:00Z. This value defaults to the last 10 minutes if both --from and --to are not specified.Yes, if the --to flag is used.
--to=DATE_TIME_TOThe start of the time range in ISO 8601 format, for example: 2023-06-21T12:00:00Z. The time range between --from and --to can be a maximum of one hour. This value defaults to the last 10 minutes if both --from and --to are not specified.Yes, if the --from flag is used.
-l=30 or --limit=30The maximum number of logs to be returned. The default is 100 and it must be an integer from 1 to 10,000.No
--level=WARNThe maximum log level to return. Possible values are TRACE (currently unused), ERROR, DEBUG, INFO, and WARN.No
--msgPattern=STRING_PATTERNThe pattern in the messages to be returned. Only exact substring match is supported.No
--prettyThis flag returns the logs as prettified text.No
--jsonThis flag returns the logs in JSON format.No

Creating multiple credentials profiles

In some cases you may want to use different credentials with a Mambu API key and Mambu environment URL that is different from the one you set when installing the Mambu CLI.

A more durable solution for credentials that you may use repeatedly is to create credentials profiles that store the API key and environment URL. In this way you can call up these details using a flag or by calling the profile, instead of having to repeatedly add an API key and an environment URL to your commands.

To create a credentials profile run the following command:

mambu configure --profile=PROFILE_NAME --apiKey=7g6f5e4d3c2b1a --url=MAMBU_TENANT.mambu.com [--yes]

or, using the shortened flags:

mambu configure -p=PROFILE_NAME -k=7g6f5e4d3c2b1a -u=MAMBU_TENANT.mambu.com [-y]
ExampleDescriptionRequired
mambu configureThis part of the command is always required and can be used without the profile flags below. Using it without the flags sets the default credentials.YES
-p or --profileThe name of the profile. This is used to call the profile when using its credentials in individual commands. If the profile name contains spaces or special characters, it should be bracketed by quotation marks. For example: -p="This is a profile name!".YES
-k or --apiKeyThe Mambu API key attached to the named profile.YES
-u or --urlThe URL of the Mambu environment attached to the named profile.YES
-y or --yesThis flag allows the command to complete without interrupting with the confirmation prompt.NO

Using credentials profiles

There are two ways to use a credentials profile:

You can switch profiles so that any commands that follow use the profile that you have switched to.

export MAMBU_PROFILE="PROFILE_NAME"

Or, you can use the -p or --profile flag to define the credentials profile to use for that particular command.

mambu functions delete --functionName=my-function --profile=PROFILE_NAME

Listing profiles

You can use the list-profiles command to list all profiles:

mambu list-profiles

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence