cloudflare/cloudflared

Public

mirrored fromhttps://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0c9014870a0624febb6f3fd63b0cd90101c94197

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cfapi/tunnel_filter.go

59lines · modecode

1package cfapi
2
3import (
4 "net/url"
5 "strconv"
6 "time"
7
8 "github.com/google/uuid"
9)
10
11const (
12 TimeLayout = time.RFC3339
13)
14
15type TunnelFilter struct {
16 queryParams url.Values
17}
18
19func NewTunnelFilter() *TunnelFilter {
20 return &TunnelFilter{
21 queryParams: url.Values{},
22 }
23}
24
25func (f *TunnelFilter) ByName(name string) {
26 f.queryParams.Set("name", name)
27}
28
29func (f *TunnelFilter) ByNamePrefix(namePrefix string) {
30 f.queryParams.Set("name_prefix", namePrefix)
31}
32
33func (f *TunnelFilter) ExcludeNameWithPrefix(excludePrefix string) {
34 f.queryParams.Set("exclude_prefix", excludePrefix)
35}
36
37func (f *TunnelFilter) NoDeleted() {
38 f.queryParams.Set("is_deleted", "false")
39}
40
41func (f *TunnelFilter) ByExistedAt(existedAt time.Time) {
42 f.queryParams.Set("existed_at", existedAt.Format(TimeLayout))
43}
44
45func (f *TunnelFilter) ByTunnelID(tunnelID uuid.UUID) {
46 f.queryParams.Set("uuid", tunnelID.String())
47}
48
49func (f *TunnelFilter) MaxFetchSize(max uint) {
50 f.queryParams.Set("per_page", strconv.Itoa(int(max)))
51}
52
53func (f *TunnelFilter) Page(page int) {
54 f.queryParams.Set("page", strconv.Itoa(page))
55}
56
57func (f TunnelFilter) encode() string {
58 return f.queryParams.Encode()
59}
60