id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
18,300
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
getFlags
func (v *VerbalExpression) getFlags() string { flags := "misU" // warning, follow Flag const order result := []rune{} for i, flag := range flags { if v.flags&(1<<uint(i)) != 0 { result = append(result, flag) } } return string(result) }
go
func (v *VerbalExpression) getFlags() string { flags := "misU" // warning, follow Flag const order result := []rune{} for i, flag := range flags { if v.flags&(1<<uint(i)) != 0 { result = append(result, flag) } } return string(result) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "getFlags", "(", ")", "string", "{", "flags", ":=", "\"", "\"", "// warning, follow Flag const order", "\n", "result", ":=", "[", "]", "rune", "{", "}", "\n\n", "for", "i", ",", "flag", ":=", "range", "flag...
// append modifiers that are activated
[ "append", "modifiers", "that", "are", "activated" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L87-L98
18,301
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
add
func (v *VerbalExpression) add(s string) *VerbalExpression { v.compiled = false //reinit previous regexp compilation v.expression += s return v }
go
func (v *VerbalExpression) add(s string) *VerbalExpression { v.compiled = false //reinit previous regexp compilation v.expression += s return v }
[ "func", "(", "v", "*", "VerbalExpression", ")", "add", "(", "s", "string", ")", "*", "VerbalExpression", "{", "v", ".", "compiled", "=", "false", "//reinit previous regexp compilation", "\n", "v", ".", "expression", "+=", "s", "\n", "return", "v", "\n", "}...
// add method, append expresions to the internal string that will be parsed
[ "add", "method", "append", "expresions", "to", "the", "internal", "string", "that", "will", "be", "parsed" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L101-L105
18,302
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
EndCapture
func (v *VerbalExpression) EndCapture() *VerbalExpression { v.suffixes = strings.Replace(v.suffixes, ")", "", 1) return v.add(")") }
go
func (v *VerbalExpression) EndCapture() *VerbalExpression { v.suffixes = strings.Replace(v.suffixes, ")", "", 1) return v.add(")") }
[ "func", "(", "v", "*", "VerbalExpression", ")", "EndCapture", "(", ")", "*", "VerbalExpression", "{", "v", ".", "suffixes", "=", "strings", ".", "Replace", "(", "v", ".", "suffixes", ",", "\"", "\"", ",", "\"", "\"", ",", "1", ")", "\n", "return", ...
// Stop capturing expresions parts
[ "Stop", "capturing", "expresions", "parts" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L114-L117
18,303
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
AnythingBut
func (v *VerbalExpression) AnythingBut(s string) *VerbalExpression { return v.add(`(?:[^` + quote(s) + `]*)`) }
go
func (v *VerbalExpression) AnythingBut(s string) *VerbalExpression { return v.add(`(?:[^` + quote(s) + `]*)`) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "AnythingBut", "(", "s", "string", ")", "*", "VerbalExpression", "{", "return", "v", ".", "add", "(", "`(?:[^`", "+", "quote", "(", "s", ")", "+", "`]*)`", ")", "\n", "}" ]
// AnythingBut will match anything excpeting the given string.
[ "AnythingBut", "will", "match", "anything", "excpeting", "the", "given", "string", "." ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L125-L127
18,304
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
SomethingBut
func (v *VerbalExpression) SomethingBut(s string) *VerbalExpression { return v.add(`(?:[^` + quote(s) + `]+)`) }
go
func (v *VerbalExpression) SomethingBut(s string) *VerbalExpression { return v.add(`(?:[^` + quote(s) + `]+)`) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "SomethingBut", "(", "s", "string", ")", "*", "VerbalExpression", "{", "return", "v", ".", "add", "(", "`(?:[^`", "+", "quote", "(", "s", ")", "+", "`]+)`", ")", "\n", "}" ]
// Same as Something but excepting chars given in string "s"
[ "Same", "as", "Something", "but", "excepting", "chars", "given", "in", "string", "s" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L135-L137
18,305
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
Maybe
func (v *VerbalExpression) Maybe(s string) *VerbalExpression { return v.add(`(?:` + quote(s) + `)?`) }
go
func (v *VerbalExpression) Maybe(s string) *VerbalExpression { return v.add(`(?:` + quote(s) + `)?`) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "Maybe", "(", "s", "string", ")", "*", "VerbalExpression", "{", "return", "v", ".", "add", "(", "`(?:`", "+", "quote", "(", "s", ")", "+", "`)?`", ")", "\n", "}" ]
// Maybe will search string zero on more times
[ "Maybe", "will", "search", "string", "zero", "on", "more", "times" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L149-L151
18,306
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
Any
func (v *VerbalExpression) Any(s string) *VerbalExpression { return v.add(`(?:[` + quote(s) + `])`) }
go
func (v *VerbalExpression) Any(s string) *VerbalExpression { return v.add(`(?:[` + quote(s) + `])`) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "Any", "(", "s", "string", ")", "*", "VerbalExpression", "{", "return", "v", ".", "add", "(", "`(?:[`", "+", "quote", "(", "s", ")", "+", "`])`", ")", "\n", "}" ]
// Any accepts caracters to be matched
[ "Any", "accepts", "caracters", "to", "be", "matched" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L198-L200
18,307
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
Or
func (v *VerbalExpression) Or(ve *VerbalExpression) *VerbalExpression { v.parts = append(v.parts, ve.Regex().String()+"|") return v }
go
func (v *VerbalExpression) Or(ve *VerbalExpression) *VerbalExpression { v.parts = append(v.parts, ve.Regex().String()+"|") return v }
[ "func", "(", "v", "*", "VerbalExpression", ")", "Or", "(", "ve", "*", "VerbalExpression", ")", "*", "VerbalExpression", "{", "v", ".", "parts", "=", "append", "(", "v", ".", "parts", ",", "ve", ".", "Regex", "(", ")", ".", "String", "(", ")", "+", ...
// Or, chains an alternative VerbalExpression
[ "Or", "chains", "an", "alternative", "VerbalExpression" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L325-L328
18,308
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
And
func (v *VerbalExpression) And(ve *VerbalExpression) *VerbalExpression { return v.add("(?:" + ve.Regex().String() + ")") }
go
func (v *VerbalExpression) And(ve *VerbalExpression) *VerbalExpression { return v.add("(?:" + ve.Regex().String() + ")") }
[ "func", "(", "v", "*", "VerbalExpression", ")", "And", "(", "ve", "*", "VerbalExpression", ")", "*", "VerbalExpression", "{", "return", "v", ".", "add", "(", "\"", "\"", "+", "ve", ".", "Regex", "(", ")", ".", "String", "(", ")", "+", "\"", "\"", ...
// Add another VerbalExpression to the current. // Usefull to concatenate several complex search patterns
[ "Add", "another", "VerbalExpression", "to", "the", "current", ".", "Usefull", "to", "concatenate", "several", "complex", "search", "patterns" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L332-L334
18,309
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
WithAnyCase
func (v *VerbalExpression) WithAnyCase(sensitive bool) *VerbalExpression { if sensitive { return v.addmodifier(IGNORE_CASE) } return v.removemodifier(IGNORE_CASE) }
go
func (v *VerbalExpression) WithAnyCase(sensitive bool) *VerbalExpression { if sensitive { return v.addmodifier(IGNORE_CASE) } return v.removemodifier(IGNORE_CASE) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "WithAnyCase", "(", "sensitive", "bool", ")", "*", "VerbalExpression", "{", "if", "sensitive", "{", "return", "v", ".", "addmodifier", "(", "IGNORE_CASE", ")", "\n", "}", "\n", "return", "v", ".", "removemodi...
// WithAnyCase asks verbalexpressions to match with or without case sensitivity
[ "WithAnyCase", "asks", "verbalexpressions", "to", "match", "with", "or", "without", "case", "sensitivity" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L337-L342
18,310
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
SearchOneLine
func (v *VerbalExpression) SearchOneLine(oneline bool) *VerbalExpression { if !oneline { return v.addmodifier(MULTILINE) } return v.removemodifier(MULTILINE) }
go
func (v *VerbalExpression) SearchOneLine(oneline bool) *VerbalExpression { if !oneline { return v.addmodifier(MULTILINE) } return v.removemodifier(MULTILINE) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "SearchOneLine", "(", "oneline", "bool", ")", "*", "VerbalExpression", "{", "if", "!", "oneline", "{", "return", "v", ".", "addmodifier", "(", "MULTILINE", ")", "\n", "}", "\n", "return", "v", ".", "removem...
// SearchOneLine deactivates "multiline" mode if online argument is true // Default is false
[ "SearchOneLine", "deactivates", "multiline", "mode", "if", "online", "argument", "is", "true", "Default", "is", "false" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L346-L351
18,311
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
MatchAllWithDot
func (v *VerbalExpression) MatchAllWithDot(enable bool) *VerbalExpression { if enable { return v.addmodifier(DOTALL) } return v.removemodifier(DOTALL) }
go
func (v *VerbalExpression) MatchAllWithDot(enable bool) *VerbalExpression { if enable { return v.addmodifier(DOTALL) } return v.removemodifier(DOTALL) }
[ "func", "(", "v", "*", "VerbalExpression", ")", "MatchAllWithDot", "(", "enable", "bool", ")", "*", "VerbalExpression", "{", "if", "enable", "{", "return", "v", ".", "addmodifier", "(", "DOTALL", ")", "\n", "}", "\n", "return", "v", ".", "removemodifier", ...
// MatchAllWithDot lets VerbalExpression matching "." for everything including \n, \r, and so on
[ "MatchAllWithDot", "lets", "VerbalExpression", "matching", ".", "for", "everything", "including", "\\", "n", "\\", "r", "and", "so", "on" ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L354-L359
18,312
VerbalExpressions/GoVerbalExpressions
verbalexpressions.go
Regex
func (v *VerbalExpression) Regex() *regexp.Regexp { if !v.compiled { v.regexp = regexp.MustCompile( strings.Join([]string{ strings.Join(v.parts, ""), `(?` + v.getFlags() + `)`, v.prefixes, v.expression, v.suffixes}, "")) v.compiled = true } return v.regexp }
go
func (v *VerbalExpression) Regex() *regexp.Regexp { if !v.compiled { v.regexp = regexp.MustCompile( strings.Join([]string{ strings.Join(v.parts, ""), `(?` + v.getFlags() + `)`, v.prefixes, v.expression, v.suffixes}, "")) v.compiled = true } return v.regexp }
[ "func", "(", "v", "*", "VerbalExpression", ")", "Regex", "(", ")", "*", "regexp", ".", "Regexp", "{", "if", "!", "v", ".", "compiled", "{", "v", ".", "regexp", "=", "regexp", ".", "MustCompile", "(", "strings", ".", "Join", "(", "[", "]", "string",...
// Regex returns the regular expression to use to test on string.
[ "Regex", "returns", "the", "regular", "expression", "to", "use", "to", "test", "on", "string", "." ]
9cfb19cb04c9f48489be15cbacac3d3af9d7706a
https://github.com/VerbalExpressions/GoVerbalExpressions/blob/9cfb19cb04c9f48489be15cbacac3d3af9d7706a/verbalexpressions.go#L362-L375
18,313
zenhotels/astranet
route/secondary.go
NewSecondaryLayer
func NewSecondaryLayer(cmp SecondaryCmpFunc) SecondaryLayer { var synced uint64 return SecondaryLayer{ synced: &synced, store: NewSecondaryTree(cmp), offset: uint64(util.RevOffset()), lock: lockie.NewLockie(), cmp: cmp, } }
go
func NewSecondaryLayer(cmp SecondaryCmpFunc) SecondaryLayer { var synced uint64 return SecondaryLayer{ synced: &synced, store: NewSecondaryTree(cmp), offset: uint64(util.RevOffset()), lock: lockie.NewLockie(), cmp: cmp, } }
[ "func", "NewSecondaryLayer", "(", "cmp", "SecondaryCmpFunc", ")", "SecondaryLayer", "{", "var", "synced", "uint64", "\n", "return", "SecondaryLayer", "{", "synced", ":", "&", "synced", ",", "store", ":", "NewSecondaryTree", "(", "cmp", ")", ",", "offset", ":",...
// NewSecondaryLayer initializes a new secondary layer handle.
[ "NewSecondaryLayer", "initializes", "a", "new", "secondary", "layer", "handle", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L30-L39
18,314
zenhotels/astranet
route/secondary.go
Put
func (l SecondaryLayer) Put(k RouteInfo, finalizers ...func()) (added int) { l.lock.Lock() l.store.Put(k, func(oldV *FinalizerList, exists bool) (newV *FinalizerList, write bool) { if !exists || oldV == nil { if len(finalizers) == 0 { return nil, true } oldV = &FinalizerList{} } for i := range finalizers { if oldV.AddFinalizer(finalizers[i]) { added++ } } return oldV, true }) l.lock.Unlock() return }
go
func (l SecondaryLayer) Put(k RouteInfo, finalizers ...func()) (added int) { l.lock.Lock() l.store.Put(k, func(oldV *FinalizerList, exists bool) (newV *FinalizerList, write bool) { if !exists || oldV == nil { if len(finalizers) == 0 { return nil, true } oldV = &FinalizerList{} } for i := range finalizers { if oldV.AddFinalizer(finalizers[i]) { added++ } } return oldV, true }) l.lock.Unlock() return }
[ "func", "(", "l", "SecondaryLayer", ")", "Put", "(", "k", "RouteInfo", ",", "finalizers", "...", "func", "(", ")", ")", "(", "added", "int", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "l", ".", "store", ".", "Put", "(", "k", ",", ...
// Put adds finalizers for the key, creating the item if not exists yet.
[ "Put", "adds", "finalizers", "for", "the", "key", "creating", "the", "item", "if", "not", "exists", "yet", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L46-L64
18,315
zenhotels/astranet
route/secondary.go
Seek
func (l SecondaryLayer) Seek(k RouteInfo) (e *SecondaryEnumerator, ok bool) { l.lock.Lock() e, ok = l.store.Seek(k) l.lock.Unlock() return }
go
func (l SecondaryLayer) Seek(k RouteInfo) (e *SecondaryEnumerator, ok bool) { l.lock.Lock() e, ok = l.store.Seek(k) l.lock.Unlock() return }
[ "func", "(", "l", "SecondaryLayer", ")", "Seek", "(", "k", "RouteInfo", ")", "(", "e", "*", "SecondaryEnumerator", ",", "ok", "bool", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "e", ",", "ok", "=", "l", ".", "store", ".", "Seek", ...
// Seek returns an SecondaryEnumerator positioned on a key such that k >= key.
[ "Seek", "returns", "an", "SecondaryEnumerator", "positioned", "on", "a", "key", "such", "that", "k", ">", "=", "key", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L87-L92
18,316
zenhotels/astranet
route/secondary.go
SeekFirst
func (l SecondaryLayer) SeekFirst() (e *SecondaryEnumerator, err error) { l.lock.Lock() e, err = l.store.SeekFirst() l.lock.Unlock() return }
go
func (l SecondaryLayer) SeekFirst() (e *SecondaryEnumerator, err error) { l.lock.Lock() e, err = l.store.SeekFirst() l.lock.Unlock() return }
[ "func", "(", "l", "SecondaryLayer", ")", "SeekFirst", "(", ")", "(", "e", "*", "SecondaryEnumerator", ",", "err", "error", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "e", ",", "err", "=", "l", ".", "store", ".", "SeekFirst", "(", ")...
// SeekFirst returns an SecondaryEnumerator positioned on the first key in the tree.
[ "SeekFirst", "returns", "an", "SecondaryEnumerator", "positioned", "on", "the", "first", "key", "in", "the", "tree", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L95-L100
18,317
zenhotels/astranet
route/secondary.go
Delete
func (l SecondaryLayer) Delete(k RouteInfo) (ok bool) { l.lock.Lock() v, found := l.store.Get(k) if found { ok = l.store.Delete(k) } l.lock.Unlock() if found && v != nil { v.Finalize() } return }
go
func (l SecondaryLayer) Delete(k RouteInfo) (ok bool) { l.lock.Lock() v, found := l.store.Get(k) if found { ok = l.store.Delete(k) } l.lock.Unlock() if found && v != nil { v.Finalize() } return }
[ "func", "(", "l", "SecondaryLayer", ")", "Delete", "(", "k", "RouteInfo", ")", "(", "ok", "bool", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "v", ",", "found", ":=", "l", ".", "store", ".", "Get", "(", "k", ")", "\n", "if", "fou...
// Delete removes the key and runs all its finalizers.
[ "Delete", "removes", "the", "key", "and", "runs", "all", "its", "finalizers", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L103-L114
18,318
zenhotels/astranet
route/secondary.go
Finalize
func (l SecondaryLayer) Finalize() { l.lock.Lock() e, err := l.store.SeekFirst() if err != io.EOF { _, v, err := e.Next() for err != io.EOF { if v != nil { v.Finalize() } _, v, err = e.Next() } e.Close() } l.lock.Unlock() }
go
func (l SecondaryLayer) Finalize() { l.lock.Lock() e, err := l.store.SeekFirst() if err != io.EOF { _, v, err := e.Next() for err != io.EOF { if v != nil { v.Finalize() } _, v, err = e.Next() } e.Close() } l.lock.Unlock() }
[ "func", "(", "l", "SecondaryLayer", ")", "Finalize", "(", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "e", ",", "err", ":=", "l", ".", "store", ".", "SeekFirst", "(", ")", "\n", "if", "err", "!=", "io", ".", "EOF", "{", "_", ",",...
// Finalize locks the layer and runs finalizers of all the keys // from this layer. Call this if you're going to drop an entire layer.
[ "Finalize", "locks", "the", "layer", "and", "runs", "finalizers", "of", "all", "the", "keys", "from", "this", "layer", ".", "Call", "this", "if", "you", "re", "going", "to", "drop", "an", "entire", "layer", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/route/secondary.go#L122-L136
18,319
zenhotels/astranet
service/primary_btree.go
Seek
func (t *PrimaryTree) Seek(k string) (e *PrimaryEnumerator, ok bool) { q := t.r if q == nil { e = btEPool1.get(nil, false, 0, k, nil, t, atomic.LoadUint64(&t.ver)) return } for { var i int if i, ok = t.find(q, k); ok { switch x := q.(type) { case *x1: q = x.x[i+1].ch continue case *d1: return btEPool1.get(nil, ok, i, k, x, t, atomic.LoadUint64(&t.ver)), true } } switch x := q.(type) { case *x1: q = x.x[i].ch case *d1: return btEPool1.get(nil, ok, i, k, x, t, atomic.LoadUint64(&t.ver)), false } } }
go
func (t *PrimaryTree) Seek(k string) (e *PrimaryEnumerator, ok bool) { q := t.r if q == nil { e = btEPool1.get(nil, false, 0, k, nil, t, atomic.LoadUint64(&t.ver)) return } for { var i int if i, ok = t.find(q, k); ok { switch x := q.(type) { case *x1: q = x.x[i+1].ch continue case *d1: return btEPool1.get(nil, ok, i, k, x, t, atomic.LoadUint64(&t.ver)), true } } switch x := q.(type) { case *x1: q = x.x[i].ch case *d1: return btEPool1.get(nil, ok, i, k, x, t, atomic.LoadUint64(&t.ver)), false } } }
[ "func", "(", "t", "*", "PrimaryTree", ")", "Seek", "(", "k", "string", ")", "(", "e", "*", "PrimaryEnumerator", ",", "ok", "bool", ")", "{", "q", ":=", "t", ".", "r", "\n", "if", "q", "==", "nil", "{", "e", "=", "btEPool1", ".", "get", "(", "...
// Seek returns an PrimaryEnumerator positioned on an item such that k >= item's key. // ok reports if k == item.key The PrimaryEnumerator's position is possibly after the // last item in the tree.
[ "Seek", "returns", "an", "PrimaryEnumerator", "positioned", "on", "an", "item", "such", "that", "k", ">", "=", "item", "s", "key", ".", "ok", "reports", "if", "k", "==", "item", ".", "key", "The", "PrimaryEnumerator", "s", "position", "is", "possibly", "...
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary_btree.go#L474-L500
18,320
zenhotels/astranet
service/primary.go
NewPrimaryLayer
func NewPrimaryLayer(cmp1 PrimaryCmpFunc, cmp2 SecondaryCmpFunc) PrimaryLayer { var synced uint64 return PrimaryLayer{ synced: &synced, store: NewPrimaryTree(cmp1), offset: uint64(util.RevOffset()), lock: lockie.NewLockie(), cmp1: cmp1, cmp2: cmp2, } }
go
func NewPrimaryLayer(cmp1 PrimaryCmpFunc, cmp2 SecondaryCmpFunc) PrimaryLayer { var synced uint64 return PrimaryLayer{ synced: &synced, store: NewPrimaryTree(cmp1), offset: uint64(util.RevOffset()), lock: lockie.NewLockie(), cmp1: cmp1, cmp2: cmp2, } }
[ "func", "NewPrimaryLayer", "(", "cmp1", "PrimaryCmpFunc", ",", "cmp2", "SecondaryCmpFunc", ")", "PrimaryLayer", "{", "var", "synced", "uint64", "\n", "return", "PrimaryLayer", "{", "synced", ":", "&", "synced", ",", "store", ":", "NewPrimaryTree", "(", "cmp1", ...
// NewPrimaryLayer initializes a new primary layer handle.
[ "NewPrimaryLayer", "initializes", "a", "new", "primary", "layer", "handle", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L30-L40
18,321
zenhotels/astranet
service/primary.go
Set
func (l PrimaryLayer) Set(k string, layer SecondaryLayer) { l.lock.Lock() l.store.Put(k, func(oldLayer SecondaryLayer, exists bool) (newLayer SecondaryLayer, write bool) { if exists { oldLayer.Finalize() } return layer, true }) l.lock.Unlock() }
go
func (l PrimaryLayer) Set(k string, layer SecondaryLayer) { l.lock.Lock() l.store.Put(k, func(oldLayer SecondaryLayer, exists bool) (newLayer SecondaryLayer, write bool) { if exists { oldLayer.Finalize() } return layer, true }) l.lock.Unlock() }
[ "func", "(", "l", "PrimaryLayer", ")", "Set", "(", "k", "string", ",", "layer", "SecondaryLayer", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "l", ".", "store", ".", "Put", "(", "k", ",", "func", "(", "oldLayer", "SecondaryLayer", ",",...
// Set just adds a secondary layer to the tree, overwriting the previous one. // Note that this action would trigger the replaced layer finalizers.
[ "Set", "just", "adds", "a", "secondary", "layer", "to", "the", "tree", "overwriting", "the", "previous", "one", ".", "Note", "that", "this", "action", "would", "trigger", "the", "replaced", "layer", "finalizers", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L44-L53
18,322
zenhotels/astranet
service/primary.go
Put
func (l PrimaryLayer) Put(k string, k2 ServiceInfo, finalizers ...func()) { l.lock.Lock() l.store.Put(k, func(oldLayer SecondaryLayer, exists bool) (newLayer SecondaryLayer, write bool) { if !exists { oldLayer = NewSecondaryLayer(l.cmp2) } oldLayer.Put(k2, finalizers...) return oldLayer, true }) l.lock.Unlock() }
go
func (l PrimaryLayer) Put(k string, k2 ServiceInfo, finalizers ...func()) { l.lock.Lock() l.store.Put(k, func(oldLayer SecondaryLayer, exists bool) (newLayer SecondaryLayer, write bool) { if !exists { oldLayer = NewSecondaryLayer(l.cmp2) } oldLayer.Put(k2, finalizers...) return oldLayer, true }) l.lock.Unlock() }
[ "func", "(", "l", "PrimaryLayer", ")", "Put", "(", "k", "string", ",", "k2", "ServiceInfo", ",", "finalizers", "...", "func", "(", ")", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "l", ".", "store", ".", "Put", "(", "k", ",", "func...
// Put adds keys and callbacks to the secondary layer, which will be created // if not yet existing.
[ "Put", "adds", "keys", "and", "callbacks", "to", "the", "secondary", "layer", "which", "will", "be", "created", "if", "not", "yet", "existing", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L61-L71
18,323
zenhotels/astranet
service/primary.go
Seek
func (l PrimaryLayer) Seek(k string) (e *PrimaryEnumerator, ok bool) { l.lock.Lock() e, ok = l.store.Seek(k) l.lock.Unlock() return }
go
func (l PrimaryLayer) Seek(k string) (e *PrimaryEnumerator, ok bool) { l.lock.Lock() e, ok = l.store.Seek(k) l.lock.Unlock() return }
[ "func", "(", "l", "PrimaryLayer", ")", "Seek", "(", "k", "string", ")", "(", "e", "*", "PrimaryEnumerator", ",", "ok", "bool", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "e", ",", "ok", "=", "l", ".", "store", ".", "Seek", "(", ...
// Seek returns an PrimaryEnumerator positioned on a secondary layer such that k >= layer's key.
[ "Seek", "returns", "an", "PrimaryEnumerator", "positioned", "on", "a", "secondary", "layer", "such", "that", "k", ">", "=", "layer", "s", "key", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L74-L79
18,324
zenhotels/astranet
service/primary.go
SeekFirst
func (l PrimaryLayer) SeekFirst() (e *PrimaryEnumerator, err error) { l.lock.Lock() e, err = l.store.SeekFirst() l.lock.Unlock() return }
go
func (l PrimaryLayer) SeekFirst() (e *PrimaryEnumerator, err error) { l.lock.Lock() e, err = l.store.SeekFirst() l.lock.Unlock() return }
[ "func", "(", "l", "PrimaryLayer", ")", "SeekFirst", "(", ")", "(", "e", "*", "PrimaryEnumerator", ",", "err", "error", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "e", ",", "err", "=", "l", ".", "store", ".", "SeekFirst", "(", ")", ...
// SeekFirst returns an PrimaryEnumerator positioned on the first secondary layer in the tree.
[ "SeekFirst", "returns", "an", "PrimaryEnumerator", "positioned", "on", "the", "first", "secondary", "layer", "in", "the", "tree", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L82-L87
18,325
zenhotels/astranet
service/primary.go
Get
func (l PrimaryLayer) Get(k string) (layer SecondaryLayer, ok bool) { l.lock.Lock() v, ok := l.store.Get(k) l.lock.Unlock() return v, ok }
go
func (l PrimaryLayer) Get(k string) (layer SecondaryLayer, ok bool) { l.lock.Lock() v, ok := l.store.Get(k) l.lock.Unlock() return v, ok }
[ "func", "(", "l", "PrimaryLayer", ")", "Get", "(", "k", "string", ")", "(", "layer", "SecondaryLayer", ",", "ok", "bool", ")", "{", "l", ".", "lock", ".", "Lock", "(", ")", "\n", "v", ",", "ok", ":=", "l", ".", "store", ".", "Get", "(", "k", ...
// Get returns the secondary layer associated with the key.
[ "Get", "returns", "the", "secondary", "layer", "associated", "with", "the", "key", "." ]
d8d973c9a29df370c1d53ba287661fa8e9b37956
https://github.com/zenhotels/astranet/blob/d8d973c9a29df370c1d53ba287661fa8e9b37956/service/primary.go#L126-L131
18,326
mailgun/mailgun-go
ips.go
GetIP
func (mg *MailgunImpl) GetIP(ctx context.Context, ip string) (IPAddress, error) { r := newHTTPRequest(generatePublicApiUrl(mg, ipsEndpoint) + "/" + ip) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp IPAddress err := getResponseFromJSON(ctx, r, &resp) return resp, err }
go
func (mg *MailgunImpl) GetIP(ctx context.Context, ip string) (IPAddress, error) { r := newHTTPRequest(generatePublicApiUrl(mg, ipsEndpoint) + "/" + ip) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp IPAddress err := getResponseFromJSON(ctx, r, &resp) return resp, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetIP", "(", "ctx", "context", ".", "Context", ",", "ip", "string", ")", "(", "IPAddress", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "ipsEndpoint", ")", ...
// GetIP returns information about the specified IP
[ "GetIP", "returns", "information", "about", "the", "specified", "IP" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/ips.go#L42-L49
18,327
mailgun/mailgun-go
ips.go
ListDomainIPS
func (mg *MailgunImpl) ListDomainIPS(ctx context.Context) ([]IPAddress, error) { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ipAddressListResponse if err := getResponseFromJSON(ctx, r, &resp); err != nil { return nil, err } var result []IPAddress for _, ip := range resp.Items { result = append(result, IPAddress{IP: ip}) } return result, nil }
go
func (mg *MailgunImpl) ListDomainIPS(ctx context.Context) ([]IPAddress, error) { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ipAddressListResponse if err := getResponseFromJSON(ctx, r, &resp); err != nil { return nil, err } var result []IPAddress for _, ip := range resp.Items { result = append(result, IPAddress{IP: ip}) } return result, nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListDomainIPS", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "IPAddress", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "domainsEndpoint", ")", ...
// ListDomainIPS returns a list of IPs currently assigned to the specified domain.
[ "ListDomainIPS", "returns", "a", "list", "of", "IPs", "currently", "assigned", "to", "the", "specified", "domain", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/ips.go#L52-L66
18,328
mailgun/mailgun-go
ips.go
AddDomainIP
func (mg *MailgunImpl) AddDomainIP(ctx context.Context, ip string) error { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("ip", ip) _, err := makePostRequest(ctx, r, payload) return err }
go
func (mg *MailgunImpl) AddDomainIP(ctx context.Context, ip string) error { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("ip", ip) _, err := makePostRequest(ctx, r, payload) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "AddDomainIP", "(", "ctx", "context", ".", "Context", ",", "ip", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "domainsEndpoint", ")", "+", "\"", "\"", "...
// Assign a dedicated IP to the domain specified.
[ "Assign", "a", "dedicated", "IP", "to", "the", "domain", "specified", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/ips.go#L69-L78
18,329
mailgun/mailgun-go
ips.go
DeleteDomainIP
func (mg *MailgunImpl) DeleteDomainIP(ctx context.Context, ip string) error { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips/" + ip) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteDomainIP(ctx context.Context, ip string) error { r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + mg.domain + "/ips/" + ip) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteDomainIP", "(", "ctx", "context", ".", "Context", ",", "ip", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "domainsEndpoint", ")", "+", "\"", "\"", ...
// Unassign an IP from the domain specified.
[ "Unassign", "an", "IP", "from", "the", "domain", "specified", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/ips.go#L81-L87
18,330
mailgun/mailgun-go
credentials.go
CreateCredential
func (mg *MailgunImpl) CreateCredential(ctx context.Context, login, password string) error { if (login == "") || (password == "") { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, "")) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("login", login) p.addValue("password", password) _, err := makePostRequest(ctx, r, p) return err }
go
func (mg *MailgunImpl) CreateCredential(ctx context.Context, login, password string) error { if (login == "") || (password == "") { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, "")) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("login", login) p.addValue("password", password) _, err := makePostRequest(ctx, r, p) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateCredential", "(", "ctx", "context", ".", "Context", ",", "login", ",", "password", "string", ")", "error", "{", "if", "(", "login", "==", "\"", "\"", ")", "||", "(", "password", "==", "\"", "\"", ")"...
// CreateCredential attempts to create associate a new principle with your domain.
[ "CreateCredential", "attempts", "to", "create", "associate", "a", "new", "principle", "with", "your", "domain", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/credentials.go#L178-L190
18,331
mailgun/mailgun-go
credentials.go
ChangeCredentialPassword
func (mg *MailgunImpl) ChangeCredentialPassword(ctx context.Context, id, password string) error { if (id == "") || (password == "") { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, id)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("password", password) _, err := makePutRequest(ctx, r, p) return err }
go
func (mg *MailgunImpl) ChangeCredentialPassword(ctx context.Context, id, password string) error { if (id == "") || (password == "") { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, id)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("password", password) _, err := makePutRequest(ctx, r, p) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ChangeCredentialPassword", "(", "ctx", "context", ".", "Context", ",", "id", ",", "password", "string", ")", "error", "{", "if", "(", "id", "==", "\"", "\"", ")", "||", "(", "password", "==", "\"", "\"", "...
// ChangeCredentialPassword attempts to alter the indicated credential's password.
[ "ChangeCredentialPassword", "attempts", "to", "alter", "the", "indicated", "credential", "s", "password", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/credentials.go#L193-L204
18,332
mailgun/mailgun-go
credentials.go
DeleteCredential
func (mg *MailgunImpl) DeleteCredential(ctx context.Context, id string) error { if id == "" { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, id)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteCredential(ctx context.Context, id string) error { if id == "" { return ErrEmptyParam } r := newHTTPRequest(generateCredentialsUrl(mg, id)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteCredential", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "error", "{", "if", "id", "==", "\"", "\"", "{", "return", "ErrEmptyParam", "\n", "}", "\n", "r", ":=", "newHTTPRequest", "...
// DeleteCredential attempts to remove the indicated principle from the domain.
[ "DeleteCredential", "attempts", "to", "remove", "the", "indicated", "principle", "from", "the", "domain", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/credentials.go#L207-L216
18,333
mailgun/mailgun-go
template_versions.go
AddTemplateVersion
func (mg *MailgunImpl) AddTemplateVersion(ctx context.Context, templateName string, version *TemplateVersion) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("template", version.Template) if version.Tag != "" { payload.addValue("tag", string(version.Tag)) } if version.Engine != "" { payload.addValue("engine", string(version.Engine)) } if version.Comment != "" { payload.addValue("comment", version.Comment) } if version.Active { payload.addValue("active", boolToString(version.Active)) } var resp templateResp if err := postResponseFromJSON(ctx, r, payload, &resp); err != nil { return err } *version = resp.Item.Version return nil }
go
func (mg *MailgunImpl) AddTemplateVersion(ctx context.Context, templateName string, version *TemplateVersion) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("template", version.Template) if version.Tag != "" { payload.addValue("tag", string(version.Tag)) } if version.Engine != "" { payload.addValue("engine", string(version.Engine)) } if version.Comment != "" { payload.addValue("comment", version.Comment) } if version.Active { payload.addValue("active", boolToString(version.Active)) } var resp templateResp if err := postResponseFromJSON(ctx, r, payload, &resp); err != nil { return err } *version = resp.Item.Version return nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "AddTemplateVersion", "(", "ctx", "context", ".", "Context", ",", "templateName", "string", ",", "version", "*", "TemplateVersion", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ...
// AddTemplateVersion adds a template version to a template
[ "AddTemplateVersion", "adds", "a", "template", "version", "to", "a", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template_versions.go#L26-L53
18,334
mailgun/mailgun-go
template_versions.go
GetTemplateVersion
func (mg *MailgunImpl) GetTemplateVersion(ctx context.Context, templateName, tag string) (TemplateVersion, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp templateResp err := getResponseFromJSON(ctx, r, &resp) if err != nil { return TemplateVersion{}, err } return resp.Item.Version, nil }
go
func (mg *MailgunImpl) GetTemplateVersion(ctx context.Context, templateName, tag string) (TemplateVersion, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp templateResp err := getResponseFromJSON(ctx, r, &resp) if err != nil { return TemplateVersion{}, err } return resp.Item.Version, nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetTemplateVersion", "(", "ctx", "context", ".", "Context", ",", "templateName", ",", "tag", "string", ")", "(", "TemplateVersion", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", ...
// GetTemplateVersion gets a specific version of a template
[ "GetTemplateVersion", "gets", "a", "specific", "version", "of", "a", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template_versions.go#L56-L67
18,335
mailgun/mailgun-go
template_versions.go
UpdateTemplateVersion
func (mg *MailgunImpl) UpdateTemplateVersion(ctx context.Context, templateName string, version *TemplateVersion) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + version.Tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if version.Comment != "" { p.addValue("comment", version.Comment) } if version.Active { p.addValue("active", boolToString(version.Active)) } var resp templateResp err := putResponseFromJSON(ctx, r, p, &resp) if err != nil { return err } *version = resp.Item.Version return nil }
go
func (mg *MailgunImpl) UpdateTemplateVersion(ctx context.Context, templateName string, version *TemplateVersion) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + version.Tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if version.Comment != "" { p.addValue("comment", version.Comment) } if version.Active { p.addValue("active", boolToString(version.Active)) } var resp templateResp err := putResponseFromJSON(ctx, r, p, &resp) if err != nil { return err } *version = resp.Item.Version return nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateTemplateVersion", "(", "ctx", "context", ".", "Context", ",", "templateName", "string", ",", "version", "*", "TemplateVersion", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg",...
// Update the comment and mark a version of a template active
[ "Update", "the", "comment", "and", "mark", "a", "version", "of", "a", "template", "active" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template_versions.go#L70-L90
18,336
mailgun/mailgun-go
template_versions.go
DeleteTemplateVersion
func (mg *MailgunImpl) DeleteTemplateVersion(ctx context.Context, templateName, tag string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteTemplateVersion(ctx context.Context, templateName, tag string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteTemplateVersion", "(", "ctx", "context", ".", "Context", ",", "templateName", ",", "tag", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ...
// Delete a specific version of a template
[ "Delete", "a", "specific", "version", "of", "a", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template_versions.go#L93-L99
18,337
mailgun/mailgun-go
template_versions.go
ListTemplateVersions
func (mg *MailgunImpl) ListTemplateVersions(templateName string, opts *ListOptions) *TemplateVersionsIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &TemplateVersionsIterator{ mg: mg, templateVersionListResp: templateVersionListResp{Paging: Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListTemplateVersions(templateName string, opts *ListOptions) *TemplateVersionsIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + templateName + "/versions") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &TemplateVersionsIterator{ mg: mg, templateVersionListResp: templateVersionListResp{Paging: Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListTemplateVersions", "(", "templateName", "string", ",", "opts", "*", "ListOptions", ")", "*", "TemplateVersionsIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ...
// List all the versions of a specific template
[ "List", "all", "the", "versions", "of", "a", "specific", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template_versions.go#L108-L123
18,338
mailgun/mailgun-go
routes.go
ListRoutes
func (mg *MailgunImpl) ListRoutes(opts *ListOptions) *RoutesIterator { var limit int if opts != nil { limit = opts.Limit } if limit == 0 { limit = 100 } return &RoutesIterator{ mg: mg, url: generatePublicApiUrl(mg, routesEndpoint), routesListResponse: routesListResponse{TotalCount: -1}, limit: limit, } }
go
func (mg *MailgunImpl) ListRoutes(opts *ListOptions) *RoutesIterator { var limit int if opts != nil { limit = opts.Limit } if limit == 0 { limit = 100 } return &RoutesIterator{ mg: mg, url: generatePublicApiUrl(mg, routesEndpoint), routesListResponse: routesListResponse{TotalCount: -1}, limit: limit, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListRoutes", "(", "opts", "*", "ListOptions", ")", "*", "RoutesIterator", "{", "var", "limit", "int", "\n", "if", "opts", "!=", "nil", "{", "limit", "=", "opts", ".", "Limit", "\n", "}", "\n\n", "if", "lim...
// ListRoutes allows you to iterate through a list of routes returned by the API
[ "ListRoutes", "allows", "you", "to", "iterate", "through", "a", "list", "of", "routes", "returned", "by", "the", "API" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/routes.go#L43-L59
18,339
mailgun/mailgun-go
routes.go
CreateRoute
func (mg *MailgunImpl) CreateRoute(ctx context.Context, prototype Route) (_ignored Route, err error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("priority", strconv.Itoa(prototype.Priority)) p.addValue("description", prototype.Description) p.addValue("expression", prototype.Expression) for _, action := range prototype.Actions { p.addValue("action", action) } var resp createRouteResp if err = postResponseFromJSON(ctx, r, p, &resp); err != nil { return _ignored, err } return resp.Route, err }
go
func (mg *MailgunImpl) CreateRoute(ctx context.Context, prototype Route) (_ignored Route, err error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("priority", strconv.Itoa(prototype.Priority)) p.addValue("description", prototype.Description) p.addValue("expression", prototype.Expression) for _, action := range prototype.Actions { p.addValue("action", action) } var resp createRouteResp if err = postResponseFromJSON(ctx, r, p, &resp); err != nil { return _ignored, err } return resp.Route, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateRoute", "(", "ctx", "context", ".", "Context", ",", "prototype", "Route", ")", "(", "_ignored", "Route", ",", "err", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ...
// CreateRoute installs a new route for your domain. // The route structure you provide serves as a template, and // only a subset of the fields influence the operation. // See the Route structure definition for more details.
[ "CreateRoute", "installs", "a", "new", "route", "for", "your", "domain", ".", "The", "route", "structure", "you", "provide", "serves", "as", "a", "template", "and", "only", "a", "subset", "of", "the", "fields", "influence", "the", "operation", ".", "See", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/routes.go#L199-L215
18,340
mailgun/mailgun-go
routes.go
DeleteRoute
func (mg *MailgunImpl) DeleteRoute(ctx context.Context, id string) error { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteRoute(ctx context.Context, id string) error { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteRoute", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "routesEndpoint", ")", "+", "\"", "\"", "+...
// DeleteRoute removes the specified route from your domain's configuration. // To avoid ambiguity, Mailgun identifies the route by unique ID. // See the Route structure definition and the Mailgun API documentation for more details.
[ "DeleteRoute", "removes", "the", "specified", "route", "from", "your", "domain", "s", "configuration", ".", "To", "avoid", "ambiguity", "Mailgun", "identifies", "the", "route", "by", "unique", "ID", ".", "See", "the", "Route", "structure", "definition", "and", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/routes.go#L220-L226
18,341
mailgun/mailgun-go
routes.go
GetRoute
func (mg *MailgunImpl) GetRoute(ctx context.Context, id string) (Route, error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var envelope struct { Message string `json:"message"` *Route `json:"route"` } err := getResponseFromJSON(ctx, r, &envelope) if err != nil { return Route{}, err } return *envelope.Route, err }
go
func (mg *MailgunImpl) GetRoute(ctx context.Context, id string) (Route, error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var envelope struct { Message string `json:"message"` *Route `json:"route"` } err := getResponseFromJSON(ctx, r, &envelope) if err != nil { return Route{}, err } return *envelope.Route, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetRoute", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "Route", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "routesEndpoint", ")"...
// GetRoute retrieves the complete route definition associated with the unique route ID.
[ "GetRoute", "retrieves", "the", "complete", "route", "definition", "associated", "with", "the", "unique", "route", "ID", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/routes.go#L229-L243
18,342
mailgun/mailgun-go
routes.go
UpdateRoute
func (mg *MailgunImpl) UpdateRoute(ctx context.Context, id string, route Route) (Route, error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if route.Priority != 0 { p.addValue("priority", strconv.Itoa(route.Priority)) } if route.Description != "" { p.addValue("description", route.Description) } if route.Expression != "" { p.addValue("expression", route.Expression) } if route.Actions != nil { for _, action := range route.Actions { p.addValue("action", action) } } // For some reason, this API function just returns a bare Route on success. // Unsure why this is the case; it seems like it ought to be a bug. var envelope Route err := putResponseFromJSON(ctx, r, p, &envelope) return envelope, err }
go
func (mg *MailgunImpl) UpdateRoute(ctx context.Context, id string, route Route) (Route, error) { r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if route.Priority != 0 { p.addValue("priority", strconv.Itoa(route.Priority)) } if route.Description != "" { p.addValue("description", route.Description) } if route.Expression != "" { p.addValue("expression", route.Expression) } if route.Actions != nil { for _, action := range route.Actions { p.addValue("action", action) } } // For some reason, this API function just returns a bare Route on success. // Unsure why this is the case; it seems like it ought to be a bug. var envelope Route err := putResponseFromJSON(ctx, r, p, &envelope) return envelope, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateRoute", "(", "ctx", "context", ".", "Context", ",", "id", "string", ",", "route", "Route", ")", "(", "Route", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ...
// UpdateRoute provides an "in-place" update of the specified route. // Only those route fields which are non-zero or non-empty are updated. // All other fields remain as-is.
[ "UpdateRoute", "provides", "an", "in", "-", "place", "update", "of", "the", "specified", "route", ".", "Only", "those", "route", "fields", "which", "are", "non", "-", "zero", "or", "non", "-", "empty", "are", "updated", ".", "All", "other", "fields", "re...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/routes.go#L248-L272
18,343
mailgun/mailgun-go
members.go
GetMember
func (mg *MailgunImpl) GetMember(ctx context.Context, s, l string) (Member, error) { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, l) + "/" + s) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return Member{}, err } var resp memberResponse err = response.parseFromJSON(&resp) return resp.Member, err }
go
func (mg *MailgunImpl) GetMember(ctx context.Context, s, l string) (Member, error) { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, l) + "/" + s) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return Member{}, err } var resp memberResponse err = response.parseFromJSON(&resp) return resp.Member, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetMember", "(", "ctx", "context", ".", "Context", ",", "s", ",", "l", "string", ")", "(", "Member", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateMemberApiUrl", "(", "mg", ",", "listsEn...
// GetMember returns a complete Member structure for a member of a mailing list, // given only their subscription e-mail address.
[ "GetMember", "returns", "a", "complete", "Member", "structure", "for", "a", "member", "of", "a", "mailing", "list", "given", "only", "their", "subscription", "e", "-", "mail", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/members.go#L160-L171
18,344
mailgun/mailgun-go
members.go
CreateMember
func (mg *MailgunImpl) CreateMember(ctx context.Context, merge bool, addr string, prototype Member) error { vs, err := json.Marshal(prototype.Vars) if err != nil { return err } r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, addr)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newFormDataPayload() p.addValue("upsert", yesNo(merge)) p.addValue("address", prototype.Address) p.addValue("name", prototype.Name) p.addValue("vars", string(vs)) if prototype.Subscribed != nil { p.addValue("subscribed", yesNo(*prototype.Subscribed)) } _, err = makePostRequest(ctx, r, p) return err }
go
func (mg *MailgunImpl) CreateMember(ctx context.Context, merge bool, addr string, prototype Member) error { vs, err := json.Marshal(prototype.Vars) if err != nil { return err } r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, addr)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newFormDataPayload() p.addValue("upsert", yesNo(merge)) p.addValue("address", prototype.Address) p.addValue("name", prototype.Name) p.addValue("vars", string(vs)) if prototype.Subscribed != nil { p.addValue("subscribed", yesNo(*prototype.Subscribed)) } _, err = makePostRequest(ctx, r, p) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateMember", "(", "ctx", "context", ".", "Context", ",", "merge", "bool", ",", "addr", "string", ",", "prototype", "Member", ")", "error", "{", "vs", ",", "err", ":=", "json", ".", "Marshal", "(", "prototy...
// CreateMember registers a new member of the indicated mailing list. // If merge is set to true, then the registration may update an existing Member's settings. // Otherwise, an error will occur if you attempt to add a member with a duplicate e-mail address.
[ "CreateMember", "registers", "a", "new", "member", "of", "the", "indicated", "mailing", "list", ".", "If", "merge", "is", "set", "to", "true", "then", "the", "registration", "may", "update", "an", "existing", "Member", "s", "settings", ".", "Otherwise", "an"...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/members.go#L176-L195
18,345
mailgun/mailgun-go
members.go
UpdateMember
func (mg *MailgunImpl) UpdateMember(ctx context.Context, s, l string, prototype Member) (Member, error) { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, l) + "/" + s) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newFormDataPayload() if prototype.Address != "" { p.addValue("address", prototype.Address) } if prototype.Name != "" { p.addValue("name", prototype.Name) } if prototype.Vars != nil { vs, err := json.Marshal(prototype.Vars) if err != nil { return Member{}, err } p.addValue("vars", string(vs)) } if prototype.Subscribed != nil { p.addValue("subscribed", yesNo(*prototype.Subscribed)) } response, err := makePutRequest(ctx, r, p) if err != nil { return Member{}, err } var envelope struct { Member Member `json:"member"` } err = response.parseFromJSON(&envelope) return envelope.Member, err }
go
func (mg *MailgunImpl) UpdateMember(ctx context.Context, s, l string, prototype Member) (Member, error) { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, l) + "/" + s) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newFormDataPayload() if prototype.Address != "" { p.addValue("address", prototype.Address) } if prototype.Name != "" { p.addValue("name", prototype.Name) } if prototype.Vars != nil { vs, err := json.Marshal(prototype.Vars) if err != nil { return Member{}, err } p.addValue("vars", string(vs)) } if prototype.Subscribed != nil { p.addValue("subscribed", yesNo(*prototype.Subscribed)) } response, err := makePutRequest(ctx, r, p) if err != nil { return Member{}, err } var envelope struct { Member Member `json:"member"` } err = response.parseFromJSON(&envelope) return envelope.Member, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateMember", "(", "ctx", "context", ".", "Context", ",", "s", ",", "l", "string", ",", "prototype", "Member", ")", "(", "Member", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateMemberApiU...
// UpdateMember lets you change certain details about the indicated mailing list member. // Address, Name, Vars, and Subscribed fields may be changed.
[ "UpdateMember", "lets", "you", "change", "certain", "details", "about", "the", "indicated", "mailing", "list", "member", ".", "Address", "Name", "Vars", "and", "Subscribed", "fields", "may", "be", "changed", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/members.go#L199-L229
18,346
mailgun/mailgun-go
members.go
DeleteMember
func (mg *MailgunImpl) DeleteMember(ctx context.Context, member, addr string) error { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, addr) + "/" + member) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteMember(ctx context.Context, member, addr string) error { r := newHTTPRequest(generateMemberApiUrl(mg, listsEndpoint, addr) + "/" + member) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteMember", "(", "ctx", "context", ".", "Context", ",", "member", ",", "addr", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateMemberApiUrl", "(", "mg", ",", "listsEndpoint", ",", "add...
// DeleteMember removes the member from the list.
[ "DeleteMember", "removes", "the", "member", "from", "the", "list", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/members.go#L232-L238
18,347
mailgun/mailgun-go
mock.go
NewMockServer
func NewMockServer() MockServer { ms := MockServer{} // Add all our handlers r := chi.NewRouter() r.Route("/v3", func(r chi.Router) { ms.addIPRoutes(r) ms.addExportRoutes(r) ms.addDomainRoutes(r) ms.addMailingListRoutes(r) ms.addEventRoutes(r) ms.addMessagesRoutes(r) ms.addValidationRoutes(r) ms.addRoutes(r) }) // Start the server ms.srv = httptest.NewServer(r) return ms }
go
func NewMockServer() MockServer { ms := MockServer{} // Add all our handlers r := chi.NewRouter() r.Route("/v3", func(r chi.Router) { ms.addIPRoutes(r) ms.addExportRoutes(r) ms.addDomainRoutes(r) ms.addMailingListRoutes(r) ms.addEventRoutes(r) ms.addMessagesRoutes(r) ms.addValidationRoutes(r) ms.addRoutes(r) }) // Start the server ms.srv = httptest.NewServer(r) return ms }
[ "func", "NewMockServer", "(", ")", "MockServer", "{", "ms", ":=", "MockServer", "{", "}", "\n\n", "// Add all our handlers", "r", ":=", "chi", ".", "NewRouter", "(", ")", "\n\n", "r", ".", "Route", "(", "\"", "\"", ",", "func", "(", "r", "chi", ".", ...
// Create a new instance of the mailgun API mock server
[ "Create", "a", "new", "instance", "of", "the", "mailgun", "API", "mock", "server" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mock.go#L30-L50
18,348
mailgun/mailgun-go
mock.go
pageOffsets
func pageOffsets(pivotIdx []string, pivotDir, pivotVal string, limit int) (int, int) { switch pivotDir { case "first": if limit < len(pivotIdx) { return 0, limit } return 0, len(pivotIdx) case "last": if limit < len(pivotIdx) { return len(pivotIdx) - limit, len(pivotIdx) } return 0, len(pivotIdx) case "next": for i, item := range pivotIdx { if item == pivotVal { offset := i + 1 + limit if offset > len(pivotIdx) { offset = len(pivotIdx) } return i + 1, offset } } return 0, 0 case "prev": for i, item := range pivotIdx { if item == pivotVal { if i == 0 { return 0, 0 } offset := i - limit if offset < 0 { offset = 0 } return offset, i } } return 0, 0 } if limit > len(pivotIdx) { return 0, len(pivotIdx) } return 0, limit }
go
func pageOffsets(pivotIdx []string, pivotDir, pivotVal string, limit int) (int, int) { switch pivotDir { case "first": if limit < len(pivotIdx) { return 0, limit } return 0, len(pivotIdx) case "last": if limit < len(pivotIdx) { return len(pivotIdx) - limit, len(pivotIdx) } return 0, len(pivotIdx) case "next": for i, item := range pivotIdx { if item == pivotVal { offset := i + 1 + limit if offset > len(pivotIdx) { offset = len(pivotIdx) } return i + 1, offset } } return 0, 0 case "prev": for i, item := range pivotIdx { if item == pivotVal { if i == 0 { return 0, 0 } offset := i - limit if offset < 0 { offset = 0 } return offset, i } } return 0, 0 } if limit > len(pivotIdx) { return 0, len(pivotIdx) } return 0, limit }
[ "func", "pageOffsets", "(", "pivotIdx", "[", "]", "string", ",", "pivotDir", ",", "pivotVal", "string", ",", "limit", "int", ")", "(", "int", ",", "int", ")", "{", "switch", "pivotDir", "{", "case", "\"", "\"", ":", "if", "limit", "<", "len", "(", ...
// Given the page direction, pivot value and limit, calculate the offsets for the slice
[ "Given", "the", "page", "direction", "pivot", "value", "and", "limit", "calculate", "the", "offsets", "for", "the", "slice" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mock.go#L123-L167
18,349
mailgun/mailgun-go
spam_complaints.go
ListComplaints
func (mg *MailgunImpl) ListComplaints(opts *ListOptions) *ComplaintsIterator { r := newHTTPRequest(generateApiUrl(mg, complaintsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &ComplaintsIterator{ mg: mg, complaintsResponse: complaintsResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListComplaints(opts *ListOptions) *ComplaintsIterator { r := newHTTPRequest(generateApiUrl(mg, complaintsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &ComplaintsIterator{ mg: mg, complaintsResponse: complaintsResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListComplaints", "(", "opts", "*", "ListOptions", ")", "*", "ComplaintsIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "complaintsEndpoint", ")", ")", "\n", "r", ".", "setClient...
// ListComplaints returns a set of spam complaints registered against your domain. // Recipients of your messages can click on a link which sends feedback to Mailgun // indicating that the message they received is, to them, spam.
[ "ListComplaints", "returns", "a", "set", "of", "spam", "complaints", "registered", "against", "your", "domain", ".", "Recipients", "of", "your", "messages", "can", "click", "on", "a", "link", "which", "sends", "feedback", "to", "Mailgun", "indicating", "that", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/spam_complaints.go#L28-L43
18,350
mailgun/mailgun-go
spam_complaints.go
GetComplaint
func (mg *MailgunImpl) GetComplaint(ctx context.Context, address string) (Complaint, error) { r := newHTTPRequest(generateApiUrl(mg, complaintsEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var c Complaint err := getResponseFromJSON(ctx, r, &c) return c, err }
go
func (mg *MailgunImpl) GetComplaint(ctx context.Context, address string) (Complaint, error) { r := newHTTPRequest(generateApiUrl(mg, complaintsEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var c Complaint err := getResponseFromJSON(ctx, r, &c) return c, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetComplaint", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "Complaint", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "complaintsEndpo...
// GetComplaint returns a single complaint record filed by a recipient at the email address provided. // If no complaint exists, the Complaint instance returned will be empty.
[ "GetComplaint", "returns", "a", "single", "complaint", "record", "filed", "by", "a", "recipient", "at", "the", "email", "address", "provided", ".", "If", "no", "complaint", "exists", "the", "Complaint", "instance", "returned", "will", "be", "empty", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/spam_complaints.go#L144-L152
18,351
mailgun/mailgun-go
mailgun.go
NewMailgun
func NewMailgun(domain, apiKey string) *MailgunImpl { return &MailgunImpl{ apiBase: APIBase, domain: domain, apiKey: apiKey, client: http.DefaultClient, } }
go
func NewMailgun(domain, apiKey string) *MailgunImpl { return &MailgunImpl{ apiBase: APIBase, domain: domain, apiKey: apiKey, client: http.DefaultClient, } }
[ "func", "NewMailgun", "(", "domain", ",", "apiKey", "string", ")", "*", "MailgunImpl", "{", "return", "&", "MailgunImpl", "{", "apiBase", ":", "APIBase", ",", "domain", ":", "domain", ",", "apiKey", ":", "apiKey", ",", "client", ":", "http", ".", "Defaul...
// NewMailGun creates a new client instance.
[ "NewMailGun", "creates", "a", "new", "client", "instance", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L242-L249
18,352
mailgun/mailgun-go
mailgun.go
NewMailgunFromEnv
func NewMailgunFromEnv() (*MailgunImpl, error) { apiKey := os.Getenv("MG_API_KEY") if apiKey == "" { return nil, errors.New("required environment variable MG_API_KEY not defined") } domain := os.Getenv("MG_DOMAIN") if domain == "" { return nil, errors.New("required environment variable MG_DOMAIN not defined") } mg := NewMailgun(domain, apiKey) url := os.Getenv("MG_URL") if url != "" { mg.SetAPIBase(url) } return mg, nil }
go
func NewMailgunFromEnv() (*MailgunImpl, error) { apiKey := os.Getenv("MG_API_KEY") if apiKey == "" { return nil, errors.New("required environment variable MG_API_KEY not defined") } domain := os.Getenv("MG_DOMAIN") if domain == "" { return nil, errors.New("required environment variable MG_DOMAIN not defined") } mg := NewMailgun(domain, apiKey) url := os.Getenv("MG_URL") if url != "" { mg.SetAPIBase(url) } return mg, nil }
[ "func", "NewMailgunFromEnv", "(", ")", "(", "*", "MailgunImpl", ",", "error", ")", "{", "apiKey", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "apiKey", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", ...
// NewMailgunFromEnv returns a new Mailgun client using the environment variables // MG_API_KEY, MG_DOMAIN, and MG_URL
[ "NewMailgunFromEnv", "returns", "a", "new", "Mailgun", "client", "using", "the", "environment", "variables", "MG_API_KEY", "MG_DOMAIN", "and", "MG_URL" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L253-L271
18,353
mailgun/mailgun-go
mailgun.go
generateApiUrlWithDomain
func generateApiUrlWithDomain(m Mailgun, endpoint, domain string) string { return fmt.Sprintf("%s/%s/%s", m.APIBase(), domain, endpoint) }
go
func generateApiUrlWithDomain(m Mailgun, endpoint, domain string) string { return fmt.Sprintf("%s/%s/%s", m.APIBase(), domain, endpoint) }
[ "func", "generateApiUrlWithDomain", "(", "m", "Mailgun", ",", "endpoint", ",", "domain", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "APIBase", "(", ")", ",", "domain", ",", "endpoint", ")", "\n", "}" ...
// generateApiUrlWithDomain renders a URL for an API endpoint using a separate domain and endpoint name.
[ "generateApiUrlWithDomain", "renders", "a", "URL", "for", "an", "API", "endpoint", "using", "a", "separate", "domain", "and", "endpoint", "name", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L309-L311
18,354
mailgun/mailgun-go
mailgun.go
generateMemberApiUrl
func generateMemberApiUrl(m Mailgun, endpoint, address string) string { return fmt.Sprintf("%s/%s/%s/members", m.APIBase(), endpoint, address) }
go
func generateMemberApiUrl(m Mailgun, endpoint, address string) string { return fmt.Sprintf("%s/%s/%s/members", m.APIBase(), endpoint, address) }
[ "func", "generateMemberApiUrl", "(", "m", "Mailgun", ",", "endpoint", ",", "address", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "APIBase", "(", ")", ",", "endpoint", ",", "address", ")", "\n", "}" ]
// generateMemberApiUrl renders a URL relevant for specifying mailing list members. // The address parameter refers to the mailing list in question.
[ "generateMemberApiUrl", "renders", "a", "URL", "relevant", "for", "specifying", "mailing", "list", "members", ".", "The", "address", "parameter", "refers", "to", "the", "mailing", "list", "in", "question", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L315-L317
18,355
mailgun/mailgun-go
mailgun.go
generateApiUrlWithTarget
func generateApiUrlWithTarget(m Mailgun, endpoint, target string) string { tail := "" if target != "" { tail = fmt.Sprintf("/%s", target) } return fmt.Sprintf("%s%s", generateApiUrl(m, endpoint), tail) }
go
func generateApiUrlWithTarget(m Mailgun, endpoint, target string) string { tail := "" if target != "" { tail = fmt.Sprintf("/%s", target) } return fmt.Sprintf("%s%s", generateApiUrl(m, endpoint), tail) }
[ "func", "generateApiUrlWithTarget", "(", "m", "Mailgun", ",", "endpoint", ",", "target", "string", ")", "string", "{", "tail", ":=", "\"", "\"", "\n", "if", "target", "!=", "\"", "\"", "{", "tail", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t...
// generateApiUrlWithTarget works as generateApiUrl, // but consumes an additional resource parameter called 'target'.
[ "generateApiUrlWithTarget", "works", "as", "generateApiUrl", "but", "consumes", "an", "additional", "resource", "parameter", "called", "target", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L321-L327
18,356
mailgun/mailgun-go
mailgun.go
generateDomainApiUrl
func generateDomainApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/domains/%s/%s", m.APIBase(), m.Domain(), endpoint) }
go
func generateDomainApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/domains/%s/%s", m.APIBase(), m.Domain(), endpoint) }
[ "func", "generateDomainApiUrl", "(", "m", "Mailgun", ",", "endpoint", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "APIBase", "(", ")", ",", "m", ".", "Domain", "(", ")", ",", "endpoint", ")", "\n", ...
// generateDomainApiUrl renders a URL as generateApiUrl, but // addresses a family of functions which have a non-standard URL structure. // Most URLs consume a domain in the 2nd position, but some endpoints // require the word "domains" to be there instead.
[ "generateDomainApiUrl", "renders", "a", "URL", "as", "generateApiUrl", "but", "addresses", "a", "family", "of", "functions", "which", "have", "a", "non", "-", "standard", "URL", "structure", ".", "Most", "URLs", "consume", "a", "domain", "in", "the", "2nd", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L333-L335
18,357
mailgun/mailgun-go
mailgun.go
generateCredentialsUrl
func generateCredentialsUrl(m Mailgun, id string) string { tail := "" if id != "" { tail = fmt.Sprintf("/%s", id) } return generateDomainApiUrl(m, fmt.Sprintf("credentials%s", tail)) // return fmt.Sprintf("%s/domains/%s/credentials%s", apiBase, m.Domain(), tail) }
go
func generateCredentialsUrl(m Mailgun, id string) string { tail := "" if id != "" { tail = fmt.Sprintf("/%s", id) } return generateDomainApiUrl(m, fmt.Sprintf("credentials%s", tail)) // return fmt.Sprintf("%s/domains/%s/credentials%s", apiBase, m.Domain(), tail) }
[ "func", "generateCredentialsUrl", "(", "m", "Mailgun", ",", "id", "string", ")", "string", "{", "tail", ":=", "\"", "\"", "\n", "if", "id", "!=", "\"", "\"", "{", "tail", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n...
// generateCredentialsUrl renders a URL as generateDomainApiUrl, // but focuses on the SMTP credentials family of API functions.
[ "generateCredentialsUrl", "renders", "a", "URL", "as", "generateDomainApiUrl", "but", "focuses", "on", "the", "SMTP", "credentials", "family", "of", "API", "functions", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L339-L346
18,358
mailgun/mailgun-go
mailgun.go
generateStoredMessageUrl
func generateStoredMessageUrl(m Mailgun, endpoint, id string) string { return generateDomainApiUrl(m, fmt.Sprintf("%s/%s", endpoint, id)) // return fmt.Sprintf("%s/domains/%s/%s/%s", apiBase, m.Domain(), endpoint, id) }
go
func generateStoredMessageUrl(m Mailgun, endpoint, id string) string { return generateDomainApiUrl(m, fmt.Sprintf("%s/%s", endpoint, id)) // return fmt.Sprintf("%s/domains/%s/%s/%s", apiBase, m.Domain(), endpoint, id) }
[ "func", "generateStoredMessageUrl", "(", "m", "Mailgun", ",", "endpoint", ",", "id", "string", ")", "string", "{", "return", "generateDomainApiUrl", "(", "m", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "endpoint", ",", "id", ")", ")", "\n", "// re...
// generateStoredMessageUrl generates the URL needed to acquire a copy of a stored message.
[ "generateStoredMessageUrl", "generates", "the", "URL", "needed", "to", "acquire", "a", "copy", "of", "a", "stored", "message", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L349-L352
18,359
mailgun/mailgun-go
mailgun.go
generatePublicApiUrl
func generatePublicApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/%s", m.APIBase(), endpoint) }
go
func generatePublicApiUrl(m Mailgun, endpoint string) string { return fmt.Sprintf("%s/%s", m.APIBase(), endpoint) }
[ "func", "generatePublicApiUrl", "(", "m", "Mailgun", ",", "endpoint", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "APIBase", "(", ")", ",", "endpoint", ")", "\n", "}" ]
// generatePublicApiUrl works as generateApiUrl, except that generatePublicApiUrl has no need for the domain.
[ "generatePublicApiUrl", "works", "as", "generateApiUrl", "except", "that", "generatePublicApiUrl", "has", "no", "need", "for", "the", "domain", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L355-L357
18,360
mailgun/mailgun-go
mailgun.go
generateParameterizedUrl
func generateParameterizedUrl(m Mailgun, endpoint string, payload payload) (string, error) { paramBuffer, err := payload.getPayloadBuffer() if err != nil { return "", err } params := string(paramBuffer.Bytes()) return fmt.Sprintf("%s?%s", generateApiUrl(m, eventsEndpoint), params), nil }
go
func generateParameterizedUrl(m Mailgun, endpoint string, payload payload) (string, error) { paramBuffer, err := payload.getPayloadBuffer() if err != nil { return "", err } params := string(paramBuffer.Bytes()) return fmt.Sprintf("%s?%s", generateApiUrl(m, eventsEndpoint), params), nil }
[ "func", "generateParameterizedUrl", "(", "m", "Mailgun", ",", "endpoint", "string", ",", "payload", "payload", ")", "(", "string", ",", "error", ")", "{", "paramBuffer", ",", "err", ":=", "payload", ".", "getPayloadBuffer", "(", ")", "\n", "if", "err", "!=...
// generateParameterizedUrl works as generateApiUrl, but supports query parameters.
[ "generateParameterizedUrl", "works", "as", "generateApiUrl", "but", "supports", "query", "parameters", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L360-L367
18,361
mailgun/mailgun-go
mailgun.go
parseMailgunTime
func parseMailgunTime(ts string) (t time.Time, err error) { t, err = time.Parse("Mon, 2 Jan 2006 15:04:05 MST", ts) return }
go
func parseMailgunTime(ts string) (t time.Time, err error) { t, err = time.Parse("Mon, 2 Jan 2006 15:04:05 MST", ts) return }
[ "func", "parseMailgunTime", "(", "ts", "string", ")", "(", "t", "time", ".", "Time", ",", "err", "error", ")", "{", "t", ",", "err", "=", "time", ".", "Parse", "(", "\"", "\"", ",", "ts", ")", "\n", "return", "\n", "}" ]
// parseMailgunTime translates a timestamp as returned by Mailgun into a Go standard timestamp.
[ "parseMailgunTime", "translates", "a", "timestamp", "as", "returned", "by", "Mailgun", "into", "a", "Go", "standard", "timestamp", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailgun.go#L370-L373
18,362
mailgun/mailgun-go
parse.go
new_
func new_(e interface{}) func() Event { typ := reflect.TypeOf(e) return func() Event { return reflect.New(typ).Interface().(Event) } }
go
func new_(e interface{}) func() Event { typ := reflect.TypeOf(e) return func() Event { return reflect.New(typ).Interface().(Event) } }
[ "func", "new_", "(", "e", "interface", "{", "}", ")", "func", "(", ")", "Event", "{", "typ", ":=", "reflect", ".", "TypeOf", "(", "e", ")", "\n", "return", "func", "(", ")", "Event", "{", "return", "reflect", ".", "New", "(", "typ", ")", ".", "...
// new_ is a universal event "constructor".
[ "new_", "is", "a", "universal", "event", "constructor", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L41-L46
18,363
mailgun/mailgun-go
parse.go
ParseEvents
func ParseEvents(raw []events.RawJSON) ([]Event, error) { var result []Event for _, value := range raw { event, err := ParseEvent(value) if err != nil { return nil, fmt.Errorf("while parsing event: %s", err) } result = append(result, event) } return result, nil }
go
func ParseEvents(raw []events.RawJSON) ([]Event, error) { var result []Event for _, value := range raw { event, err := ParseEvent(value) if err != nil { return nil, fmt.Errorf("while parsing event: %s", err) } result = append(result, event) } return result, nil }
[ "func", "ParseEvents", "(", "raw", "[", "]", "events", ".", "RawJSON", ")", "(", "[", "]", "Event", ",", "error", ")", "{", "var", "result", "[", "]", "Event", "\n", "for", "_", ",", "value", ":=", "range", "raw", "{", "event", ",", "err", ":=", ...
// Given a slice of events.RawJSON events return a slice of Event for each parsed event
[ "Given", "a", "slice", "of", "events", ".", "RawJSON", "events", "return", "a", "slice", "of", "Event", "for", "each", "parsed", "event" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L66-L76
18,364
mailgun/mailgun-go
parse.go
ParseEvent
func ParseEvent(raw []byte) (Event, error) { // Try to recognize the event first. var e events.EventName if err := easyjson.Unmarshal(raw, &e); err != nil { return nil, fmt.Errorf("failed to recognize event: %v", err) } // Get the event "constructor" from the map. newEvent, ok := EventNames[e.Name] if !ok { return nil, fmt.Errorf("unsupported event: '%s'", e.Name) } event := newEvent() // Parse the known event. if err := easyjson.Unmarshal(raw, event); err != nil { return nil, fmt.Errorf("failed to parse event '%s': %v", e.Name, err) } return event, nil }
go
func ParseEvent(raw []byte) (Event, error) { // Try to recognize the event first. var e events.EventName if err := easyjson.Unmarshal(raw, &e); err != nil { return nil, fmt.Errorf("failed to recognize event: %v", err) } // Get the event "constructor" from the map. newEvent, ok := EventNames[e.Name] if !ok { return nil, fmt.Errorf("unsupported event: '%s'", e.Name) } event := newEvent() // Parse the known event. if err := easyjson.Unmarshal(raw, event); err != nil { return nil, fmt.Errorf("failed to parse event '%s': %v", e.Name, err) } return event, nil }
[ "func", "ParseEvent", "(", "raw", "[", "]", "byte", ")", "(", "Event", ",", "error", ")", "{", "// Try to recognize the event first.", "var", "e", "events", ".", "EventName", "\n", "if", "err", ":=", "easyjson", ".", "Unmarshal", "(", "raw", ",", "&", "e...
// Parse converts raw bytes data into an event struct. Can accept events.RawJSON as input
[ "Parse", "converts", "raw", "bytes", "data", "into", "an", "event", "struct", ".", "Can", "accept", "events", ".", "RawJSON", "as", "input" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/parse.go#L79-L99
18,365
mailgun/mailgun-go
unsubscribes.go
ListUnsubscribes
func (mg *MailgunImpl) ListUnsubscribes(opts *ListOptions) *UnsubscribesIterator { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &UnsubscribesIterator{ mg: mg, unsubscribesResponse: unsubscribesResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListUnsubscribes(opts *ListOptions) *UnsubscribesIterator { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &UnsubscribesIterator{ mg: mg, unsubscribesResponse: unsubscribesResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListUnsubscribes", "(", "opts", "*", "ListOptions", ")", "*", "UnsubscribesIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "unsubscribesEndpoint", ")", ")", "\n", "r", ".", "set...
// Fetches the list of unsubscribes
[ "Fetches", "the", "list", "of", "unsubscribes" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L21-L36
18,366
mailgun/mailgun-go
unsubscribes.go
GetUnsubscribe
func (mg *MailgunImpl) GetUnsubscribe(ctx context.Context, address string) (Unsubscribe, error) { r := newHTTPRequest(generateApiUrlWithTarget(mg, unsubscribesEndpoint, address)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) envelope := Unsubscribe{} err := getResponseFromJSON(ctx, r, &envelope) return envelope, err }
go
func (mg *MailgunImpl) GetUnsubscribe(ctx context.Context, address string) (Unsubscribe, error) { r := newHTTPRequest(generateApiUrlWithTarget(mg, unsubscribesEndpoint, address)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) envelope := Unsubscribe{} err := getResponseFromJSON(ctx, r, &envelope) return envelope, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetUnsubscribe", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "Unsubscribe", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrlWithTarget", "(", "mg", ",", "u...
// Retreives a single unsubscribe record. Can be used to check if a given address is present in the list of unsubscribed users.
[ "Retreives", "a", "single", "unsubscribe", "record", ".", "Can", "be", "used", "to", "check", "if", "a", "given", "address", "is", "present", "in", "the", "list", "of", "unsubscribed", "users", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L136-L145
18,367
mailgun/mailgun-go
unsubscribes.go
CreateUnsubscribe
func (mg *MailgunImpl) CreateUnsubscribe(ctx context.Context, address, tag string) error { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("address", address) p.addValue("tag", tag) _, err := makePostRequest(ctx, r, p) return err }
go
func (mg *MailgunImpl) CreateUnsubscribe(ctx context.Context, address, tag string) error { r := newHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() p.addValue("address", address) p.addValue("tag", tag) _, err := makePostRequest(ctx, r, p) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateUnsubscribe", "(", "ctx", "context", ".", "Context", ",", "address", ",", "tag", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "unsubscribesEndpoint", ")", ...
// Unsubscribe adds an e-mail address to the domain's unsubscription table.
[ "Unsubscribe", "adds", "an", "e", "-", "mail", "address", "to", "the", "domain", "s", "unsubscription", "table", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/unsubscribes.go#L148-L157
18,368
mailgun/mailgun-go
tags.go
DeleteTag
func (mg *MailgunImpl) DeleteTag(ctx context.Context, tag string) error { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteTag(ctx context.Context, tag string) error { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteTag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "tagsEndpoint", ")", "+", "\"", "\"", "+", "tag...
// DeleteTag removes all counters for a particular tag, including the tag itself.
[ "DeleteTag", "removes", "all", "counters", "for", "a", "particular", "tag", "including", "the", "tag", "itself", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L30-L36
18,369
mailgun/mailgun-go
tags.go
GetTag
func (mg *MailgunImpl) GetTag(ctx context.Context, tag string) (Tag, error) { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var tagItem Tag return tagItem, getResponseFromJSON(ctx, r, &tagItem) }
go
func (mg *MailgunImpl) GetTag(ctx context.Context, tag string) (Tag, error) { r := newHTTPRequest(generateApiUrl(mg, tagsEndpoint) + "/" + tag) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var tagItem Tag return tagItem, getResponseFromJSON(ctx, r, &tagItem) }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetTag", "(", "ctx", "context", ".", "Context", ",", "tag", "string", ")", "(", "Tag", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "tagsEndpoint", ")", "+", ...
// GetTag retrieves metadata about the tag from the api
[ "GetTag", "retrieves", "metadata", "about", "the", "tag", "from", "the", "api" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L39-L45
18,370
mailgun/mailgun-go
tags.go
Next
func (ti *TagIterator) Next(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } if !canFetchPage(ti.Paging.Next) { return false } ti.err = ti.fetch(ctx, ti.Paging.Next) if ti.err != nil { return false } *items = ti.Items if len(ti.Items) == 0 { return false } return true }
go
func (ti *TagIterator) Next(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } if !canFetchPage(ti.Paging.Next) { return false } ti.err = ti.fetch(ctx, ti.Paging.Next) if ti.err != nil { return false } *items = ti.Items if len(ti.Items) == 0 { return false } return true }
[ "func", "(", "ti", "*", "TagIterator", ")", "Next", "(", "ctx", "context", ".", "Context", ",", "items", "*", "[", "]", "Tag", ")", "bool", "{", "if", "ti", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "canFetchP...
// Next returns the next page in the list of tags
[ "Next", "returns", "the", "next", "page", "in", "the", "list", "of", "tags" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L84-L102
18,371
mailgun/mailgun-go
tags.go
First
func (ti *TagIterator) First(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } ti.err = ti.fetch(ctx, ti.Paging.First) if ti.err != nil { return false } *items = ti.Items return true }
go
func (ti *TagIterator) First(ctx context.Context, items *[]Tag) bool { if ti.err != nil { return false } ti.err = ti.fetch(ctx, ti.Paging.First) if ti.err != nil { return false } *items = ti.Items return true }
[ "func", "(", "ti", "*", "TagIterator", ")", "First", "(", "ctx", "context", ".", "Context", ",", "items", "*", "[", "]", "Tag", ")", "bool", "{", "if", "ti", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "ti", ".", "err", "=...
// First returns the first page in the list of tags
[ "First", "returns", "the", "first", "page", "in", "the", "list", "of", "tags" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/tags.go#L130-L140
18,372
mailgun/mailgun-go
mailing_lists.go
ListMailingLists
func (mg *MailgunImpl) ListMailingLists(opts *ListOptions) *ListsIterator { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/pages") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &ListsIterator{ mg: mg, listsResponse: listsResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListMailingLists(opts *ListOptions) *ListsIterator { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/pages") r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } } url, err := r.generateUrlWithParameters() return &ListsIterator{ mg: mg, listsResponse: listsResponse{Paging: Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListMailingLists", "(", "opts", "*", "ListOptions", ")", "*", "ListsIterator", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEndpoint", ")", "+", "\"", "\"", ")", "\n", "r"...
// ListMailingLists returns the specified set of mailing lists administered by your account.
[ "ListMailingLists", "returns", "the", "specified", "set", "of", "mailing", "lists", "administered", "by", "your", "account", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L53-L68
18,373
mailgun/mailgun-go
mailing_lists.go
DeleteMailingList
func (mg *MailgunImpl) DeleteMailingList(ctx context.Context, addr string) error { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteMailingList(ctx context.Context, addr string) error { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEndpoint", ")", "+", "\"", "\"...
// DeleteMailingList removes all current members of the list, then removes the list itself. // Attempts to send e-mail to the list will fail subsequent to this call.
[ "DeleteMailingList", "removes", "all", "current", "members", "of", "the", "list", "then", "removes", "the", "list", "itself", ".", "Attempts", "to", "send", "e", "-", "mail", "to", "the", "list", "will", "fail", "subsequent", "to", "this", "call", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L194-L200
18,374
mailgun/mailgun-go
mailing_lists.go
GetMailingList
func (mg *MailgunImpl) GetMailingList(ctx context.Context, addr string) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return MailingList{}, err } var resp mailingListResponse err = response.parseFromJSON(&resp) return resp.MailingList, err }
go
func (mg *MailgunImpl) GetMailingList(ctx context.Context, addr string) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) response, err := makeGetRequest(ctx, r) if err != nil { return MailingList{}, err } var resp mailingListResponse err = response.parseFromJSON(&resp) return resp.MailingList, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ")", "(", "MailingList", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "listsEnd...
// GetMailingList allows your application to recover the complete List structure // representing a mailing list, so long as you have its e-mail address.
[ "GetMailingList", "allows", "your", "application", "to", "recover", "the", "complete", "List", "structure", "representing", "a", "mailing", "list", "so", "long", "as", "you", "have", "its", "e", "-", "mail", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L204-L216
18,375
mailgun/mailgun-go
mailing_lists.go
UpdateMailingList
func (mg *MailgunImpl) UpdateMailingList(ctx context.Context, addr string, prototype MailingList) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if prototype.Address != "" { p.addValue("address", prototype.Address) } if prototype.Name != "" { p.addValue("name", prototype.Name) } if prototype.Description != "" { p.addValue("description", prototype.Description) } if prototype.AccessLevel != "" { p.addValue("access_level", string(prototype.AccessLevel)) } var l MailingList response, err := makePutRequest(ctx, r, p) if err != nil { return l, err } err = response.parseFromJSON(&l) return l, err }
go
func (mg *MailgunImpl) UpdateMailingList(ctx context.Context, addr string, prototype MailingList) (MailingList, error) { r := newHTTPRequest(generatePublicApiUrl(mg, listsEndpoint) + "/" + addr) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if prototype.Address != "" { p.addValue("address", prototype.Address) } if prototype.Name != "" { p.addValue("name", prototype.Name) } if prototype.Description != "" { p.addValue("description", prototype.Description) } if prototype.AccessLevel != "" { p.addValue("access_level", string(prototype.AccessLevel)) } var l MailingList response, err := makePutRequest(ctx, r, p) if err != nil { return l, err } err = response.parseFromJSON(&l) return l, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateMailingList", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "prototype", "MailingList", ")", "(", "MailingList", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublic...
// UpdateMailingList allows you to change various attributes of a list. // Address, Name, Description, and AccessLevel are all optional; // only those fields which are set in the prototype will change. // // Be careful! If changing the address of a mailing list, // e-mail sent to the old address will not succeed. // Make sure you account for the change accordingly.
[ "UpdateMailingList", "allows", "you", "to", "change", "various", "attributes", "of", "a", "list", ".", "Address", "Name", "Description", "and", "AccessLevel", "are", "all", "optional", ";", "only", "those", "fields", "which", "are", "set", "in", "the", "protot...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/mailing_lists.go#L225-L249
18,376
mailgun/mailgun-go
stats.go
GetStats
func (mg *MailgunImpl) GetStats(ctx context.Context, events []string, opts *GetStatOptions) ([]Stats, error) { r := newHTTPRequest(generateApiUrl(mg, statsTotalEndpoint)) if opts != nil { if !opts.Start.IsZero() { r.addParameter("start", opts.Start.Format(iso8601date)) } if !opts.End.IsZero() { r.addParameter("end", opts.End.Format(iso8601date)) } if opts.Resolution != "" { r.addParameter("resolution", string(opts.Resolution)) } if opts.Duration != "" { r.addParameter("duration", opts.Duration) } } for _, e := range events { r.addParameter("event", e) } r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var res statsTotalResponse err := getResponseFromJSON(ctx, r, &res) if err != nil { return nil, err } else { return res.Stats, nil } }
go
func (mg *MailgunImpl) GetStats(ctx context.Context, events []string, opts *GetStatOptions) ([]Stats, error) { r := newHTTPRequest(generateApiUrl(mg, statsTotalEndpoint)) if opts != nil { if !opts.Start.IsZero() { r.addParameter("start", opts.Start.Format(iso8601date)) } if !opts.End.IsZero() { r.addParameter("end", opts.End.Format(iso8601date)) } if opts.Resolution != "" { r.addParameter("resolution", string(opts.Resolution)) } if opts.Duration != "" { r.addParameter("duration", opts.Duration) } } for _, e := range events { r.addParameter("event", e) } r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var res statsTotalResponse err := getResponseFromJSON(ctx, r, &res) if err != nil { return nil, err } else { return res.Stats, nil } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetStats", "(", "ctx", "context", ".", "Context", ",", "events", "[", "]", "string", ",", "opts", "*", "GetStatOptions", ")", "(", "[", "]", "Stats", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(...
// GetStats returns total stats for a given domain for the specified time period
[ "GetStats", "returns", "total", "stats", "for", "a", "given", "domain", "for", "the", "specified", "time", "period" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/stats.go#L89-L121
18,377
mailgun/mailgun-go
events.go
ListEvents
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator { req := newHTTPRequest(generateApiUrl(mg, eventsEndpoint)) if opts != nil { if opts.Limit > 0 { req.addParameter("limit", fmt.Sprintf("%d", opts.Limit)) } if opts.Compact { req.addParameter("pretty", "no") } if opts.ForceAscending { req.addParameter("ascending", "yes") } else if opts.ForceDescending { req.addParameter("ascending", "no") } if !opts.Begin.IsZero() { req.addParameter("begin", formatMailgunTime(opts.Begin)) } if !opts.End.IsZero() { req.addParameter("end", formatMailgunTime(opts.End)) } if opts.Filter != nil { for k, v := range opts.Filter { req.addParameter(k, v) } } } url, err := req.generateUrlWithParameters() return &EventIterator{ mg: mg, Response: events.Response{Paging: events.Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator { req := newHTTPRequest(generateApiUrl(mg, eventsEndpoint)) if opts != nil { if opts.Limit > 0 { req.addParameter("limit", fmt.Sprintf("%d", opts.Limit)) } if opts.Compact { req.addParameter("pretty", "no") } if opts.ForceAscending { req.addParameter("ascending", "yes") } else if opts.ForceDescending { req.addParameter("ascending", "no") } if !opts.Begin.IsZero() { req.addParameter("begin", formatMailgunTime(opts.Begin)) } if !opts.End.IsZero() { req.addParameter("end", formatMailgunTime(opts.End)) } if opts.Filter != nil { for k, v := range opts.Filter { req.addParameter(k, v) } } } url, err := req.generateUrlWithParameters() return &EventIterator{ mg: mg, Response: events.Response{Paging: events.Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListEvents", "(", "opts", "*", "ListEventOptions", ")", "*", "EventIterator", "{", "req", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "eventsEndpoint", ")", ")", "\n", "if", "opts", "!=", "nil...
// Create an new iterator to fetch a page of events from the events api
[ "Create", "an", "new", "iterator", "to", "fetch", "a", "page", "of", "events", "from", "the", "events", "api" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/events.go#L39-L71
18,378
mailgun/mailgun-go
recipients.go
UnmarshalText
func (r *Recipient) UnmarshalText(text []byte) error { s := string(text) if s[len(s)-1:] != ">" { *r = Recipient{Email: s} return nil } i := strings.Index(s, "<") // at least 1 char followed by a space if i < 2 { return fmt.Errorf("malformed recipient string '%s'", s) } *r = Recipient{ Name: strings.TrimSpace(s[:i]), Email: s[i+1 : len(s)-1], } return nil }
go
func (r *Recipient) UnmarshalText(text []byte) error { s := string(text) if s[len(s)-1:] != ">" { *r = Recipient{Email: s} return nil } i := strings.Index(s, "<") // at least 1 char followed by a space if i < 2 { return fmt.Errorf("malformed recipient string '%s'", s) } *r = Recipient{ Name: strings.TrimSpace(s[:i]), Email: s[i+1 : len(s)-1], } return nil }
[ "func", "(", "r", "*", "Recipient", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "error", "{", "s", ":=", "string", "(", "text", ")", "\n", "if", "s", "[", "len", "(", "s", ")", "-", "1", ":", "]", "!=", "\"", "\"", "{", "*", "...
// UnmarshalText satisfies TextUnmarshaler
[ "UnmarshalText", "satisfies", "TextUnmarshaler" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/recipients.go#L24-L42
18,379
mailgun/mailgun-go
bounces.go
GetBounce
func (mg *MailgunImpl) GetBounce(ctx context.Context, address string) (Bounce, error) { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var response Bounce err := getResponseFromJSON(ctx, r, &response) return response, err }
go
func (mg *MailgunImpl) GetBounce(ctx context.Context, address string) (Bounce, error) { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var response Bounce err := getResponseFromJSON(ctx, r, &response) return response, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetBounce", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "Bounce", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "bouncesEndpoint", "...
// GetBounce retrieves a single bounce record, if any exist, for the given recipient address.
[ "GetBounce", "retrieves", "a", "single", "bounce", "record", "if", "any", "exist", "for", "the", "given", "recipient", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/bounces.go#L152-L160
18,380
mailgun/mailgun-go
bounces.go
DeleteBounce
func (mg *MailgunImpl) DeleteBounce(ctx context.Context, address string) error { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteBounce(ctx context.Context, address string) error { r := newHTTPRequest(generateApiUrl(mg, bouncesEndpoint) + "/" + address) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteBounce", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "bouncesEndpoint", ")", "+", "\"", "\"", "...
// DeleteBounce removes all bounces associted with the provided e-mail address.
[ "DeleteBounce", "removes", "all", "bounces", "associted", "with", "the", "provided", "e", "-", "mail", "address", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/bounces.go#L196-L202
18,381
mailgun/mailgun-go
template.go
CreateTemplate
func (mg *MailgunImpl) CreateTemplate(ctx context.Context, template *Template) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() if template.Name != "" { payload.addValue("name", template.Name) } if template.Description != "" { payload.addValue("description", template.Description) } if template.Version.Engine != "" { payload.addValue("engine", string(template.Version.Engine)) } if template.Version.Template != "" { payload.addValue("template", template.Version.Template) } if template.Version.Comment != "" { payload.addValue("comment", template.Version.Comment) } var resp templateResp if err := postResponseFromJSON(ctx, r, payload, &resp); err != nil { return err } *template = resp.Item return nil }
go
func (mg *MailgunImpl) CreateTemplate(ctx context.Context, template *Template) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() if template.Name != "" { payload.addValue("name", template.Name) } if template.Description != "" { payload.addValue("description", template.Description) } if template.Version.Engine != "" { payload.addValue("engine", string(template.Version.Engine)) } if template.Version.Template != "" { payload.addValue("template", template.Version.Template) } if template.Version.Comment != "" { payload.addValue("comment", template.Version.Comment) } var resp templateResp if err := postResponseFromJSON(ctx, r, payload, &resp); err != nil { return err } *template = resp.Item return nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateTemplate", "(", "ctx", "context", ".", "Context", ",", "template", "*", "Template", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", ")", "\n...
// Create a new template which can be used to attach template versions to
[ "Create", "a", "new", "template", "which", "can", "be", "used", "to", "attach", "template", "versions", "to" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L36-L66
18,382
mailgun/mailgun-go
template.go
GetTemplate
func (mg *MailgunImpl) GetTemplate(ctx context.Context, name string) (Template, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addParameter("active", "yes") var resp templateResp err := getResponseFromJSON(ctx, r, &resp) if err != nil { return Template{}, err } return resp.Item, nil }
go
func (mg *MailgunImpl) GetTemplate(ctx context.Context, name string) (Template, error) { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addParameter("active", "yes") var resp templateResp err := getResponseFromJSON(ctx, r, &resp) if err != nil { return Template{}, err } return resp.Item, nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetTemplate", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "Template", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ...
// GetTemplate gets a template given the template name
[ "GetTemplate", "gets", "a", "template", "given", "the", "template", "name" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L69-L81
18,383
mailgun/mailgun-go
template.go
UpdateTemplate
func (mg *MailgunImpl) UpdateTemplate(ctx context.Context, template *Template) error { if template.Name == "" { return errors.New("UpdateTemplate() Template.Name cannot be empty") } r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + template.Name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if template.Name != "" { p.addValue("name", template.Name) } if template.Description != "" { p.addValue("description", template.Description) } var resp templateResp err := putResponseFromJSON(ctx, r, p, &resp) if err != nil { return err } *template = resp.Item return nil }
go
func (mg *MailgunImpl) UpdateTemplate(ctx context.Context, template *Template) error { if template.Name == "" { return errors.New("UpdateTemplate() Template.Name cannot be empty") } r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + template.Name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) p := newUrlEncodedPayload() if template.Name != "" { p.addValue("name", template.Name) } if template.Description != "" { p.addValue("description", template.Description) } var resp templateResp err := putResponseFromJSON(ctx, r, p, &resp) if err != nil { return err } *template = resp.Item return nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "UpdateTemplate", "(", "ctx", "context", ".", "Context", ",", "template", "*", "Template", ")", "error", "{", "if", "template", ".", "Name", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", ...
// Update the name and description of a template
[ "Update", "the", "name", "and", "description", "of", "a", "template" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L84-L108
18,384
mailgun/mailgun-go
template.go
DeleteTemplate
func (mg *MailgunImpl) DeleteTemplate(ctx context.Context, name string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
go
func (mg *MailgunImpl) DeleteTemplate(ctx context.Context, name string) error { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint) + "/" + name) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) _, err := makeDeleteRequest(ctx, r) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "DeleteTemplate", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", "+", "\"", "\"", ...
// Delete a template given a template name
[ "Delete", "a", "template", "given", "a", "template", "name" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L111-L117
18,385
mailgun/mailgun-go
template.go
ListTemplates
func (mg *MailgunImpl) ListTemplates(opts *ListTemplateOptions) *TemplatesIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } if opts.Active { r.addParameter("active", "yes") } } url, err := r.generateUrlWithParameters() return &TemplatesIterator{ mg: mg, templateListResp: templateListResp{Paging: Paging{Next: url, First: url}}, err: err, } }
go
func (mg *MailgunImpl) ListTemplates(opts *ListTemplateOptions) *TemplatesIterator { r := newHTTPRequest(generateApiUrl(mg, templatesEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) if opts != nil { if opts.Limit != 0 { r.addParameter("limit", strconv.Itoa(opts.Limit)) } if opts.Active { r.addParameter("active", "yes") } } url, err := r.generateUrlWithParameters() return &TemplatesIterator{ mg: mg, templateListResp: templateListResp{Paging: Paging{Next: url, First: url}}, err: err, } }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListTemplates", "(", "opts", "*", "ListTemplateOptions", ")", "*", "TemplatesIterator", "{", "r", ":=", "newHTTPRequest", "(", "generateApiUrl", "(", "mg", ",", "templatesEndpoint", ")", ")", "\n", "r", ".", "setC...
// List all available templates
[ "List", "all", "available", "templates" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/template.go#L131-L149
18,386
mailgun/mailgun-go
exports.go
CreateExport
func (mg *MailgunImpl) CreateExport(ctx context.Context, url string) error { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("url", url) _, err := makePostRequest(ctx, r, payload) return err }
go
func (mg *MailgunImpl) CreateExport(ctx context.Context, url string) error { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) payload := newUrlEncodedPayload() payload.addValue("url", url) _, err := makePostRequest(ctx, r, payload) return err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "CreateExport", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "error", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint", ")", ")", "\n", "r", ...
// Create an export based on the URL given
[ "Create", "an", "export", "based", "on", "the", "URL", "given" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L21-L30
18,387
mailgun/mailgun-go
exports.go
ListExports
func (mg *MailgunImpl) ListExports(ctx context.Context, url string) ([]Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) if url != "" { r.addParameter("url", url) } r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ExportList if err := getResponseFromJSON(ctx, r, &resp); err != nil { return nil, err } var result []Export for _, item := range resp.Items { result = append(result, Export(item)) } return result, nil }
go
func (mg *MailgunImpl) ListExports(ctx context.Context, url string) ([]Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint)) r.setClient(mg.Client()) if url != "" { r.addParameter("url", url) } r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp ExportList if err := getResponseFromJSON(ctx, r, &resp); err != nil { return nil, err } var result []Export for _, item := range resp.Items { result = append(result, Export(item)) } return result, nil }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "ListExports", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "[", "]", "Export", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exp...
// List all exports created within the past 24 hours
[ "List", "all", "exports", "created", "within", "the", "past", "24", "hours" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L33-L51
18,388
mailgun/mailgun-go
exports.go
GetExport
func (mg *MailgunImpl) GetExport(ctx context.Context, id string) (Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp Export err := getResponseFromJSON(ctx, r, &resp) return resp, err }
go
func (mg *MailgunImpl) GetExport(ctx context.Context, id string) (Export, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id) r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) var resp Export err := getResponseFromJSON(ctx, r, &resp) return resp, err }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetExport", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "Export", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint", ...
// GetExport gets an export by id
[ "GetExport", "gets", "an", "export", "by", "id" ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L54-L61
18,389
mailgun/mailgun-go
exports.go
GetExportLink
func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id + "/download_url") c := mg.Client() // Ensure the client doesn't attempt to retry c.CheckRedirect = func(req *http.Request, via []*http.Request) error { return errors.New("redirect") } r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("User-Agent", MailgunGoUserAgent) req, err := r.NewRequest(ctx, "GET", nil) if err != nil { return "", err } if Debug { fmt.Println(r.curlString(req, nil)) } resp, err := r.Client.Do(req) if err != nil { if resp != nil && resp.StatusCode == http.StatusFound { url, err := resp.Location() if err != nil { return "", fmt.Errorf("while parsing 302 redirect url: %s", err) } return url.String(), nil } return "", err } return "", fmt.Errorf("expected a 302 response, API returned a '%d' instead", resp.StatusCode) }
go
func (mg *MailgunImpl) GetExportLink(ctx context.Context, id string) (string, error) { r := newHTTPRequest(generatePublicApiUrl(mg, exportsEndpoint) + "/" + id + "/download_url") c := mg.Client() // Ensure the client doesn't attempt to retry c.CheckRedirect = func(req *http.Request, via []*http.Request) error { return errors.New("redirect") } r.setClient(mg.Client()) r.setBasicAuth(basicAuthUser, mg.APIKey()) r.addHeader("User-Agent", MailgunGoUserAgent) req, err := r.NewRequest(ctx, "GET", nil) if err != nil { return "", err } if Debug { fmt.Println(r.curlString(req, nil)) } resp, err := r.Client.Do(req) if err != nil { if resp != nil && resp.StatusCode == http.StatusFound { url, err := resp.Location() if err != nil { return "", fmt.Errorf("while parsing 302 redirect url: %s", err) } return url.String(), nil } return "", err } return "", fmt.Errorf("expected a 302 response, API returned a '%d' instead", resp.StatusCode) }
[ "func", "(", "mg", "*", "MailgunImpl", ")", "GetExportLink", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "string", ",", "error", ")", "{", "r", ":=", "newHTTPRequest", "(", "generatePublicApiUrl", "(", "mg", ",", "exportsEndpoint"...
// Download an export by ID. This will respond with a '302 Moved' // with the Location header of temporary S3 URL if it is available.
[ "Download", "an", "export", "by", "ID", ".", "This", "will", "respond", "with", "a", "302", "Moved", "with", "the", "Location", "header", "of", "temporary", "S3", "URL", "if", "it", "is", "available", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/exports.go#L65-L99
18,390
mailgun/mailgun-go
messages.go
AddReaderAttachment
func (m *Message) AddReaderAttachment(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerAttachments = append(m.readerAttachments, ra) }
go
func (m *Message) AddReaderAttachment(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerAttachments = append(m.readerAttachments, ra) }
[ "func", "(", "m", "*", "Message", ")", "AddReaderAttachment", "(", "filename", "string", ",", "readCloser", "io", ".", "ReadCloser", ")", "{", "ra", ":=", "ReaderAttachment", "{", "Filename", ":", "filename", ",", "ReadCloser", ":", "readCloser", "}", "\n", ...
// AddReaderAttachment arranges to send a file along with the e-mail message. // File contents are read from a io.ReadCloser. // The filename parameter is the resulting filename of the attachment. // The readCloser parameter is the io.ReadCloser which reads the actual bytes to be used // as the contents of the attached file.
[ "AddReaderAttachment", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", ".", "File", "contents", "are", "read", "from", "a", "io", ".", "ReadCloser", ".", "The", "filename", "parameter", "is", "the", "resulting", ...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L208-L211
18,391
mailgun/mailgun-go
messages.go
AddAttachment
func (m *Message) AddAttachment(attachment string) { m.attachments = append(m.attachments, attachment) }
go
func (m *Message) AddAttachment(attachment string) { m.attachments = append(m.attachments, attachment) }
[ "func", "(", "m", "*", "Message", ")", "AddAttachment", "(", "attachment", "string", ")", "{", "m", ".", "attachments", "=", "append", "(", "m", ".", "attachments", ",", "attachment", ")", "\n", "}" ]
// AddAttachment arranges to send a file from the filesystem along with the e-mail message. // The attachment parameter is a filename, which must refer to a file which actually resides // in the local filesystem.
[ "AddAttachment", "arranges", "to", "send", "a", "file", "from", "the", "filesystem", "along", "with", "the", "e", "-", "mail", "message", ".", "The", "attachment", "parameter", "is", "a", "filename", "which", "must", "refer", "to", "a", "file", "which", "a...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L226-L228
18,392
mailgun/mailgun-go
messages.go
AddReaderInline
func (m *Message) AddReaderInline(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerInlines = append(m.readerInlines, ra) }
go
func (m *Message) AddReaderInline(filename string, readCloser io.ReadCloser) { ra := ReaderAttachment{Filename: filename, ReadCloser: readCloser} m.readerInlines = append(m.readerInlines, ra) }
[ "func", "(", "m", "*", "Message", ")", "AddReaderInline", "(", "filename", "string", ",", "readCloser", "io", ".", "ReadCloser", ")", "{", "ra", ":=", "ReaderAttachment", "{", "Filename", ":", "filename", ",", "ReadCloser", ":", "readCloser", "}", "\n", "m...
// AddReaderInline arranges to send a file along with the e-mail message. // File contents are read from a io.ReadCloser. // The filename parameter is the resulting filename of the attachment. // The readCloser parameter is the io.ReadCloser which reads the actual bytes to be used // as the contents of the attached file.
[ "AddReaderInline", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", ".", "File", "contents", "are", "read", "from", "a", "io", ".", "ReadCloser", ".", "The", "filename", "parameter", "is", "the", "resulting", "fil...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L235-L238
18,393
mailgun/mailgun-go
messages.go
AddInline
func (m *Message) AddInline(inline string) { m.inlines = append(m.inlines, inline) }
go
func (m *Message) AddInline(inline string) { m.inlines = append(m.inlines, inline) }
[ "func", "(", "m", "*", "Message", ")", "AddInline", "(", "inline", "string", ")", "{", "m", ".", "inlines", "=", "append", "(", "m", ".", "inlines", ",", "inline", ")", "\n", "}" ]
// AddInline arranges to send a file along with the e-mail message, but does so // in a way that its data remains "inline" with the rest of the message. This // can be used to send image or font data along with an HTML-encoded message body. // The attachment parameter is a filename, which must refer to a file which actually resides // in the local filesystem.
[ "AddInline", "arranges", "to", "send", "a", "file", "along", "with", "the", "e", "-", "mail", "message", "but", "does", "so", "in", "a", "way", "that", "its", "data", "remains", "inline", "with", "the", "rest", "of", "the", "message", ".", "This", "can...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L245-L247
18,394
mailgun/mailgun-go
messages.go
AddTag
func (m *Message) AddTag(tag ...string) error { if len(m.tags) >= MaxNumberOfTags { return fmt.Errorf("cannot add any new tags. Message tag limit (%b) reached", MaxNumberOfTags) } m.tags = append(m.tags, tag...) return nil }
go
func (m *Message) AddTag(tag ...string) error { if len(m.tags) >= MaxNumberOfTags { return fmt.Errorf("cannot add any new tags. Message tag limit (%b) reached", MaxNumberOfTags) } m.tags = append(m.tags, tag...) return nil }
[ "func", "(", "m", "*", "Message", ")", "AddTag", "(", "tag", "...", "string", ")", "error", "{", "if", "len", "(", "m", ".", "tags", ")", ">=", "MaxNumberOfTags", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "MaxNumberOfTags", ")", "\...
// AddTag attaches tags to the message. Tags are useful for metrics gathering and event tracking purposes. // Refer to the Mailgun documentation for further details.
[ "AddTag", "attaches", "tags", "to", "the", "message", ".", "Tags", "are", "useful", "for", "metrics", "gathering", "and", "event", "tracking", "purposes", ".", "Refer", "to", "the", "Mailgun", "documentation", "for", "further", "details", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L339-L346
18,395
mailgun/mailgun-go
messages.go
AddCampaign
func (m *Message) AddCampaign(campaign string) { m.campaigns = append(m.campaigns, campaign) }
go
func (m *Message) AddCampaign(campaign string) { m.campaigns = append(m.campaigns, campaign) }
[ "func", "(", "m", "*", "Message", ")", "AddCampaign", "(", "campaign", "string", ")", "{", "m", ".", "campaigns", "=", "append", "(", "m", ".", "campaigns", ",", "campaign", ")", "\n", "}" ]
// This feature is deprecated for new software.
[ "This", "feature", "is", "deprecated", "for", "new", "software", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L361-L363
18,396
mailgun/mailgun-go
messages.go
AddHeader
func (m *Message) AddHeader(header, value string) { if m.headers == nil { m.headers = make(map[string]string) } m.headers[header] = value }
go
func (m *Message) AddHeader(header, value string) { if m.headers == nil { m.headers = make(map[string]string) } m.headers[header] = value }
[ "func", "(", "m", "*", "Message", ")", "AddHeader", "(", "header", ",", "value", "string", ")", "{", "if", "m", ".", "headers", "==", "nil", "{", "m", ".", "headers", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", ...
// AddHeader allows you to send custom MIME headers with the message.
[ "AddHeader", "allows", "you", "to", "send", "custom", "MIME", "headers", "with", "the", "message", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L426-L431
18,397
mailgun/mailgun-go
messages.go
AddVariable
func (m *Message) AddVariable(variable string, value interface{}) error { if m.variables == nil { m.variables = make(map[string]string) } j, err := json.Marshal(value) if err != nil { return err } encoded := string(j) v, err := strconv.Unquote(encoded) if err != nil { v = encoded } m.variables[variable] = v return nil }
go
func (m *Message) AddVariable(variable string, value interface{}) error { if m.variables == nil { m.variables = make(map[string]string) } j, err := json.Marshal(value) if err != nil { return err } encoded := string(j) v, err := strconv.Unquote(encoded) if err != nil { v = encoded } m.variables[variable] = v return nil }
[ "func", "(", "m", "*", "Message", ")", "AddVariable", "(", "variable", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "if", "m", ".", "variables", "==", "nil", "{", "m", ".", "variables", "=", "make", "(", "map", "[", "string", "...
// AddVariable lets you associate a set of variables with messages you send, // which Mailgun can use to, in essence, complete form-mail. // Refer to the Mailgun documentation for more information.
[ "AddVariable", "lets", "you", "associate", "a", "set", "of", "variables", "with", "messages", "you", "send", "which", "Mailgun", "can", "use", "to", "in", "essence", "complete", "form", "-", "mail", ".", "Refer", "to", "the", "Mailgun", "documentation", "for...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L436-L454
18,398
mailgun/mailgun-go
messages.go
isValid
func isValid(m *Message) bool { if m == nil { return false } if !m.specific.isValid() { return false } if m.RecipientCount() == 0 { return false } if !validateStringList(m.tags, false) { return false } if !validateStringList(m.campaigns, false) || len(m.campaigns) > 3 { return false } return true }
go
func isValid(m *Message) bool { if m == nil { return false } if !m.specific.isValid() { return false } if m.RecipientCount() == 0 { return false } if !validateStringList(m.tags, false) { return false } if !validateStringList(m.campaigns, false) || len(m.campaigns) > 3 { return false } return true }
[ "func", "isValid", "(", "m", "*", "Message", ")", "bool", "{", "if", "m", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "m", ".", "specific", ".", "isValid", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "if", "m", "...
// isValid returns true if, and only if, // a Message instance is sufficiently initialized to send via the Mailgun interface.
[ "isValid", "returns", "true", "if", "and", "only", "if", "a", "Message", "instance", "is", "sufficiently", "initialized", "to", "send", "via", "the", "Mailgun", "interface", "." ]
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L636-L658
18,399
mailgun/mailgun-go
messages.go
validateStringList
func validateStringList(list []string, requireOne bool) bool { hasOne := false if list == nil { return !requireOne } else { for _, a := range list { if a == "" { return false } else { hasOne = hasOne || true } } } return hasOne }
go
func validateStringList(list []string, requireOne bool) bool { hasOne := false if list == nil { return !requireOne } else { for _, a := range list { if a == "" { return false } else { hasOne = hasOne || true } } } return hasOne }
[ "func", "validateStringList", "(", "list", "[", "]", "string", ",", "requireOne", "bool", ")", "bool", "{", "hasOne", ":=", "false", "\n\n", "if", "list", "==", "nil", "{", "return", "!", "requireOne", "\n", "}", "else", "{", "for", "_", ",", "a", ":...
// validateStringList returns true if, and only if, // a slice of strings exists AND all of its elements exist, // OR if the slice doesn't exist AND it's not required to exist. // The requireOne parameter indicates whether the list is required to exist.
[ "validateStringList", "returns", "true", "if", "and", "only", "if", "a", "slice", "of", "strings", "exists", "AND", "all", "of", "its", "elements", "exist", "OR", "if", "the", "slice", "doesn", "t", "exist", "AND", "it", "s", "not", "required", "to", "ex...
df421608b66e7dd4c03112d5bb01525c51f344a2
https://github.com/mailgun/mailgun-go/blob/df421608b66e7dd4c03112d5bb01525c51f344a2/messages.go#L693-L709