diff --git a/docs/apiu/guidelines/ALL_META.TXT.json b/docs/apiu/guidelines/ALL_META.TXT.json new file mode 100644 index 00000000..13f35599 --- /dev/null +++ b/docs/apiu/guidelines/ALL_META.TXT.json @@ -0,0 +1,185 @@ +[ + { + "dockw":"API Usage Guidelines" + }, + { + "uri":"apig-en-api-180328001.html", + "node_id":"apig-en-api-180328001.xml", + "product_code":"apiug", + "code":"1", + "des":"API requests sent by third-party applications to public cloud services must be authenticated using signatures.This document describes the signature procedure, provides sa", + "doc_type":"guidelines", + "kw":"Overview,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328002.html", + "node_id":"apig-en-api-180328002.xml", + "product_code":"apiug", + "code":"2", + "des":"API Gateway provides RESTful APIs.REST provides APIs to create, query, update, delete, and access service resources.A REST API request/response pair is divided into the f", + "doc_type":"guidelines", + "kw":"Overview of REST APIs,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Overview of REST APIs", + "githuburl":"" + }, + { + "uri":"apig-en-api-180925010.html", + "node_id":"apig-en-api-180925010.xml", + "product_code":"apiug", + "code":"3", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"guidelines", + "kw":"Calling APIs", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Calling APIs", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328009.html", + "node_id":"apig-en-api-180328009.xml", + "product_code":"apiug", + "code":"4", + "des":"Obtain the required information before calling APIs.A project ID needs to be specified in the URIs of some APIs. Therefore, you need to obtain the project ID before calli", + "doc_type":"guidelines", + "kw":"Obtaining Required Information,Calling APIs,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Obtaining Required Information", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328003.html", + "node_id":"apig-en-api-180328003.xml", + "product_code":"apiug", + "code":"5", + "des":"If API requests are authenticated using tokens, the request header must contain X-Auth-Token (token information).This section describes how to call an API for token authe", + "doc_type":"guidelines", + "kw":"Token Authentication,Calling APIs,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Token Authentication", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328004.html", + "node_id":"apig-en-api-180328004.xml", + "product_code":"apiug", + "code":"6", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"guidelines", + "kw":"AK/SK Authentication", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"AK/SK Authentication", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328005.html", + "node_id":"apig-en-api-180328005.xml", + "product_code":"apiug", + "code":"7", + "des":"Log in to the management console.Click the username and choose My Credential from the drop-down list.Click Access Keys.Click Add Access Keys to switch to the Add Access K", + "doc_type":"guidelines", + "kw":"Generating an AK and SK,AK/SK Authentication,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Generating an AK and SK", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328006.html", + "node_id":"apig-en-api-180328006.xml", + "product_code":"apiug", + "code":"8", + "des":"Introduce the API Gateway signing SDK in the project.Download the API Gateway signing tool from the following link:https://apig-demo.obs.eu-de.otc.t-systems.com/java/java", + "doc_type":"guidelines", + "kw":"Signing a Request,AK/SK Authentication,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Signing a Request", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328008.html", + "node_id":"apig-en-api-180328008.xml", + "product_code":"apiug", + "code":"9", + "des":"This section describes how to call the API of a public cloud service by using Eclipse.The following code shows how to sign a request and how to use an HTTP client to send", + "doc_type":"guidelines", + "kw":"Sample Code,AK/SK Authentication,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"Sample Code", + "githuburl":"" + }, + { + "uri":"apig-en-api-180328012.html", + "node_id":"apig-en-api-180328012.xml", + "product_code":"apiug", + "code":"10", + "des":"Table 1 describes common status codes.", + "doc_type":"guidelines", + "kw":"HTTP Status Codes,API Usage Guidelines", + "search_title":"", + "metedata":[ + { + "documenttype":"guidelines", + "prodname":"apiug" + } + ], + "title":"HTTP Status Codes", + "githuburl":"" + } +] \ No newline at end of file diff --git a/docs/apiu/guidelines/CLASS.TXT.json b/docs/apiu/guidelines/CLASS.TXT.json new file mode 100644 index 00000000..27a58a15 --- /dev/null +++ b/docs/apiu/guidelines/CLASS.TXT.json @@ -0,0 +1,92 @@ +[ + { + "desc":"API requests sent by third-party applications to public cloud services must be authenticated using signatures.This document describes the signature procedure, provides sa", + "product_code":"apiug", + "title":"Overview", + "uri":"apig-en-api-180328001.html", + "doc_type":"guidelines", + "p_code":"", + "code":"1" + }, + { + "desc":"API Gateway provides RESTful APIs.REST provides APIs to create, query, update, delete, and access service resources.A REST API request/response pair is divided into the f", + "product_code":"apiug", + "title":"Overview of REST APIs", + "uri":"apig-en-api-180328002.html", + "doc_type":"guidelines", + "p_code":"", + "code":"2" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"apiug", + "title":"Calling APIs", + "uri":"apig-en-api-180925010.html", + "doc_type":"guidelines", + "p_code":"", + "code":"3" + }, + { + "desc":"Obtain the required information before calling APIs.A project ID needs to be specified in the URIs of some APIs. Therefore, you need to obtain the project ID before calli", + "product_code":"apiug", + "title":"Obtaining Required Information", + "uri":"apig-en-api-180328009.html", + "doc_type":"guidelines", + "p_code":"3", + "code":"4" + }, + { + "desc":"If API requests are authenticated using tokens, the request header must contain X-Auth-Token (token information).This section describes how to call an API for token authe", + "product_code":"apiug", + "title":"Token Authentication", + "uri":"apig-en-api-180328003.html", + "doc_type":"guidelines", + "p_code":"3", + "code":"5" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"apiug", + "title":"AK/SK Authentication", + "uri":"apig-en-api-180328004.html", + "doc_type":"guidelines", + "p_code":"3", + "code":"6" + }, + { + "desc":"Log in to the management console.Click the username and choose My Credential from the drop-down list.Click Access Keys.Click Add Access Keys to switch to the Add Access K", + "product_code":"apiug", + "title":"Generating an AK and SK", + "uri":"apig-en-api-180328005.html", + "doc_type":"guidelines", + "p_code":"6", + "code":"7" + }, + { + "desc":"Introduce the API Gateway signing SDK in the project.Download the API Gateway signing tool from the following link:https://apig-demo.obs.eu-de.otc.t-systems.com/java/java", + "product_code":"apiug", + "title":"Signing a Request", + "uri":"apig-en-api-180328006.html", + "doc_type":"guidelines", + "p_code":"6", + "code":"8" + }, + { + "desc":"This section describes how to call the API of a public cloud service by using Eclipse.The following code shows how to sign a request and how to use an HTTP client to send", + "product_code":"apiug", + "title":"Sample Code", + "uri":"apig-en-api-180328008.html", + "doc_type":"guidelines", + "p_code":"6", + "code":"9" + }, + { + "desc":"Table 1 describes common status codes.", + "product_code":"apiug", + "title":"HTTP Status Codes", + "uri":"apig-en-api-180328012.html", + "doc_type":"guidelines", + "p_code":"", + "code":"10" + } +] \ No newline at end of file diff --git a/docs/apiu/guidelines/PARAMETERS.txt b/docs/apiu/guidelines/PARAMETERS.txt new file mode 100644 index 00000000..6da8d5f0 --- /dev/null +++ b/docs/apiu/guidelines/PARAMETERS.txt @@ -0,0 +1,3 @@ +version="" +language="en-us" +type="" \ No newline at end of file diff --git a/docs/apiu/guidelines/apig-en-api-180328001.html b/docs/apiu/guidelines/apig-en-api-180328001.html new file mode 100644 index 00000000..86c2e871 --- /dev/null +++ b/docs/apiu/guidelines/apig-en-api-180328001.html @@ -0,0 +1,7 @@ + + +
API requests sent by third-party applications to public cloud services must be authenticated using signatures.
+This document describes the signature procedure, provides sample code to illustrate how to use the default signer to sign requests and how to use the HTTP client to send requests.
+API Gateway provides RESTful APIs.
+REST provides APIs to create, query, update, delete, and access service resources.
+A REST API request/response pair is divided into the following parts:
+A request URI consists of the following parts:
+{URI-scheme} :// {Endpoint} / {resource-path} ? {query-string}
+Although a request URI is a part of a request header, most programming languages or frameworks require the request URI to be separately transmitted, rather than being conveyed in a request message.
+ +Parameter + |
+Description + |
+
---|---|
URI-scheme + |
+Protocol used to transmit the request. + |
+
Endpoint + |
+Domain name or IP address of the server where the RESTful service endpoint is hosted. You can obtain the value from Regions and Endpoints. + |
+
resource-path + |
+Path in which the resource requested by the API is located. The path is provided by the URI module of APIs, for example, v3/auth/tokens. + |
+
Query string + |
+This is an optional parameter. For example, the value can be the API version or resource selection criteria. + |
+
HTTP method: the type of requested operation.
+ +Method + |
+Description + |
+
---|---|
GET + |
+Requests a server to provide a specified resource. + |
+
PUT + |
+Requests a server to update a specified resource. + |
+
POST + |
+Requests a server to add resources or perform special operations. + |
+
DELETE + |
+Requests a server to delete a specified resource, for example, an object. + |
+
HEAD + |
+Similar to the GET method, the HEAD method requests a server to provide the specified resource, but the server returns only the response header (excluding the response body) to this request. + |
+
PATCH + |
+Requests a server to update a part of a specified resource. +If the resource does not exist, the PATCH method may create a new resource. + |
+
Optional header fields: For example, such fields could be those required by a specified URI and HTTP method. Table 3 describes common HTTP request header fields.
+ +Header + |
+Description + |
+Remarks + |
+Example + |
+
---|---|---|---|
Content-Type + |
+Type (or format) of the message body. + |
+Mandatory + |
+application/json + |
+
X-Auth-Token + |
+Token authentication information, which can be obtained by following the procedure in Token Authentication. + |
+Mandatory if token authentication is used. + |
+- + |
+
X-Sdk-Date + |
+Time at which the request was sent. + |
+Mandatory if AK/SK authentication is used. + |
+20151222T034042Z + |
+
Authorization + |
+Signature authentication information, which comes from the request signature result. + |
+Mandatory if AK/SK authentication is used. + |
+- + + |
+
A request body conveys information other than the request header and is generally sent in a structured format (for example, JSON or XML) defined by the Content-type field.
+A response header consists of an HTTP status code and additional response header fields.
+Header + |
+Description + |
+Example + |
+
---|---|---|
Date + |
+A standard HTTP header, which indicates the date and time when a message is sent. The format of this header field is defined in RFC 822. + |
+Mon, 12 Nov 2007 15:55:01 GMT + |
+
Server + |
+A standard HTTP header, which contains the information about the software that the server uses to process requests. + |
+Apache + |
+
Content-Length + |
+A standard HTTP header, which indicates the size of the response body, in decimal number of bytes. + |
+xxx + |
+
Content-Type + |
+A standard HTTP header, which specifies the media type of the response body sent to the recipient. + |
+application/json + |
+
A response body conveys information other than the response header and is generally sent in a structured format (for example, JSON or XML) defined by the Content-type field.
+A request can be initiated by using any of the following methods:
+cURL is a command line tool used to perform URL operations and transmit information. It serves as an HTTP client to send HTTP requests to the server and receive response messages. cURL is suitable for use in API tuning scenarios. For more information about cURL, visit https://curl.haxx.se/.
+You can call APIs through code to assemble, send, and process requests.
+Mozilla Firefox and Google Chrome provide a graphical browser plug-in for REST clients to send and process requests. For Mozilla Firefox, see REST Client APIsHub. For Google Chrome, see Postman.
+If API requests are authenticated using tokens, the request header must contain X-Auth-Token (token information).
+This section describes how to call an API for token authentication.
+A cloud service can be deployed globally or at the project level.
+Replace the texts in italic with actual ones. For details, see Identity and Access Management API Reference.
+Log in to the management console, click your username in the upper right corner, and choose My Credential from the drop-down list. On the My Credentials page, obtain your username, domain name, and project ID.
+{ + "auth": { + "identity": { + "methods": [ + "password" + ], + "password": { + "user": { + "name": "username", // IAM username + "password": "password", // IAM user password + "domain": { + "name": "domainname" // Name of the domain to which the IAM user belongs + } + } + } + }, + "scope": { + "project": { + "id": "0215ef11e49d4743be23dd97a1561e91" // Project ID + } + } + } +}+
The following shows an example of a global service request:
+{ + "auth": { + "identity": { + "methods": [ + "password" + ], + "password": { + "user": { + "name": "username", // IAM username + "password": "password", // IAM user password + "domain": { + "name": "domainname" // Name of the domain to which the IAM user belongs + } + } + } + }, + "scope": { + "domain": { + "name": "domainname" // Name of the domain to which the IAM user belongs + } + } + } +}+
The following figures illustrate how to use Postman to manually obtain a token.
+When you use API Gateway to send requests to underlying services, the requests must be signed using the AK and SK.
+AK is a unique identifier that is associated with a secret access key; the access key ID and secret access key are used together to sign requests cryptographically.
+SK is a key that is used in conjunction with an access key ID to cryptographically sign requests. Signing a request identifies the sender and prevents the request from being altered.
+The AK/SK authentication process is as follows:
+Figure 1 shows the process of calling APIs through AK/SK authentication.
+ +Keep the AK/SK file confidential to prevent information leakage.
+https://apig-demo.obs.eu-de.otc.t-systems.com/java/java-sdk-core.zip
+The signing method is integrated into the .jar file added in 1. Before sending the request, sign the requested content. The signature obtained is included in the HTTP header of the request.
+For details, see Sample Code.
+The JDK version cannot be earlier than 1.8.
+This section describes how to call the API of a public cloud service by using Eclipse.
+You can download the sample code package from https://apig-demo.obs.eu-de.otc.t-systems.com/java/SdkDemo.zip.
+The JDK version cannot be earlier than 1.8.
+Replace the bold texts with actual values. If you use other methods, such as POST, PUT, and DELETE, see the corresponding annotations.
+Replace the parameters in the URL, for example, project_id.
+For details on how to obtain your region name, service name, AK/SK, project ID, and domain ID, see Obtaining Required Information.
+//TODO: Replace eu-de with the name of the region in which the service to be accessed is located. +private static final String region = "eu-de"; + +//TODO: Replace vpc with the name of the service you want to access. For example, ecs, vpc, iam, and elb. +private static final String serviceName = "vpc"; + +public static void main(String[] args) throws UnsupportedEncodingException +{ +//TODO: Replace the AK and SK with those obtained on the My Credential page. +String ak = "ZIRRKMTWPTQFQI1WKNKB"; +String sk = "Us0mdMNHk******YrRCnW0ecfzl"; + +//TODO: To specify a project ID (multi-project scenarios), add the X-Project-Id header. +//TODO: To access a global service, such as IAM, DNS, CDN, and TMS, add the X-Domain-Id header to specify an account ID. +//TODO: To add a header, find "Add special headers" in the AccessServiceImple.java file. + +//TODO: Test the API +String url = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/vpcs/{vpc_id}"; +get(ak, sk, url); + +//TODO: When creating a VPC, replace {project_id} in postUrl with the actual value. +//String postUrl = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/cloudservers"; +//String postbody ="{\"vpc\": {\"name\": \"vpc\",\"cidr\": \"192.168.0.0/16\"}}"; +//post(ak, sk, postUrl, postbody); + +//TODO: When querying a VPC, replace {project_id} in url with the actual value. +//String url = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/vpcs/{vpc_id}"; +//get(ak, sk, url); + +//TODO: When updating a VPC, replace {project_id} and {vpc_id} in putUrl with the actual values. +//String putUrl = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/vpcs/{vpc_id}"; +//String putbody ="{\"vpc\":{\"name\": \"vpc1\",\"cidr\": \"192.168.0.0/16\"}}"; +//put(ak, sk, putUrl, putbody); + +//TODO: When deleting a VPC, replace {project_id} and {vpc_id} in deleteUrl with the actual values. +//String deleteUrl = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/vpcs/{vpc_id}"; +//delete(ak, sk, deleteUrl); +}+
//TODO: Test the API +String url = "https://vpc.eu-de.otc.t-systems.com/v1/{project_id}/vpcs/{vpc_id}"; +get(ak, sk, url);+
//TODO: Add special headers. +//request.addHeader("X-Project-Id", "xxxxx");+
Find Demo.java in the left pane of the Package Explorer, right-click, and choose Run AS > Java Application.
+View the API call logs on the console.
+Obtain the required information before calling APIs.
+Item + |
+Parameter + |
+Description + |
+
---|---|---|
Service name + |
+serviceName + |
+Service name, for example, iam, vpc, and ecs. + |
+
Region/Endpoint + |
+- + |
+Region and endpoint. + + |
+
Project ID + |
+project_id + |
+Project ID, which is configured in the URI in most cases. +For details about how to obtain the value of this parameter, see Obtaining a Project ID. + |
+
username/password + |
+username/password + |
+Username and password, which are used to obtain a token in token authentication mode. + |
+
AK/SK + |
+ak/sk + |
+AK/SK pair. +It is used in AK/SK authentication mode. +For details about how to obtain the value of this parameter, see Generating an AK and SK. + |
+
uri + |
+uri + |
+Request path and parameters. +Obtain the URI according to the API reference guide of each service. + |
+
Domain Name + |
+- + |
+Account name, which is used to obtain a token in token authentication mode. +For details about how to obtain the value of this parameter, see Obtaining the Domain Name and Domain ID. + |
+
Domain ID + |
+X-Domain-Id + |
+Account ID, which is used to: +
For details about how to obtain the value of this parameter, see Obtaining the Domain Name and Domain ID. + |
+
Sub-project ID + |
+X-Project-Id + |
+Sub-project ID, which is used in multi-project scenarios. +For details about how to obtain the value of this parameter, see Obtaining a Project ID. + |
+
A project ID needs to be specified in the URIs of some APIs. Therefore, you need to obtain the project ID before calling APIs. The following procedure describes how to obtain a project ID:
+On the My Credential page, view project IDs in the project list.
+In multi-project scenarios, expand the region, and obtain your sub-project ID from the Project ID column.
+When you call APIs, your domain name and domain ID are required in some URLs. Obtain your domain name and domain ID on the console by performing the following steps:
+On the My Credential page, view the domain name and domain ID.
+Table 1 describes common status codes.
+ +Return Value + |
+Description + |
+
---|---|
200 OK + |
+The request has been processed successfully. + |
+
204 No Content + |
+The server does not return any information. + |
+
400 Bad Request + |
+The server failed to process the request. Possible causes include: +
|
+
401 Unauthorized + |
+The request requires user authentication. For example, the username and password are required. + |
+
403 Forbidden + |
+You are forbidden to access the requested page. + |
+
404 Not Found + |
+The request failed because the requested resource could not be found on the server. + |
+
405 Method Not Allowed + |
+You are not allowed to use the method specified in the request. + |
+
406 Not Acceptable + |
+The response generated by the server could not be accepted by the client. + |
+
407 Proxy Authentication Required + |
+You must use the proxy server for authentication so that the request can be processed. + |
+
408 Request Timeout + |
+The request timed out. + |
+
409 Conflict + |
+The request could not be processed due to a conflict. + |
+
410 Gone + |
+The requested resource is not available on the server and no known forwarding address is provided. + |
+
412 Precondition Failed + |
+One or more conditions specified in the request header are not met when the server tests the conditions. + |
+
500 Internal Server Error + |
+The server failed to process the request due to an unexpected condition. + |
+
501 Not Implemented + |
+Failed to complete the request because the server does not support the requested function. + |
+
502 Bad Gateway + |
+Failed to complete the request because the server has received an invalid response. + |
+
503 Service Unavailable + |
+Failed to complete the request because the service is unavailable. + |
+
504 Gateway Timeout + |
+The gateway timed out. + |
+