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 = [
1212 'CreateTrigger' ,
1313 'DeleteTrigger' ,
1414 'PublishVersion' ,
15+ 'ListVersionByFunction' ,
1516 'ListAliases' ,
1617 'CreateAlias' ,
1718 'UpdateAlias' ,
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ import { ScfPublishVersionInputs } from '../interface';
22
33import BaseEntity from './base' ;
44
5+ export interface ScfListVersionInputs {
6+ functionName : string ;
7+ namespace ?: string ;
8+ offset ?: number ;
9+ limit ?: number ;
10+ }
11+
512export default class VersionEntity extends BaseEntity {
613 /**
714 * publish function version
@@ -20,4 +27,18 @@ export default class VersionEntity extends BaseEntity {
2027 console . log ( `Published function ${ inputs . functionName } version ${ Response . FunctionVersion } ` ) ;
2128 return Response ;
2229 }
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+ }
2344}
You can’t perform that action at this time.
0 commit comments