(Optional) Configuring the Environment and Environment Variables
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.
Example: an API whose variable Path is defined in the backend request path. If variable Path is configured for environment 1 and is assigned value /Stage/test, use the backend request path /Stage/test to call this API in this environment. If variable Path is configured for environment 2 and is assigned value /Stage/AA, use the backend request path /Stage/AA to call this API in this environment.
Creating an Environment
- Go to the APIG console.
- Select a dedicated gateway at the top of the navigation pane.
- In the navigation pane, choose API Management > API Policies.
- Click the Environments tab.
- Click Create Environment and set the environment information.
Table 1 Environment information Parameter
Description
Name
Environment name.
Description
Description of the environment.
- Click OK.
After the environment is created, it is displayed in the environment list.
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, where the parameter 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
- Go to the APIG console.
- Select a dedicated gateway at the top of the navigation pane.
- Choose API Management > API Groups.
- Click a group name.
- Click the Group Information tab.
- In the Environment Variables area, select an environment. If no environment is available, click Create Environment to create one.
- Click Add Environment Variable and enter the variable information.
- Environment variable names and values will be displayed in plain text in API requests. Do not include sensitive information in the variable names and values.
- APIG does not support API debugging with environment variables.
Table 2 Adding an environment variable Parameter
Description
Name
Variable name. Ensure that the name is the same as the name of the variable defined for the API.
Value
The path to be used in the selected environment.
- Click OK.
Follow-Up Operations
You can publish an API in the environment for calling.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot