-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(huawei & dummy): added missing descriptions and fixed breadcrumbs
- Loading branch information
Showing
6 changed files
with
275 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,101 @@ | ||
//#region Imports | ||
|
||
import { BothValueHeaders } from '../index'; | ||
|
||
//#endregion | ||
|
||
/** | ||
* The interface that represents the Api Gateway Event of Huawei when integrate with Function Graph of Event Type. | ||
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}. | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent | ||
*/ | ||
export interface HuaweiApiGatewayEvent { | ||
/** | ||
* The body value with the content of this event serialized in JSON | ||
*/ | ||
body: string; | ||
|
||
/** | ||
* The headers of the request which this event represents | ||
*/ | ||
headers: BothValueHeaders; | ||
|
||
/** | ||
* The HTTP Method of the request which this event represents | ||
*/ | ||
httpMethod: string; | ||
|
||
/** | ||
* Tells if the body is base64 encoded | ||
*/ | ||
isBase64Encoded: boolean; | ||
|
||
/** | ||
* The path of the request which this event represents | ||
*/ | ||
path: string; | ||
|
||
/** | ||
* The path parameters of the request which this event represents | ||
*/ | ||
pathParameters: HuaweiRequestPathParameters; | ||
|
||
/** | ||
* The query strings of the request which this event represents | ||
*/ | ||
queryStringParameters: HuaweiRequestQueryStringParameters; | ||
|
||
/** | ||
* The request context with information about the stage, api and requestId | ||
*/ | ||
requestContext: HuaweiRequestContext; | ||
|
||
/** | ||
* It can have more properties that I could not discover yet | ||
*/ | ||
[key: string]: any; | ||
} | ||
|
||
/** | ||
* The path parameters of the request, usually is the name of the wildcard you create in FunctionGraph, such as /\{proxy\}. | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent | ||
*/ | ||
export type HuaweiRequestPathParameters = Record<string, string>; | ||
|
||
/** | ||
* The query strings of the request | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent | ||
*/ | ||
export type HuaweiRequestQueryStringParameters = Record< | ||
string, | ||
string | string[] | ||
>; | ||
|
||
/** | ||
* The interface that represents the values you can get inside request context. | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent | ||
*/ | ||
export interface HuaweiRequestContext { | ||
/** | ||
* The ID of your API inside Api Gateway | ||
*/ | ||
apiId: string; | ||
|
||
/** | ||
* The ID of this request | ||
*/ | ||
requestId: string; | ||
|
||
/** | ||
* The name of the stage running this Function Graph | ||
*/ | ||
stage: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
//#region Imports | ||
|
||
import { MultiValueHeaders } from '../headers'; | ||
|
||
//#endregion | ||
|
||
/** | ||
* The interface that represents the Api Gateway Response of Huawei when integrate with Function Graph of Event Type. | ||
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}. | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiApiGatewayResponse | ||
*/ | ||
export interface HuaweiApiGatewayResponse { | ||
/** | ||
* Tells if the body was encoded as base64 | ||
*/ | ||
isBase64Encoded: boolean; | ||
|
||
/** | ||
* The HTTP Status code of this response | ||
*/ | ||
statusCode: number; | ||
|
||
/** | ||
* The headers sent with this response | ||
*/ | ||
headers: MultiValueHeaders; | ||
|
||
/** | ||
* The body value with the content of this response serialized in JSON | ||
*/ | ||
body: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,215 @@ | ||
/** | ||
* The return value of {@link HuaweiContext} getRequestID | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetRequestIDSecondsReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getRemainingTimeInMilliSeconds | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetRemainingTimeInMilliSecondsReturn = number; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getAccessKey | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetAccessKeyReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getSecretKey | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetSecretKeyReturn = string; | ||
|
||
/** | ||
* The parameters of the method {@link HuaweiContext} getUserData | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetUserDataKeyParameter = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getUserData | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetUserDataReturn = any; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getFunctionName | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetFunctionNameReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getRunningTimeInSeconds | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetRunningTimeInSecondsReturn = number; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getVersion | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetVersionReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getMemorySize | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetMemorySizeReturn = number; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getCPUNumber | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetCPUNumberReturn = number; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getProjectID | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetProjectIdReturn = number; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getPackage | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetPackageReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getToken | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetTokenReturn = string; | ||
|
||
/** | ||
* The return value of {@link HuaweiContext} getLogger | ||
* | ||
* Is the instance of logger that can be used to send logs to | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export type GetLoggerReturn = { | ||
info(message: string): void; | ||
}; | ||
|
||
/** | ||
* The interface that represents methods sent by huawei to get information about the function graph. | ||
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0410.html#section1 | Context Methods} | ||
* | ||
* @public | ||
* @breadcrumb Types / Huawei / HuaweiContext | ||
*/ | ||
export interface HuaweiContext { | ||
/** | ||
* Obtains a request ID. | ||
*/ | ||
getRequestID(): GetRequestIDSecondsReturn; | ||
|
||
/** | ||
* Obtains the remaining running time of a function. | ||
*/ | ||
getRemainingTimeInMilliSeconds(): GetRemainingTimeInMilliSecondsReturn; | ||
|
||
/** | ||
* Obtains the AK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function. | ||
*/ | ||
getAccessKey(): GetAccessKeyReturn; | ||
|
||
/** | ||
* Obtains the SK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function. | ||
*/ | ||
getSecretKey(): GetSecretKeyReturn; | ||
|
||
/** | ||
* Uses keys to obtain the values passed by environment variables. | ||
* | ||
* @param key - The key to get environment variables values | ||
*/ | ||
getUserData(key: GetUserDataKeyParameter): GetUserDataReturn; | ||
|
||
/** | ||
* Obtains the name of a function. | ||
*/ | ||
getFunctionName(): GetFunctionNameReturn; | ||
|
||
/** | ||
* Obtains the timeout of a function. | ||
*/ | ||
getRunningTimeInSeconds(): GetRunningTimeInSecondsReturn; | ||
|
||
/** | ||
* Obtains the version of a function. | ||
*/ | ||
getVersion(): GetVersionReturn; | ||
|
||
/** | ||
* Obtains the allocated memory. | ||
*/ | ||
getMemorySize(): GetMemorySizeReturn; | ||
|
||
/** | ||
* Number of CPU millicores used by the function (1 core = 1000 millicores). | ||
* | ||
* The value of this field is proportional to that of MemorySize. By default, 100 CPU millicores are required for 128 MB memory. The number of CPU millicores is calculated as follows: Memory/128 x 100 + 200 (basic CPU millicores). | ||
*/ | ||
getCPUNumber(): GetCPUNumberReturn; | ||
|
||
/** | ||
* Obtains a project ID. | ||
*/ | ||
getProjectID(): GetProjectIdReturn; | ||
|
||
/** | ||
* Obtains a function group, that is, an app. | ||
*/ | ||
getPackage(): GetPackageReturn; | ||
|
||
/** | ||
* Obtains the token (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function. | ||
*/ | ||
getToken(): GetTokenReturn; | ||
|
||
/** | ||
* Obtains the logger method provided by the context and returns a log output class. Logs are output in the format of Time-Request ID-Content by using the info method. | ||
* | ||
* For example, use the info method to output logs: | ||
* | ||
* @example | ||
* ```typescript | ||
* logg = context.getLogger() | ||
* | ||
* logg.info("hello") | ||
* ``` | ||
*/ | ||
getLogger(): GetLoggerReturn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters