From f2eade654c3da44bae8636900a36c2e22c42b1b8 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 10 Apr 2014 13:45:02 +0200 Subject: [PATCH] ExportDir as parameter to export api --- apier/cdre.go | 11 +++++++++-- sessionmanager/fsevent.go | 2 +- utils/apitpdata.go | 7 ++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apier/cdre.go b/apier/cdre.go index 3d9bc0422..84e8f1093 100644 --- a/apier/cdre.go +++ b/apier/cdre.go @@ -48,6 +48,7 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E return err } } + exportDir := attr.ExportDir fileName := attr.ExportFileName exportId := attr.ExportId if len(exportId) == 0 { @@ -85,6 +86,9 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E } *reply = utils.ExportedFileCdrs{ExportedFilePath: utils.CDRE_DRYRUN, TotalRecords: len(cdrs), ExportedCgrIds: exportedIds} case utils.CDRE_CSV: + if len(exportDir) == 0 { + exportDir = path.Join(self.Config.CdreDir, utils.CDRE_CSV) + } if len(fileName) == 0 { fileName = fmt.Sprintf("cdre_%s.csv", exportId) } @@ -97,7 +101,7 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E if len(exportedFields) == 0 { return fmt.Errorf("%s:ExportTemplate", utils.ERR_MANDATORY_IE_MISSING) } - filePath := path.Join(self.Config.CdreDir, utils.CDRE_CSV, fileName) + filePath := path.Join(exportDir, fileName) fileOut, err := os.Create(filePath) if err != nil { return err @@ -117,6 +121,9 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E *reply = utils.ExportedFileCdrs{ExportedFilePath: filePath, TotalRecords: len(cdrs), ExportedCgrIds: exportedIds, UnexportedCgrIds: unexportedIds, FirstOrderId: csvWriter.FirstOrderId(), LastOrderId: csvWriter.LastOrderId()} case utils.CDRE_FIXED_WIDTH: + if len(exportDir) == 0 { + exportDir = path.Join(self.Config.CdreDir, utils.CDRE_FIXED_WIDTH) + } if len(fileName) == 0 { fileName = fmt.Sprintf("cdre_%s.fwv", exportId) } @@ -131,7 +138,7 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E if exportTemplate == nil { return fmt.Errorf("%s:ExportTemplate", utils.ERR_MANDATORY_IE_MISSING) } - filePath := path.Join(self.Config.CdreDir, utils.CDRE_FIXED_WIDTH, fileName) + filePath := path.Join(exportDir, fileName) fileOut, err := os.Create(filePath) if err != nil { return err diff --git a/sessionmanager/fsevent.go b/sessionmanager/fsevent.go index 95baddc51..b06f0612d 100644 --- a/sessionmanager/fsevent.go +++ b/sessionmanager/fsevent.go @@ -45,7 +45,7 @@ const ( SETUP_TIME = "Caller-Channel-Created-Time" ANSWER_TIME = "Caller-Channel-Answered-Time" END_TIME = "Caller-Channel-Hangup-Time" - DURATION = "" + DURATION = "billsec" NAME = "Event-Name" HEARTBEAT = "HEARTBEAT" ANSWER = "CHANNEL_ANSWER" diff --git a/utils/apitpdata.go b/utils/apitpdata.go index aceec5214..f66980635 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -318,12 +318,13 @@ type CachedItemAge struct { type AttrExpFileCdrs struct { CdrFormat string // Cdr output file format ExportId string // Optional exportid + ExportDir string // If provided it overwrites the configured export directory ExportFileName string // If provided the output filename will be set to this ExportTemplate string // Exported fields template <""|fld1,fld2|*xml:instance_name> - CostShiftDigits int // If defined it will shift cost digits before applying rouding (eg: convert from Eur->cents) - RoundDecimals int // Overwrite configured roundDecimals with this dynamically + CostShiftDigits int // If defined it will shift cost digits before applying rouding (eg: convert from Eur->cents), -1 to use general config ones + RoundDecimals int // Overwrite configured roundDecimals with this dynamically, -1 to use general config ones MaskDestinationId string // Overwrite configured MaskDestId - MaskLength int // Overwrite configured MaskLength + MaskLength int // Overwrite configured MaskLength, -1 to use general config ones CgrIds []string // If provided, it will filter based on the cgrids present in list MediationRunId []string // If provided, it will filter on mediation runid CdrHost []string // If provided, it will filter cdrhost