mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
ExportDir as parameter to export api
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -318,12 +318,13 @@ type CachedItemAge struct {
|
||||
type AttrExpFileCdrs struct {
|
||||
CdrFormat string // Cdr output file format <utils.CdreCdrFormats>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user