Debian Codegraph @

fastly/fastly.go

raw symbols SCIP
1 package fastly
2
3 import (
4 "bytes"
5 "encoding"
6 )
7
8 type BatchOperation string
9
10 const (
11 CreateBatchOperation BatchOperation = "create"
12 UpdateBatchOperation BatchOperation = "update"
13 UpsertBatchOperation BatchOperation = "upsert"
14 DeleteBatchOperation BatchOperation = "delete"
15
16 // Represents the maximum number of operations that can be sent within a single batch request.
17 // This is currently not documented in the API.
18 BatchModifyMaximumOperations = 1000
19
20 // Represents the maximum number of items that can be placed within an Edge Dictionary.
21 MaximumDictionarySize = 10000
22
23 // Represents the maximum number of entries that can be placed within an ACL.
24 MaximumACLSize = 10000
25 )
26
27 type statusResp struct {
28 Status string
29 Msg string
30 }
31
32 func (t *statusResp) Ok() bool {
33 return t.Status == "ok"
34 }
35
36 // Ensure Compatibool implements the proper interfaces.
37 var (
38 _ encoding.TextMarshaler = new(Compatibool)
39 _ encoding.TextUnmarshaler = new(Compatibool)
40 )
41
42 // Helper function to get a pointer to bool
43 func CBool(b bool) *Compatibool {
44 c := Compatibool(b)
45 return &c
46 }
47
48 // Compatibool is a boolean value that marshalls to 0/1 instead of true/false
49 // for compatability with Fastly's API.
50 type Compatibool bool
51
52 // MarshalText implements the encoding.TextMarshaler interface.
53 func (b Compatibool) MarshalText() ([]byte, error) {
54 if b {
55 return []byte("1"), nil
56 }
57 return []byte("0"), nil
58 }
59
60 // UnmarshalText implements the encoding.TextUnmarshaler interface.
61 func (b *Compatibool) UnmarshalText(t []byte) error {
62 if bytes.Equal(t, []byte("1")) {
63 *b = Compatibool(true)
64 }
65 return nil
66 }