Copyright © Huawei Technologies Co., Ltd. 2018. All rights reserved.No part of this document may be reproduced or transmitted in any form or by any means without prior writtenconsent of Huawei Technologies Co., Ltd. Trademarks and Permissions
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei and thecustomer. All or part of the products, services and features described in this document may not be within thepurchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information,and recommendations in this document are provided "AS IS" without warranties, guarantees orrepresentations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.
Huawei Technologies Co., Ltd.Address: Huawei Industrial Base
Bantian, LonggangShenzhen 518129People's Republic of China
Website: http://www.huawei.com
Email: [email protected]
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. i
Contents
1 Overview......................................................................................................................................... 1
2 API Gateway and Other Services............................................................................................... 2
3 Experiencing the Demo................................................................................................................ 3
4 Getting Started............................................................................................................................... 54.1 Overview........................................................................................................................................................................ 54.2 Creating an API Group................................................................................................................................................... 64.3 Creating an API.............................................................................................................................................................. 74.4 (Optional) Creating an environment.............................................................................................................................154.5 Publishing an API.........................................................................................................................................................164.6 Querying Information................................................................................................................................................... 17
5 API Group..................................................................................................................................... 215.1 Creating an API Group................................................................................................................................................. 215.2 Creating an Environment Variable............................................................................................................................... 225.3 Binding a Domain Name.............................................................................................................................................. 235.4 Editing an API Group................................................................................................................................................... 245.5 Deleting an API Group................................................................................................................................................. 25
6 API Management......................................................................................................................... 276.1 Creating an API............................................................................................................................................................ 276.2 Creating an API with the OPTIONS Method...............................................................................................................356.3 Authorizing an API.......................................................................................................................................................436.4 Editing an API.............................................................................................................................................................. 446.5 Publishing an API.........................................................................................................................................................526.6 Publication History....................................................................................................................................................... 526.7 Removing an API......................................................................................................................................................... 536.8 Debugging an API........................................................................................................................................................ 546.9 Canceling Authorization...............................................................................................................................................556.10 Deleting an API.......................................................................................................................................................... 56
7 Request Throttling...................................................................................................................... 587.1 Creating a Throttling Policy......................................................................................................................................... 587.2 Associating a Throttling Policy with an API................................................................................................................607.3 Editing a Throttling Policy........................................................................................................................................... 61
API GatewayUser Guide (API Publishing) Contents
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. ii
7.4 Deleting a Throttling Policy......................................................................................................................................... 637.5 Adding an Override Application.................................................................................................................................. 637.6 Disassociating a Throttling Policy from an API...........................................................................................................647.7 Deleting an Override Application.................................................................................................................................65
8 Access Control..............................................................................................................................668.1 Creating an Access Control Policy...............................................................................................................................668.2 Associating an Access Control Policy with an API..................................................................................................... 678.3 Editing an Access Control Policy.................................................................................................................................688.4 Deleting an Access Control Policy...............................................................................................................................698.5 Disassociating an Access Control Policy from an API................................................................................................ 69
9 Environment Management........................................................................................................ 719.1 Creating an Environment..............................................................................................................................................719.2 Accessing an Environment........................................................................................................................................... 729.3 Editing an Environment................................................................................................................................................729.4 Deleting an Environment..............................................................................................................................................73
10 Signature Key............................................................................................................................. 7410.1 Creating a Key............................................................................................................................................................ 7410.2 Editing a Key.............................................................................................................................................................. 7510.3 Associating a Signature Key with an API.................................................................................................................. 7610.4 Disassociating a Signature Key from an API............................................................................................................. 7710.5 Deleting a Key............................................................................................................................................................ 78
11 VPC Link..................................................................................................................................... 7911.1 Creating a VPC Link...................................................................................................................................................7911.2 Editing a VPC Link.....................................................................................................................................................8111.3 Deleting a VPC Link...................................................................................................................................................8311.4 Editing Health Check Configurations.........................................................................................................................8411.5 Editing ECS Configurations....................................................................................................................................... 85
12 Auditing...................................................................................................................................... 87
13 Monitoring.................................................................................................................................. 8813.1 API Gateway Metrics................................................................................................................................................. 8813.2 Creating Alarm Rules................................................................................................................................................. 8813.3 Viewing Metrics..........................................................................................................................................................89
14 FAQs.............................................................................................................................................9114.1 How Is API Gateway Charged?..................................................................................................................................9114.2 What Are the Relationships Between an API, Environment, and App?.................................................................... 9214.3 How Can I Use API Gateway?................................................................................................................................... 9214.4 Why Does a Backend Service Fail to Be invoked?.................................................................................................... 9214.5 What Is an Error Message Returned by API Gateway Like?..................................................................................... 9314.6 Do I Need to Publish an API Again After Modification?.......................................................................................... 9314.7 How Can I Protect My APIs?..................................................................................................................................... 93
API GatewayUser Guide (API Publishing) Contents
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. iii
14.8 Can Mobile Applications Call APIs?......................................................................................................................... 9314.9 Can I Upload Files Using the POST Method?........................................................................................................... 9314.10 Can Applications Deployed in a VPC Call APIs?....................................................................................................9314.11 How Can I Ensure the Security of Backend Services Invoked by API Gateway?................................................... 9714.12 What SDK Languages Does API Gateway Support?...............................................................................................9714.13 How Can I Make an API Published in a Non-RELEASE Environment Accessible?..............................................9714.14 Does API Gateway Support Multiple Backend Endpoints?.....................................................................................9714.15 What Is the Maximum Size of an API Request Package?........................................................................................97
A What's New..................................................................................................................................98
API GatewayUser Guide (API Publishing) Contents
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. iv
1 Overview
API Gateway is a high-performance, high-availability, and high-security API hosting servicethat helps enterprises to build, manage, and deploy APIs at any scale. With just a few clicks,you can implement system integration, microservice aggregation, and serverless architectureswhile minimizing costs and risks.
API Gateway is suitable for diversified API opening scenarios. In addition to opening cloudservice capabilities of HUAWEI CLOUD, API Gateway enables you to enjoy secure,convenient, and efficient API services. Furthermore, API Gateway provides full API hostingservices, such as publishing, maintaining, and monitoring APIs, so that you can focus onservice development and quickly commercialize IT capabilities.
Figure 1-1 API Gateway overview
API GatewayUser Guide (API Publishing) 1 Overview
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 1
2 API Gateway and Other Services
Elastic Cloud Server (ECS)ECS allows you to obtain scalable cloud servers at any time. If your backend services aredeployed on ECS, you can use VPC links to access them without the need for ECS to enablepublic network access. This ensures network access security of the backend services. VPClinks support load balancing, which improves the response speed of ECS and reduces itspressure.
FunctionGraphFunctionGraph enables you to orchestrate service processes in a visualized manner, andcoordinates a series of function components to control service processes. API Gateway can beused as a trigger of the backend FunctionGraph. With an API Gateway trigger, computingfunctions can be invoked by calling APIs.
Cloud EyeCloud Eye is a secure, scalable monitoring platform in the public cloud. It monitors APIGateway service metrics, and sends notifications when alarms or events occur.
CTSCloud Trace Service (CTS) provides records of operations on cloud service resources,allowing you to query, audit, and backtrack the resource operation requests initiated from themanagement console or open APIs as well as responses to the requests.
API GatewayUser Guide (API Publishing) 2 API Gateway and Other Services
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 2
3 Experiencing the Demo
Scenario
This demo shows how to use API Gateway to create and publish an API for querying mobilenumber home locations and associate a request throttling policy with the API with a fewclicks.
NOTE
If you want to experience the demo again, first delete the API and API group created in the demo.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
The navigation pane contains four columns: Dashboard, API Publishing, API Calling, andHelp Center.
Step 4 In the navigation pane, choose Dashboard.
Step 5 Click Experience Demo.
The system automatically performs the following operations:
l Creating an API group.
l Creating an API.
l Publishing the API in the RELEASE environment.
l Creating a request throttling policy.
l Associating the request throttling policy with the API.
Step 6 Click Call API.
Step 7 Enter a mobile number to be queried in the value column, click Send Request, and then viewthe return result.
API GatewayUser Guide (API Publishing) 3 Experiencing the Demo
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 3
Step 8 Call the API.
1. Choose API Publishing > API Management, and click QueryPhoneNumber.
2. On the Monitoring tab page, click to copy the URL.
3. Paste the URL in the address bar of a browser, replace {phoneNumber} with a mobilenumber to be queried, and press Enter to view the home location of the mobile number.
----End
API GatewayUser Guide (API Publishing) 3 Experiencing the Demo
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 4
4 Getting Started
Overview
Creating an API Group
Creating an API
(Optional) Creating an environment
Publishing an API
Querying Information
4.1 OverviewTo open one or a group of APIs, you need to do the following:
1. Creating an API groupAn API group is a collection of APIs.
2. Creating an APIWhen creating an API, you need to configure the request path, parameters, andprotocols.
3. (Optional) Creating an environmentAPIs can be called in different scenarios, such as the production environment(RELEASE) and other customized environments. The RELEASE environment is thedefault one.
4. Publishing an APIAn API can be called only after it has been published in an environment.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 5
NOTICEl Ensure that the backend services are accessible.
l API Gateway transfers the packet body to backend services by default. If the contentcontains private or sensitive user information, the API developer is advised to provide anencrypted transmission mechanism to prevent leakage of such information.
l API Gateway transfers the user IP address in the request packet header to backend servicesby default. If the user IP address is private or sensitive information, the API developershould provide privacy statement to the API caller.
4.2 Creating an API Group
Scenario
An API group is a collection of APIs. This section describes how to create an API group tomanage APIs.
NOTE
l An API can belong to only one API group.
l You can create a maximum of 50 API groups.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Groups.
Step 5 Click Create API Group. On the Create API Group page, set the parameters listed in Table4-1.
Table 4-1 Parameters
Parameter Description Value
Group Name Name of the API group, which isused to manage APIs
l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 6
Parameter Description Value
Description Description of the API group Cannot contain more than 255characters.
Step 6 After setting the required information, click OK.
After the API group is created, it is displayed in the API group list on the API Groups page.
NOTE
l The system automatically allocates a subdomain name to the API group for internal test. Thesubdomain name can be accessed up to 1000 times a day.
l To open APIs, you need to bind the API group to an independent domain name or a domain nameissued by the marketplace.
----End
4.3 Creating an API
ScenarioConfigure an API in API Gateway to open service capabilities.
NOTE
l API Gateway is based on the API architecture of REST. Opening or calling APIs must comply withRESTful specifications.
l You create a maximum of 200 APIs.
Prerequisitesl An API group has been created. If no API group is available, you can click the Create
API Group link to create one.l If a VPC link is required for backend services, create one by following the procedure in
Creating a VPC Link or by clicking Create VPC Link.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Click Create API. On the Create API page, set the parameters listed in Table 4-2.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 7
Table 4-2 Basic information
Parameter Description Value
API Name Name of the API l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
API Group Group to which the API belongs If no API group has been created,click Create API Group to createan API group first.
Type There are two types of APIs:l Public: The API is open to the
public.l Private: The API is not open to
the public.
l If you select Public, the API canbe made available for sale in themarketplace.
l If you select Private, the APIwill not be available for salewhen the API group to which itbelongs is launched to themarketplace.
SecurityAuthentication
There are three authenticationmodes:l APP: indicates that API
Gateway performs securityauthentication on API requests.
l IAM: indicates that the Identityand Access Management(IAM) service is used forsecurity authentication.
l NONE: indicates thatauthentication is not required.
The API calling method variesdepending on the authenticationmode. For details, see the APIGateway Developer Guide.The APP authentication mode isrecommended.NOTICE
l When the authentication mode is setto IAM, any HUAWEI CLOUDtenant can access the API, whichmay result in excessive chargingcaused by malicious requests.
l If the authentication mode is set toNONE, any public network user canaccess the API, which may result inexcessive charging caused bymalicious requests.
Description Description of the API (Optional) Contains 0 to 255characters.
Step 6 Click Next. On the Define API Request page, set the parameters listed in Table 4-3.
Table 4-3 Defining API requests
Parameter Description Value
DomainName
Domain name A subdomain name is assigned bydefault.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 8
Parameter Description Value
RequestProtocol
Options:l HTTPl HTTPSl HTTP&HTTPS
HTTPS is recommended fortransmitting important or sensitivedata.
Request Path API request path The format is /{serviceName}/{interfaceName}.l The content in {} is case-
sensitive.l If the request path contains
request parameters, you mustdefine the request parameters asinput parameters.
MatchingMethod
There are two modes:l Exact matchl Prefix match
l If you select exact match, therequest path is fixed to the APIrequest path configured duringcreation.
l If you select prefix match, therequest path uses the API requestpath configured during creationas the prefix, and multiple pathscan be customized for the API.For example, if the request pathis set to /test/AA, the API can beaccessed using /test/AA/CC butcannot be accessed using /test/AACC.NOTE
The plus (+) sign is not supportedfor prefix match.
Method The following API callingmethods are available:l GETl POSTl DELETEl PUTl PATCHl HEADl OPTIONSl ANY
ANY indicates that the API supportsany request method.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 9
Parameter Description Value
Enable CORS Enables or disables cross-originresource sharing (CORS).CORS allows browsers to sendXMLHttpRequest requests tocross-origin servers, whichovercomes the limitation thatAsynchronous JavaScript andXML (AJAX) can be used onlywithin the same origin.CORS requests are classified intothe following types:l Simple request: An Origin
field is added to the headerinformation.
l Not-so-simple request: AnHTTP request is sent beforeformal communication.
If you enable CORS (not-so-simplerequest), you must create anotherAPI with the OPTIONS method. Fordetails, see Creating an API withthe OPTIONS Method.
Step 7 (Optional) Set input parameters.
Input parameters are parameters that need to be passed when an API is called.
1. Click Add Input Parameter.2. In the Add Input Parameter dialog box, set the parameters listed in Table 4-4.
Table 4-4 Input parameter definition
Parameter Description
ParameterName
Name of an input parameter. If the parameter location is set toPATH, the parameter name must be the same as that in the requestpath.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in a request.The options include PATH, HEADER, and QUERY.
Type Type of the field. Options: String and Number. This field is notrequired when Location is set to PATH.
Mandatory Indicates whether the input parameter is required in a request to theAPI. When you select Yes, API Gateway will verify whether an APIrequest contains the input parameter.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 10
Parameter Description
Default Value This value will be used when the Mandatory field is set to No. Ifthe parameter is not specified in a request, API Gateway willautomatically send this default value to the backend service.
Example Example of the parameter value.
Description Description of the parameter.
3. Click OK.
Step 8 If you set Method to POST, PUT, PATCH, or ANY, enter a description in Body.
Step 9 Click Next.
On the Define Backend page, select the backend service type of the API. Available backendservice types include HTTP/HTTPS, FunctionGraph, and Mock. Table 4-5 lists theparameters required for defining a backend service.
Table 4-5 Parameters required for defining a backend service
ServiceType
ServiceParameter
Description
HTTP Protocol HTTP or HTTPS. HTTPS is recommended fortransmitting important or sensitive data.NOTE
WebSocket communication is supported.
RequestMethod
Specifies the API calling method. The value can beGET, POST, DELETE, PUT, PATCH, HEAD,OPTIONS, or ANY.ANY indicates that the API supports any requestmethod.
Use VPC Link Indicates whether to use a VPC link.You can configure the API to use or not to use a VPClink.
BackendAddress(optional)
IP address or domain name of the associated port. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #ipaddress#. You can create multiplevariables, for example, #ipaddress##test#.
Port (optional) The port number ranges from 1 to 65535. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #port#. Only one variable is allowed.
VPC Link(optional)
Specifies a VPC link. This parameter is required onlywhen a VPC link is used.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 11
ServiceType
ServiceParameter
Description
Custom HostHeader(optional)
Before a request is forwarded to ECSs in the VPC link,you are allowed to customize the host header for therequest. By default, the original host header of therequest is used. This parameter is required only when aVPC link is used.
BackendRequest Path
Specifies the path of a backend service, that is, the URIof the backend service. The path can contain aparameter, which is defined in the format of {pathparameter}, for example, /getUserInfo/{userId}.If the request path contains an environment variable,you can define the environment variable in the format of#variable name#, for example, /#path#. You can createmultiple environment variables, for example, /#path##request#.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
FunctionGraph
functionURN Specifies the unique ID of a function for a request.Click Add to add the required function URN.
Version Specifies the version of a function.
Call Type l sync: indicates synchronous calling. After receivinga calling request, FunctionGraph immediatelyprocesses the request and returns a calling result.After sending the request, the client disables theconnection once receiving the response.
l async: indicates asynchronous calling. Clients do notcare about the function invocation results of theirrequests. After receiving requests, FunctionGraphputs them in queues, returns responses, and thenprocesses the requests one by one in idle state.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
Mock Response fromMock
Mock is used for development, commissioning, andverification. In the initial phase of a project when theAPI joint commissioning environment is not set up, youcan use the Mock mode to return the expected result tothe API invoker for project development.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 12
NOTE
l After a variable is configured in the API definition, the API cannot be debugged on the debuggingpage.
l The variable name is case-sensitive.l If you set a variable for an API, you must configure the variable name and value in the environment
in which the API is to be published. Otherwise, no value can be assigned to the variable and the APIcannot be called normally.
Step 10 (Optional) Configure backend parameters.
Map the defined input parameters to corresponding locations in a backend request.
1. Click next to Backend Parameters, and set backend parameters in either of thefollowing two ways:– Click Import Input Parameter. All the defined input parameters are automatically
displayed.– Click Add Backend Parameter, and map the input parameters to backend
parameters.2. Modify the mapping based on the actual parameter names and their locations in a
backend request, as shown in Figure 4-1.
Figure 4-1 Configuring backend parameters
a. If the parameter location is set to PATH, the parameter name must be the same asthat in the backend request path.
b. The name and location of an input parameter can be different from those of themapping backend request parameter.
NOTE
n The parameter name cannot start with x-sdk-*.n The parameter name cannot be x-stage.n The name of a header parameter is not case-sensitive.
c. As shown in the preceding figure, test01 and test03 are located in the path andquery positions of an API request, and their values will be received in the header ofa backend request. test02 is located in the header of the API request, and its valuewill be received through test05 in the path of the backend request.For example, test01 is abc, test02 is def, and test03 is xyz.API request:
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 13
curl -ik -H 'test02:def' -X GET https://myhwclouds.com/v1.0/abc?test03=xyzBackend request:curl -ik -H 'test01:abc' -H 'test03:xyz' -X GET https://myhwclouds.com/v1.0/def
Step 11 (Optional) Set constant parameters.
You can set constant parameters to enable the backend service to receive constants that areinvisible to API callers. When requesting the backend service, API Gateway adds the constantparameters to the request and then sends the request to the backend service.
1. Click next to Constant Parameters.2. Click Add Constant Parameter, and set the parameters listed in Table 4-6.
Table 4-6 Constant parameters
Parameter Description
Backend Parameter Name of a backend parameter. If the parameter location isset to PATH, the parameter name must be the same as thatin the backend request path.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in arequest.The options include PATH, QUERY, and HEADER.
Value Enter a parameter value.
Description Enter a description for the constant parameter.
NOTE
– API Gateway sends requests containing constant parameters after percent-encoding of specialparameter values. Ensure that the backend services support percent-encoding. For example,parameter value [apig] becomes %5Bapig%5D after percent-encoding.
– For parameter values contained in a path, the following characters will be percent encoded:ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters ?></%#"[\]^`{|}
– For parameter values contained in a query request, the following characters will be percentencoded: ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters >=<+&%#"[\]^`{|}
Step 12 Click Next, and set responses (see Table 4-7) on the Define Response page.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 14
Table 4-7 Responses
Parameter Description
Example SuccessResponse
Example of a response returned when the API is calledsuccessfully.
Example FailureResponse
Example of a response returned when the API fails to be called.
Step 13 Click Finish.
After the API is created, click the API name in the API list to view its details.
----End
4.4 (Optional) Creating an environment
Scenario
APIs can be called in different environments, such as the production, test, and developmentenvironments. API Gateway provides environment management. You can define API callingpaths for different environments.
NOTE
Each user can create a maximum of 10 environments.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Environment Management.
Step 5 Click Create Environment. On the Create Environment page, set the parameters listed inTable 4-8.
Table 4-8 Environment information
Parameter Description Value
EnvironmentName
Name of the API environment l Must start with a letter.l Can contain letters,
digits, and underscores(_).
l Consists of 3 to 64characters.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 15
Parameter Description Value
Description Description of the environment The value can contain 0–255 characters.
Step 6 Click OK.
After the environment is created, it is displayed in environment list on the EnvironmentManagement page.
----End
4.5 Publishing an API
Scenario
After creating an API, you can publish it so that you can obtain the API information on theAPI Management page.
Prerequisitesl An API group and APIs have been created.
l An environment has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Publish API page:
l Locate the row that contains the API to be published and click Publish.
l Click the name of the target API. In the upper right corner of the API details page that isdisplayed, click Publish.
Step 6 Select the environment in which the API is to be published and enter the description.
NOTE
l If the API has been published in the selected environment, publishing it again will overwrite theexisting API.
l If you do not find the environment you need, you can create an environment as needed.
Step 7 Click Publish.
----End
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 16
4.6 Querying InformationQuery API Gateway information, such as the API group information, API information,throttling policies, signature key information, and VPC link information.
To help you quickly find required information on the management console, Table 4-9 lists theinformation query indexes.
NOTE
You may find the following information in different paths on the management console. One of the pathsis described as an example.
Table 4-9 Key information query indexes
Category ConsolePath
Key Information Description
API group APIPublishing >API Groups> Groupname
Group name Name of the API group
Status Status of the API group
Throttling (unit:QPS)
Maximum number of requestsallowed for the API group
Subdomain name Subdomain name automaticallyassigned by the system and displayedafter the group is created
Creation time Time when the group was created
Description Description of the API group
List of APIs in thegroup
All APIs in the API group
List of environmentvariables in thegroup
All environment variables in aselected environment
List of independentdomain namesbound to the group
All independent domain names boundto the group
API APIPublishing >APIManagement> API name
API invocationdetails, that is,monitoring data
API requests, API invocation latency,API data traffic, and API errorinformation in a certain period oftime
API group Group to which the API belongs
Name Name of the API
Type Type of the API, which is Public orPrivate
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 17
Category ConsolePath
Key Information Description
Securityauthentication
Security authentication mode of theAPI
Creation time Time when the API was created
Environment Environment in which the API ispublished. Multiple environments canbe selected and are separated by |.
Update time Time when the API was updated
Enable CORS Indicates whether CORS is enabledfor the API.
Description Description of the API
Calling information API call chain and constantparameter list
Authorizationinformation
Applications that have beenauthorized by the API
Request throttlinginformation
Request throttling information of theAPI
Signature key Signature key information of the API
Publication history Historical publication information ofthe API
Access ControlPolicies
Request throttling policies bound tothe API
Throttlingpolicy
APIPublishing >RequestThrottling >Throttlingpolicy name
Policy name Name of the policy
Duration Duration unit of an API call limit.This parameter is used together withan API call limit and indicates themaximum number of API requests ina specified period.
Maximum numberof API requests
Upper limit of API calls. Thisparameter is used together withDuration and indicates the maximumnumber of API requests in a specifiedperiod.
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 18
Category ConsolePath
Key Information Description
Maximum numberof user requests
l Maximum number of times thatan API can be called by a user.This parameter is used togetherwith Duration and indicates themaximum number of times that anAPI can be called by a user in aspecified period.
l The value cannot exceed themaximum number of APIrequests.
Maximum numberof applicationrequests
l Maximum number of times thatan API can be called by anapplication. This parameter isused together with Duration andindicates the maximum number oftimes that an API can be called byan application in a specifiedperiod.
l The value cannot exceed themaximum number of userrequests.
Throttling override l If the policy contains specialapplications, Yes is displayed.
l If the policy does not containspecial applications, No isdisplayed.
Creation time Time when the policy was created
Description Description of the policy
API list APIs to which the policy has beenbound
Special applications Special applications that have beenadded to the policy
Signaturekey
APIPublishing >SignatureKey >Signature keyname
Key name Name of the key
Key This parameter is used together withSecret and indicates the signature keypair.
Secret This parameter is used together withKey and indicates the signature keypair.
Creation time Time when the signature key wascreated
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 19
Category ConsolePath
Key Information Description
Update time Time when the signature key wasupdated
List of APIs towhich the signaturekey has been bound
APIs to which the signature key hasbeen bound
VPC link APIPublishing >VPC Links >VPC linkname
VPC link Name of a VPC link
Status Health status of a VPC link
Type Type of a VPC link
Port Host port of a VPC link
Distributionalgorithm
Distribution algorithm of a VPC link
Creation time Date and time when a VPC link wascreated
Health check Health check configurationinformation of a VPC link
ECS ECS list and weights of a VPC link
Accesscontrolpolicy
APIPublishing >AccessControl >Accesscontrol policyname
Policy Name Name of an access control policy
Restriction Type Type of sources allowed or notallowed to access an API
IP Address IP addresses or IP address rangesallowed or not allowed to access anAPI
Action Allow or deny
Created Time when the access control policyis created
API GatewayUser Guide (API Publishing) 4 Getting Started
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 20
5 API Group
Creating an API Group
Creating an Environment Variable
Binding a Domain Name
Editing an API Group
Deleting an API Group
5.1 Creating an API Group
ScenarioAn API group is a collection of APIs. This section describes how to create an API group tomanage APIs.
NOTE
l An API can belong to only one API group.
l You can create a maximum of 50 API groups.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Groups.
Step 5 Click Create API Group. On the Create API Group page, set the parameters listed in Table5-1.
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 21
Table 5-1 Parameters
Parameter Description Value
Group Name Name of the API group, which isused to manage APIs
l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
Description Description of the API group Cannot contain more than 255characters.
Step 6 After setting the required information, click OK.
After the API group is created, it is displayed in the API group list on the API Groups page.
NOTE
l The system automatically allocates a subdomain name to the API group for internal test. Thesubdomain name can be accessed up to 1000 times a day.
l To open APIs, you need to bind the API group to an independent domain name or a domain nameissued by the marketplace.
----End
5.2 Creating an Environment Variable
ScenarioAn environment variable is a variable that can be managed in the environment. The variable isfixed in the environment. WIth the environment variable, you can call backend services indifferent environments using the same API.
If you set a variable when creating an API, you need to add the variable in the environment.For example, if the variable Path is defined during API creation, and the variable Path withvalue /Stage/test is created in environment 1, replace Path with /Stage/test when publishingthe API in environment 1. If the variable Path with value /Stage/AA is created inenvironment 2, replace Path with /Stage/AA when publishing the API in environment 2.
NOTE
A maximum of 50 variables can be created for each API group in any environment.
PrerequisitesAn API has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 22
Step 4 Choose API Publishing > API Groups.
Step 5 Use either of the following methods to access the Variable Management page:l Click the name of the target group. On the group details page that is displayed, click
Variable Management.l Locate the row that contains the target group, and choose More > Variable
Management.
Step 6 In Environment, select the target environment and click Add Variable.
Step 7 On the Add Variable page, set the parameters listed in Table 5-2.
Table 5-2 Adding a variable
Parameter Description Value
VariableName
Name of the variable, which mustbe the same as the variable definedduring API creation.
l Contains only letters, digits,underscores (_), and hyphens.
l Must start with a letter.l Contains 3 to 32 characters.l Case-sensitive
VariableValue
Variable path l Can contain letters, digits,underscores (_), hyphens (-),slashes (/), dots (.), and colons(:).
l Contains 1 to 255 characters.
Step 8 Click OK.
NOTE
If you do not need this variable any longer, click Delete in the row that contains the variable.
----End
5.3 Binding a Domain Name
ScenarioBind an independent domain name to a group. The API Gateway locates the group by itsindependent domain name.
NOTE
A maximum of five independent domain names can be bound to each group.
Prerequisitesl The independent domain name has been registered at related regulatory bodies.
Independent domain names that have not been registered cannot be accessed.l The independent domain name has been bound to the subdomain name of the group
through CNAME.
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 23
l If HTTPS is used to define an API request when creating an API, add an SSL certificateto the independent domain name.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Groups.
Step 5 Use either of the following methods to access the Domain Name Management page:l Click the name of the target group. On the group details page that is displayed, click
Domain Name Management.l Locate the row that contains the group to which the domain name is to be bound, and
choose More > Domain Name Management.
Step 6 Click Bind Domain Name, enter the domain name, and click to bind the domain name.
NOTE
If the domain name is no longer required, click Unbind in the row where the domain name resides.
Step 7 (Optional) Add an SSL certificate.
1. Click Add SSL Certificate. The Add SSL Certificate page is displayed.2. Enter the certificate name, certificate content, and key, and click OK.
NOTE
– To edit the SSL certificate, click next to the certificate name. The certificate content andkey have been encrypted and cannot be viewed again. To modify the certificate content andkey, input the new certificate content or key.
– If the SSL certificate is no longer required, click Delete SSL Certificate in the row where thedomain name resides.
----End
5.4 Editing an API Group
ScenarioAfter creating an API group, you can modify its configuration parameters.
PrerequisitesAn API group has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 24
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Groups.
Step 5 Use either of the following methods to access the Edit Group page:l Locate the row that contains the target API group and click Edit.l Click the name of the target group. In the upper right corner of the group details page
that is displayed, click Edit.
Step 6 Set the parameters in the following table.
Table 5-3 Parameters
Parameter Description Value
Group Name Name of the API group, which isused to manage APIs
l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
Description Description of the API group Cannot contain more than 255characters.
Step 7 Click OK.
----End
5.5 Deleting an API Group
Scenario
After an API group is created, you can delete it to clear its data.
NOTE
API groups that have already been launched to the cloud market cannot be deleted.
Prerequisites
An API group has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Groups.
Step 5 Use either of the following methods to access the Delete API Group page:
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 25
l Locate the row that contains the target API group and choose More > Delete.l Click the name of the target group. In the upper right corner of the group details page
that is displayed, click Delete.
Step 6 Enter DELETE in the text box and click Yes.
NOTE
Deleting this API group will delete all APIs included in the group.
----End
API GatewayUser Guide (API Publishing) 5 API Group
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 26
6 API Management
Creating an API
Creating an API with the OPTIONS Method
Authorizing an API
Editing an API
Publishing an API
Publication History
Removing an API
Debugging an API
Canceling Authorization
Deleting an API
6.1 Creating an API
Scenario
Configure an API in API Gateway to open service capabilities.
NOTE
l API Gateway is based on the API architecture of REST. Opening or calling APIs must comply withRESTful specifications.
l You create a maximum of 200 APIs.
Prerequisites
An API group has been created.
Procedure
Step 1 Log in to the management console.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 27
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Click Create API. On the Create API page, set the parameters listed in Table 6-1.
Table 6-1 Basic information
Parameter Description Value
API Name Name of the API l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
API Group Group to which the API belongs If no API group has been created,click Create API Group to createan API group first.
Type There are two types of APIs:l Public: The API is open to the
public.l Private: The API is not open to
the public.
l If you select Public, the API canbe made available for sale in themarketplace.
l If you select Private, the APIwill not be available for salewhen the API group to which itbelongs is launched to themarketplace.
SecurityAuthentication
There are three authenticationmodes:l APP: indicates that API
Gateway performs securityauthentication on API requests.
l IAM: indicates that the Identityand Access Management(IAM) service is used forsecurity authentication.
l NONE: indicates thatauthentication is not required.
The API calling method variesdepending on the authenticationmode. For details, see the APIGateway Developer Guide.The APP authentication mode isrecommended.NOTICE
l When the authentication mode is setto IAM, any HUAWEI CLOUDtenant can access the API, whichmay result in excessive chargingcaused by malicious requests.
l If the authentication mode is set toNONE, any public network user canaccess the API, which may result inexcessive charging caused bymalicious requests.
Description Description of the API (Optional) Contains 0 to 255characters.
Step 6 Click Next. On the Define API Request page, set the parameters listed in Table 6-2.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 28
Table 6-2 Defining API requests
Parameter Description Value
DomainName
Domain name A subdomain name is assigned bydefault.
RequestProtocol
Options:l HTTPl HTTPSl HTTP&HTTPS
HTTPS is recommended fortransmitting important or sensitivedata.
Request Path API request path The format is /{serviceName}/{interfaceName}.l The content in {} is case-
sensitive.l If the request path contains
request parameters, you mustdefine the request parameters asinput parameters.
MatchingMethod
There are two modes:l Exact matchl Prefix match
l If you select exact match, therequest path is fixed to the APIrequest path configured duringcreation.
l If you select prefix match, therequest path uses the API requestpath configured during creationas the prefix, and multiple pathscan be customized for the API.For example, if the request pathis set to /test/AA, the API can beaccessed using /test/AA/CC butcannot be accessed using /test/AACC.NOTE
The plus (+) sign is not supportedfor prefix match.
Method The following API callingmethods are available:l GETl POSTl DELETEl PUTl PATCHl HEADl OPTIONSl ANY
ANY indicates that the API supportsany request method.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 29
Parameter Description Value
Enable CORS Enables or disables cross-originresource sharing (CORS).CORS allows browsers to sendXMLHttpRequest requests tocross-origin servers, whichovercomes the limitation thatAsynchronous JavaScript andXML (AJAX) can be used onlywithin the same origin.CORS requests are classified intothe following types:l Simple request: An Origin
field is added to the headerinformation.
l Not-so-simple request: AnHTTP request is sent beforeformal communication.
If you enable CORS (not-so-simplerequest), you must create anotherAPI with the OPTIONS method. Fordetails, see Creating an API withthe OPTIONS Method.
Step 7 (Optional) Set input parameters.
Input parameters are parameters that need to be passed when an API is called.
1. Click Add Input Parameter.2. In the Add Input Parameter dialog box, set the parameters listed in Table 6-3.
Table 6-3 Input parameter definition
Parameter Description
ParameterName
Name of an input parameter. If the parameter location is set toPATH, the parameter name must be the same as that in the requestpath.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in a request.The options include PATH, HEADER, and QUERY.
Type Type of the field. Options: String and Number. This field is notrequired when Location is set to PATH.
Mandatory Indicates whether the input parameter is required in a request to theAPI. When you select Yes, API Gateway will verify whether an APIrequest contains the input parameter.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 30
Parameter Description
Default Value This value will be used when the Mandatory field is set to No. Ifthe parameter is not specified in a request, API Gateway willautomatically send this default value to the backend service.
Example Example of the parameter value.
Description Description of the parameter.
3. Click OK.
Step 8 If you set Method to POST, PUT, PATCH, or ANY, enter a description in Body.
Step 9 Click Next.
On the Define Backend page, select the backend service type of the API. Available backendservice types include HTTP/HTTPS, FunctionGraph, and Mock. Table 6-4 lists theparameters required for defining a backend service.
Table 6-4 Parameters required for defining a backend service
ServiceType
ServiceParameter
Description
HTTP Protocol HTTP or HTTPS. HTTPS is recommended fortransmitting important or sensitive data.NOTE
WebSocket communication is supported.
RequestMethod
Specifies the API calling method. The value can beGET, POST, DELETE, PUT, PATCH, HEAD,OPTIONS, or ANY.ANY indicates that the API supports any requestmethod.
Use VPC Link Indicates whether to use a VPC link.You can configure the API to use or not to use a VPClink.
BackendAddress(optional)
IP address or domain name of the associated port. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #ipaddress#. You can create multiplevariables, for example, #ipaddress##test#.
Port (optional) The port number ranges from 1 to 65535. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #port#. Only one variable is allowed.
VPC Link(optional)
Specifies a VPC link. This parameter is required onlywhen a VPC link is used.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 31
ServiceType
ServiceParameter
Description
Custom HostHeader(optional)
Before a request is forwarded to ECSs in the VPC link,you are allowed to customize the host header for therequest. By default, the original host header of therequest is used. This parameter is required only when aVPC link is used.
BackendRequest Path
Specifies the path of a backend service, that is, the URIof the backend service. The path can contain aparameter, which is defined in the format of {pathparameter}, for example, /getUserInfo/{userId}.If the request path contains an environment variable,you can define the environment variable in the format of#variable name#, for example, /#path#. You can createmultiple environment variables, for example, /#path##request#.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
FunctionGraph
functionURN Specifies the unique ID of a function for a request.Click Add to add the required function URN.
Version Specifies the version of a function.
Call Type l sync: indicates synchronous calling. After receivinga calling request, FunctionGraph immediatelyprocesses the request and returns a calling result.After sending the request, the client disables theconnection once receiving the response.
l async: indicates asynchronous calling. Clients do notcare about the function invocation results of theirrequests. After receiving requests, FunctionGraphputs them in queues, returns responses, and thenprocesses the requests one by one in idle state.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
Mock Response fromMock
Mock is used for development, commissioning, andverification. In the initial phase of a project when theAPI joint commissioning environment is not set up, youcan use the Mock mode to return the expected result tothe API invoker for project development.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 32
NOTE
l After a variable is configured in the API definition, the API cannot be debugged on the debuggingpage.
l The variable name is case-sensitive.l If you set a variable for an API, you must configure the variable name and value in the environment
in which the API is to be published. Otherwise, no value can be assigned to the variable and the APIcannot be called normally.
Step 10 (Optional) Configure backend parameters.
Map the defined input parameters to corresponding locations in a backend request.
1. Click next to Backend Parameters, and set backend parameters in either of thefollowing two ways:– Click Import Input Parameter. All the defined input parameters are automatically
displayed.– Click Add Backend Parameter, and map the input parameters to backend
parameters.2. Modify the mapping based on the actual parameter names and their locations in a
backend request, as shown in Figure 6-1.
Figure 6-1 Configuring backend parameters
a. If the parameter location is set to PATH, the parameter name must be the same asthat in the backend request path.
b. The name and location of an input parameter can be different from those of themapping backend request parameter.
NOTE
n The parameter name cannot start with x-sdk-*.n The parameter name cannot be x-stage.n The name of a header parameter is not case-sensitive.
c. As shown in the preceding figure, test01 and test03 are located in the path andquery positions of an API request, and their values will be received in the header ofa backend request. test02 is located in the header of the API request, and its valuewill be received through test05 in the path of the backend request.For example, test01 is abc, test02 is def, and test03 is xyz.API request:
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 33
curl -ik -H 'test02:def' -X GET https://myhwclouds.com/v1.0/abc?test03=xyzBackend request:curl -ik -H 'test01:abc' -H 'test03:xyz' -X GET https://myhwclouds.com/v1.0/def
Step 11 (Optional) Set constant parameters.
You can set constant parameters to enable the backend service to receive constants that areinvisible to API callers. When requesting the backend service, API Gateway adds the constantparameters to the request and then sends the request to the backend service.
1. Click next to Constant Parameters.2. Click Add Constant Parameter, and set the parameters listed in Table 6-5.
Table 6-5 Constant parameters
Parameter Description
Backend Parameter Name of a backend parameter. If the parameter location isset to PATH, the parameter name must be the same as thatin the backend request path.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in arequest.The options include PATH, QUERY, and HEADER.
Value Enter a parameter value.
Description Enter a description for the constant parameter.
NOTE
– API Gateway sends requests containing constant parameters after percent-encoding of specialparameter values. Ensure that the backend services support percent-encoding. For example,parameter value [apig] becomes %5Bapig%5D after percent-encoding.
– For parameter values contained in a path, the following characters will be percent encoded:ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters ?></%#"[\]^`{|}
– For parameter values contained in a query request, the following characters will be percentencoded: ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters >=<+&%#"[\]^`{|}
Step 12 Click Next, and set responses (see Table 6-6) on the Define Response page.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 34
Table 6-6 Responses
Parameter Description
Example SuccessResponse
Example of a response returned when the API is calledsuccessfully.
Example FailureResponse
Example of a response returned when the API fails to be called.
Step 13 Click Finish.
After the API is created, click the API name in the API list to view its details.
----End
6.2 Creating an API with the OPTIONS Method
Scenario
When CORS (not-so-simple request) is enabled, you must create another API that uses theOPTIONS method.
Prerequisites
You have created an API for which CORS (not-so-simple request) is enabled.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Click Create API. On the Create API page, set the parameters listed in Table 6-7.
Table 6-7 Basic information
Parameter Description Value
API Name Name of the API l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
API Group Group to which the API belongs Select the group to which the APIbelongs.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 35
Parameter Description Value
Type There are two types of APIs:l Public: The API is open to the
public.l Private: The API is not open to
the public.
l If you select Public, the API canbe made available for sale in themarketplace.
l If you select Private, the APIwill not be available for salewhen the API group to which itbelongs is launched to themarketplace.
SecurityAuthentication
There are three authenticationmodes:l APP: indicates that API
Gateway performs securityauthentication on API requests.
l IAM: indicates that the IAMservice is used for securityauthentication.
l NONE: indicates thatauthentication is not required.
Authentication is not supported nomatter which authentication mode isselected.
Description Description of the API (Optional) Contains 0 to 255characters.
Step 6 Click Next. On the Define API Request page, set the parameters listed in Table 6-8.
Table 6-8 Defining API requests
Parameter Description Value
DomainName
Domain name A subdomain name is assigned bydefault.
RequestProtocol
There are two types of protocols:l HTTPl HTTPS
Select the request protocol set forthe API with CORS enabled.
Request Path Request path Select the request path that has beenset for or matches the API withCORS enabled.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 36
Parameter Description Value
MatchingMethod
There are two modes:l Exact matchl Prefix match
l If you select exact match, therequest path is fixed to the APIrequest path configured duringcreation.
l If you select prefix match, therequest path uses the API requestpath configured during creationas the prefix, and multiple pathscan be customized for the API.For example, if the request pathis set to /test/AA, the API can beaccessed using /test/AA/CC butcannot be accessed using /test/AACC.NOTE
– The plus (+) sign is notsupported for prefix match.
– If the API group containsmultiple APIs with CORSenabled, select Prefix match.Then, these APIs can use thisnew API to send HTTP requests.
Method API calling method. SelectOPTIONS.
-
Enable CORS Enables or disables CORS.CORS allows browsers to sendXMLHttpRequest requests tocross-origin servers, whichovercomes the limitation thatAJAX can be used only within thesame origin.
Enable CORS.
Step 7 (Optional) Set input parameters.
Input parameters are parameters that need to be passed when an API is called.
1. Click Add Input Parameter.2. In the Add Input Parameter dialog box, set the parameters listed in Table 6-9.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 37
Table 6-9 Input parameter definition
Parameter Description
ParameterName
Name of an input parameter. If the parameter location is set toPATH, the parameter name must be the same as that in the requestpath.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in a request.The options include PATH, HEADER, and QUERY.
Type Type of the field. Options: String and Number. This field is notrequired when Location is set to PATH.
Mandatory Indicates whether the input parameter is required in a request to theAPI. When you select Yes, API Gateway will verify whether an APIrequest contains the input parameter.
Default Value This value will be used when the Mandatory field is set to No. Ifthe parameter is not specified in a request, API Gateway willautomatically send this default value to the backend service.
Example Example of the parameter value.
Description Description of the parameter.
3. Click OK.
Step 8 Click Next.
On the Define Backend page, select the backend service type of the API. Available backendservice types include HTTP/HTTPS, FunctionGraph, and Mock. Table 6-10 lists theparameters.
Table 6-10 Defining backend services
ServiceType
ServiceParameter
Description
HTTP Protocol HTTP or HTTPS. HTTPS is recommended fortransmitting important or sensitive data.NOTE
WebSocket communication is supported.
RequestMethod
Specifies the API calling method. The value can beGET, POST, DELETE, PUT, PATCH, HEAD,OPTIONS, or ANY.ANY indicates that the API supports any requestmethod.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 38
ServiceType
ServiceParameter
Description
Use VPC Link Indicates whether to use a VPC link.You can configure the API to use or not to use a VPClink.
BackendAddress(optional)
IP address or domain name of the associated port. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #ipaddress#. You can create multiplevariables, for example, #ipaddress##test#.
Port (optional) The port number ranges from 1 to 65535. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #port#. Only one variable is allowed.
VPC Link(optional)
Specifies a VPC link. This parameter is required onlywhen a VPC link is used.
Custom HostHeader(optional)
Before a request is forwarded to ECSs in the VPC link,you are allowed to customize the host header for therequest. By default, the original host header of therequest is used. This parameter is required only when aVPC link is used.
BackendRequest Path
Specifies the path of a backend service, that is, the URIof the backend service. The path can contain aparameter, which is defined in the format of {pathparameter}, for example, /getUserInfo/{userId}.If the request path contains an environment variable,you can define the environment variable in the format of#variable name#, for example, /#path#. You can createmultiple environment variables, for example, /#path##request#.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
FunctionGraph
functionURN Specifies the unique ID of a function request.Click Add to add the required function URN.
Version Specifies the version of a function.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 39
ServiceType
ServiceParameter
Description
Call Type l sync: indicates synchronous calling. After receivinga calling request, FunctionGraph immediatelyprocesses the request and returns a calling result.After sending the request, the client disables theconnection once receiving the response.
l async: indicates asynchronous calling. Clients do notcare about the function invocation results of theirrequests. After receiving requests, FunctionGraphputs them in queues, returns responses, and thenprocesses the requests one by one in idle state.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
Mock Response fromMock
Mock is used for development, commissioning, andverification. In the initial phase of a project when theAPI joint commissioning environment is not set up, youcan use the Mock mode to return the expected result tothe API invoker for project development.
NOTE
l After a variable is configured in the API definition, the API cannot be debugged on the debuggingpage.
l The variable name is case-sensitive.
l If you set a variable in the API definition, you must configure the variable name and value in theenvironment in which the API is to be published. Otherwise, no value cannot be assigned to thevariable and the API cannot be called normally.
Step 9 (Optional) Configure backend parameters.
Map the defined input parameters to corresponding locations in a backend request.
1. Click next to Backend Parameters, and set backend parameters in either of thefollowing two ways:– Click Import Input Parameter. All the defined input parameters are automatically
displayed.– Click Add Backend Parameter, and map the input parameters to backend
parameters.2. Modify the mapping based on the actual parameter names and their locations in a
backend request, as shown in Figure 6-2.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 40
Figure 6-2 Configuring backend parameters
a. If the parameter location is set to PATH, the parameter name must be the same asthat in the backend request path.
b. The name and location of an input parameter can be different from those of themapping backend request parameter.
NOTE
n The parameter name cannot start with x-sdk-*.
n The parameter name cannot be x-stage.
n The name of a header parameter is not case-sensitive.
c. As shown in the preceding figure, test01 and test03 are located in the path andquery positions of an API request, and their values will be received in the header ofa backend request. test02 is located in the header of the API request, and its valuewill be received through test05 in the path of the backend request.For example, test01 is abc, test02 is def, and test03 is xyz.API request:curl -ik -H 'test02:def' -X GET https://myhwclouds.com/v1.0/abc?test03=xyzBackend request:curl -ik -H 'test01:abc' -H 'test03:xyz' -X GET https://myhwclouds.com/v1.0/def
Step 10 (Optional) Set constant parameters.
You can set constant parameters to enable the backend service to receive constants that areinvisible to API callers. When requesting the backend service, API Gateway adds the constantparameters to the request and then sends the request to the backend service.
1. Click next to Constant Parameters.2. Click Add Constant Parameter, and set the parameters listed in Table 6-11.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 41
Table 6-11 Constant parameters
Parameter Description
Backend Parameter Name of a backend parameter. If the parameter location isset to PATH, the parameter name must be the same as thatin the backend request path.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in arequest.The options include PATH, QUERY, and HEADER.
Value Enter a parameter value.
Description Enter a description for the constant parameter.
NOTE
– API Gateway sends requests containing constant parameters after percent-encoding of specialparameter values. Ensure that the backend services support percent-encoding. For example,parameter value [apig] becomes %5Bapig%5D after percent-encoding.
– For parameter values contained in a path, the following characters will be percent encoded:ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters ?></%#"[\]^`{|}
– For parameter values contained in a query request, the following characters will be percentencoded: ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters >=<+&%#"[\]^`{|}
Step 11 Click Next, and set responses (see Table 6-12) on the Define Response page.
Table 6-12 Responses
Parameter Description
Example SuccessResponse
Example of a response returned when the API is calledsuccessfully.
Example FailureResponse
Example of a response returned when the API fails to be called.
Step 12 Click Finish.
After the API is created, click the API name in the API list to view its details.
----End
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 42
6.3 Authorizing an API
Scenario
After an API is created, you can authorize specified applications to call it.
NOTE
l An API can be called only after it has been published in an environment.
l An application can be associated with an API only when the API uses App authentication.
Prerequisitesl An API group and APIs have been created.
l An environment has been created.
l An application has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use any of the following methods to access the Authorize Application page:
l Locate the row that contains the target API and click Authorize. Click AddApplication. The Authorize Application page is displayed.
l Select the target API and click Authorize. Click Add Application. The AuthorizeApplication page is displayed.
l Perform the following operations on the API details page:
a. Click the name of the target API.
b. On the API details page that is displayed, click Detailed Information.
c. Click Authorizations.
d. Click Grant Authorization. The Authorize Application page is displayed.
Step 6 Specify the authorized environment, query and select the application, and click Authorize.
Step 7 After the authorization is successful, view the authorized applications on the Authorizationstab page of the API details page or the Authorize API Calling page.
NOTE
If the list of authorized applications contains an application that does not need to be authorized, clickCancel Authorization in the row that contains the target application.
----End
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 43
6.4 Editing an API
Scenario
After creating an API, you can modify its configuration parameters.
NOTE
After modifying the information about a published API, you must publish the API again to synchronizethe modified information to the environment.
Prerequisites
An API group and APIs have been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Edit API page:
l Locate the row that contains the target API and choose More > Edit.
l Click the name of the target API. In the upper right corner of the API details page that isdisplayed, click Edit.
Step 6 On the Basic Information page, set the parameters listed in Table 6-13.
Table 6-13 Basic information
Parameter Description Value
API Name Name of the API l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
Type There are two types of APIs:l Public: The API is open to the
public.l Private: The API is not open to
the public.
l If you select Public, the API canbe made available for sale in themarketplace.
l If you select Private, the APIwill not be available for salewhen the API group to which itbelongs is launched to themarketplace.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 44
Parameter Description Value
SecurityAuthentication
There are three authenticationmodes:l APP: indicates that API
Gateway performs securityauthentication on API requests.
l IAM: indicates that the IAMservice is used for securityauthentication.
l NONE: indicates thatauthentication is not required.
The API calling method variesdepending on the authenticationmode. For details, see the APIGateway Developer Guide.The APP authentication mode isrecommended.NOTICE
l When the authentication mode is setto IAM, any HUAWEI CLOUDtenant can access the API, whichmay result in excessive chargingcaused by malicious requests.
l If the authentication mode is set toNONE, any public network user canaccess the API, which may result inexcessive charging caused bymalicious requests.
Description Description of the API (Optional) Contains 0 to 255characters.
Step 7 Click Next. On the Define API Request page, set the parameters listed in Table 6-14.
Table 6-14 Defining API requests
Parameter Description Value
RequestProtocol
Options:l HTTPl HTTPSl HTTP&HTTPS
-
Request Path Request path The format is /{serviceName}/{interfaceName}.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 45
Parameter Description Value
MatchingMethod
There are two modes:l Exact matchl Prefix match
l If you select exact match, therequest path is fixed to the APIrequest path configured duringcreation.
l If you select prefix match, therequest path uses the API requestpath configured during creationas the prefix, and multiple pathscan be customized for the API.For example, if the request pathis set to /test/AA, the API can beaccessed using /test/AA/CC butcannot be accessed using /test/AACC.NOTE
The plus (+) sign is not supportedfor prefix match.
Method The following API callingmethods are available:l GETl POSTl DELETEl PUTl PATCHl HEADl OPTIONSl ANY
ANY indicates that the API supportsany request method.
Enable CORS Enables or disables CORS.CORS allows browsers to sendXMLHttpRequest requests tocross-origin servers, whichovercomes the limitation thatAJAX can be used only within thesame origin.CORS requests are classified intothe following types:l Simple request: An Origin
field is added to the headerinformation.
l Not-so-simple request: AnHTTP request is sent beforeformal communication.
If you enable CORS (not-so-simplerequest), you must create anotherAPI with the OPTIONS method. Fordetails, see Creating an API withthe OPTIONS Method.
Step 8 (Optional) Set input parameters.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 46
Input parameters are parameters that need to be passed when an API is called.
1. Locate the row that contains the target input parameter and click Edit.2. In the Edit Input Parameter dialog box, set the parameters listed in Table 6-15.
Table 6-15 Input parameter definition
Parameter Description
ParameterName
Name of an input parameter. If the parameter location is set toPATH, the parameter name must be the same as that in the requestpath.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in a request.The options include PATH, HEADER, and QUERY.
Type Type of the field. Options: String and Number. This field is notrequired when Location is set to PATH.
Mandatory Indicates whether the input parameter is required in a request to theAPI. When you select Yes, API Gateway will verify whether an APIrequest contains the input parameter.
Default Value This value will be used when the Mandatory field is set to No. Ifthe parameter is not specified in a request, API Gateway willautomatically send this default value to the backend service.
Example Example of the parameter value.
Description Description of the parameter.
3. Click OK.
Step 9 If you set Method to POST, PUT, PATCH, or ANY, enter a description in Body.
Step 10 Click Next. On the Define Backend page, set the parameters listed in Table 6-16.
Table 6-16 Defining backend services
ServiceType
ServiceParameter
Description
HTTP Protocol The value can be HTTP or HTTPS.NOTE
WebSocket communication is supported.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 47
ServiceType
ServiceParameter
Description
RequestMethod
Specifies the API calling method. The value can beGET, POST, DELETE, PUT, PATCH, HEAD,OPTIONS, or ANY.ANY indicates that the API supports any requestmethod.
Use VPC Link Indicates whether to use a VPC link.You can configure the API to use or not to use a VPClink.
BackendAddress(optional)
IP address or domain name of the associated port. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #ipaddress#. You can create multiplevariables, for example, #ipaddress##test#.
Port (optional) The port number ranges from 1 to 65535. Thisparameter is required only when no VPC link is used.To create a variable, enter #variable name#, forexample, #port#. Only one variable is allowed.
VPC Link(optional)
Specifies a VPC link. This parameter is required onlywhen a VPC link is used.
Custom HostHeader(optional)
Before a request is forwarded to ECSs in the VPC link,you are allowed to customize the host header for therequest. By default, the original host header of therequest is used. This parameter is required only when aVPC link is used.
BackendRequest Path
Specifies the path of a backend service, that is, the URIof the backend service. The path can contain aparameter, which is defined in the format of {pathparameter}, for example, /getUserInfo/{userId}.If the request path contains an environment variable,you can define the environment variable in the format of#variable name#, for example, /#path#. You can createmultiple environment variables, for example, /#path##request#.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
FunctionGraph
functionURN Specifies the unique ID of a function request.Click Add to add the required function URN.
Version Specifies the version of a function.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 48
ServiceType
ServiceParameter
Description
Call Type l sync: indicates synchronous calling. After receivinga calling request, FunctionGraph immediatelyprocesses the request and returns a calling result.After sending the request, the client disables theconnection once receiving the response.
l async: indicates asynchronous calling. Clients do notcare about the function invocation results of theirrequests. After receiving requests, FunctionGraphputs them in queues, returns responses, and thenprocesses the requests one by one in idle state.
BackendTimeoutPeriod
Specifies the request timeout duration. The value rangesfrom 1 ms to 60000 ms. The default value is 5000 ms.
Mock Response fromMock
Mock is used for development, commissioning, andverification. In the initial phase of a project when theAPI joint commissioning environment is not set up, youcan use the Mock mode to return the expected result tothe API invoker for project development.
NOTE
l After a variable is configured in the API definition, the API cannot be debugged on the debuggingpage.
l The variable name is case-sensitive.
l If you set a variable in the API definition, you must configure the variable name and value in theenvironment in which the API is to be published. Otherwise, no value cannot be assigned to thevariable and the API cannot be called normally.
Step 11 (Optional) Configure backend parameters.
Map the defined input parameters to corresponding locations in a backend request.
1. Click next to Backend Parameters, and set backend parameters in either of thefollowing two ways:– Click Import Input Parameter. All the defined input parameters are automatically
displayed.– Click Add Backend Parameter, and map the input parameters to backend
parameters.2. Modify the mapping based on the actual parameter names and their locations in a
backend request, as shown in Figure 6-3.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 49
Figure 6-3 Configuring backend parameters
a. If the parameter location is set to PATH, the parameter name must be the same asthat in the backend request path.
b. The name and location of an input parameter can be different from those of themapping backend request parameter.
NOTE
n The parameter name cannot start with x-sdk-*.
n The parameter name cannot be x-stage.
n The name of a header parameter is not case-sensitive.
c. As shown in the preceding figure, test01 and test03 are located in the path andquery positions of an API request, and their values will be received in the header ofa backend request. test02 is located in the header of the API request, and its valuewill be received through test05 in the path of the backend request.For example, test01 is abc, test02 is def, and test03 is xyz.API request:curl -ik -H 'test02:def' -X GET https://myhwclouds.com/v1.0/abc?test03=xyzBackend request:curl -ik -H 'test01:abc' -H 'test03:xyz' -X GET https://myhwclouds.com/v1.0/def
Step 12 (Optional) Set constant parameters.
You can set constant parameters to enable the backend service to receive constants that areinvisible to API callers. When requesting the backend service, API Gateway adds the constantparameters to the request and then sends the request to the backend service.
1. Click next to Constant Parameters.2. Click Add Constant Parameter, and set the parameters listed in Table 6-17.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 50
Table 6-17 Constant parameters
Parameter Description
Backend Parameter Name of a backend parameter. If the parameter location isset to PATH, the parameter name must be the same as thatin the backend request path.NOTE
– The parameter name cannot start with x-sdk-*.
– The parameter name cannot be x-stage.
– The name of a header parameter is not case-sensitive.
Location Select the location where the parameter will be added in arequest.The options include PATH, QUERY, and HEADER.
Value Enter a parameter value.
Description Enter a description for the constant parameter.
NOTE
– API Gateway sends requests containing constant parameters after percent-encoding of specialparameter values. Ensure that the backend services support percent-encoding. For example,parameter value [apig] becomes %5Bapig%5D after percent-encoding.
– For parameter values contained in a path, the following characters will be percent encoded:ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters ?></%#"[\]^`{|}
– For parameter values contained in a query request, the following characters will be percentencoded: ASCII codes 0–31, blank symbols, ASCII codes 127–255, and characters >=<+&%#"[\]^`{|}
Step 13 Click Next, and set responses (see Table 6-18) on the Define Response page.
Table 6-18 Responses
Parameter Description
Example SuccessResponse
Example of a response returned when the API is calledsuccessfully.
Example FailureResponse
Example of a response returned when the API fails to be called.
Step 14 Click Finish.
----End
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 51
6.5 Publishing an API
ScenarioAfter creating an API, you can publish it so that you can obtain the API information on theAPI Management page.
Prerequisitesl An API group and APIs have been created.l An environment has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Publish API page:l Locate the row that contains the API to be published and click Publish.l Click the name of the target API. In the upper right corner of the API details page that is
displayed, click Publish.
Step 6 Select the environment in which the API is to be published and enter the description.
NOTE
l If the API has been published in the selected environment, publishing it again will overwrite theexisting API.
l If you do not find the environment you need, you can create an environment as needed.
Step 7 Click Publish.
----End
6.6 Publication History
ScenarioView the publication history (such as version, description, time, and environment) of an API,and switch API versions in the same environment.
NOTE
An API can have up to 10 publication records for each environment.
PrerequisitesAn API has been published.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 52
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Click the name of the target API.
Step 6 On the API details page that is displayed, click Detailed Information.
Step 7 Click Publication History.
View the API publication history.
Step 8 Click View Details in the Operation column of a version.
The View Details page shows the configurations of the API version, including API request,backend request, response, input parameters, parameter mappings, and constant parameters.
Step 9 To roll the API back to an earlier version, click Switch Version in the same row as theversion, and click OK.
If "current version" is displayed next to the target version, the rollback is successful.
When the API is called, configurations of the current version rather than those last saved forthe API are used.
For example, an API was published in the RELEASE environment on August 1, 2018. OnAugust 20, 2018, the API was published in the same environment after modification. If theversion published on August 1 is set as the current version, configurations of this version areused when the API is called.
----End
6.7 Removing an API
Scenario
If you want to suspend a published API, you can temporarily remove it from the environmentin which it has been published.
NOTICEThis operation will cause the API to be inaccessible in the specified environment. Ensure thatyou have notified API users of this operation.
Prerequisitesl An API group and APIs have been created.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 53
l An API has been published in the environment.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Remove API page:l Locate the row that contains the target API and choose More > Remove.l Click the name of the target API. In the upper right corner of the API details page that is
displayed, click Remove.
Step 6 Select the environment where the API needs to be brought offline and click Yes.
----End
6.8 Debugging an API
Scenario
After an API is created, you can verify its functions on the management console by addingHTTP header parameters and body parameters.
NOTE
l APIs with backend request paths containing variables do not support debugging.
l When an API bound with a throttling policy is debugged, the throttling policy is invalid.
Prerequisitesl An API group and APIs have been created.l The backend service has been prepared.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Debug page:l Locate the row that contains the target API and choose More > Debug.l Click the name of the target API. In the upper right corner of the API details page that is
displayed, click Debug.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 54
On the left side, set API request parameters listed in Table 6-19. On the right side, view theAPI request and response information after you click Send Request.
Table 6-19 Parameters for debugging an API
Parameter Value
Http Method This parameter can be modified only when Method is set to ANY.
SuffixPath User-defined paths are supported only when Matching Method is set toPrefix match.
Parameter This parameter can be modified only when the value of Path contains{}.
Headers Parameter HTTP Headers and its value
Query Parameter Body and its value
Body This parameter can be modified only when Method is set to ANY,PATCH, POST, or PUT.
Step 6 After adding the request parameters, click Send Request.
The API invoking response information is displayed in the command output area in the rightpane.
Step 7 You can send different requests using varied parameters and values to verify the API.
NOTE
To modify API parameters, click Edit in the upper right corner, and modify the parameters on the EditAPI page.
----End
6.9 Canceling Authorization
Scenario
You can cancel authorization for an application that has been authorized to invoke an API.
Prerequisitesl An API group and APIs have been created.l An application has been authorized to invoke the API.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 55
Step 4 Choose API Publishing > API Management.
Step 5 Use any of the following methods to view the list of authorized applications:
l Locate the row that contains the target API and click Authorize. Click .
l Select the target API and click Authorize. Click .l Perform the following operations on the API details page:
a. Click the name of the target API.b. On the API details page that is displayed, click Detailed Information.c. Click Authorizations.
Step 6 Locate the row that contains the target application and click Cancel Authorization.
Step 7 Click Yes.
----End
6.10 Deleting an API
Scenario
You can delete a published API if it no longer needs to provide services.
NOTICEl After deletion, the API cannot be accessed, which may affect the functioning of related
applications. Ensure that you have notified users of the deletion.l APIs that have already been launched to the cloud marketplace cannot be deleted.
Prerequisitesl An API group and APIs have been created.l An API does not need to provide services.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > API Management.
Step 5 Use either of the following methods to access the Delete API page:l Locate the row that contains the target API group and choose More > Delete.l Click the name of the target API. In the upper right corner of the API details page that is
displayed, click Delete.
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 56
Step 6 Enter DELETE and click Yes.
----End
API GatewayUser Guide (API Publishing) 6 API Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 57
7 Request Throttling
Creating a Throttling Policy
Associating a Throttling Policy with an API
Editing a Throttling Policy
Deleting a Throttling Policy
Adding an Override Application
Disassociating a Throttling Policy from an API
Deleting an Override Application
7.1 Creating a Throttling Policy
Scenario
The request throttling function allows you to limit the number of API calls within a specifiedperiod to protect backend services.
To provide continuous, stable services, you can create a throttling policy to control requests tosome APIs.
NOTE
Each user can create a maximum of 30 throttling policies.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Click Create Throttling Policy. Set the parameters listed in Table 7-1.
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 58
Table 7-1 Parameters
Parameter Description Value
Policy Name Name of the throttling policy l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
Duration Duration of an API call limit l This parameter is used togetherwith Maximum API Requestsand indicates the maximumnumber of requests to a singleAPI in a specified period.
l This parameter is used togetherwith Maximum UserRequests and indicates themaximum number of requestsmade by a single user in aspecified period.
l This parameter is used togetherwith Maximum ApplicationRequests and indicates themaximum number of requestsmade by a single application ina specified period.
Maximum APIRequests
Maximum number of times that anAPI can be called.
This parameter is used togetherwith Duration and indicates themaximum number of times that anAPI can be called in a specifiedperiod.
Maximum UserRequests
Maximum number of times that anAPI can be called by a user.
l The value cannot exceed thevalue of Maximum APIRequests.
l This parameter is used togetherwith Duration and indicatesthe maximum number of timesthat an API can be called by auser in a specified period.
MaximumApplicationRequests
Maximum number of times that anAPI can be called by anapplication.
l The value cannot exceed thevalue of Maximum UserRequests.
l This parameter is used togetherwith Duration and indicatesthe maximum number of timesthat an API can be called by anapplication in a specifiedperiod.
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 59
Parameter Description Value
Description Description of the throttling policy The value can contain 0–255characters.
Step 6 Click OK.
After the policy is created, it is displayed on the policy information page. You can bind relatedAPIs to the policy to implement request throttling.
----End
7.2 Associating a Throttling Policy with an API
ScenarioAssociate a throttling policy with an API.
NOTE
Only one throttling policy can be bound to an API.
Prerequisitesl A throttling policy has been created.l The API with which the policy is to be associated has been published.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Use either of the following methods to access the Associate with API page:l Locate the row that contains the target throttling policy and click Associate with API.
On the Associate Throttling Policy with API page, click Associate with API.l Click the name of the target policy. On the Associated APIs page, click Associate with
API.
Step 6 Specify an API group, environment, and API name keyword to filter the required APIs.
Step 7 Select the APIs and click Associate.
NOTE
To implement request throttling on an application, add an override application to the policy. For details,see section Adding an Override Application. After a special application is added, traffic of theapplication is restricted by the threshold set when the special application is added. The API call limit anduser traffic limit are restricted by the policy.
----End
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 60
7.3 Editing a Throttling Policy
ScenarioAfter creating a throttling policy, you can modify the parameters set during creation by editingthe throttling policy.
PrerequisitesA throttling policy has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Use either of the following ways to open the Edit Throttling Policy dialog box:l Locate the row that contains the target policy and click Edit.l Click the name of the target policy. In the upper right corner of the policy details page
that is displayed, click Edit.
Step 6 Set the parameters in the following table.
Table 7-2 Parameters
Parameter Description Value
Policy Name Name of the throttling policy l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 61
Parameter Description Value
Duration Duration of an API call limit l This parameter is used togetherwith Maximum API Requestsand indicates the maximumnumber of requests to a singleAPI in a specified period.
l This parameter is used togetherwith Maximum UserRequests and indicates themaximum number of requestsmade by a single user in aspecified period.
l This parameter is used togetherwith Maximum ApplicationRequests and indicates themaximum number of requestsmade by a single application ina specified period.
Maximum APIRequests
Maximum number of times that anAPI can be called.
This parameter is used togetherwith Duration and indicates themaximum number of times that anAPI can be called in a specifiedperiod.
Maximum UserRequests
Maximum number of times that anAPI can be called by a user.
l The value cannot exceed thevalue of Maximum APIRequests.
l This parameter is used togetherwith Duration and indicatesthe maximum number of timesthat an API can be called by auser in a specified period.
MaximumApplicationRequests
Maximum number of times that anAPI can be called by anapplication.
l The value cannot exceed thevalue of Maximum UserRequests.
l This parameter is used togetherwith Duration and indicatesthe maximum number of timesthat an API can be called by anapplication in a specifiedperiod.
Description Description of the throttling policy The value can contain 0–255characters.
NOTE
When emergency request throttling is required, the value of Maximum API Requests can be less thanthe maximum threshold of override applications.
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 62
Step 7 Click OK.
----End
7.4 Deleting a Throttling Policy
Scenario
If the created throttling policy does not need to provide services any longer, you can delete thepolicy.
Prerequisites
A throttling policy has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Use either of the following ways to access the Delete Throttling Policy page:l Locate the row that contains the target policy and click Delete.l Click the name of the target policy. In the upper right corner of the policy details page
that is displayed, click Delete.
NOTE
A throttling policy can be deleted only if it is not bound to any API. Otherwise, unbind the policy fromthe API before deleting the policy.
Step 6 Click Yes.
----End
7.5 Adding an Override Application
Scenario
After a throttling policy is created, you can add override applications to the policy.
Prerequisites
An application has been created.
Procedure
Step 1 Log in to the management console.
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 63
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Click the name of the target throttling policy to enter the policy details page.
Step 6 Click Override Applications.
Step 7 Click Add Override Application.
Step 8 Add a special application in either of the following ways:
1. To add an existing application, click Existing, select an existing application, and enter athreshold.
2. To add other applications, click Other and enter the application ID and threshold ofanother user.
NOTE
The threshold cannot exceed the API call limit and must be a positive integer.
----End
7.6 Disassociating a Throttling Policy from an API
Scenario
After a throttling policy is associated an API, if the API does not need to invoke this policyany longer, you can disassociate the policy from the API.
Prerequisitesl A throttling policy has been created.l The throttling policy has been associated with the API.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Click the name of the target throttling policy to enter the policy details page.
Step 6 Locate the row that contains the target API and click Disassociate.
Step 7 Click Yes.
----End
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 64
7.7 Deleting an Override Application
ScenarioIf an override application added to the throttling policy has no use any longer, you can deletethe application.
Prerequisitesl A throttling policy has been created.l An override application has been added.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Request Throttling.
Step 5 Click the name of the target throttling policy to enter the policy details page.
Step 6 Click Override Applications.
Step 7 Locate the row that contains the target special application and click Delete.
Step 8 Click Yes.
----End
API GatewayUser Guide (API Publishing) 7 Request Throttling
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 65
8 Access Control
Creating an Access Control Policy
Associating an Access Control Policy with an API
Editing an Access Control Policy
Deleting an Access Control Policy
Disassociating an Access Control Policy from an API
8.1 Creating an Access Control Policy
ScenarioCreate an access control policy to control the sources from which API calls can be received.
NOTE
You can create a maximum of 100 access control policies.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 In the navigation pane, choose API Publishing > Access Control.
Step 5 Click Create Access Control Policy.
Step 6 In the Create Access Control Policy dialog box, set the parameters listed in Table 8-1.
API GatewayUser Guide (API Publishing) 8 Access Control
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 66
Table 8-1 Parameters for creating an access control policy
Parameter Description Value
Policy Name Name of the access controlpolicy you want to create.
l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
RestrictionType
Type of the source from whichAPI calls are controlled.
IP Address: Specify IP addresses or IPaddress ranges that are allowed or notallowed to access an API.
Action Options: Allow and Deny. This parameter is used along withRestriction Type to control the accessof specified IP addresses or IP addressranges to an API.
IP Address Specify IP addresses and IPaddress ranges that are allowedor not allowed to access an API.
-
Step 7 Click OK.
----End
8.2 Associating an Access Control Policy with an API
Scenario
Associate an access control policy with an API.
Prerequisitesl You have created an access control policy.l The API with which you want to associate an access control policy has been published.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 In the navigation pane, choose API Publishing > Access Control.
Step 5 Use either of the following methods to access the Associate with API page:l Locate the row that contains the target access control policy and click Associate with
API. On the Associate Access Control Policy with API page, click Associate withAPI.
API GatewayUser Guide (API Publishing) 8 Access Control
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 67
l Click the name of the target policy. On the Associate Access Control Policy with APIpage, click Associate with API.
Step 6 Specify an API group, environment, and API name keyword to filter the required APIs.
Step 7 Select the APIs and click Associate.
----End
8.3 Editing an Access Control Policy
ScenarioModify the parameters of an access control policy that you have created.
PrerequisitesYou have created an access control policy.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 In the navigation pane, choose API Publishing > Access Control.
Step 5 Use either of the following ways to open the Edit Access Control Policy dialog box:l Locate the row that contains the target policy and click Edit.l Click the name of the target policy. In the upper right corner of the policy details page
that is displayed, click Edit.
Step 6 Set the parameters listed in the following table.
Table 8-2 Parameters for editing an access control policy
Parameter Description Value
Policy Name Name of the access controlpolicy you want to create.
l Must start with a letter.l Can contain letters, digits, and
underscores (_).l Consists of 3 to 64 characters.
Action Options: Allow and Deny. This parameter is used along withRestriction Type to control the accessof specified IP addresses or IP addressranges to an API.
IP Address Specify IP addresses and IPaddress ranges that are allowedor not allowed to access an API.
-
API GatewayUser Guide (API Publishing) 8 Access Control
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 68
Step 7 Click OK.
----End
8.4 Deleting an Access Control Policy
Scenario
Delete an access control policy that will no longer be used.
Prerequisites
You have created an access control policy.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 In the navigation pane, choose API Publishing > Access Control.
Step 5 Use either of the following ways to access the Delete Access Control Policy page:l Locate the row that contains the target access control policy and click Delete.l Click the name of the target policy. In the upper right corner of the policy details page
that is displayed, click Delete.
NOTE
To delete an access control policy that is associated with an API, first disassociate the policy from theAPI.
Step 6 Click Yes.
----End
8.5 Disassociating an Access Control Policy from an API
Scenario
Disassociate an access control policy from the associated API if the API will never need tocall the policy again.
Prerequisitesl You have created an access control policy.l You have associated the access control policy with an API.
API GatewayUser Guide (API Publishing) 8 Access Control
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 69
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 In the navigation pane, choose API Publishing > Access Control.
Step 5 On the Access Control page, click the name of the access control policy that you want todisassociate.
Step 6 Locate the row that contains the target API and click Disassociate.
Step 7 Click Yes.
----End
API GatewayUser Guide (API Publishing) 8 Access Control
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 70
9 Environment Management
Creating an Environment
Accessing an Environment
Editing an Environment
Deleting an Environment
9.1 Creating an Environment
ScenarioAPIs can be called in different environments, such as the production, test, and developmentenvironments. API Gateway provides environment management. You can define API callingpaths for different environments.
NOTE
Each user can create a maximum of 10 environments.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Environment Management.
Step 5 Click Create Environment. On the Create Environment page, set the parameters listed inTable 9-1.
API GatewayUser Guide (API Publishing) 9 Environment Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 71
Table 9-1 Environment information
Parameter Description Value
EnvironmentName
Name of the API environment l Must start with a letter.l Can contain letters,
digits, and underscores(_).
l Consists of 3 to 64characters.
Description Description of the environment The value can contain 0–255 characters.
Step 6 Click OK.
After the environment is created, it is displayed in environment list on the EnvironmentManagement page.
----End
9.2 Accessing an EnvironmentThe default RELEASE environment can be accessed using a RESTful API. For access toother environments, you need to add the X-stage header to the request header to specify anenvironment name. For example, to access the DEVELOP environment, add X-Stage:DEVELOP to the request header.
9.3 Editing an Environment
Scenario
After creating an environment, you can modify the environment parameters.
Prerequisites
An environment has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Environment Management.
Step 5 Locate the row that contains the target environment and click Edit.
API GatewayUser Guide (API Publishing) 9 Environment Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 72
Step 6 Set the parameters in the following table.
Table 9-2 Environment information
Parameter Description Value
EnvironmentName
Name of the API environment l Must start with a letter.l Can contain letters,
digits, and underscores(_).
l Consists of 3 to 64characters.
Description Description of the environment The value can contain 0–255 characters.
Step 7 Click OK.
----End
9.4 Deleting an Environment
Scenario
You can delete an environment that no longer provides services.
Prerequisites
An environment has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Environment Management.
Step 5 Locate the row that contains the environment to be deleted and click Delete.
NOTE
An environment can be deleted only if no API has been published in the environment.
Step 6 Click Yes.
----End
API GatewayUser Guide (API Publishing) 9 Environment Management
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 73
10 Signature Key
Creating a Key
Editing a Key
Associating a Signature Key with an API
Disassociating a Signature Key from an API
Deleting a Key
10.1 Creating a Key
ScenarioThe signature key is used by backend services to verify the identity of API Gateway to ensuresecurity of backend services.
NOTE
Each user can create a maximum of 30 signature keys.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Signature Key.
Step 5 Click Create Key.
Step 6 On the Create Key page, set the parameters listed in Table 10-1.
API GatewayUser Guide (API Publishing) 10 Signature Key
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 74
Table 10-1 Parameters
Parameter Description Value
Key Name User-defined name that identifies a key l Can contain letters,digits, and underscores(_).
l Must start with a letter.l Consists of 3 to 64
characters.
Key This parameter is used together withSecret and indicates the signature key pair.
l Can contain letters,digits, and underscores(_).
l Must start with a letter.l Contains 8 to 32
characters.
Secret This parameter is used together with Keyand indicates the signature key pair.
l Can contain letters,digits, and specialcharacters _!@#$%
l Must start with a letter.l Contains 16 to 64
characters.
Step 7 Click OK.
----End
10.2 Editing a Key
Scenario
If a key is leaked and the binding relationship between the key and API needs to be retained,you can modify the key.
Prerequisites
A key has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Signature Key.
API GatewayUser Guide (API Publishing) 10 Signature Key
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 75
Step 5 Use either of the following methods to access the Edit Key page:l Locate the row that contains the target key and click Edit.l Click the name of the target key. In the upper right corner of the key details page that is
displayed, click Edit.
Step 6 Set the parameters in the following table.
Table 10-2 Parameters
Parameter Description Value
Key Name User-defined name that identifies a key l Can contain letters,digits, and underscores(_).
l Must start with a letter.l Consists of 3 to 64
characters.
Key This parameter is used together withSecret and indicates the signature key pair.
l Can contain letters,digits, and underscores(_).
l Must start with a letter.l Contains 8 to 32
characters.
Secret This parameter is used together with Keyand indicates the signature key pair.
l Can contain letters,digits, and specialcharacters _!@#$%
l Must start with a letter.l Contains 16 to 64
characters.
Step 7 Click OK.
----End
10.3 Associating a Signature Key with an API
Scenario
After a signature key is bound to an API, API Gateway adds signature information to therequest sent to the backend service. After receiving the request, the backend service calculatesthe signature information and checks whether the calculated signature information isconsistent with the signature information of API Gateway.
Prerequisitesl A key has been created.l The API with which the signature key is to be associated has been published.
API GatewayUser Guide (API Publishing) 10 Signature Key
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 76
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Signature Key.
Step 5 Use either of the following methods to enter the page displaying the APIs to which thesignature key has been bound:l Locate the row that contains the target key and click Associate with API.l Click the name of the target key.
Step 6 Click Associate with API.
Step 7 Specify API Group, Environment, and API Name to filter out target APIs.
Step 8 Select the APIs and click Associate.
----End
Related Operations
Sign the API and backend service by following the instructions in Signature Algorithm, andcheck whether the signatures are consistent.
10.4 Disassociating a Signature Key from an API
Scenario
After a signature key is associated with an API, if the API does not need to invoke this keyany longer, you can disassociate the key from the API.
Prerequisites
The signature key has been associated with an API.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Signature Key.
Step 5 Use either of the following methods to enter the page displaying the APIs to which thesignature key has been bound:l Locate the row that contains the target key and click Associate with API.
API GatewayUser Guide (API Publishing) 10 Signature Key
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 77
l Click the name of the target key.
Step 6 Locate the row that contains the target API and click Disassociate.
Step 7 Click Yes.
----End
10.5 Deleting a Key
ScenarioIf a key does not provide services any longer, you can delete it.
PrerequisitesA key has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > Signature Key.
Step 5 Use either of the following methods to access the Delete Key page:l Locate the row that contains the target key and click Delete.l Click the name of the target key. In the upper right corner of the key details page that is
displayed, click Delete.
Step 6 Click Yes.
----End
API GatewayUser Guide (API Publishing) 10 Signature Key
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 78
11 VPC Link
Creating a VPC Link
Editing a VPC Link
Deleting a VPC Link
Editing Health Check Configurations
Editing ECS Configurations
11.1 Creating a VPC Link
Scenario
API Gateway allows you to open APIs for backend services deployed in VPCs.
After creating a VPC link, you can configure it for an API of the HTTP backend service type.
For example, a VPC contains six ECSs, and a VPC link has been created to reach ECS 01 andECS 04. Therefore, API Gateway can access these two ECSs through the VPC link.
NOTE
You can create a maximum of 30 VPC links.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 79
Prerequisites
An ECS has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > VPC Links.
Step 5 Click Create VPC Link, and set the parameters listed in Table 11-1.
Table 11-1 VPC link configuration
Parameter Description Value
VPC Link Name of a VPC link l Can contain letters, digits,underscores (_), and hyphens (-).
l Must start with a letter.l Consists of 3 to 64 characters.
Port Host port of the VPC link. 1–65535
DistributionAlgorithm
Determines to which host requestsare to be sent.The following distributionalgorithms are available:l WRR: weighted round robinl WLC: weighted least
connectionl SH: source hashingl URI hashing
This parameter is required onlywhen Type is set to Fast link.
Protocol Used to perform health checks onECSs in a VPC link. Options:l TCPl HTTP
Default value: TCP
Check Path Destination path for health checks This parameter is required onlywhen Protocol is set to HTTP.
Check Port Destination port for health checks By default, the host port of a VPClink is used.
HealthyThreshold
Number (x) of consecutivesuccessful checks required for anECS to be marked as healthy. xrefers to the healthy threshold.
Range: 2–10. Default value: 2.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 80
Parameter Description Value
UnhealthyThreshold
Number (x) of consecutive failedchecks required for an ECS to bemarked as unhealthy. x refers tothe unhealthy threshold.
Range: 2–10. Default value: 5.
Timeout Timeout used to determinewhether a health check fails. Unit:s.
Range: 2–30. Default value: 5.
Interval Interval between consecutivechecks. Unit: s.
Range: 5–300. Default value: 10.
ResponseCodes
Response codes for determining asuccessful HTTP response.
This parameter is required onlywhen Protocol is set to HTTP.
Step 6 Click Next.
Step 7 Click Add ECS.
Step 8 Select the ECSs you want to add, and click Add.
NOTE
To ensure successful health check and service availability, the 100.125.0.0/16 segment must have beenconfigured for security groups of the backend ECSs in the inbound direction.
Step 9 Click Finish.
----End
11.2 Editing a VPC Link
Scenario
After creating a VPC link, you can modify its configuration parameters.
Prerequisites
A VPC link has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > VPC Links.
Step 5 Use either of the following methods to access the Edit VPC Link page:l Locate the row that contains the target VPC link and click Edit.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 81
l Click the name of the target VPC link. In the upper right corner of the VPC link detailspage that is displayed, click Edit.
Step 6 On the Configure VPC Link page, edit the parameters listed in Table 11-2.
Table 11-2 VPC link configuration
Parameter Description Value
VPC Link Name of a VPC link l Can contain letters, digits,underscores (_), and hyphens (-).
l Must start with a letter.l Consists of 3 to 64 characters.
Port Host port of the VPC link. 1–65535
DistributionAlgorithm
Determines to which host requestsare to be sent.The following distributionalgorithms are available:l WRR: weighted round robinl WLC: weighted least
connectionl SH: source hashingl URI hashing
This parameter is required onlywhen Type is set to Fast link.
Protocol Used to perform health checks onECSs in a VPC link. Options:l TCPl HTTP
Default value: TCP
Check Path Destination path for health checks This parameter is required onlywhen Protocol is set to HTTP.
Check Port Destination port for health checks By default, the host port of a VPClink is used.
HealthyThreshold
Number (x) of consecutivesuccessful checks required for anECS to be marked as healthy. xrefers to the healthy threshold.
Range: 2–10. Default value: 2.
UnhealthyThreshold
Number (x) of consecutive failedchecks required for an ECS to bemarked as unhealthy. x refers tothe unhealthy threshold.
Range: 2–10. Default value: 5.
Timeout Timeout used to determinewhether a health check fails. Unit:s.
Range: 2–30. Default value: 5.
Interval Interval between consecutivechecks. Unit: s.
Range: 5–300. Default value: 10.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 82
Parameter Description Value
ResponseCodes
Response codes for determining asuccessful HTTP response.
This parameter is required onlywhen Protocol is set to HTTP.
Step 7 Click Next.
Step 8 Add or delete ECSs, modify ECS weights, and click Finish.
NOTE
To ensure successful health check and service availability, the 100.125.0.0/16 segment must have beenconfigured for security groups of the backend ECSs in the inbound direction.
----End
11.3 Deleting a VPC Link
Scenario
You can delete a VPC link if it is no longer needed.
NOTE
VPC links that have been used by APIs cannot be deleted.
Prerequisites
A VPC link has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > VPC Links.
Step 5 Use either of the following methods to access the Delete VPC Link page:
l Locate the row that contains the target VPC link and click Delete.
l Click the name of the target VPC link. In the upper right corner of the VPC details pagethat is displayed, click Delete.
Step 6 Click Yes.
----End
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 83
11.4 Editing Health Check Configurations
Scenario
After creating a VPC link, you can modify its health check configurations.
Prerequisites
A VPC link has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > VPC Links.
Step 5 Click the name of the target VPC link.
Step 6 Click the Health Check tab.
Step 7 Click Edit.
Step 8 On the Edit Health Check Configuration page, edit the parameters listed in Table 11-3.
Table 11-3 Health check configuration
Parameter Description Value
Protocol Used to perform healthchecks on ECSs in a VPClink. Options:l TCPl HTTP
Default value: TCP
Check Path Destination path for healthchecks
This parameter is requiredonly when Protocol is set toHTTP.
Check Port Destination port for healthchecks
By default, the host port of aVPC link is used.
Healthy Threshold Number (x) of consecutivesuccessful checks requiredfor an ECS to be marked ashealthy. x refers to thehealthy threshold.
Range: 2–10. Defaultvalue: 2.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 84
Parameter Description Value
Unhealthy Threshold Number (x) of consecutivefailed checks required for anECS to be marked asunhealthy. x refers to theunhealthy threshold.
Range: 2–10. Defaultvalue: 5.
Timeout Timeout used to determinewhether a health check fails.Unit: s.
Range: 2–30. Defaultvalue: 5.
Interval Interval betweenconsecutive checks. Unit: s.
Range: 5–300. Defaultvalue: 10.
Response Codes HTTP codes used to checkfor an HTTP response froma target.
This parameter is requiredonly when Protocol is set toHTTP.
Step 9 Click OK.
----End
11.5 Editing ECS Configurations
Scenario
After creating a VPC link, you can add or delete ECSs and edit ECS weights for the VPClink.
Prerequisites
A VPC link has been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
Step 4 Choose API Publishing > VPC Links.
Step 5 Click the name of the target VPC link.
Step 6 Click the ECS tab.
Step 7 Add or delete ECSs and edit ECS weights as required.l Adding ECSs
a. Click Add ECS.
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 85
b. Select the ECSs you want to add, set their weights, and click Add.
NOTE
To ensure successful health check and service availability, the 100.125.0.0/16 segment musthave been configured for security groups of the backend ECSs in the inbound direction.
l Deleting an ECS
a. Locate the row that contains the target ECS and click Delete.b. Click Yes.
l Editing the weight of an ECS
a. Locate the row that contains the target ECS, and click in the Weight column.
b. Change the weight and click .l Editing the weights of multiple ECSs
a. Select the ECSs to be edited, and click Batch Edit Weights.b. Change the weight of each ECS, and click OK.
----End
API GatewayUser Guide (API Publishing) 11 VPC Link
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 86
12 Auditing
Enabling CTS
If you want to collect, record, or query operation logs of API Gateway in common scenariossuch as security analysis, compliance audit, resource tracing, and problem locating, you needto enable CTS.
With CTS, you can:
l Record audit logs.
l Query audit logs.
l Dump audit logs.
l Encrypt trace files.
l Enable notification of key operations.
Querying Audit Logs
To query audit logs, see Querying Real-Time Traces.
Querying Key Operations
With CTS, you can record operations associated with API Gateway for later query, audit, andbacktrack operations. For details, see Key Operations on API Gateway.
Disabling CTS
To disable CTS, see Deleting a Tracker.
API GatewayUser Guide (API Publishing) 12 Auditing
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 87
13 Monitoring
API Gateway Metrics
Creating Alarm Rules
Viewing Metrics
13.1 API Gateway Metrics
Table 13-1 API Gateway metrics
Metric Description
Number ofrequests
Total number of API requests
Average latency Average invocation latency of a single API in a specified period
Maximumlatency
Maximum invocation latency of a single API in a specified period
Upstreamtraffic
Total requested traffic of the API in a specified period
Downstreamtraffic
Total returned traffic of the API in a specified period
5xx error Total number of 5xx errors returned for your API requests
4xx error Total number of 4xx errors returned for your API requests
13.2 Creating Alarm Rules
ScenarioYou can create alarm rules with specified monitored objects and notification policies. Thishelps you track the running status of API Gateway to prevent service abnormalities.
API GatewayUser Guide (API Publishing) 13 Monitoring
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 88
An alarm rule includes the rule name, monitored object, metric, alarm threshold, monitoringinterval, and whether to send a notification.
Prerequisites
An API has been called.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
The navigation pane contains four columns: Dashboard, API Publishing, API Calling, andDocumentation.
Step 4 Choose API Publishing > API Management.
Step 5 Click the name of the target API. The Monitoring page is displayed.
Step 6 Click View More Metrics. On the Cloud Eye console that is displayed, create alarm rules byfollowing the procedure in Creating Alarm Rules.
----End
13.3 Viewing Metrics
Scenario
Cloud Eye monitors the running status of API Gateway, and you can view the API Gatewaymetrics on the Cloud Eye console.
Prerequisites
An API group and APIs have been created.
Procedure
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Application > API Gateway.
The navigation pane contains four columns: Dashboard, API Publishing, API Calling, andDocumentation.
Step 4 Choose API Publishing > API Management.
Step 5 Click the name of the target API. The Monitoring page is displayed.
View API metrics.
API GatewayUser Guide (API Publishing) 13 Monitoring
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 89
Step 6 Click View More Metrics. The Cloud Eye monitoring page is displayed, where you can viewmore monitoring statistics.
NOTE
The monitoring data is retained for two days. To retain the data for a longer time, you need to configureOBS buckets and save the data in these OBS buckets. For details, see Transferring Metric Data toOBS.
----End
API GatewayUser Guide (API Publishing) 13 Monitoring
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 90
14 FAQs
How Is API Gateway Charged?
What Are the Relationships Between an API, Environment, and App?
How Can I Use API Gateway?
Why Does a Backend Service Fail to Be invoked?
What Is an Error Message Returned by API Gateway Like?
Do I Need to Publish an API Again After Modification?
How Can I Protect My APIs?
Can Mobile Applications Call APIs?
Can I Upload Files Using the POST Method?
Can Applications Deployed in a VPC Call APIs?
How Can I Ensure the Security of Backend Services Invoked by API Gateway?
What SDK Languages Does API Gateway Support?
How Can I Make an API Published in a Non-RELEASE Environment Accessible?
Does API Gateway Support Multiple Backend Endpoints?
What Is the Maximum Size of an API Request Package?
14.1 How Is API Gateway Charged?You can enable API Gateway and create and manage APIs for free. You only need to pay forthe number of API calls and the amount of data transmitted. There are no minimum charges orupfront commitments.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 91
14.2 What Are the Relationships Between an API,Environment, and App?
An API can be published in different environments, such as RELEASE (online environment)and BETA (test environment).
An App refers to the identity of an API caller. After you create an App, the systemautomatically generates an AppKey and AppSecret for authenticating the App. After an APIis published and authorized to a specified App, the App owner can call the API.
When publishing an API in different environments, you can define different request throttlingpolicies and authorize different Apps to call the API. For example, during the test process,API v2 can be published in the BETA environment and authorized to the test Apps. API v1 isa stable version and can be authorized to all users or Apps in the RELEASE environment.
14.3 How Can I Use API Gateway?You can use API Gateway to manage and call APIs through the following methods:
l Management console, a web-based service management platformAfter registering with the public cloud platform, log in to the management console, andchoose All Services > Application > API Gateway.
l SDKs of multiple languages such as Java, Go, Python, JavaScript, C#, PHP, C++, and C.You can download the SDKs to call APIs. For details, see the API Gateway DeveloperGuide.
14.4 Why Does a Backend Service Fail to Be invoked?A backend service may fail to be invoked due to the following causes.
Possible Cause Solution
The backend service IP address is incorrect. Change the backend service IP address inthe API definition.
The timeout duration is incorrect.If the backend service fails to return aresponse within the configured timeoutduration, API Gateway displays a messageindicating that the backend service fails tobe invoked.
Increase the backend timeout duration in theAPI definition.
The security group of the Elastic CloudServer (ECS) on which the backend serviceis deployed cannot be accessed.
Ensure that the inbound and outbound portsand protocols of the service are correct.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 92
14.5 What Is an Error Message Returned by API GatewayLike?
When receiving an API request, API Gateway returns a response. A similar response body isas follows:
{ "error_code": "APIG.0101", "error_msg": "API not exist or not published to environment", "request_id": "acbc548ac6f2a0dbdb9e3518a7c0ff84"}l "error_code": indicates an error code.l "error_msg": indicates an error message.
14.6 Do I Need to Publish an API Again AfterModification?
Yes. After an API is published, if you modify its parameters, you must publish the API againto synchronize the modified information to the environment.
14.7 How Can I Protect My APIs?Bind request throttling policies to your APIs to protect the APIs against a large number ofrequests. By default, an API can be called up to 200 times per second.
14.8 Can Mobile Applications Call APIs?Yes, mobile Apps can call APIs. In App authentication mode, the AppKey and AppSecret of amobile App are replaced with those in the relevant SDK to sign the App.
14.9 Can I Upload Files Using the POST Method?Yes, you can upload files using the POST method. The maximum size of an API requestpackage is 12 MB.
14.10 Can Applications Deployed in a VPC Call APIs?Yes, applications deployed in a Virtual Private Cloud (VPC) can call APIs by default. Ifdomain name resolution fails, configure a DNS server on the current endpoint by followingthe instructions in Configuring an Intranet DNS Server. After the configuration,applications deployed in the VPC can call APIs.
Configuring an Intranet DNS Server
To configure a DNS server, specify its IP address in the resolv.conf file under the /etcdirectory.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 93
The IP address of the intranet DNS server depends on which region you are located in. Obtainthe IP address of the intranet DNS server in your region from Table 14-1.
Table 14-1 Mapping between intranet DNS server IP addresses and regions
Region DNS Server IP Address
CN North-Beijng1 100.125.1.250
CN South-Guangzhou 100.125.1.250
CN East-Shanghai2 100.125.17.29
Add an intranet DNS server by using either of the following two methods:
l Method 1: Modify the subnet information of the VPC.l Method 2: Edit the resolv.conf file under the /etc directory.
NOTE
The intranet DNS server configuration becomes invalid every time the ECS restarts, and theintranet DNS server must be configured again. Therefore, method 1 is recommended.
Method 1Perform the following procedure to add a DNS server IP address to the subnet configurationsof the ECS in the VPC. The following procedure is based on CN North-Beijng1.
Step 1 Log in to the management console.
Step 2 Click in the upper left corner to select a region.
Step 3 In the service list, choose Computing > Elastic Cloud Server.
Step 4 Click the name of the ECS to be used.
Step 5 On the ECS details page, click the NICs tab, and click to view the subnet name of theECS.
The following figure highlights the subnet name subnet-9c19 of the ECS.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 94
Step 6 On the ECS details page, view the VPC name of the ECS.
The following figure highlights the VPC name vpc-9c19 of the ECS.
Step 7 Click the VPC name to visit the VPC console.
Step 8 On the VPC page, click the VPC name obtained in step Step 6.
Step 9 On the Subnets tab page, find the subnet name obtained in step Step 5, and click Modify inthe Operation column.
Step 10 Modify the DNS information of the subnet, and then click OK to save the modifications.
Change DNS Server Address 1 to 100.125.1.250.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 95
Step 11 Restart the ECS. Check whether the resolv.conf file under the /etc directory contains the IPaddress of the DNS server to be configured, and whether the IP address precedes that of anyother DNS server.
The following figure shows the IP address 100.125.1.250 of the DNS server to be configured.
NOTE
Modifying the subnet information of a VPC will affect all ECSs created using the subnet.
----End
Method 2Add the IP address of the intranet DNS server to the resolv.conf file under the /etc directory.
For example, if you are located in North China-Beijing 1, add the intranet DNS server of IPaddress 100.125.1.250 to the resolv.conf file.
NOTE
l The IP address of the new DNS server must precede that of any other DNS server.
l The DNS configuration takes effect immediately after the resolv.conf file is saved.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 96
14.11 How Can I Ensure the Security of Backend ServicesInvoked by API Gateway?
You can ensure the security of backend services invoked by API Gateway by using thefollowing methods:
l Bind a signature key to an API. After a signature key is bound to the API, API Gatewayadds signature information to the request sent to the backend service. After receiving therequest, the backend service calculates the signature information and checks whether it isconsistent with that on API Gateway.
l Encrypt requests using HTTPS. Before using this method, ensure that the required SSLcertificates are available.
14.12 What SDK Languages Does API Gateway Support?API Gateway supports SDKs of multiple languages such as Java, Go, Python, C#, JavaScript,PHP, C++, and C.
14.13 How Can I Make an API Published in a Non-RELEASE Environment Accessible?
To make an API published in a non-RELEASE environment accessible, add the x-stageheader to the API request. For details, see Step 5 in API Calling.
14.14 Does API Gateway Support Multiple BackendEndpoints?
Yes, API Gateway supports multiple backend endpoints by using VPC channels. You can addmultiple ECSs to a VPC channel.
14.15 What Is the Maximum Size of an API RequestPackage?
The maximum size of an API request body is 12 MB.
API GatewayUser Guide (API Publishing) 14 FAQs
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 97
A What's New
Table A-1 Change history
Date Description
2018-08-31 Added descriptions of switching API versions in section"Publication History".
2018-07-26 l Added section "Access Control" to describe how to specifyIP addresses or IP address ranges that are allowed or notallowed to access an API.
l Added support for configuring and mapping input andbackend parameters.
2018-07-16 Added chapter "Experiencing the Demo" to demonstrate how touse API gateway with a few clicks.
2018-06-29 l Added support for configuring CORS and constantparameters for APIs.
l Added section "Creating an API with the OPTIONSMethod" in chapter "API Management".
2018-05-30 Added chapter "VPC Link".
2018-05-02 l Added chapter "API Gateway and Other Services".l Added section "Binding a Domain Name" in chapter "API
Group".l Added section "Publication History" in chapter "API
Management".l Added chapter "Monitoring".l Added chapter "Auditing".
2018-04-04 Adjusted the quotas of APIs, API groups, throttling policies,environments, and signature keys.
2018-03-09 Added section "Enabling CTS".
API GatewayUser Guide (API Publishing) A What's New
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 98
Date Description
2018-01-31 l Added section "Creating an Environment Variable" inchapter "API Group".
l Added chapter "Signature Key".
2017-12-25 This issue is the first official release.
API GatewayUser Guide (API Publishing) A What's New
Issue 10 (2018-08-31) Copyright © Huawei Technologies Co., Ltd. 99