forked from ggordan/go-onedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync.go
31 lines (26 loc) · 763 Bytes
/
async.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
package onedrive
// AsyncJob stores the location (URL) which can be pinged with CheckStatus() to
// check progress of an Async job.
type AsyncJob struct {
*OneDrive
Location string
}
// AsyncJobStatus provides information on the status of a asynchronous job progress.
type AsyncJobStatus struct {
Operation string `json:"operation"`
PercentageComplete float64 `json:"percentageComplete"`
Status string `json:"status"`
}
// CheckStatus returns a new AsyncJobStatus
func (aj AsyncJob) CheckStatus() (*AsyncJobStatus, error) {
req, err := aj.newRequest("GET", aj.Location, nil, nil)
if err != nil {
return nil, err
}
ajs := new(AsyncJobStatus)
_, err = aj.do(req, ajs)
if err != nil {
return nil, err
}
return ajs, nil
}