cloud-pipeline
cloud-pipeline copied to clipboard
[API] Add support to export faceted search result with template file
Background At the moment, Cloud Pipeline does not allow to export facet search result with predefined format and it would be nice to support it.
Approach
- Introduce a new system preference
search.export.template.mappingwith the following format:
{
"TemplateName": {
"save_to": "<...>", # optional, cloud path to save search report
"friendly_name": "<..>", # optional, short file description
"template_path": "<...>", # required, path to template file that shall be available for API
"permissions": [{
"name": "<..>", # user or group name
"principal": true, # boolean, 'true' for users 'false' for groups
}, ... ],
"mapping": { # required, describes template columns mappings
"Sheet1": [ # the name of the sheet
{
"column": "AA", # string, indicates an column index
"start_row": "2", # 1-base start index for rows
"value": "{Placeholder1} some text {Placeholder2}", # content for cells with placeholders to replace
"unique": false, # optional, bool, default: false, indicates if values in this column shall be unique
"keep_unresolved": false, # optional, bool, default: false, indicates if unresolved placeholders shall be left as is
# if false unresolved placeholders shall be replaced with empty strings
}, {
}, ...
]
}
}
}
Configuration field save_to shall support placeholders:
- Template_ID - the name of template
- Export_Date - the current date
- Export_Date:yyyyMMdd-HH:mm:ss - current date with datetime format
- User - the name of the user initiated template generation
Example: s3://bucket_name/{User}/{Export_Date:yyyyMMdd-HH:mm:ss}/{Template_ID}.xls
- Introduce a new API method
POST /search/facet/export/templatesthat streams template content. Request parameters:templateId- required, the name of template (the key from template configuration)fileName- optional, the name of the result report file. If not specified a file name<TemplateId>-<DateTime>.xlsshall be generated.
- Introduce a new API method
POST /search/facet/export/templates/savethat saves search results report tosave_topath from template configuration. Request params:templateId- required, the name of template (the key from template configuration) Request body:
{
"fullPath": "s3://bucket_name/folder/export.xls",
"storageId": 1, # this storage registered by path `s3://bucket_name/folder/`
"storagePath": "export.xls"
}
Also, it would be nice to support storage files filter: if user manually specified multiple storage files, only this files shall be present in export reports. A new field files shall be added to request body:
{ ....,
"files": [
{
"path": "file1.txt", # path from facet response
"storageId": 1 # parentId from facet response
},
{
"path": "file2.txt",
"storageId": 2
},
{
"path": "file3.txt",
"storageId": 3
}
], ...
}
If files provides query and filters shall be ignored.