-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathoptions.go
54 lines (46 loc) · 1.03 KB
/
options.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
package config
import (
"time"
)
// Options defines optional parameters for configuring an API client.
type Options struct {
// PageSize used for the client operations, a maximum of 100 is enforced by the Goharbor API.
PageSize int64
// Page to be used for client operations.
Page int64
// The timeout for client operations.
Timeout time.Duration
// Sort string used on 'list' client operations.
Sort string
// Query string used for client operations.
Query string
}
func Defaults() *Options {
return &Options{
PageSize: 10,
Page: 1,
Sort: "",
Query: "",
Timeout: 30 * time.Second,
}
}
func (o *Options) WithPageSize(pageSize int64) *Options {
o.PageSize = pageSize
return o
}
func (o *Options) WithPage(page int64) *Options {
o.Page = page
return o
}
func (o *Options) WithTimeout(timeout time.Duration) *Options {
o.Timeout = timeout
return o
}
func (o *Options) WithSort(sort string) *Options {
o.Sort = sort
return o
}
func (o *Options) WithQuery(query string) *Options {
o.Query = query
return o
}