forked from grails-aws/grails-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAwsSesGetSendStatistics.groovy
43 lines (29 loc) · 1.66 KB
/
AwsSesGetSendStatistics.groovy
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
43
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient
import com.amazonaws.services.simpleemail.model.GetSendQuotaResult
includeTargets << grailsScript("Init")
includeTargets << new File("${awsPluginDir}/scripts/_ReadAwsCredentials.groovy")
target(main: "Queries about the sending statistics in AWS SES") {
depends (readAwsCredentials)
def credentials = new BasicAWSCredentials(accessKey, secretKey)
def ses = new AmazonSimpleEmailServiceClient(credentials)
def sendStatisticsResult = ses.getSendStatistics()
if (sendStatisticsResult.getSendDataPoints().size() > 0) {
def intervals = sendStatisticsResult.getSendDataPoints().sort { it.timestamp }
println "[AWS SES] -------------------------------------------------------------------------------"
println "[AWS SES] | time range | attemps | rejects (SES) | complaints (recipient) | bounces |"
println "[AWS SES] |-------------------------------------------------------------------------------|"
intervals.each { dp ->
def _timestamp = dp.timestamp?.format('yyyy/MM/dd HH:mm')
def _attemps = dp.deliveryAttempts?.toString()?.center(7, " ")
def _rejects = dp.rejects?.toString()?.center(13, " ")
def _complaints = dp.complaints?.toString()?.center(22, " ")
def _bounces = dp.bounces?.toString()?.center(7, " ")
println "[AWS SES] | ${_timestamp} | ${_attemps} | ${_rejects} | ${_complaints} | ${_bounces} |"
}
println "[AWS SES] -------------------------------------------------------------------------------"
} else {
println "[AWS SES] No statistics available for this account"
}
}
setDefaultTarget(main)