Help Center> ROMA Connect> User Guide> Service Integration Guide (Old Edition)> Exposing APIs> (Optional) Creating the Environment and Environment Variables
Updated on 2023-05-17 GMT+08:00

(Optional) Creating the Environment and Environment Variables

Overview

An environment refers to the usage scope of an API. An API can be called only after it is published in an environment. APIs can be published in different customized environments, such as the development environment and test environment. RELEASE is the default and formal publishing environment of the system.

Environment variables are specific to environments. If environment variables are defined in backend information of an API, you need to add the variables to the environment. You can create variables in different environments to call different backend services using the same API.

For example, when an API is created, variable Path is defined in the backend request path. Two variables with the same name are respectively created and assigned values /Stage/test and /Stage/AA in environments 1 and 2. If the API is published and called in environment 1, the path /Stage/test is used. If the API is published and called in environment 2, the path /Stage/AA is used.

Figure 1 Application of environment variables

Creating an Environment

  1. Log in to the ROMA Connect console. On the Instances page, click View Console of an instance.
  2. In the navigation pane on the left, choose API Connect > API Management. On the Environments tab page, click Create.
  3. In the dialog box displayed, configure environment information and click OK.
    Table 1 Parameters for creating an environment

    Parameter

    Description

    Name

    Enter an environment name. It is recommended that you enter a name based on naming rules to facilitate search.

    Description

    Enter a brief description of the environment.

    When a user needs to call an open API, the API in the RELEASE environment is called by default. To access an API in another environment, add the X-Stage parameter to the header of the API request. The parameter value is the environment name. For example, to access an API in the Develop environment, add X-Stage: Develop to the header of the API request.

Creating an Environment Variable

  1. Log in to the ROMA Connect console. On the Instances page, click View Console of an instance.
  2. In the navigation pane on the left, choose API Connect > API Management. On the API Groups tab page, click More > Manage Variable in the Operation column of the target API group.
  3. Select the environment for which you want to add a variable and click Create Variable.
  4. In the dialog box displayed, configure environment variable information and click OK.
    Table 2 Parameters for creating an environment variable

    Parameter

    Description

    Name

    Enter the variable name, which must be the same as that defined in the API backend service information.

    Value

    Enter the value of the environment variable.