-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
57 lines (51 loc) · 1.59 KB
/
option.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
package cstorage
import (
"github.com/GabrielHCataldo/go-helper/helper"
)
// OptsListObjects bucket object search options
type OptsListObjects struct {
// Delimiter returns results in a directory-like fashion.
// Results will contain only objects whose names, aside from the
// prefix, do not contain delimiter. Objects whose names,
// aside from the prefix, contain delimiter will have their name,
// truncated after the delimiter, returned in prefixes.
// Duplicate prefixes are omitted.
// Must be set to / when used with the MatchGlob parameter to filter results
// in a directory-like mode.
// Optional.
Delimiter string
// Prefix is the prefix filter to query objects
// whose names begin with this prefix.
// Optional.
Prefix string
}
// NewOptsListObjects creates a new OptsListObjects instance
func NewOptsListObjects() *OptsListObjects {
return &OptsListObjects{}
}
// SetDelimiter sets value for the Delimiter field
func (o *OptsListObjects) SetDelimiter(s string) *OptsListObjects {
o.Delimiter = s
return o
}
// SetPrefix sets value for the Prefix field
func (o *OptsListObjects) SetPrefix(s string) *OptsListObjects {
o.Prefix = s
return o
}
// MergeOptsListObjectsByParams assembles the OptsListObjects object from optional parameters.
func MergeOptsListObjectsByParams(opts []*OptsListObjects) *OptsListObjects {
result := &OptsListObjects{}
for _, opt := range opts {
if helper.IsNil(opt) {
continue
}
if helper.IsNotEmpty(opt.Delimiter) {
result.Delimiter = opt.Delimiter
}
if helper.IsNotEmpty(opt.Prefix) {
result.Prefix = opt.Prefix
}
}
return result
}