-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathalias.ts
43 lines (36 loc) · 1.32 KB
/
alias.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { CloudBaseError } from '../error'
import { IUpdateFunctionAliasConfig, IGetFunctionAlias, IGetFunctionAliasRes } from '../types'
import { getFunctionService } from './base'
// 设置函数流量配置信息(ALIAS 配置)
export async function setFunctionAliasConfig(options: IUpdateFunctionAliasConfig) {
const { envId, functionName, name, functionVersion, description, routingConfig } = options
const scfService = await getFunctionService(envId)
try {
await scfService.updateFunctionAliasConfig({
functionName,
name,
functionVersion,
description,
routingConfig
})
} catch (e) {
throw new CloudBaseError(`[${functionName}] 设置函数流量配置失败: ${e.message}`, {
code: e.code
})
}
}
// 查询函数别名配置信息
export async function getFunctionAliasConfig(options: IGetFunctionAlias): Promise<IGetFunctionAliasRes> {
const { envId, functionName, name } = options
const scfService = await getFunctionService(envId)
try {
return scfService.getFunctionAlias({
functionName,
name
})
} catch (e) {
throw new CloudBaseError(`[${functionName}] 查询函数别名配置失败: ${e.message}`, {
code: e.code
})
}
}