-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathbackground_task.go
78 lines (67 loc) · 1.63 KB
/
background_task.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// this file is @generated (with minor manual changes)
package svix
import (
"context"
"github.com/svix/svix-webhooks/go/internal/openapi"
)
type BackgroundTask struct {
api *openapi.APIClient
}
type BackgroundTaskListOptions struct {
// Filter the response based on the status.
Status *BackgroundTaskStatus
// Filter the response based on the type.
Task *BackgroundTaskType
// Limit the number of returned items
Limit *int32
// The iterator returned from a prior invocation
Iterator *string
// The sorting order of the returned items
Order *Ordering
}
// List background tasks executed in the past 90 days.
func (backgroundTask *BackgroundTask) List(
ctx context.Context,
options *BackgroundTaskListOptions,
) (*ListResponseBackgroundTaskOut, error) {
req := backgroundTask.api.BackgroundTasksAPI.V1BackgroundTaskList(
ctx,
)
if options != nil {
if options.Status != nil {
req = req.Status(*options.Status)
}
if options.Task != nil {
req = req.Task(*options.Task)
}
if options.Limit != nil {
req = req.Limit(*options.Limit)
}
if options.Iterator != nil {
req = req.Iterator(*options.Iterator)
}
if options.Order != nil {
req = req.Order(*options.Order)
}
}
ret, res, err := req.Execute()
if err != nil {
return nil, wrapError(err, res)
}
return ret, nil
}
// Get a background task by ID.
func (backgroundTask *BackgroundTask) Get(
ctx context.Context,
taskId string,
) (*BackgroundTaskOut, error) {
req := backgroundTask.api.BackgroundTasksAPI.V1BackgroundTaskGet(
ctx,
taskId,
)
ret, res, err := req.Execute()
if err != nil {
return nil, wrapError(err, res)
}
return ret, nil
}