-
Notifications
You must be signed in to change notification settings - Fork 2
/
export.go
52 lines (44 loc) · 1.49 KB
/
export.go
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
44
45
46
47
48
49
50
51
52
package gocensys
//ExportJob represents an export job.
type ExportJob struct {
Status string `json:"status"`
Configuration struct {
Format string `json:"format"`
Compress bool `json:"compress"`
Headers bool `json:"headers"`
Delimiter bool `json:"delimiter"`
Flatten bool `json:"flatten"`
Query string `json:"query"`
} `json:"configuration"`
JobID string `json:"job_id"`
}
//ExportJobStatus represents the status of a submitted job.
type ExportJobStatus struct {
Status string `json:"status"`
Statistics struct {
BackendTime interface{} `json:"backend_time"`
ResultCount interface{} `json:"result_count"`
} `json:"statistics"`
JobID string `json:"job_id"`
Configuration struct {
Format string `json:"format"`
Compress bool `json:"compress"`
Headers bool `json:"headers"`
Delimiter bool `json:"delimiter"`
Flatten bool `json:"flatten"`
Query string `json:"query"`
} `json:"configuration"`
DownloadPaths []string `json:"download_paths"`
}
//StartExportJob lets you submit an export job.
func (c CensysAPI) StartExportJob(data map[string]interface{}) (ExportJob, error) {
var job ExportJob
err := c.apiPost("/export", data, &job)
return job, err
}
//GetExportJobStatus lets you retrieve information about a previously submitted job.
func (c CensysAPI) GetExportJobStatus(jobID string) (ExportJobStatus, error) {
var jobStatus ExportJobStatus
err := c.apiGet("/export/"+jobID, nil, &jobStatus)
return jobStatus, err
}