1
1
const secret = require ( '../../../../secret' )
2
- const ScfUtils = require ( './index' ) . Scf
2
+ const ScfUtils = require ( './index' )
3
3
4
4
class ClientTest {
5
5
async scfTest ( ) {
@@ -8,16 +8,15 @@ class ClientTest {
8
8
SecretKey : secret . SecretKey
9
9
} )
10
10
const scfDemo = {
11
- name : 'myFunction1 ' ,
11
+ name : 'sync_cos_bucket ' ,
12
12
code : {
13
- bucket : 'sls-cloudfunction-ap-guangzhou' ,
14
- object : 'sls-cloudfunction-default-hello_world-1584670117 .zip'
13
+ bucket : 'sls-cloudfunction-ap-guangzhou-code ' ,
14
+ object : 'mytestFunction-1585915515 .zip'
15
15
} ,
16
16
handler : 'index.main_handler' ,
17
17
runtime : 'Python3.6' ,
18
- role : 'SCF_PythonLogsRole' ,
19
- // eip: true,
20
- region : 'ap-shanghai' ,
18
+ // role: 'SCF_PythonLogsRole',
19
+ region : 'ap-guangzhou' ,
21
20
description : 'My Serverless Function' ,
22
21
memorySize : '256' ,
23
22
timeout : '20' ,
@@ -30,38 +29,54 @@ class ClientTest {
30
29
}
31
30
} ,
32
31
events : [
33
- {
34
- timer : {
35
- name : 'timer' ,
36
- parameters : {
37
- cronExpression : '*/6 * * * *' ,
38
- enable : true ,
39
- argument : 'mytest argument'
40
- }
41
- }
42
- } ,
43
- {
44
- apigw : {
45
- name : 'serverless' ,
46
- parameters : {
47
- protocols : [ 'http' ] ,
48
- serviceName : 'serverless' ,
49
- description : 'the serverless service' ,
50
- environment : 'release' ,
51
- endpoints : [ {
52
- path : '/users' ,
53
- method : 'POST'
54
- } ]
55
- }
56
-
57
- }
58
- }
32
+ // {
33
+ // timer: {
34
+ // name: 'timer',
35
+ // parameters: {
36
+ // cronExpression: '*/6 * * * *',
37
+ // enable: true,
38
+ // argument: 'mytest argument'
39
+ // }
40
+ // }
41
+ // },
42
+ {
43
+ cos : {
44
+ name : 'anycodesimage-1256773370.cos.ap-guangzhou.myqcloud.com' ,
45
+ parameters : {
46
+ bucket : 'anycodesimage-1256773370.cos.ap-guangzhou.myqcloud.com' ,
47
+ enable : true ,
48
+ events : 'cos:ObjectCreated:*' ,
49
+ filter :{
50
+ prefix : "aaaasad"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ // {
56
+ // apigw: {
57
+ // name: 'serverless',
58
+ // parameters: {
59
+ // protocols: ['http'],
60
+ // serviceName: 'serverless',
61
+ // description: 'the serverless service',
62
+ // environment: 'release',
63
+ // endpoints: [{
64
+ // path: '/users',
65
+ // method: 'POST'
66
+ // }]
67
+ // }
68
+ //
69
+ // }
70
+ // }
59
71
]
60
72
}
61
73
const result = await scf . deploy ( scfDemo )
62
- console . log ( JSON . stringify ( result ) )
63
- console . log ( await scf . invoke ( result . FunctionName ) )
64
- await scf . remove ( result )
74
+ try { console . log ( JSON . stringify ( result ) ) } catch ( e ) {
75
+ console . log ( e )
76
+ }
77
+ // console.log(JSON.stringify(result))
78
+ // console.log(await scf.invoke(result.FunctionName))
79
+ // await scf.remove(result)
65
80
}
66
81
}
67
82
0 commit comments