File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Scf } from '../../src' ;
2
+
3
+ describe ( 'Scf Version' , ( ) => {
4
+ const credentials = {
5
+ SecretId : process . env . TENCENT_SECRET_ID ,
6
+ SecretKey : process . env . TENCENT_SECRET_KEY ,
7
+ } ;
8
+ const scf = new Scf ( credentials ) ;
9
+
10
+ test ( 'list' , async ( ) => {
11
+ const scfList = await scf . version . list ( {
12
+ functionName : 'koaDemo' ,
13
+ } ) ;
14
+ expect ( Array . isArray ( scfList . Versions ) ) . toBe ( true ) ;
15
+ } ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const ACTIONS = [
12
12
'CreateTrigger' ,
13
13
'DeleteTrigger' ,
14
14
'PublishVersion' ,
15
+ 'ListVersionByFunction' ,
15
16
'ListAliases' ,
16
17
'CreateAlias' ,
17
18
'UpdateAlias' ,
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ import { ScfPublishVersionInputs } from '../interface';
2
2
3
3
import BaseEntity from './base' ;
4
4
5
+ export interface ScfListVersionInputs {
6
+ functionName : string ;
7
+ namespace ?: string ;
8
+ offset ?: number ;
9
+ limit ?: number ;
10
+ }
11
+
5
12
export default class VersionEntity extends BaseEntity {
6
13
/**
7
14
* publish function version
@@ -20,4 +27,18 @@ export default class VersionEntity extends BaseEntity {
20
27
console . log ( `Published function ${ inputs . functionName } version ${ Response . FunctionVersion } ` ) ;
21
28
return Response ;
22
29
}
30
+
31
+ async list ( inputs : ScfListVersionInputs ) {
32
+ const listInputs = {
33
+ Action : 'ListVersionByFunction' as const ,
34
+ FunctionName : inputs . functionName ,
35
+ Namespace : inputs . namespace ?? 'default' ,
36
+ Offset : inputs . offset ?? 0 ,
37
+ Limit : inputs . limit ?? 100 ,
38
+ } ;
39
+ const Response = await this . request ( listInputs ) ;
40
+
41
+ console . log ( `Published function ${ inputs . functionName } version ${ Response . FunctionVersion } ` ) ;
42
+ return Response ;
43
+ }
23
44
}
You can’t perform that action at this time.
0 commit comments