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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,300 | tendermint/iavl | nodedb.go | cacheNode | func (ndb *nodeDB) cacheNode(node *Node) {
elem := ndb.nodeCacheQueue.PushBack(node)
ndb.nodeCache[string(node.hash)] = elem
if ndb.nodeCacheQueue.Len() > ndb.nodeCacheSize {
oldest := ndb.nodeCacheQueue.Front()
hash := ndb.nodeCacheQueue.Remove(oldest).(*Node).hash
delete(ndb.nodeCache, string(hash))
}
} | go | func (ndb *nodeDB) cacheNode(node *Node) {
elem := ndb.nodeCacheQueue.PushBack(node)
ndb.nodeCache[string(node.hash)] = elem
if ndb.nodeCacheQueue.Len() > ndb.nodeCacheSize {
oldest := ndb.nodeCacheQueue.Front()
hash := ndb.nodeCacheQueue.Remove(oldest).(*Node).hash
delete(ndb.nodeCache, string(hash))
}
} | [
"func",
"(",
"ndb",
"*",
"nodeDB",
")",
"cacheNode",
"(",
"node",
"*",
"Node",
")",
"{",
"elem",
":=",
"ndb",
".",
"nodeCacheQueue",
".",
"PushBack",
"(",
"node",
")",
"\n",
"ndb",
".",
"nodeCache",
"[",
"string",
"(",
"node",
".",
"hash",
")",
"]",
"=",
"elem",
"\n\n",
"if",
"ndb",
".",
"nodeCacheQueue",
".",
"Len",
"(",
")",
">",
"ndb",
".",
"nodeCacheSize",
"{",
"oldest",
":=",
"ndb",
".",
"nodeCacheQueue",
".",
"Front",
"(",
")",
"\n",
"hash",
":=",
"ndb",
".",
"nodeCacheQueue",
".",
"Remove",
"(",
"oldest",
")",
".",
"(",
"*",
"Node",
")",
".",
"hash",
"\n",
"delete",
"(",
"ndb",
".",
"nodeCache",
",",
"string",
"(",
"hash",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Add a node to the cache and pop the least recently used node if we've
// reached the cache size limit. | [
"Add",
"a",
"node",
"to",
"the",
"cache",
"and",
"pop",
"the",
"least",
"recently",
"used",
"node",
"if",
"we",
"ve",
"reached",
"the",
"cache",
"size",
"limit",
"."
] | a0c58a289b0cdceb468b1e1246b6dc09ba4311eb | https://github.com/tendermint/iavl/blob/a0c58a289b0cdceb468b1e1246b6dc09ba4311eb/nodedb.go#L316-L325 |
6,301 | tendermint/iavl | nodedb.go | Commit | func (ndb *nodeDB) Commit() {
ndb.mtx.Lock()
defer ndb.mtx.Unlock()
ndb.batch.Write()
ndb.batch.Close()
ndb.batch = ndb.db.NewBatch()
} | go | func (ndb *nodeDB) Commit() {
ndb.mtx.Lock()
defer ndb.mtx.Unlock()
ndb.batch.Write()
ndb.batch.Close()
ndb.batch = ndb.db.NewBatch()
} | [
"func",
"(",
"ndb",
"*",
"nodeDB",
")",
"Commit",
"(",
")",
"{",
"ndb",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ndb",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"ndb",
".",
"batch",
".",
"Write",
"(",
")",
"\n",
"ndb",
".",
"batch",
".",
"Close",
"(",
")",
"\n",
"ndb",
".",
"batch",
"=",
"ndb",
".",
"db",
".",
"NewBatch",
"(",
")",
"\n",
"}"
] | // Write to disk. | [
"Write",
"to",
"disk",
"."
] | a0c58a289b0cdceb468b1e1246b6dc09ba4311eb | https://github.com/tendermint/iavl/blob/a0c58a289b0cdceb468b1e1246b6dc09ba4311eb/nodedb.go#L328-L335 |
6,302 | tendermint/iavl | nodedb.go | SaveRoot | func (ndb *nodeDB) SaveRoot(root *Node, version int64) error {
if len(root.hash) == 0 {
panic("Hash should not be empty")
}
return ndb.saveRoot(root.hash, version)
} | go | func (ndb *nodeDB) SaveRoot(root *Node, version int64) error {
if len(root.hash) == 0 {
panic("Hash should not be empty")
}
return ndb.saveRoot(root.hash, version)
} | [
"func",
"(",
"ndb",
"*",
"nodeDB",
")",
"SaveRoot",
"(",
"root",
"*",
"Node",
",",
"version",
"int64",
")",
"error",
"{",
"if",
"len",
"(",
"root",
".",
"hash",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"ndb",
".",
"saveRoot",
"(",
"root",
".",
"hash",
",",
"version",
")",
"\n",
"}"
] | // SaveRoot creates an entry on disk for the given root, so that it can be
// loaded later. | [
"SaveRoot",
"creates",
"an",
"entry",
"on",
"disk",
"for",
"the",
"given",
"root",
"so",
"that",
"it",
"can",
"be",
"loaded",
"later",
"."
] | a0c58a289b0cdceb468b1e1246b6dc09ba4311eb | https://github.com/tendermint/iavl/blob/a0c58a289b0cdceb468b1e1246b6dc09ba4311eb/nodedb.go#L354-L359 |
6,303 | tendermint/iavl | nodedb.go | SaveEmptyRoot | func (ndb *nodeDB) SaveEmptyRoot(version int64) error {
return ndb.saveRoot([]byte{}, version)
} | go | func (ndb *nodeDB) SaveEmptyRoot(version int64) error {
return ndb.saveRoot([]byte{}, version)
} | [
"func",
"(",
"ndb",
"*",
"nodeDB",
")",
"SaveEmptyRoot",
"(",
"version",
"int64",
")",
"error",
"{",
"return",
"ndb",
".",
"saveRoot",
"(",
"[",
"]",
"byte",
"{",
"}",
",",
"version",
")",
"\n",
"}"
] | // SaveEmptyRoot creates an entry on disk for an empty root. | [
"SaveEmptyRoot",
"creates",
"an",
"entry",
"on",
"disk",
"for",
"an",
"empty",
"root",
"."
] | a0c58a289b0cdceb468b1e1246b6dc09ba4311eb | https://github.com/tendermint/iavl/blob/a0c58a289b0cdceb468b1e1246b6dc09ba4311eb/nodedb.go#L362-L364 |
6,304 | antchfx/htmlquery | query.go | Find | func Find(top *html.Node, expr string) []*html.Node {
exp, err := xpath.Compile(expr)
if err != nil {
panic(err)
}
var elems []*html.Node
t := exp.Select(CreateXPathNavigator(top))
for t.MoveNext() {
nav := t.Current().(*NodeNavigator)
n := getCurrentNode(nav)
// avoid adding duplicate nodes.
if len(elems) > 0 && (elems[0] == n || (nav.NodeType() == xpath.AttributeNode &&
nav.LocalName() == elems[0].Data && nav.Value() == InnerText(elems[0]))) {
continue
}
elems = append(elems, n)
}
return elems
} | go | func Find(top *html.Node, expr string) []*html.Node {
exp, err := xpath.Compile(expr)
if err != nil {
panic(err)
}
var elems []*html.Node
t := exp.Select(CreateXPathNavigator(top))
for t.MoveNext() {
nav := t.Current().(*NodeNavigator)
n := getCurrentNode(nav)
// avoid adding duplicate nodes.
if len(elems) > 0 && (elems[0] == n || (nav.NodeType() == xpath.AttributeNode &&
nav.LocalName() == elems[0].Data && nav.Value() == InnerText(elems[0]))) {
continue
}
elems = append(elems, n)
}
return elems
} | [
"func",
"Find",
"(",
"top",
"*",
"html",
".",
"Node",
",",
"expr",
"string",
")",
"[",
"]",
"*",
"html",
".",
"Node",
"{",
"exp",
",",
"err",
":=",
"xpath",
".",
"Compile",
"(",
"expr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"var",
"elems",
"[",
"]",
"*",
"html",
".",
"Node",
"\n",
"t",
":=",
"exp",
".",
"Select",
"(",
"CreateXPathNavigator",
"(",
"top",
")",
")",
"\n",
"for",
"t",
".",
"MoveNext",
"(",
")",
"{",
"nav",
":=",
"t",
".",
"Current",
"(",
")",
".",
"(",
"*",
"NodeNavigator",
")",
"\n",
"n",
":=",
"getCurrentNode",
"(",
"nav",
")",
"\n",
"// avoid adding duplicate nodes.",
"if",
"len",
"(",
"elems",
")",
">",
"0",
"&&",
"(",
"elems",
"[",
"0",
"]",
"==",
"n",
"||",
"(",
"nav",
".",
"NodeType",
"(",
")",
"==",
"xpath",
".",
"AttributeNode",
"&&",
"nav",
".",
"LocalName",
"(",
")",
"==",
"elems",
"[",
"0",
"]",
".",
"Data",
"&&",
"nav",
".",
"Value",
"(",
")",
"==",
"InnerText",
"(",
"elems",
"[",
"0",
"]",
")",
")",
")",
"{",
"continue",
"\n",
"}",
"\n",
"elems",
"=",
"append",
"(",
"elems",
",",
"n",
")",
"\n",
"}",
"\n",
"return",
"elems",
"\n",
"}"
] | // Find searches the html.Node that matches by the specified XPath expr. | [
"Find",
"searches",
"the",
"html",
".",
"Node",
"that",
"matches",
"by",
"the",
"specified",
"XPath",
"expr",
"."
] | b8d36292614567671decfe6f96c7b8c432d3249b | https://github.com/antchfx/htmlquery/blob/b8d36292614567671decfe6f96c7b8c432d3249b/query.go#L25-L43 |
6,305 | antchfx/htmlquery | query.go | LoadURL | func LoadURL(url string) (*html.Node, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
r, err := charset.NewReader(resp.Body, resp.Header.Get("Content-Type"))
if err != nil {
return nil, err
}
return html.Parse(r)
} | go | func LoadURL(url string) (*html.Node, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
r, err := charset.NewReader(resp.Body, resp.Header.Get("Content-Type"))
if err != nil {
return nil, err
}
return html.Parse(r)
} | [
"func",
"LoadURL",
"(",
"url",
"string",
")",
"(",
"*",
"html",
".",
"Node",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"http",
".",
"Get",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"r",
",",
"err",
":=",
"charset",
".",
"NewReader",
"(",
"resp",
".",
"Body",
",",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"html",
".",
"Parse",
"(",
"r",
")",
"\n",
"}"
] | // LoadURL loads the HTML document from the specified URL. | [
"LoadURL",
"loads",
"the",
"HTML",
"document",
"from",
"the",
"specified",
"URL",
"."
] | b8d36292614567671decfe6f96c7b8c432d3249b | https://github.com/antchfx/htmlquery/blob/b8d36292614567671decfe6f96c7b8c432d3249b/query.go#L61-L73 |
6,306 | antchfx/htmlquery | query.go | Parse | func Parse(r io.Reader) (*html.Node, error) {
return html.Parse(r)
} | go | func Parse(r io.Reader) (*html.Node, error) {
return html.Parse(r)
} | [
"func",
"Parse",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"html",
".",
"Node",
",",
"error",
")",
"{",
"return",
"html",
".",
"Parse",
"(",
"r",
")",
"\n",
"}"
] | // Parse returns the parse tree for the HTML from the given Reader. | [
"Parse",
"returns",
"the",
"parse",
"tree",
"for",
"the",
"HTML",
"from",
"the",
"given",
"Reader",
"."
] | b8d36292614567671decfe6f96c7b8c432d3249b | https://github.com/antchfx/htmlquery/blob/b8d36292614567671decfe6f96c7b8c432d3249b/query.go#L93-L95 |
6,307 | antchfx/htmlquery | query.go | InnerText | func InnerText(n *html.Node) string {
var output func(*bytes.Buffer, *html.Node)
output = func(buf *bytes.Buffer, n *html.Node) {
switch n.Type {
case html.TextNode:
buf.WriteString(n.Data)
return
case html.CommentNode:
return
}
for child := n.FirstChild; child != nil; child = child.NextSibling {
output(buf, child)
}
}
var buf bytes.Buffer
output(&buf, n)
return buf.String()
} | go | func InnerText(n *html.Node) string {
var output func(*bytes.Buffer, *html.Node)
output = func(buf *bytes.Buffer, n *html.Node) {
switch n.Type {
case html.TextNode:
buf.WriteString(n.Data)
return
case html.CommentNode:
return
}
for child := n.FirstChild; child != nil; child = child.NextSibling {
output(buf, child)
}
}
var buf bytes.Buffer
output(&buf, n)
return buf.String()
} | [
"func",
"InnerText",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"string",
"{",
"var",
"output",
"func",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"*",
"html",
".",
"Node",
")",
"\n",
"output",
"=",
"func",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
",",
"n",
"*",
"html",
".",
"Node",
")",
"{",
"switch",
"n",
".",
"Type",
"{",
"case",
"html",
".",
"TextNode",
":",
"buf",
".",
"WriteString",
"(",
"n",
".",
"Data",
")",
"\n",
"return",
"\n",
"case",
"html",
".",
"CommentNode",
":",
"return",
"\n",
"}",
"\n",
"for",
"child",
":=",
"n",
".",
"FirstChild",
";",
"child",
"!=",
"nil",
";",
"child",
"=",
"child",
".",
"NextSibling",
"{",
"output",
"(",
"buf",
",",
"child",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"output",
"(",
"&",
"buf",
",",
"n",
")",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] | // InnerText returns the text between the start and end tags of the object. | [
"InnerText",
"returns",
"the",
"text",
"between",
"the",
"start",
"and",
"end",
"tags",
"of",
"the",
"object",
"."
] | b8d36292614567671decfe6f96c7b8c432d3249b | https://github.com/antchfx/htmlquery/blob/b8d36292614567671decfe6f96c7b8c432d3249b/query.go#L98-L116 |
6,308 | antchfx/htmlquery | query.go | OutputHTML | func OutputHTML(n *html.Node, self bool) string {
var buf bytes.Buffer
if self {
html.Render(&buf, n)
} else {
for n := n.FirstChild; n != nil; n = n.NextSibling {
html.Render(&buf, n)
}
}
return buf.String()
} | go | func OutputHTML(n *html.Node, self bool) string {
var buf bytes.Buffer
if self {
html.Render(&buf, n)
} else {
for n := n.FirstChild; n != nil; n = n.NextSibling {
html.Render(&buf, n)
}
}
return buf.String()
} | [
"func",
"OutputHTML",
"(",
"n",
"*",
"html",
".",
"Node",
",",
"self",
"bool",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"self",
"{",
"html",
".",
"Render",
"(",
"&",
"buf",
",",
"n",
")",
"\n",
"}",
"else",
"{",
"for",
"n",
":=",
"n",
".",
"FirstChild",
";",
"n",
"!=",
"nil",
";",
"n",
"=",
"n",
".",
"NextSibling",
"{",
"html",
".",
"Render",
"(",
"&",
"buf",
",",
"n",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] | // OutputHTML returns the text including tags name. | [
"OutputHTML",
"returns",
"the",
"text",
"including",
"tags",
"name",
"."
] | b8d36292614567671decfe6f96c7b8c432d3249b | https://github.com/antchfx/htmlquery/blob/b8d36292614567671decfe6f96c7b8c432d3249b/query.go#L136-L146 |
6,309 | adlio/trello | organization.go | GetOrganization | func (c *Client) GetOrganization(orgID string, args Arguments) (organization *Organization, err error) {
path := fmt.Sprintf("organizations/%s", orgID)
err = c.Get(path, args, &organization)
if organization != nil {
organization.client = c
}
return
} | go | func (c *Client) GetOrganization(orgID string, args Arguments) (organization *Organization, err error) {
path := fmt.Sprintf("organizations/%s", orgID)
err = c.Get(path, args, &organization)
if organization != nil {
organization.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetOrganization",
"(",
"orgID",
"string",
",",
"args",
"Arguments",
")",
"(",
"organization",
"*",
"Organization",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"orgID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"organization",
")",
"\n",
"if",
"organization",
"!=",
"nil",
"{",
"organization",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetOrganization takes an organization id and Arguments and either
// GETs returns an Organization, or an error. | [
"GetOrganization",
"takes",
"an",
"organization",
"id",
"and",
"Arguments",
"and",
"either",
"GETs",
"returns",
"an",
"Organization",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/organization.go#L28-L35 |
6,310 | adlio/trello | token.go | GetToken | func (c *Client) GetToken(tokenID string, args Arguments) (token *Token, err error) {
path := fmt.Sprintf("tokens/%s", tokenID)
err = c.Get(path, args, &token)
if token != nil {
token.client = c
}
return
} | go | func (c *Client) GetToken(tokenID string, args Arguments) (token *Token, err error) {
path := fmt.Sprintf("tokens/%s", tokenID)
err = c.Get(path, args, &token)
if token != nil {
token.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetToken",
"(",
"tokenID",
"string",
",",
"args",
"Arguments",
")",
"(",
"token",
"*",
"Token",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"tokenID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"token",
")",
"\n",
"if",
"token",
"!=",
"nil",
"{",
"token",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetToken takes a token id and Arguments and GETs and returns the Token or an error. | [
"GetToken",
"takes",
"a",
"token",
"id",
"and",
"Arguments",
"and",
"GETs",
"and",
"returns",
"the",
"Token",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/token.go#L34-L41 |
6,311 | adlio/trello | action-collection.go | FirstCardCreateAction | func (c ActionCollection) FirstCardCreateAction() *Action {
sort.Sort(c)
for _, action := range c {
if action.DidCreateCard() {
return action
}
}
return nil
} | go | func (c ActionCollection) FirstCardCreateAction() *Action {
sort.Sort(c)
for _, action := range c {
if action.DidCreateCard() {
return action
}
}
return nil
} | [
"func",
"(",
"c",
"ActionCollection",
")",
"FirstCardCreateAction",
"(",
")",
"*",
"Action",
"{",
"sort",
".",
"Sort",
"(",
"c",
")",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"c",
"{",
"if",
"action",
".",
"DidCreateCard",
"(",
")",
"{",
"return",
"action",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // FirstCardCreateAction returns first card-create action | [
"FirstCardCreateAction",
"returns",
"first",
"card",
"-",
"create",
"action"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action-collection.go#L16-L24 |
6,312 | adlio/trello | action-collection.go | FilterToCardCreationActions | func (c ActionCollection) FilterToCardCreationActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidCreateCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | go | func (c ActionCollection) FilterToCardCreationActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidCreateCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | [
"func",
"(",
"c",
"ActionCollection",
")",
"FilterToCardCreationActions",
"(",
")",
"ActionCollection",
"{",
"newSlice",
":=",
"make",
"(",
"ActionCollection",
",",
"0",
",",
"len",
"(",
"c",
")",
")",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"c",
"{",
"if",
"action",
".",
"DidCreateCard",
"(",
")",
"{",
"newSlice",
"=",
"append",
"(",
"newSlice",
",",
"action",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"newSlice",
"\n",
"}"
] | // FilterToCardCreationActions returns this collection's card-create actions | [
"FilterToCardCreationActions",
"returns",
"this",
"collection",
"s",
"card",
"-",
"create",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action-collection.go#L32-L40 |
6,313 | adlio/trello | action-collection.go | FilterToListChangeActions | func (c ActionCollection) FilterToListChangeActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidChangeListForCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | go | func (c ActionCollection) FilterToListChangeActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidChangeListForCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | [
"func",
"(",
"c",
"ActionCollection",
")",
"FilterToListChangeActions",
"(",
")",
"ActionCollection",
"{",
"newSlice",
":=",
"make",
"(",
"ActionCollection",
",",
"0",
",",
"len",
"(",
"c",
")",
")",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"c",
"{",
"if",
"action",
".",
"DidChangeListForCard",
"(",
")",
"{",
"newSlice",
"=",
"append",
"(",
"newSlice",
",",
"action",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"newSlice",
"\n",
"}"
] | // FilterToListChangeActions returns card-change-list actions | [
"FilterToListChangeActions",
"returns",
"card",
"-",
"change",
"-",
"list",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action-collection.go#L43-L51 |
6,314 | adlio/trello | action-collection.go | FilterToCardMembershipChangeActions | func (c ActionCollection) FilterToCardMembershipChangeActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidChangeCardMembership() || action.DidArchiveCard() || action.DidUnarchiveCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | go | func (c ActionCollection) FilterToCardMembershipChangeActions() ActionCollection {
newSlice := make(ActionCollection, 0, len(c))
for _, action := range c {
if action.DidChangeCardMembership() || action.DidArchiveCard() || action.DidUnarchiveCard() {
newSlice = append(newSlice, action)
}
}
return newSlice
} | [
"func",
"(",
"c",
"ActionCollection",
")",
"FilterToCardMembershipChangeActions",
"(",
")",
"ActionCollection",
"{",
"newSlice",
":=",
"make",
"(",
"ActionCollection",
",",
"0",
",",
"len",
"(",
"c",
")",
")",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"c",
"{",
"if",
"action",
".",
"DidChangeCardMembership",
"(",
")",
"||",
"action",
".",
"DidArchiveCard",
"(",
")",
"||",
"action",
".",
"DidUnarchiveCard",
"(",
")",
"{",
"newSlice",
"=",
"append",
"(",
"newSlice",
",",
"action",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"newSlice",
"\n",
"}"
] | // FilterToCardMembershipChangeActions returns the collection's card-change, archive and unarchive actions | [
"FilterToCardMembershipChangeActions",
"returns",
"the",
"collection",
"s",
"card",
"-",
"change",
"archive",
"and",
"unarchive",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action-collection.go#L54-L62 |
6,315 | adlio/trello | member.go | GetMember | func (c *Client) GetMember(memberID string, args Arguments) (member *Member, err error) {
path := fmt.Sprintf("members/%s", memberID)
err = c.Get(path, args, &member)
if err == nil {
member.client = c
}
return
} | go | func (c *Client) GetMember(memberID string, args Arguments) (member *Member, err error) {
path := fmt.Sprintf("members/%s", memberID)
err = c.Get(path, args, &member)
if err == nil {
member.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMember",
"(",
"memberID",
"string",
",",
"args",
"Arguments",
")",
"(",
"member",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"memberID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"member",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"member",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMember takes a member id and Arguments and returns a Member or an error. | [
"GetMember",
"takes",
"a",
"member",
"id",
"and",
"Arguments",
"and",
"returns",
"a",
"Member",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/member.go#L25-L32 |
6,316 | adlio/trello | member.go | GetMembers | func (o *Organization) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("organizations/%s/members", o.ID)
err = o.client.Get(path, args, &members)
for i := range members {
members[i].client = o.client
}
return
} | go | func (o *Organization) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("organizations/%s/members", o.ID)
err = o.client.Get(path, args, &members)
for i := range members {
members[i].client = o.client
}
return
} | [
"func",
"(",
"o",
"*",
"Organization",
")",
"GetMembers",
"(",
"args",
"Arguments",
")",
"(",
"members",
"[",
"]",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"o",
".",
"ID",
")",
"\n",
"err",
"=",
"o",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"members",
")",
"\n",
"for",
"i",
":=",
"range",
"members",
"{",
"members",
"[",
"i",
"]",
".",
"client",
"=",
"o",
".",
"client",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMembers takes Arguments and returns a slice of all members of the organization or an error. | [
"GetMembers",
"takes",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"all",
"members",
"of",
"the",
"organization",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/member.go#L35-L42 |
6,317 | adlio/trello | member.go | GetMembers | func (b *Board) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("boards/%s/members", b.ID)
err = b.client.Get(path, args, &members)
for i := range members {
members[i].client = b.client
}
return
} | go | func (b *Board) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("boards/%s/members", b.ID)
err = b.client.Get(path, args, &members)
for i := range members {
members[i].client = b.client
}
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetMembers",
"(",
"args",
"Arguments",
")",
"(",
"members",
"[",
"]",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"members",
")",
"\n",
"for",
"i",
":=",
"range",
"members",
"{",
"members",
"[",
"i",
"]",
".",
"client",
"=",
"b",
".",
"client",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMembers takes Arguments and returns a slice of all members of the Board or an error. | [
"GetMembers",
"takes",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"all",
"members",
"of",
"the",
"Board",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/member.go#L45-L52 |
6,318 | adlio/trello | member.go | GetMembers | func (c *Card) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("cards/%s/members", c.ID)
err = c.client.Get(path, args, &members)
for i := range members {
members[i].client = c.client
}
return
} | go | func (c *Card) GetMembers(args Arguments) (members []*Member, err error) {
path := fmt.Sprintf("cards/%s/members", c.ID)
err = c.client.Get(path, args, &members)
for i := range members {
members[i].client = c.client
}
return
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetMembers",
"(",
"args",
"Arguments",
")",
"(",
"members",
"[",
"]",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"err",
"=",
"c",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"members",
")",
"\n",
"for",
"i",
":=",
"range",
"members",
"{",
"members",
"[",
"i",
"]",
".",
"client",
"=",
"c",
".",
"client",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMembers takes Arguments and returns a slice of all members of the Card or an error. | [
"GetMembers",
"takes",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"all",
"members",
"of",
"the",
"Card",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/member.go#L55-L62 |
6,319 | adlio/trello | custom-fields.go | GetCustomField | func (c *Client) GetCustomField(fieldID string, args Arguments) (customField *CustomField, err error) {
path := fmt.Sprintf("customFields/%s", fieldID)
err = c.Get(path, args, &customField)
return
} | go | func (c *Client) GetCustomField(fieldID string, args Arguments) (customField *CustomField, err error) {
path := fmt.Sprintf("customFields/%s", fieldID)
err = c.Get(path, args, &customField)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetCustomField",
"(",
"fieldID",
"string",
",",
"args",
"Arguments",
")",
"(",
"customField",
"*",
"CustomField",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"fieldID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"customField",
")",
"\n",
"return",
"\n",
"}"
] | // GetCustomField takes a field id string and Arguments and returns the matching custom Field. | [
"GetCustomField",
"takes",
"a",
"field",
"id",
"string",
"and",
"Arguments",
"and",
"returns",
"the",
"matching",
"custom",
"Field",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/custom-fields.go#L43-L47 |
6,320 | adlio/trello | custom-fields.go | GetCustomFields | func (b *Board) GetCustomFields(args Arguments) (customFields []*CustomField, err error) {
path := fmt.Sprintf("boards/%s/customFields", b.ID)
err = b.client.Get(path, args, &customFields)
return
} | go | func (b *Board) GetCustomFields(args Arguments) (customFields []*CustomField, err error) {
path := fmt.Sprintf("boards/%s/customFields", b.ID)
err = b.client.Get(path, args, &customFields)
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetCustomFields",
"(",
"args",
"Arguments",
")",
"(",
"customFields",
"[",
"]",
"*",
"CustomField",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"customFields",
")",
"\n",
"return",
"\n",
"}"
] | // GetCustomFields returns a slice of all receiver board's custom fields. | [
"GetCustomFields",
"returns",
"a",
"slice",
"of",
"all",
"receiver",
"board",
"s",
"custom",
"fields",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/custom-fields.go#L50-L54 |
6,321 | adlio/trello | list-duration-sort.go | Less | func (durs ByFirstEntered) Less(i, j int) bool {
return durs[i].FirstEntered.Before(durs[j].FirstEntered)
} | go | func (durs ByFirstEntered) Less(i, j int) bool {
return durs[i].FirstEntered.Before(durs[j].FirstEntered)
} | [
"func",
"(",
"durs",
"ByFirstEntered",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"durs",
"[",
"i",
"]",
".",
"FirstEntered",
".",
"Before",
"(",
"durs",
"[",
"j",
"]",
".",
"FirstEntered",
")",
"\n",
"}"
] | // Less takes two indexes i and j and returns true exactly if the ListDuration
// at i was entered before j. | [
"Less",
"takes",
"two",
"indexes",
"i",
"and",
"j",
"and",
"returns",
"true",
"exactly",
"if",
"the",
"ListDuration",
"at",
"i",
"was",
"entered",
"before",
"j",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list-duration-sort.go#L11-L13 |
6,322 | adlio/trello | member-duration.go | GetMemberDurations | func (c *Card) GetMemberDurations() (durations []*MemberDuration, err error) {
var actions ActionCollection
if len(c.Actions) == 0 {
c.client.log("[trello] GetMemberDurations() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
actions, err = c.GetMembershipChangeActions()
if err != nil {
err = errors.Wrap(err, "GetMembershipChangeActions() call failed.")
return
}
} else {
actions = c.Actions.FilterToCardMembershipChangeActions()
}
return actions.GetMemberDurations()
} | go | func (c *Card) GetMemberDurations() (durations []*MemberDuration, err error) {
var actions ActionCollection
if len(c.Actions) == 0 {
c.client.log("[trello] GetMemberDurations() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
actions, err = c.GetMembershipChangeActions()
if err != nil {
err = errors.Wrap(err, "GetMembershipChangeActions() call failed.")
return
}
} else {
actions = c.Actions.FilterToCardMembershipChangeActions()
}
return actions.GetMemberDurations()
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetMemberDurations",
"(",
")",
"(",
"durations",
"[",
"]",
"*",
"MemberDuration",
",",
"err",
"error",
")",
"{",
"var",
"actions",
"ActionCollection",
"\n",
"if",
"len",
"(",
"c",
".",
"Actions",
")",
"==",
"0",
"{",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"actions",
",",
"err",
"=",
"c",
".",
"GetMembershipChangeActions",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"else",
"{",
"actions",
"=",
"c",
".",
"Actions",
".",
"FilterToCardMembershipChangeActions",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"actions",
".",
"GetMemberDurations",
"(",
")",
"\n",
"}"
] | // GetMemberDurations returns a slice containing all durations of a card. | [
"GetMemberDurations",
"returns",
"a",
"slice",
"containing",
"all",
"durations",
"of",
"a",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/member-duration.go#L58-L72 |
6,323 | adlio/trello | board.go | NewBoard | func NewBoard(name string) Board {
b := Board{Name: name}
// default values in line with API POST
b.Prefs.SelfJoin = true
b.Prefs.CardCovers = true
return b
} | go | func NewBoard(name string) Board {
b := Board{Name: name}
// default values in line with API POST
b.Prefs.SelfJoin = true
b.Prefs.CardCovers = true
return b
} | [
"func",
"NewBoard",
"(",
"name",
"string",
")",
"Board",
"{",
"b",
":=",
"Board",
"{",
"Name",
":",
"name",
"}",
"\n\n",
"// default values in line with API POST",
"b",
".",
"Prefs",
".",
"SelfJoin",
"=",
"true",
"\n",
"b",
".",
"Prefs",
".",
"CardCovers",
"=",
"true",
"\n\n",
"return",
"b",
"\n",
"}"
] | // NewBoard is a constructor that sets the default values
// for Prefs.SelfJoin and Prefs.CardCovers also set by the API. | [
"NewBoard",
"is",
"a",
"constructor",
"that",
"sets",
"the",
"default",
"values",
"for",
"Prefs",
".",
"SelfJoin",
"and",
"Prefs",
".",
"CardCovers",
"also",
"set",
"by",
"the",
"API",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L64-L72 |
6,324 | adlio/trello | board.go | CreatedAt | func (b *Board) CreatedAt() time.Time {
t, _ := IDToTime(b.ID)
return t
} | go | func (b *Board) CreatedAt() time.Time {
t, _ := IDToTime(b.ID)
return t
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"CreatedAt",
"(",
")",
"time",
".",
"Time",
"{",
"t",
",",
"_",
":=",
"IDToTime",
"(",
"b",
".",
"ID",
")",
"\n",
"return",
"t",
"\n",
"}"
] | // CreatedAt returns a board's created-at attribute as time.Time. | [
"CreatedAt",
"returns",
"a",
"board",
"s",
"created",
"-",
"at",
"attribute",
"as",
"time",
".",
"Time",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L82-L85 |
6,325 | adlio/trello | board.go | Delete | func (b *Board) Delete(extraArgs Arguments) error {
path := fmt.Sprintf("boards/%s", b.ID)
return b.client.Delete(path, Arguments{}, b)
} | go | func (b *Board) Delete(extraArgs Arguments) error {
path := fmt.Sprintf("boards/%s", b.ID)
return b.client.Delete(path, Arguments{}, b)
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"Delete",
"(",
"extraArgs",
"Arguments",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"return",
"b",
".",
"client",
".",
"Delete",
"(",
"path",
",",
"Arguments",
"{",
"}",
",",
"b",
")",
"\n",
"}"
] | // Delete makes a DELETE call for the receiver Board. | [
"Delete",
"makes",
"a",
"DELETE",
"call",
"for",
"the",
"receiver",
"Board",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L134-L137 |
6,326 | adlio/trello | board.go | GetBoard | func (c *Client) GetBoard(boardID string, args Arguments) (board *Board, err error) {
path := fmt.Sprintf("boards/%s", boardID)
err = c.Get(path, args, &board)
if board != nil {
board.client = c
}
return
} | go | func (c *Client) GetBoard(boardID string, args Arguments) (board *Board, err error) {
path := fmt.Sprintf("boards/%s", boardID)
err = c.Get(path, args, &board)
if board != nil {
board.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBoard",
"(",
"boardID",
"string",
",",
"args",
"Arguments",
")",
"(",
"board",
"*",
"Board",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"boardID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"board",
")",
"\n",
"if",
"board",
"!=",
"nil",
"{",
"board",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetBoard retrieves a Trello board by its ID. | [
"GetBoard",
"retrieves",
"a",
"Trello",
"board",
"by",
"its",
"ID",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L140-L147 |
6,327 | adlio/trello | board.go | GetMyBoards | func (c *Client) GetMyBoards(args Arguments) (boards []*Board, err error) {
path := "members/me/boards"
err = c.Get(path, args, &boards)
for i := range boards {
boards[i].client = c
}
return
} | go | func (c *Client) GetMyBoards(args Arguments) (boards []*Board, err error) {
path := "members/me/boards"
err = c.Get(path, args, &boards)
for i := range boards {
boards[i].client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMyBoards",
"(",
"args",
"Arguments",
")",
"(",
"boards",
"[",
"]",
"*",
"Board",
",",
"err",
"error",
")",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"boards",
")",
"\n",
"for",
"i",
":=",
"range",
"boards",
"{",
"boards",
"[",
"i",
"]",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMyBoards returns a slice of all boards associated with the credentials set on the client. | [
"GetMyBoards",
"returns",
"a",
"slice",
"of",
"all",
"boards",
"associated",
"with",
"the",
"credentials",
"set",
"on",
"the",
"client",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L150-L157 |
6,328 | adlio/trello | board.go | GetBoards | func (m *Member) GetBoards(args Arguments) (boards []*Board, err error) {
path := fmt.Sprintf("members/%s/boards", m.ID)
err = m.client.Get(path, args, &boards)
for i := range boards {
boards[i].client = m.client
}
return
} | go | func (m *Member) GetBoards(args Arguments) (boards []*Board, err error) {
path := fmt.Sprintf("members/%s/boards", m.ID)
err = m.client.Get(path, args, &boards)
for i := range boards {
boards[i].client = m.client
}
return
} | [
"func",
"(",
"m",
"*",
"Member",
")",
"GetBoards",
"(",
"args",
"Arguments",
")",
"(",
"boards",
"[",
"]",
"*",
"Board",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
".",
"ID",
")",
"\n",
"err",
"=",
"m",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"boards",
")",
"\n",
"for",
"i",
":=",
"range",
"boards",
"{",
"boards",
"[",
"i",
"]",
".",
"client",
"=",
"m",
".",
"client",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetBoards returns a slice of all public boards of the receiver Member. | [
"GetBoards",
"returns",
"a",
"slice",
"of",
"all",
"public",
"boards",
"of",
"the",
"receiver",
"Member",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/board.go#L160-L167 |
6,329 | adlio/trello | client.go | NewClient | func NewClient(key, token string) *Client {
return &Client{
Client: http.DefaultClient,
BaseURL: DefaultBaseURL,
Key: key,
Token: token,
throttle: time.Tick(time.Second / 8), // Actually 10/second, but we're extra cautious
testMode: false,
ctx: context.Background(),
}
} | go | func NewClient(key, token string) *Client {
return &Client{
Client: http.DefaultClient,
BaseURL: DefaultBaseURL,
Key: key,
Token: token,
throttle: time.Tick(time.Second / 8), // Actually 10/second, but we're extra cautious
testMode: false,
ctx: context.Background(),
}
} | [
"func",
"NewClient",
"(",
"key",
",",
"token",
"string",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"Client",
":",
"http",
".",
"DefaultClient",
",",
"BaseURL",
":",
"DefaultBaseURL",
",",
"Key",
":",
"key",
",",
"Token",
":",
"token",
",",
"throttle",
":",
"time",
".",
"Tick",
"(",
"time",
".",
"Second",
"/",
"8",
")",
",",
"// Actually 10/second, but we're extra cautious",
"testMode",
":",
"false",
",",
"ctx",
":",
"context",
".",
"Background",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewClient is a constructor for the Client. It takes the key and token credentials
// of a Trello member to authenticate and authorise requests with. | [
"NewClient",
"is",
"a",
"constructor",
"for",
"the",
"Client",
".",
"It",
"takes",
"the",
"key",
"and",
"token",
"credentials",
"of",
"a",
"Trello",
"member",
"to",
"authenticate",
"and",
"authorise",
"requests",
"with",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/client.go#L42-L52 |
6,330 | adlio/trello | client.go | WithContext | func (c *Client) WithContext(ctx context.Context) *Client {
newC := *c
newC.ctx = ctx
return &newC
} | go | func (c *Client) WithContext(ctx context.Context) *Client {
newC := *c
newC.ctx = ctx
return &newC
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Client",
"{",
"newC",
":=",
"*",
"c",
"\n",
"newC",
".",
"ctx",
"=",
"ctx",
"\n",
"return",
"&",
"newC",
"\n",
"}"
] | // WithContext takes a context.Context, sets it as context on the client and returns
// a Client pointer. | [
"WithContext",
"takes",
"a",
"context",
".",
"Context",
"sets",
"it",
"as",
"context",
"on",
"the",
"client",
"and",
"returns",
"a",
"Client",
"pointer",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/client.go#L56-L60 |
6,331 | adlio/trello | notification.go | GetMyNotifications | func (c *Client) GetMyNotifications(args Arguments) (notifications []*Notification, err error) {
path := "members/me/notifications"
err = c.Get(path, args, ¬ifications)
for i := range notifications {
notifications[i].client = c
}
return
} | go | func (c *Client) GetMyNotifications(args Arguments) (notifications []*Notification, err error) {
path := "members/me/notifications"
err = c.Get(path, args, ¬ifications)
for i := range notifications {
notifications[i].client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMyNotifications",
"(",
"args",
"Arguments",
")",
"(",
"notifications",
"[",
"]",
"*",
"Notification",
",",
"err",
"error",
")",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"notifications",
")",
"\n",
"for",
"i",
":=",
"range",
"notifications",
"{",
"notifications",
"[",
"i",
"]",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetMyNotifications returns the notifications of the authenticated user | [
"GetMyNotifications",
"returns",
"the",
"notifications",
"of",
"the",
"authenticated",
"user"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/notification.go#L46-L53 |
6,332 | adlio/trello | webhook.go | CreateWebhook | func (c *Client) CreateWebhook(webhook *Webhook) error {
path := "webhooks"
args := Arguments{"idModel": webhook.IDModel, "description": webhook.Description, "callbackURL": webhook.CallbackURL}
err := c.Post(path, args, webhook)
if err == nil {
webhook.client = c
}
return err
} | go | func (c *Client) CreateWebhook(webhook *Webhook) error {
path := "webhooks"
args := Arguments{"idModel": webhook.IDModel, "description": webhook.Description, "callbackURL": webhook.CallbackURL}
err := c.Post(path, args, webhook)
if err == nil {
webhook.client = c
}
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateWebhook",
"(",
"webhook",
"*",
"Webhook",
")",
"error",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"args",
":=",
"Arguments",
"{",
"\"",
"\"",
":",
"webhook",
".",
"IDModel",
",",
"\"",
"\"",
":",
"webhook",
".",
"Description",
",",
"\"",
"\"",
":",
"webhook",
".",
"CallbackURL",
"}",
"\n",
"err",
":=",
"c",
".",
"Post",
"(",
"path",
",",
"args",
",",
"webhook",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"webhook",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // CreateWebhook takes a Webhook, POSTs it and returns an error object. | [
"CreateWebhook",
"takes",
"a",
"Webhook",
"POSTs",
"it",
"and",
"returns",
"an",
"error",
"object",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/webhook.go#L54-L62 |
6,333 | adlio/trello | webhook.go | GetWebhook | func (c *Client) GetWebhook(webhookID string, args Arguments) (webhook *Webhook, err error) {
path := fmt.Sprintf("webhooks/%s", webhookID)
err = c.Get(path, args, &webhook)
if webhook != nil {
webhook.client = c
}
return
} | go | func (c *Client) GetWebhook(webhookID string, args Arguments) (webhook *Webhook, err error) {
path := fmt.Sprintf("webhooks/%s", webhookID)
err = c.Get(path, args, &webhook)
if webhook != nil {
webhook.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetWebhook",
"(",
"webhookID",
"string",
",",
"args",
"Arguments",
")",
"(",
"webhook",
"*",
"Webhook",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"webhookID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"webhook",
")",
"\n",
"if",
"webhook",
"!=",
"nil",
"{",
"webhook",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetWebhook takes a webhook id and Arguments, GETs the matching Webhook and returns it or an error. | [
"GetWebhook",
"takes",
"a",
"webhook",
"id",
"and",
"Arguments",
"GETs",
"the",
"matching",
"Webhook",
"and",
"returns",
"it",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/webhook.go#L65-L72 |
6,334 | adlio/trello | webhook.go | GetWebhooks | func (t *Token) GetWebhooks(args Arguments) (webhooks []*Webhook, err error) {
path := fmt.Sprintf("tokens/%s/webhooks", t.ID)
err = t.client.Get(path, args, &webhooks)
return
} | go | func (t *Token) GetWebhooks(args Arguments) (webhooks []*Webhook, err error) {
path := fmt.Sprintf("tokens/%s/webhooks", t.ID)
err = t.client.Get(path, args, &webhooks)
return
} | [
"func",
"(",
"t",
"*",
"Token",
")",
"GetWebhooks",
"(",
"args",
"Arguments",
")",
"(",
"webhooks",
"[",
"]",
"*",
"Webhook",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"t",
".",
"ID",
")",
"\n",
"err",
"=",
"t",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"webhooks",
")",
"\n",
"return",
"\n",
"}"
] | // GetWebhooks takes Arguments and returns a list of all Webhooks for the receiver Token or an error. | [
"GetWebhooks",
"takes",
"Arguments",
"and",
"returns",
"a",
"list",
"of",
"all",
"Webhooks",
"for",
"the",
"receiver",
"Token",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/webhook.go#L75-L79 |
6,335 | adlio/trello | webhook.go | GetBoardWebhookRequest | func GetBoardWebhookRequest(r *http.Request) (whr *BoardWebhookRequest, err error) {
if r.Method == "HEAD" {
return &BoardWebhookRequest{}, nil
}
decoder := json.NewDecoder(r.Body)
err = decoder.Decode(&whr)
if err != nil {
err = errors.Wrapf(err, "GetBoardWebhookRequest() failed to decode '%s'.", r.URL)
}
return
} | go | func GetBoardWebhookRequest(r *http.Request) (whr *BoardWebhookRequest, err error) {
if r.Method == "HEAD" {
return &BoardWebhookRequest{}, nil
}
decoder := json.NewDecoder(r.Body)
err = decoder.Decode(&whr)
if err != nil {
err = errors.Wrapf(err, "GetBoardWebhookRequest() failed to decode '%s'.", r.URL)
}
return
} | [
"func",
"GetBoardWebhookRequest",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"whr",
"*",
"BoardWebhookRequest",
",",
"err",
"error",
")",
"{",
"if",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"return",
"&",
"BoardWebhookRequest",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"decoder",
":=",
"json",
".",
"NewDecoder",
"(",
"r",
".",
"Body",
")",
"\n",
"err",
"=",
"decoder",
".",
"Decode",
"(",
"&",
"whr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"r",
".",
"URL",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetBoardWebhookRequest takes a http.Request and returns the decoded body as BoardWebhookRequest or an error. | [
"GetBoardWebhookRequest",
"takes",
"a",
"http",
".",
"Request",
"and",
"returns",
"the",
"decoded",
"body",
"as",
"BoardWebhookRequest",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/webhook.go#L82-L92 |
6,336 | adlio/trello | card.go | CreatedAt | func (c *Card) CreatedAt() time.Time {
t, _ := IDToTime(c.ID)
return t
} | go | func (c *Card) CreatedAt() time.Time {
t, _ := IDToTime(c.ID)
return t
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"CreatedAt",
"(",
")",
"time",
".",
"Time",
"{",
"t",
",",
"_",
":=",
"IDToTime",
"(",
"c",
".",
"ID",
")",
"\n",
"return",
"t",
"\n",
"}"
] | // CreatedAt returns the receiver card's created-at attribute as time.Time. | [
"CreatedAt",
"returns",
"the",
"receiver",
"card",
"s",
"created",
"-",
"at",
"attribute",
"as",
"time",
".",
"Time",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L89-L92 |
6,337 | adlio/trello | card.go | CustomFields | func (c *Card) CustomFields(boardCustomFields []*CustomField) map[string]interface{} {
cfm := c.customFieldMap
if cfm == nil {
cfm = &(map[string]interface{}{})
// bcfOptionNames[CustomField ID] = Custom Field Name
bcfOptionNames := map[string]string{}
// bcfOptionsMap[CustomField ID][ID of the option] = Value of the option
bcfOptionsMap := map[string]map[string]interface{}{}
for _, bcf := range boardCustomFields {
bcfOptionNames[bcf.ID] = bcf.Name
for _, cf := range bcf.Options {
// create 2nd level map when not available yet
map2, ok := bcfOptionsMap[cf.IDCustomField]
if !ok {
map2 = map[string]interface{}{}
bcfOptionsMap[bcf.ID] = map2
}
bcfOptionsMap[bcf.ID][cf.ID] = cf.Value.Text
}
}
for _, cf := range c.CustomFieldItems {
name := bcfOptionNames[cf.IDCustomField]
// create 2nd level map when not available yet
map2, ok := bcfOptionsMap[cf.IDCustomField]
if !ok {
continue
}
value, ok := map2[cf.IDValue]
if ok {
(*cfm)[name] = value
}
}
c.customFieldMap = cfm
}
return *cfm
} | go | func (c *Card) CustomFields(boardCustomFields []*CustomField) map[string]interface{} {
cfm := c.customFieldMap
if cfm == nil {
cfm = &(map[string]interface{}{})
// bcfOptionNames[CustomField ID] = Custom Field Name
bcfOptionNames := map[string]string{}
// bcfOptionsMap[CustomField ID][ID of the option] = Value of the option
bcfOptionsMap := map[string]map[string]interface{}{}
for _, bcf := range boardCustomFields {
bcfOptionNames[bcf.ID] = bcf.Name
for _, cf := range bcf.Options {
// create 2nd level map when not available yet
map2, ok := bcfOptionsMap[cf.IDCustomField]
if !ok {
map2 = map[string]interface{}{}
bcfOptionsMap[bcf.ID] = map2
}
bcfOptionsMap[bcf.ID][cf.ID] = cf.Value.Text
}
}
for _, cf := range c.CustomFieldItems {
name := bcfOptionNames[cf.IDCustomField]
// create 2nd level map when not available yet
map2, ok := bcfOptionsMap[cf.IDCustomField]
if !ok {
continue
}
value, ok := map2[cf.IDValue]
if ok {
(*cfm)[name] = value
}
}
c.customFieldMap = cfm
}
return *cfm
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"CustomFields",
"(",
"boardCustomFields",
"[",
"]",
"*",
"CustomField",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"cfm",
":=",
"c",
".",
"customFieldMap",
"\n\n",
"if",
"cfm",
"==",
"nil",
"{",
"cfm",
"=",
"&",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n\n",
"// bcfOptionNames[CustomField ID] = Custom Field Name",
"bcfOptionNames",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n\n",
"// bcfOptionsMap[CustomField ID][ID of the option] = Value of the option",
"bcfOptionsMap",
":=",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n\n",
"for",
"_",
",",
"bcf",
":=",
"range",
"boardCustomFields",
"{",
"bcfOptionNames",
"[",
"bcf",
".",
"ID",
"]",
"=",
"bcf",
".",
"Name",
"\n",
"for",
"_",
",",
"cf",
":=",
"range",
"bcf",
".",
"Options",
"{",
"// create 2nd level map when not available yet",
"map2",
",",
"ok",
":=",
"bcfOptionsMap",
"[",
"cf",
".",
"IDCustomField",
"]",
"\n",
"if",
"!",
"ok",
"{",
"map2",
"=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"bcfOptionsMap",
"[",
"bcf",
".",
"ID",
"]",
"=",
"map2",
"\n",
"}",
"\n\n",
"bcfOptionsMap",
"[",
"bcf",
".",
"ID",
"]",
"[",
"cf",
".",
"ID",
"]",
"=",
"cf",
".",
"Value",
".",
"Text",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"cf",
":=",
"range",
"c",
".",
"CustomFieldItems",
"{",
"name",
":=",
"bcfOptionNames",
"[",
"cf",
".",
"IDCustomField",
"]",
"\n\n",
"// create 2nd level map when not available yet",
"map2",
",",
"ok",
":=",
"bcfOptionsMap",
"[",
"cf",
".",
"IDCustomField",
"]",
"\n",
"if",
"!",
"ok",
"{",
"continue",
"\n",
"}",
"\n",
"value",
",",
"ok",
":=",
"map2",
"[",
"cf",
".",
"IDValue",
"]",
"\n\n",
"if",
"ok",
"{",
"(",
"*",
"cfm",
")",
"[",
"name",
"]",
"=",
"value",
"\n",
"}",
"\n",
"}",
"\n",
"c",
".",
"customFieldMap",
"=",
"cfm",
"\n",
"}",
"\n",
"return",
"*",
"cfm",
"\n",
"}"
] | // CustomFields returns the card's custom fields. | [
"CustomFields",
"returns",
"the",
"card",
"s",
"custom",
"fields",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L95-L139 |
6,338 | adlio/trello | card.go | MoveToList | func (c *Card) MoveToList(listID string, args Arguments) error {
path := fmt.Sprintf("cards/%s", c.ID)
args["idList"] = listID
return c.client.Put(path, args, &c)
} | go | func (c *Card) MoveToList(listID string, args Arguments) error {
path := fmt.Sprintf("cards/%s", c.ID)
args["idList"] = listID
return c.client.Put(path, args, &c)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"MoveToList",
"(",
"listID",
"string",
",",
"args",
"Arguments",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"args",
"[",
"\"",
"\"",
"]",
"=",
"listID",
"\n",
"return",
"c",
".",
"client",
".",
"Put",
"(",
"path",
",",
"args",
",",
"&",
"c",
")",
"\n",
"}"
] | // MoveToList moves a card to a list given by listID. | [
"MoveToList",
"moves",
"a",
"card",
"to",
"a",
"list",
"given",
"by",
"listID",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L142-L146 |
6,339 | adlio/trello | card.go | SetPos | func (c *Card) SetPos(newPos float64) error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, Arguments{"pos": fmt.Sprintf("%f", newPos)}, c)
} | go | func (c *Card) SetPos(newPos float64) error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, Arguments{"pos": fmt.Sprintf("%f", newPos)}, c)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"SetPos",
"(",
"newPos",
"float64",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"c",
".",
"client",
".",
"Put",
"(",
"path",
",",
"Arguments",
"{",
"\"",
"\"",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"newPos",
")",
"}",
",",
"c",
")",
"\n",
"}"
] | // SetPos sets a card's new position. | [
"SetPos",
"sets",
"a",
"card",
"s",
"new",
"position",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L149-L152 |
6,340 | adlio/trello | card.go | RemoveMember | func (c *Card) RemoveMember(memberID string) error {
path := fmt.Sprintf("cards/%s/idMembers/%s", c.ID, memberID)
return c.client.Delete(path, Defaults(), nil)
} | go | func (c *Card) RemoveMember(memberID string) error {
path := fmt.Sprintf("cards/%s/idMembers/%s", c.ID, memberID)
return c.client.Delete(path, Defaults(), nil)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"RemoveMember",
"(",
"memberID",
"string",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
",",
"memberID",
")",
"\n",
"return",
"c",
".",
"client",
".",
"Delete",
"(",
"path",
",",
"Defaults",
"(",
")",
",",
"nil",
")",
"\n",
"}"
] | // RemoveMember receives the id of a member and removes the corresponding member from the card. | [
"RemoveMember",
"receives",
"the",
"id",
"of",
"a",
"member",
"and",
"removes",
"the",
"corresponding",
"member",
"from",
"the",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L155-L158 |
6,341 | adlio/trello | card.go | AddMemberID | func (c *Card) AddMemberID(memberID string) (member []*Member, err error) {
path := fmt.Sprintf("cards/%s/idMembers", c.ID)
err = c.client.Post(path, Arguments{"value": memberID}, &member)
return member, err
} | go | func (c *Card) AddMemberID(memberID string) (member []*Member, err error) {
path := fmt.Sprintf("cards/%s/idMembers", c.ID)
err = c.client.Post(path, Arguments{"value": memberID}, &member)
return member, err
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"AddMemberID",
"(",
"memberID",
"string",
")",
"(",
"member",
"[",
"]",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"err",
"=",
"c",
".",
"client",
".",
"Post",
"(",
"path",
",",
"Arguments",
"{",
"\"",
"\"",
":",
"memberID",
"}",
",",
"&",
"member",
")",
"\n",
"return",
"member",
",",
"err",
"\n",
"}"
] | // AddMemberID receives a member id and adds the corresponding member to the card.
// Returns a list of the card's members or an error. | [
"AddMemberID",
"receives",
"a",
"member",
"id",
"and",
"adds",
"the",
"corresponding",
"member",
"to",
"the",
"card",
".",
"Returns",
"a",
"list",
"of",
"the",
"card",
"s",
"members",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L162-L166 |
6,342 | adlio/trello | card.go | RemoveIDLabel | func (c *Card) RemoveIDLabel(labelID string, label *Label) error {
path := fmt.Sprintf("cards/%s/idLabels/%s", c.ID, labelID)
return c.client.Delete(path, Defaults(), label)
} | go | func (c *Card) RemoveIDLabel(labelID string, label *Label) error {
path := fmt.Sprintf("cards/%s/idLabels/%s", c.ID, labelID)
return c.client.Delete(path, Defaults(), label)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"RemoveIDLabel",
"(",
"labelID",
"string",
",",
"label",
"*",
"Label",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
",",
"labelID",
")",
"\n",
"return",
"c",
".",
"client",
".",
"Delete",
"(",
"path",
",",
"Defaults",
"(",
")",
",",
"label",
")",
"\n\n",
"}"
] | // RemoveIDLabel removes a label id from the card. | [
"RemoveIDLabel",
"removes",
"a",
"label",
"id",
"from",
"the",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L169-L173 |
6,343 | adlio/trello | card.go | AddIDLabel | func (c *Card) AddIDLabel(labelID string) error {
path := fmt.Sprintf("cards/%s/idLabels", c.ID)
err := c.client.Post(path, Arguments{"value": labelID}, &c.IDLabels)
return err
} | go | func (c *Card) AddIDLabel(labelID string) error {
path := fmt.Sprintf("cards/%s/idLabels", c.ID)
err := c.client.Post(path, Arguments{"value": labelID}, &c.IDLabels)
return err
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"AddIDLabel",
"(",
"labelID",
"string",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Post",
"(",
"path",
",",
"Arguments",
"{",
"\"",
"\"",
":",
"labelID",
"}",
",",
"&",
"c",
".",
"IDLabels",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // AddIDLabel receives a label id and adds the corresponding label or returns an error. | [
"AddIDLabel",
"receives",
"a",
"label",
"id",
"and",
"adds",
"the",
"corresponding",
"label",
"or",
"returns",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L176-L180 |
6,344 | adlio/trello | card.go | MoveToTopOfList | func (c *Card) MoveToTopOfList() error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, Arguments{"pos": "top"}, c)
} | go | func (c *Card) MoveToTopOfList() error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, Arguments{"pos": "top"}, c)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"MoveToTopOfList",
"(",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"c",
".",
"client",
".",
"Put",
"(",
"path",
",",
"Arguments",
"{",
"\"",
"\"",
":",
"\"",
"\"",
"}",
",",
"c",
")",
"\n",
"}"
] | // MoveToTopOfList moves the card to the top of it's list. | [
"MoveToTopOfList",
"moves",
"the",
"card",
"to",
"the",
"top",
"of",
"it",
"s",
"list",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L183-L186 |
6,345 | adlio/trello | card.go | Update | func (c *Card) Update(args Arguments) error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, args, c)
} | go | func (c *Card) Update(args Arguments) error {
path := fmt.Sprintf("cards/%s", c.ID)
return c.client.Put(path, args, c)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"Update",
"(",
"args",
"Arguments",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"c",
".",
"client",
".",
"Put",
"(",
"path",
",",
"args",
",",
"c",
")",
"\n",
"}"
] | // Update UPDATEs the card's attributes. | [
"Update",
"UPDATEs",
"the",
"card",
"s",
"attributes",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L195-L198 |
6,346 | adlio/trello | card.go | CreateCard | func (c *Client) CreateCard(card *Card, extraArgs Arguments) error {
path := "cards"
args := Arguments{
"name": card.Name,
"desc": card.Desc,
"pos": strconv.FormatFloat(card.Pos, 'g', -1, 64),
"idList": card.IDList,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
}
// Allow overriding the creation position with 'top' or 'botttom'
if pos, ok := extraArgs["pos"]; ok {
args["pos"] = pos
}
err := c.Post(path, args, &card)
if err == nil {
card.client = c
}
return err
} | go | func (c *Client) CreateCard(card *Card, extraArgs Arguments) error {
path := "cards"
args := Arguments{
"name": card.Name,
"desc": card.Desc,
"pos": strconv.FormatFloat(card.Pos, 'g', -1, 64),
"idList": card.IDList,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
}
// Allow overriding the creation position with 'top' or 'botttom'
if pos, ok := extraArgs["pos"]; ok {
args["pos"] = pos
}
err := c.Post(path, args, &card)
if err == nil {
card.client = c
}
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateCard",
"(",
"card",
"*",
"Card",
",",
"extraArgs",
"Arguments",
")",
"error",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"args",
":=",
"Arguments",
"{",
"\"",
"\"",
":",
"card",
".",
"Name",
",",
"\"",
"\"",
":",
"card",
".",
"Desc",
",",
"\"",
"\"",
":",
"strconv",
".",
"FormatFloat",
"(",
"card",
".",
"Pos",
",",
"'g'",
",",
"-",
"1",
",",
"64",
")",
",",
"\"",
"\"",
":",
"card",
".",
"IDList",
",",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"card",
".",
"IDMembers",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"card",
".",
"IDLabels",
",",
"\"",
"\"",
")",
",",
"}",
"\n",
"if",
"card",
".",
"Due",
"!=",
"nil",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"card",
".",
"Due",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
"\n",
"}",
"\n",
"// Allow overriding the creation position with 'top' or 'botttom'",
"if",
"pos",
",",
"ok",
":=",
"extraArgs",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"pos",
"\n",
"}",
"\n",
"err",
":=",
"c",
".",
"Post",
"(",
"path",
",",
"args",
",",
"&",
"card",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"card",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // CreateCard takes a Card and Arguments and POSTs the card. | [
"CreateCard",
"takes",
"a",
"Card",
"and",
"Arguments",
"and",
"POSTs",
"the",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L201-L223 |
6,347 | adlio/trello | card.go | AddCard | func (l *List) AddCard(card *Card, extraArgs Arguments) error {
path := fmt.Sprintf("lists/%s/cards", l.ID)
args := Arguments{
"name": card.Name,
"desc": card.Desc,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
}
// Allow overwriting the creation position with 'top' or 'bottom'
if pos, ok := extraArgs["pos"]; ok {
args["pos"] = pos
}
err := l.client.Post(path, args, &card)
if err == nil {
card.client = l.client
} else {
err = errors.Wrapf(err, "Error adding card to list %s", l.ID)
}
return err
} | go | func (l *List) AddCard(card *Card, extraArgs Arguments) error {
path := fmt.Sprintf("lists/%s/cards", l.ID)
args := Arguments{
"name": card.Name,
"desc": card.Desc,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
}
// Allow overwriting the creation position with 'top' or 'bottom'
if pos, ok := extraArgs["pos"]; ok {
args["pos"] = pos
}
err := l.client.Post(path, args, &card)
if err == nil {
card.client = l.client
} else {
err = errors.Wrapf(err, "Error adding card to list %s", l.ID)
}
return err
} | [
"func",
"(",
"l",
"*",
"List",
")",
"AddCard",
"(",
"card",
"*",
"Card",
",",
"extraArgs",
"Arguments",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"ID",
")",
"\n",
"args",
":=",
"Arguments",
"{",
"\"",
"\"",
":",
"card",
".",
"Name",
",",
"\"",
"\"",
":",
"card",
".",
"Desc",
",",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"card",
".",
"IDMembers",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
":",
"strings",
".",
"Join",
"(",
"card",
".",
"IDLabels",
",",
"\"",
"\"",
")",
",",
"}",
"\n",
"if",
"card",
".",
"Due",
"!=",
"nil",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"card",
".",
"Due",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
"\n",
"}",
"\n",
"// Allow overwriting the creation position with 'top' or 'bottom'",
"if",
"pos",
",",
"ok",
":=",
"extraArgs",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"pos",
"\n",
"}",
"\n",
"err",
":=",
"l",
".",
"client",
".",
"Post",
"(",
"path",
",",
"args",
",",
"&",
"card",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"card",
".",
"client",
"=",
"l",
".",
"client",
"\n",
"}",
"else",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"l",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // AddCard takes a Card and Arguments and adds the card to the receiver list. | [
"AddCard",
"takes",
"a",
"Card",
"and",
"Arguments",
"and",
"adds",
"the",
"card",
"to",
"the",
"receiver",
"list",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L226-L248 |
6,348 | adlio/trello | card.go | AddComment | func (c *Card) AddComment(comment string, args Arguments) (*Action, error) {
path := fmt.Sprintf("cards/%s/actions/comments", c.ID)
args["text"] = comment
action := Action{}
err := c.client.Post(path, args, &action)
if err != nil {
err = errors.Wrapf(err, "Error commenting on card %s", c.ID)
}
return &action, err
} | go | func (c *Card) AddComment(comment string, args Arguments) (*Action, error) {
path := fmt.Sprintf("cards/%s/actions/comments", c.ID)
args["text"] = comment
action := Action{}
err := c.client.Post(path, args, &action)
if err != nil {
err = errors.Wrapf(err, "Error commenting on card %s", c.ID)
}
return &action, err
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"AddComment",
"(",
"comment",
"string",
",",
"args",
"Arguments",
")",
"(",
"*",
"Action",
",",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"args",
"[",
"\"",
"\"",
"]",
"=",
"comment",
"\n",
"action",
":=",
"Action",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Post",
"(",
"path",
",",
"args",
",",
"&",
"action",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"&",
"action",
",",
"err",
"\n",
"}"
] | // AddComment takes a comment string and Arguments and adds the comment to the card. | [
"AddComment",
"takes",
"a",
"comment",
"string",
"and",
"Arguments",
"and",
"adds",
"the",
"comment",
"to",
"the",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L271-L280 |
6,349 | adlio/trello | card.go | AddURLAttachment | func (c *Card) AddURLAttachment(attachment *Attachment) error {
path := fmt.Sprintf("cards/%s/attachments", c.ID)
args := Arguments{
"url": attachment.URL,
"name": attachment.Name,
}
err := c.client.Post(path, args, &attachment)
if err != nil {
err = errors.Wrapf(err, "Error adding attachment to card %s", c.ID)
}
return err
} | go | func (c *Card) AddURLAttachment(attachment *Attachment) error {
path := fmt.Sprintf("cards/%s/attachments", c.ID)
args := Arguments{
"url": attachment.URL,
"name": attachment.Name,
}
err := c.client.Post(path, args, &attachment)
if err != nil {
err = errors.Wrapf(err, "Error adding attachment to card %s", c.ID)
}
return err
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"AddURLAttachment",
"(",
"attachment",
"*",
"Attachment",
")",
"error",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"args",
":=",
"Arguments",
"{",
"\"",
"\"",
":",
"attachment",
".",
"URL",
",",
"\"",
"\"",
":",
"attachment",
".",
"Name",
",",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Post",
"(",
"path",
",",
"args",
",",
"&",
"attachment",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n\n",
"}"
] | // AddURLAttachment takes an Attachment and adds it to the card. | [
"AddURLAttachment",
"takes",
"an",
"Attachment",
"and",
"adds",
"it",
"to",
"the",
"card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L283-L295 |
6,350 | adlio/trello | card.go | GetParentCard | func (c *Card) GetParentCard(args Arguments) (*Card, error) {
// Hopefully the card came pre-loaded with Actions including the card creation
action := c.Actions.FirstCardCreateAction()
if action == nil {
// No luck. Go get copyCard actions for this card.
c.client.log("Creation action wasn't supplied before GetParentCard() on '%s'. Getting copyCard actions.", c.ID)
actions, err := c.GetActions(Arguments{"filter": "copyCard"})
if err != nil {
err = errors.Wrapf(err, "GetParentCard() failed to GetActions() for card '%s'", c.ID)
return nil, err
}
action = actions.FirstCardCreateAction()
}
if action != nil && action.Data != nil && action.Data.CardSource != nil {
card, err := c.client.GetCard(action.Data.CardSource.ID, args)
return card, err
}
return nil, nil
} | go | func (c *Card) GetParentCard(args Arguments) (*Card, error) {
// Hopefully the card came pre-loaded with Actions including the card creation
action := c.Actions.FirstCardCreateAction()
if action == nil {
// No luck. Go get copyCard actions for this card.
c.client.log("Creation action wasn't supplied before GetParentCard() on '%s'. Getting copyCard actions.", c.ID)
actions, err := c.GetActions(Arguments{"filter": "copyCard"})
if err != nil {
err = errors.Wrapf(err, "GetParentCard() failed to GetActions() for card '%s'", c.ID)
return nil, err
}
action = actions.FirstCardCreateAction()
}
if action != nil && action.Data != nil && action.Data.CardSource != nil {
card, err := c.client.GetCard(action.Data.CardSource.ID, args)
return card, err
}
return nil, nil
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetParentCard",
"(",
"args",
"Arguments",
")",
"(",
"*",
"Card",
",",
"error",
")",
"{",
"// Hopefully the card came pre-loaded with Actions including the card creation",
"action",
":=",
"c",
".",
"Actions",
".",
"FirstCardCreateAction",
"(",
")",
"\n\n",
"if",
"action",
"==",
"nil",
"{",
"// No luck. Go get copyCard actions for this card.",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"actions",
",",
"err",
":=",
"c",
".",
"GetActions",
"(",
"Arguments",
"{",
"\"",
"\"",
":",
"\"",
"\"",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"action",
"=",
"actions",
".",
"FirstCardCreateAction",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"action",
"!=",
"nil",
"&&",
"action",
".",
"Data",
"!=",
"nil",
"&&",
"action",
".",
"Data",
".",
"CardSource",
"!=",
"nil",
"{",
"card",
",",
"err",
":=",
"c",
".",
"client",
".",
"GetCard",
"(",
"action",
".",
"Data",
".",
"CardSource",
".",
"ID",
",",
"args",
")",
"\n",
"return",
"card",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // GetParentCard retrieves the originating Card if the Card was created
// from a copy of another Card. Returns an error only when a low-level failure occurred.
// If this Card has no parent, a nil card and nil error are returned. In other words, the
// non-existence of a parent is not treated as an error. | [
"GetParentCard",
"retrieves",
"the",
"originating",
"Card",
"if",
"the",
"Card",
"was",
"created",
"from",
"a",
"copy",
"of",
"another",
"Card",
".",
"Returns",
"an",
"error",
"only",
"when",
"a",
"low",
"-",
"level",
"failure",
"occurred",
".",
"If",
"this",
"Card",
"has",
"no",
"parent",
"a",
"nil",
"card",
"and",
"nil",
"error",
"are",
"returned",
".",
"In",
"other",
"words",
"the",
"non",
"-",
"existence",
"of",
"a",
"parent",
"is",
"not",
"treated",
"as",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L301-L323 |
6,351 | adlio/trello | card.go | GetAncestorCards | func (c *Card) GetAncestorCards(args Arguments) (ancestors []*Card, err error) {
// Get the first parent
parent, err := c.GetParentCard(args)
if IsNotFound(err) || IsPermissionDenied(err) {
c.client.log("[trello] Can't get details about the parent of card '%s' due to lack of permissions or card deleted.", c.ID)
return ancestors, nil
}
for parent != nil {
ancestors = append(ancestors, parent)
parent, err = parent.GetParentCard(args)
if IsNotFound(err) || IsPermissionDenied(err) {
c.client.log("[trello] Can't get details about the parent of card '%s' due to lack of permissions or card deleted.", c.ID)
return ancestors, nil
} else if err != nil {
return ancestors, err
}
}
return ancestors, err
} | go | func (c *Card) GetAncestorCards(args Arguments) (ancestors []*Card, err error) {
// Get the first parent
parent, err := c.GetParentCard(args)
if IsNotFound(err) || IsPermissionDenied(err) {
c.client.log("[trello] Can't get details about the parent of card '%s' due to lack of permissions or card deleted.", c.ID)
return ancestors, nil
}
for parent != nil {
ancestors = append(ancestors, parent)
parent, err = parent.GetParentCard(args)
if IsNotFound(err) || IsPermissionDenied(err) {
c.client.log("[trello] Can't get details about the parent of card '%s' due to lack of permissions or card deleted.", c.ID)
return ancestors, nil
} else if err != nil {
return ancestors, err
}
}
return ancestors, err
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetAncestorCards",
"(",
"args",
"Arguments",
")",
"(",
"ancestors",
"[",
"]",
"*",
"Card",
",",
"err",
"error",
")",
"{",
"// Get the first parent",
"parent",
",",
"err",
":=",
"c",
".",
"GetParentCard",
"(",
"args",
")",
"\n",
"if",
"IsNotFound",
"(",
"err",
")",
"||",
"IsPermissionDenied",
"(",
"err",
")",
"{",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"ancestors",
",",
"nil",
"\n",
"}",
"\n\n",
"for",
"parent",
"!=",
"nil",
"{",
"ancestors",
"=",
"append",
"(",
"ancestors",
",",
"parent",
")",
"\n",
"parent",
",",
"err",
"=",
"parent",
".",
"GetParentCard",
"(",
"args",
")",
"\n",
"if",
"IsNotFound",
"(",
"err",
")",
"||",
"IsPermissionDenied",
"(",
"err",
")",
"{",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"return",
"ancestors",
",",
"nil",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ancestors",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"ancestors",
",",
"err",
"\n",
"}"
] | // GetAncestorCards takes Arguments, GETs the card's ancestors and returns them as a slice. | [
"GetAncestorCards",
"takes",
"Arguments",
"GETs",
"the",
"card",
"s",
"ancestors",
"and",
"returns",
"them",
"as",
"a",
"slice",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L326-L347 |
6,352 | adlio/trello | card.go | GetOriginatingCard | func (c *Card) GetOriginatingCard(args Arguments) (*Card, error) {
ancestors, err := c.GetAncestorCards(args)
if err != nil {
return c, err
}
if len(ancestors) > 0 {
return ancestors[len(ancestors)-1], nil
}
return c, nil
} | go | func (c *Card) GetOriginatingCard(args Arguments) (*Card, error) {
ancestors, err := c.GetAncestorCards(args)
if err != nil {
return c, err
}
if len(ancestors) > 0 {
return ancestors[len(ancestors)-1], nil
}
return c, nil
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetOriginatingCard",
"(",
"args",
"Arguments",
")",
"(",
"*",
"Card",
",",
"error",
")",
"{",
"ancestors",
",",
"err",
":=",
"c",
".",
"GetAncestorCards",
"(",
"args",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"c",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"ancestors",
")",
">",
"0",
"{",
"return",
"ancestors",
"[",
"len",
"(",
"ancestors",
")",
"-",
"1",
"]",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] | // GetOriginatingCard takes Arguments, GETs ancestors and returns most recent ancestor card of the Card. | [
"GetOriginatingCard",
"takes",
"Arguments",
"GETs",
"ancestors",
"and",
"returns",
"most",
"recent",
"ancestor",
"card",
"of",
"the",
"Card",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L350-L360 |
6,353 | adlio/trello | card.go | CreatorMember | func (c *Card) CreatorMember() (*Member, error) {
var actions ActionCollection
var err error
if len(c.Actions) == 0 {
c.Actions, err = c.GetActions(Arguments{"filter": "all", "limit": "1000", "memberCreator_fields": "all"})
if err != nil {
err = errors.Wrapf(err, "GetActions() call failed.")
return nil, err
}
}
actions = c.Actions.FilterToCardCreationActions()
if len(actions) > 0 {
return actions[0].MemberCreator, nil
}
return nil, errors.Errorf("No card creation actions on Card %s with a .MemberCreator", c.ID)
} | go | func (c *Card) CreatorMember() (*Member, error) {
var actions ActionCollection
var err error
if len(c.Actions) == 0 {
c.Actions, err = c.GetActions(Arguments{"filter": "all", "limit": "1000", "memberCreator_fields": "all"})
if err != nil {
err = errors.Wrapf(err, "GetActions() call failed.")
return nil, err
}
}
actions = c.Actions.FilterToCardCreationActions()
if len(actions) > 0 {
return actions[0].MemberCreator, nil
}
return nil, errors.Errorf("No card creation actions on Card %s with a .MemberCreator", c.ID)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"CreatorMember",
"(",
")",
"(",
"*",
"Member",
",",
"error",
")",
"{",
"var",
"actions",
"ActionCollection",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Actions",
")",
"==",
"0",
"{",
"c",
".",
"Actions",
",",
"err",
"=",
"c",
".",
"GetActions",
"(",
"Arguments",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"\"",
"\"",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"actions",
"=",
"c",
".",
"Actions",
".",
"FilterToCardCreationActions",
"(",
")",
"\n\n",
"if",
"len",
"(",
"actions",
")",
">",
"0",
"{",
"return",
"actions",
"[",
"0",
"]",
".",
"MemberCreator",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"}"
] | // CreatorMember returns the member of the card who created it or and error.
// The creator is the member who is associated with the card's first action. | [
"CreatorMember",
"returns",
"the",
"member",
"of",
"the",
"card",
"who",
"created",
"it",
"or",
"and",
"error",
".",
"The",
"creator",
"is",
"the",
"member",
"who",
"is",
"associated",
"with",
"the",
"card",
"s",
"first",
"action",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L364-L381 |
6,354 | adlio/trello | card.go | CreatorMemberID | func (c *Card) CreatorMemberID() (string, error) {
var actions ActionCollection
var err error
if len(c.Actions) == 0 {
c.client.log("[trello] CreatorMemberID() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
c.Actions, err = c.GetActions(Defaults())
if err != nil {
err = errors.Wrapf(err, "GetActions() call failed.")
}
}
actions = c.Actions.FilterToCardCreationActions()
if len(actions) > 0 {
if actions[0].IDMemberCreator != "" {
return actions[0].IDMemberCreator, err
}
}
return "", errors.Wrapf(err, "No Actions on card '%s' could be used to find its creator.", c.ID)
} | go | func (c *Card) CreatorMemberID() (string, error) {
var actions ActionCollection
var err error
if len(c.Actions) == 0 {
c.client.log("[trello] CreatorMemberID() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
c.Actions, err = c.GetActions(Defaults())
if err != nil {
err = errors.Wrapf(err, "GetActions() call failed.")
}
}
actions = c.Actions.FilterToCardCreationActions()
if len(actions) > 0 {
if actions[0].IDMemberCreator != "" {
return actions[0].IDMemberCreator, err
}
}
return "", errors.Wrapf(err, "No Actions on card '%s' could be used to find its creator.", c.ID)
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"CreatorMemberID",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"actions",
"ActionCollection",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Actions",
")",
"==",
"0",
"{",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"c",
".",
"Actions",
",",
"err",
"=",
"c",
".",
"GetActions",
"(",
"Defaults",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"actions",
"=",
"c",
".",
"Actions",
".",
"FilterToCardCreationActions",
"(",
")",
"\n\n",
"if",
"len",
"(",
"actions",
")",
">",
"0",
"{",
"if",
"actions",
"[",
"0",
"]",
".",
"IDMemberCreator",
"!=",
"\"",
"\"",
"{",
"return",
"actions",
"[",
"0",
"]",
".",
"IDMemberCreator",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"}"
] | // CreatorMemberID returns as string the id of the member who created the card or an error.
// The creator is the member who is associated with the card's first action. | [
"CreatorMemberID",
"returns",
"as",
"string",
"the",
"id",
"of",
"the",
"member",
"who",
"created",
"the",
"card",
"or",
"an",
"error",
".",
"The",
"creator",
"is",
"the",
"member",
"who",
"is",
"associated",
"with",
"the",
"card",
"s",
"first",
"action",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L385-L406 |
6,355 | adlio/trello | card.go | ContainsCopyOfCard | func (b *Board) ContainsCopyOfCard(cardID string, args Arguments) (bool, error) {
args["filter"] = "copyCard"
actions, err := b.GetActions(args)
if err != nil {
err := errors.Wrapf(err, "GetCards() failed inside ContainsCopyOf() for board '%s' and card '%s'.", b.ID, cardID)
return false, err
}
for _, action := range actions {
if action.Data != nil && action.Data.CardSource != nil && action.Data.CardSource.ID == cardID {
return true, nil
}
}
return false, nil
} | go | func (b *Board) ContainsCopyOfCard(cardID string, args Arguments) (bool, error) {
args["filter"] = "copyCard"
actions, err := b.GetActions(args)
if err != nil {
err := errors.Wrapf(err, "GetCards() failed inside ContainsCopyOf() for board '%s' and card '%s'.", b.ID, cardID)
return false, err
}
for _, action := range actions {
if action.Data != nil && action.Data.CardSource != nil && action.Data.CardSource.ID == cardID {
return true, nil
}
}
return false, nil
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"ContainsCopyOfCard",
"(",
"cardID",
"string",
",",
"args",
"Arguments",
")",
"(",
"bool",
",",
"error",
")",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"actions",
",",
"err",
":=",
"b",
".",
"GetActions",
"(",
"args",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
":=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"b",
".",
"ID",
",",
"cardID",
")",
"\n",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"actions",
"{",
"if",
"action",
".",
"Data",
"!=",
"nil",
"&&",
"action",
".",
"Data",
".",
"CardSource",
"!=",
"nil",
"&&",
"action",
".",
"Data",
".",
"CardSource",
".",
"ID",
"==",
"cardID",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
",",
"nil",
"\n",
"}"
] | // ContainsCopyOfCard accepts a card id and Arguments and returns true
// if the receiver Board contains a Card with the id. | [
"ContainsCopyOfCard",
"accepts",
"a",
"card",
"id",
"and",
"Arguments",
"and",
"returns",
"true",
"if",
"the",
"receiver",
"Board",
"contains",
"a",
"Card",
"with",
"the",
"id",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L410-L423 |
6,356 | adlio/trello | card.go | GetCard | func (c *Client) GetCard(cardID string, args Arguments) (card *Card, err error) {
path := fmt.Sprintf("cards/%s", cardID)
err = c.Get(path, args, &card)
if card != nil {
card.client = c
}
return card, err
} | go | func (c *Client) GetCard(cardID string, args Arguments) (card *Card, err error) {
path := fmt.Sprintf("cards/%s", cardID)
err = c.Get(path, args, &card)
if card != nil {
card.client = c
}
return card, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetCard",
"(",
"cardID",
"string",
",",
"args",
"Arguments",
")",
"(",
"card",
"*",
"Card",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cardID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"card",
")",
"\n",
"if",
"card",
"!=",
"nil",
"{",
"card",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"card",
",",
"err",
"\n",
"}"
] | // GetCard receives a card id and Arguments and returns the card if found
// with the credentials given for the receiver Client. Returns an error
// otherwise. | [
"GetCard",
"receives",
"a",
"card",
"id",
"and",
"Arguments",
"and",
"returns",
"the",
"card",
"if",
"found",
"with",
"the",
"credentials",
"given",
"for",
"the",
"receiver",
"Client",
".",
"Returns",
"an",
"error",
"otherwise",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L428-L435 |
6,357 | adlio/trello | card.go | GetCards | func (b *Board) GetCards(args Arguments) (cards []*Card, err error) {
path := fmt.Sprintf("boards/%s/cards", b.ID)
err = b.client.Get(path, args, &cards)
// Naive implementation would return here. To make sure we get all
// cards, we begin
if len(cards) > 0 {
moreCards := true
for moreCards == true {
nextCardBatch := make([]*Card, 0)
args["before"] = earliestCardID(cards)
err = b.client.Get(path, args, &nextCardBatch)
if len(nextCardBatch) > 0 {
cards = append(cards, nextCardBatch...)
} else {
moreCards = false
}
}
}
for i := range cards {
cards[i].client = b.client
}
return
} | go | func (b *Board) GetCards(args Arguments) (cards []*Card, err error) {
path := fmt.Sprintf("boards/%s/cards", b.ID)
err = b.client.Get(path, args, &cards)
// Naive implementation would return here. To make sure we get all
// cards, we begin
if len(cards) > 0 {
moreCards := true
for moreCards == true {
nextCardBatch := make([]*Card, 0)
args["before"] = earliestCardID(cards)
err = b.client.Get(path, args, &nextCardBatch)
if len(nextCardBatch) > 0 {
cards = append(cards, nextCardBatch...)
} else {
moreCards = false
}
}
}
for i := range cards {
cards[i].client = b.client
}
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetCards",
"(",
"args",
"Arguments",
")",
"(",
"cards",
"[",
"]",
"*",
"Card",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"cards",
")",
"\n\n",
"// Naive implementation would return here. To make sure we get all",
"// cards, we begin",
"if",
"len",
"(",
"cards",
")",
">",
"0",
"{",
"moreCards",
":=",
"true",
"\n",
"for",
"moreCards",
"==",
"true",
"{",
"nextCardBatch",
":=",
"make",
"(",
"[",
"]",
"*",
"Card",
",",
"0",
")",
"\n",
"args",
"[",
"\"",
"\"",
"]",
"=",
"earliestCardID",
"(",
"cards",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"nextCardBatch",
")",
"\n",
"if",
"len",
"(",
"nextCardBatch",
")",
">",
"0",
"{",
"cards",
"=",
"append",
"(",
"cards",
",",
"nextCardBatch",
"...",
")",
"\n",
"}",
"else",
"{",
"moreCards",
"=",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"range",
"cards",
"{",
"cards",
"[",
"i",
"]",
".",
"client",
"=",
"b",
".",
"client",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // GetCards takes Arguments and retrieves all Cards on a Board as slice or returns error. | [
"GetCards",
"takes",
"Arguments",
"and",
"retrieves",
"all",
"Cards",
"on",
"a",
"Board",
"as",
"slice",
"or",
"returns",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L438-L464 |
6,358 | adlio/trello | card.go | GetCards | func (l *List) GetCards(args Arguments) (cards []*Card, err error) {
path := fmt.Sprintf("lists/%s/cards", l.ID)
err = l.client.Get(path, args, &cards)
for i := range cards {
cards[i].client = l.client
}
return
} | go | func (l *List) GetCards(args Arguments) (cards []*Card, err error) {
path := fmt.Sprintf("lists/%s/cards", l.ID)
err = l.client.Get(path, args, &cards)
for i := range cards {
cards[i].client = l.client
}
return
} | [
"func",
"(",
"l",
"*",
"List",
")",
"GetCards",
"(",
"args",
"Arguments",
")",
"(",
"cards",
"[",
"]",
"*",
"Card",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"ID",
")",
"\n",
"err",
"=",
"l",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"cards",
")",
"\n",
"for",
"i",
":=",
"range",
"cards",
"{",
"cards",
"[",
"i",
"]",
".",
"client",
"=",
"l",
".",
"client",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetCards retrieves all Cards in a List or an error if something goes wrong. | [
"GetCards",
"retrieves",
"all",
"Cards",
"in",
"a",
"List",
"or",
"an",
"error",
"if",
"something",
"goes",
"wrong",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/card.go#L467-L474 |
6,359 | adlio/trello | label.go | GetLabels | func (b *Board) GetLabels(args Arguments) (labels []*Label, err error) {
path := fmt.Sprintf("boards/%s/labels", b.ID)
err = b.client.Get(path, args, &labels)
return
} | go | func (b *Board) GetLabels(args Arguments) (labels []*Label, err error) {
path := fmt.Sprintf("boards/%s/labels", b.ID)
err = b.client.Get(path, args, &labels)
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetLabels",
"(",
"args",
"Arguments",
")",
"(",
"labels",
"[",
"]",
"*",
"Label",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"labels",
")",
"\n",
"return",
"\n",
"}"
] | // GetLabels takes Arguments and returns a slice containing all labels of the receiver board or an error. | [
"GetLabels",
"takes",
"Arguments",
"and",
"returns",
"a",
"slice",
"containing",
"all",
"labels",
"of",
"the",
"receiver",
"board",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/label.go#L30-L34 |
6,360 | adlio/trello | arguments.go | ToURLValues | func (args Arguments) ToURLValues() url.Values {
v := url.Values{}
for key, value := range args {
v.Set(key, value)
}
return v
} | go | func (args Arguments) ToURLValues() url.Values {
v := url.Values{}
for key, value := range args {
v.Set(key, value)
}
return v
} | [
"func",
"(",
"args",
"Arguments",
")",
"ToURLValues",
"(",
")",
"url",
".",
"Values",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"args",
"{",
"v",
".",
"Set",
"(",
"key",
",",
"value",
")",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
] | // ToURLValues returns the argument's URL value representation. | [
"ToURLValues",
"returns",
"the",
"argument",
"s",
"URL",
"value",
"representation",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/arguments.go#L21-L27 |
6,361 | adlio/trello | action.go | GetActions | func (b *Board) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("boards/%s/actions", b.ID)
err = b.client.Get(path, args, &actions)
return
} | go | func (b *Board) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("boards/%s/actions", b.ID)
err = b.client.Get(path, args, &actions)
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetActions",
"(",
"args",
"Arguments",
")",
"(",
"actions",
"ActionCollection",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"actions",
")",
"\n",
"return",
"\n",
"}"
] | // GetActions make a GET call for a board's actions | [
"GetActions",
"make",
"a",
"GET",
"call",
"for",
"a",
"board",
"s",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L53-L57 |
6,362 | adlio/trello | action.go | GetActions | func (l *List) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("lists/%s/actions", l.ID)
err = l.client.Get(path, args, &actions)
return
} | go | func (l *List) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("lists/%s/actions", l.ID)
err = l.client.Get(path, args, &actions)
return
} | [
"func",
"(",
"l",
"*",
"List",
")",
"GetActions",
"(",
"args",
"Arguments",
")",
"(",
"actions",
"ActionCollection",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"ID",
")",
"\n",
"err",
"=",
"l",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"actions",
")",
"\n",
"return",
"\n",
"}"
] | // GetActions makes a GET call for a list's actions | [
"GetActions",
"makes",
"a",
"GET",
"call",
"for",
"a",
"list",
"s",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L60-L64 |
6,363 | adlio/trello | action.go | GetActions | func (c *Card) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("cards/%s/actions", c.ID)
err = c.client.Get(path, args, &actions)
return
} | go | func (c *Card) GetActions(args Arguments) (actions ActionCollection, err error) {
path := fmt.Sprintf("cards/%s/actions", c.ID)
err = c.client.Get(path, args, &actions)
return
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetActions",
"(",
"args",
"Arguments",
")",
"(",
"actions",
"ActionCollection",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"err",
"=",
"c",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"actions",
")",
"\n",
"return",
"\n",
"}"
] | // GetActions makes a GET for a card's actions | [
"GetActions",
"makes",
"a",
"GET",
"for",
"a",
"card",
"s",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L67-L71 |
6,364 | adlio/trello | action.go | GetMembershipChangeActions | func (c *Card) GetMembershipChangeActions() (actions ActionCollection, err error) {
// We include updateCard:closed as if the member is implicitly removed from the card when it's closed.
// This allows us to "close out" the duration length.
return c.GetActions(Arguments{"filter": "addMemberToCard,removeMemberFromCard,updateCard:closed"})
} | go | func (c *Card) GetMembershipChangeActions() (actions ActionCollection, err error) {
// We include updateCard:closed as if the member is implicitly removed from the card when it's closed.
// This allows us to "close out" the duration length.
return c.GetActions(Arguments{"filter": "addMemberToCard,removeMemberFromCard,updateCard:closed"})
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetMembershipChangeActions",
"(",
")",
"(",
"actions",
"ActionCollection",
",",
"err",
"error",
")",
"{",
"// We include updateCard:closed as if the member is implicitly removed from the card when it's closed.",
"// This allows us to \"close out\" the duration length.",
"return",
"c",
".",
"GetActions",
"(",
"Arguments",
"{",
"\"",
"\"",
":",
"\"",
"\"",
"}",
")",
"\n",
"}"
] | // GetMembershipChangeActions makes a GET call for a card's membership-change actions | [
"GetMembershipChangeActions",
"makes",
"a",
"GET",
"call",
"for",
"a",
"card",
"s",
"membership",
"-",
"change",
"actions"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L86-L90 |
6,365 | adlio/trello | action.go | DidArchiveCard | func (a *Action) DidArchiveCard() bool {
return (a.Type == "updateCard") && a.Data != nil && a.Data.Card != nil && a.Data.Card.Closed
} | go | func (a *Action) DidArchiveCard() bool {
return (a.Type == "updateCard") && a.Data != nil && a.Data.Card != nil && a.Data.Card.Closed
} | [
"func",
"(",
"a",
"*",
"Action",
")",
"DidArchiveCard",
"(",
")",
"bool",
"{",
"return",
"(",
"a",
".",
"Type",
"==",
"\"",
"\"",
")",
"&&",
"a",
".",
"Data",
"!=",
"nil",
"&&",
"a",
".",
"Data",
".",
"Card",
"!=",
"nil",
"&&",
"a",
".",
"Data",
".",
"Card",
".",
"Closed",
"\n",
"}"
] | // DidArchiveCard returns true if the card was updated | [
"DidArchiveCard",
"returns",
"true",
"if",
"the",
"card",
"was",
"updated"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L105-L107 |
6,366 | adlio/trello | action.go | DidUnarchiveCard | func (a *Action) DidUnarchiveCard() bool {
return (a.Type == "updateCard") && a.Data != nil && a.Data.Old != nil && a.Data.Old.Closed
} | go | func (a *Action) DidUnarchiveCard() bool {
return (a.Type == "updateCard") && a.Data != nil && a.Data.Old != nil && a.Data.Old.Closed
} | [
"func",
"(",
"a",
"*",
"Action",
")",
"DidUnarchiveCard",
"(",
")",
"bool",
"{",
"return",
"(",
"a",
".",
"Type",
"==",
"\"",
"\"",
")",
"&&",
"a",
".",
"Data",
"!=",
"nil",
"&&",
"a",
".",
"Data",
".",
"Old",
"!=",
"nil",
"&&",
"a",
".",
"Data",
".",
"Old",
".",
"Closed",
"\n",
"}"
] | // DidUnarchiveCard returns true if the card was unarchived | [
"DidUnarchiveCard",
"returns",
"true",
"if",
"the",
"card",
"was",
"unarchived"
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/action.go#L110-L112 |
6,367 | adlio/trello | search.go | SearchCards | func (c *Client) SearchCards(query string, args Arguments) (cards []*Card, err error) {
args["query"] = query
args["modelTypes"] = "cards"
res := SearchResult{}
err = c.Get("search", args, &res)
cards = res.Cards
return
} | go | func (c *Client) SearchCards(query string, args Arguments) (cards []*Card, err error) {
args["query"] = query
args["modelTypes"] = "cards"
res := SearchResult{}
err = c.Get("search", args, &res)
cards = res.Cards
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchCards",
"(",
"query",
"string",
",",
"args",
"Arguments",
")",
"(",
"cards",
"[",
"]",
"*",
"Card",
",",
"err",
"error",
")",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"query",
"\n",
"args",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"res",
":=",
"SearchResult",
"{",
"}",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"args",
",",
"&",
"res",
")",
"\n",
"cards",
"=",
"res",
".",
"Cards",
"\n",
"return",
"\n",
"}"
] | // SearchCards takes a query string and Arguments and returns a slice of Cards or an error. | [
"SearchCards",
"takes",
"a",
"query",
"string",
"and",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"Cards",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/search.go#L38-L45 |
6,368 | adlio/trello | search.go | SearchBoards | func (c *Client) SearchBoards(query string, args Arguments) (boards []*Board, err error) {
args["query"] = query
args["modelTypes"] = "boards"
res := SearchResult{}
err = c.Get("search", args, &res)
boards = res.Boards
for _, board := range boards {
board.client = c
}
return
} | go | func (c *Client) SearchBoards(query string, args Arguments) (boards []*Board, err error) {
args["query"] = query
args["modelTypes"] = "boards"
res := SearchResult{}
err = c.Get("search", args, &res)
boards = res.Boards
for _, board := range boards {
board.client = c
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchBoards",
"(",
"query",
"string",
",",
"args",
"Arguments",
")",
"(",
"boards",
"[",
"]",
"*",
"Board",
",",
"err",
"error",
")",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"query",
"\n",
"args",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"res",
":=",
"SearchResult",
"{",
"}",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"args",
",",
"&",
"res",
")",
"\n",
"boards",
"=",
"res",
".",
"Boards",
"\n",
"for",
"_",
",",
"board",
":=",
"range",
"boards",
"{",
"board",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // SearchBoards takes a query string and Arguments and returns a slice of Boards or an error. | [
"SearchBoards",
"takes",
"a",
"query",
"string",
"and",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"Boards",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/search.go#L48-L58 |
6,369 | adlio/trello | search.go | SearchMembers | func (c *Client) SearchMembers(query string, args Arguments) (members []*Member, err error) {
args["query"] = query
err = c.Get("search/members", args, &members)
return
} | go | func (c *Client) SearchMembers(query string, args Arguments) (members []*Member, err error) {
args["query"] = query
err = c.Get("search/members", args, &members)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchMembers",
"(",
"query",
"string",
",",
"args",
"Arguments",
")",
"(",
"members",
"[",
"]",
"*",
"Member",
",",
"err",
"error",
")",
"{",
"args",
"[",
"\"",
"\"",
"]",
"=",
"query",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"\"",
"\"",
",",
"args",
",",
"&",
"members",
")",
"\n",
"return",
"\n",
"}"
] | // SearchMembers takes a query string and Arguments and returns a slice of Members or an error. | [
"SearchMembers",
"takes",
"a",
"query",
"string",
"and",
"Arguments",
"and",
"returns",
"a",
"slice",
"of",
"Members",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/search.go#L61-L65 |
6,370 | adlio/trello | errors.go | IsRateLimit | func IsRateLimit(err error) bool {
re, ok := err.(rateLimitError)
return ok && re.IsRateLimit()
} | go | func IsRateLimit(err error) bool {
re, ok := err.(rateLimitError)
return ok && re.IsRateLimit()
} | [
"func",
"IsRateLimit",
"(",
"err",
"error",
")",
"bool",
"{",
"re",
",",
"ok",
":=",
"err",
".",
"(",
"rateLimitError",
")",
"\n",
"return",
"ok",
"&&",
"re",
".",
"IsRateLimit",
"(",
")",
"\n",
"}"
] | // IsRateLimit takes an error and returns true exactly if the error is a rate-limit error. | [
"IsRateLimit",
"takes",
"an",
"error",
"and",
"returns",
"true",
"exactly",
"if",
"the",
"error",
"is",
"a",
"rate",
"-",
"limit",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/errors.go#L43-L46 |
6,371 | adlio/trello | errors.go | IsNotFound | func IsNotFound(err error) bool {
nf, ok := err.(notFoundError)
return ok && nf.IsNotFound()
} | go | func IsNotFound(err error) bool {
nf, ok := err.(notFoundError)
return ok && nf.IsNotFound()
} | [
"func",
"IsNotFound",
"(",
"err",
"error",
")",
"bool",
"{",
"nf",
",",
"ok",
":=",
"err",
".",
"(",
"notFoundError",
")",
"\n",
"return",
"ok",
"&&",
"nf",
".",
"IsNotFound",
"(",
")",
"\n",
"}"
] | // IsNotFound takes an error and returns true exactly if the error is a not-found error. | [
"IsNotFound",
"takes",
"an",
"error",
"and",
"returns",
"true",
"exactly",
"if",
"the",
"error",
"is",
"a",
"not",
"-",
"found",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/errors.go#L49-L52 |
6,372 | adlio/trello | errors.go | IsPermissionDenied | func IsPermissionDenied(err error) bool {
pd, ok := err.(permissionDeniedError)
return ok && pd.IsPermissionDenied()
} | go | func IsPermissionDenied(err error) bool {
pd, ok := err.(permissionDeniedError)
return ok && pd.IsPermissionDenied()
} | [
"func",
"IsPermissionDenied",
"(",
"err",
"error",
")",
"bool",
"{",
"pd",
",",
"ok",
":=",
"err",
".",
"(",
"permissionDeniedError",
")",
"\n",
"return",
"ok",
"&&",
"pd",
".",
"IsPermissionDenied",
"(",
")",
"\n",
"}"
] | // IsPermissionDenied takes an error and returns true exactly if the error is a
// permission-denied error. | [
"IsPermissionDenied",
"takes",
"an",
"error",
"and",
"returns",
"true",
"exactly",
"if",
"the",
"error",
"is",
"a",
"permission",
"-",
"denied",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/errors.go#L56-L59 |
6,373 | adlio/trello | list.go | CreatedAt | func (l *List) CreatedAt() time.Time {
t, _ := IDToTime(l.ID)
return t
} | go | func (l *List) CreatedAt() time.Time {
t, _ := IDToTime(l.ID)
return t
} | [
"func",
"(",
"l",
"*",
"List",
")",
"CreatedAt",
"(",
")",
"time",
".",
"Time",
"{",
"t",
",",
"_",
":=",
"IDToTime",
"(",
"l",
".",
"ID",
")",
"\n",
"return",
"t",
"\n",
"}"
] | // CreatedAt returns the time.Time from the list's id. | [
"CreatedAt",
"returns",
"the",
"time",
".",
"Time",
"from",
"the",
"list",
"s",
"id",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list.go#L27-L30 |
6,374 | adlio/trello | list.go | GetList | func (c *Client) GetList(listID string, args Arguments) (list *List, err error) {
path := fmt.Sprintf("lists/%s", listID)
err = c.Get(path, args, &list)
if list != nil {
list.client = c
for i := range list.Cards {
list.Cards[i].client = c
}
}
return
} | go | func (c *Client) GetList(listID string, args Arguments) (list *List, err error) {
path := fmt.Sprintf("lists/%s", listID)
err = c.Get(path, args, &list)
if list != nil {
list.client = c
for i := range list.Cards {
list.Cards[i].client = c
}
}
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetList",
"(",
"listID",
"string",
",",
"args",
"Arguments",
")",
"(",
"list",
"*",
"List",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"listID",
")",
"\n",
"err",
"=",
"c",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"list",
")",
"\n",
"if",
"list",
"!=",
"nil",
"{",
"list",
".",
"client",
"=",
"c",
"\n",
"for",
"i",
":=",
"range",
"list",
".",
"Cards",
"{",
"list",
".",
"Cards",
"[",
"i",
"]",
".",
"client",
"=",
"c",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetList takes a list's id and Arguments and returns the matching list. | [
"GetList",
"takes",
"a",
"list",
"s",
"id",
"and",
"Arguments",
"and",
"returns",
"the",
"matching",
"list",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list.go#L33-L43 |
6,375 | adlio/trello | list.go | GetLists | func (b *Board) GetLists(args Arguments) (lists []*List, err error) {
path := fmt.Sprintf("boards/%s/lists", b.ID)
err = b.client.Get(path, args, &lists)
for i := range lists {
lists[i].client = b.client
for j := range lists[i].Cards {
lists[i].Cards[j].client = b.client
}
}
return
} | go | func (b *Board) GetLists(args Arguments) (lists []*List, err error) {
path := fmt.Sprintf("boards/%s/lists", b.ID)
err = b.client.Get(path, args, &lists)
for i := range lists {
lists[i].client = b.client
for j := range lists[i].Cards {
lists[i].Cards[j].client = b.client
}
}
return
} | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetLists",
"(",
"args",
"Arguments",
")",
"(",
"lists",
"[",
"]",
"*",
"List",
",",
"err",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"ID",
")",
"\n",
"err",
"=",
"b",
".",
"client",
".",
"Get",
"(",
"path",
",",
"args",
",",
"&",
"lists",
")",
"\n",
"for",
"i",
":=",
"range",
"lists",
"{",
"lists",
"[",
"i",
"]",
".",
"client",
"=",
"b",
".",
"client",
"\n",
"for",
"j",
":=",
"range",
"lists",
"[",
"i",
"]",
".",
"Cards",
"{",
"lists",
"[",
"i",
"]",
".",
"Cards",
"[",
"j",
"]",
".",
"client",
"=",
"b",
".",
"client",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // GetLists takes Arguments and returns the lists of the receiver Board. | [
"GetLists",
"takes",
"Arguments",
"and",
"returns",
"the",
"lists",
"of",
"the",
"receiver",
"Board",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list.go#L46-L56 |
6,376 | adlio/trello | trello.go | IDToTime | func IDToTime(id string) (t time.Time, err error) {
if id == "" {
return time.Time{}, nil
}
// The first 8 characters in the object ID are a Unix timestamp
ts, err := strconv.ParseUint(id[:8], 16, 64)
if err != nil {
err = errors.Wrapf(err, "ID '%s' failed to convert to timestamp.", id)
} else {
t = time.Unix(int64(ts), 0)
}
return
} | go | func IDToTime(id string) (t time.Time, err error) {
if id == "" {
return time.Time{}, nil
}
// The first 8 characters in the object ID are a Unix timestamp
ts, err := strconv.ParseUint(id[:8], 16, 64)
if err != nil {
err = errors.Wrapf(err, "ID '%s' failed to convert to timestamp.", id)
} else {
t = time.Unix(int64(ts), 0)
}
return
} | [
"func",
"IDToTime",
"(",
"id",
"string",
")",
"(",
"t",
"time",
".",
"Time",
",",
"err",
"error",
")",
"{",
"if",
"id",
"==",
"\"",
"\"",
"{",
"return",
"time",
".",
"Time",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"// The first 8 characters in the object ID are a Unix timestamp",
"ts",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"id",
"[",
":",
"8",
"]",
",",
"16",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}",
"else",
"{",
"t",
"=",
"time",
".",
"Unix",
"(",
"int64",
"(",
"ts",
")",
",",
"0",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // IDToTime is a convenience function. It takes a Trello ID string and
// extracts the encoded create time as time.Time or an error. | [
"IDToTime",
"is",
"a",
"convenience",
"function",
".",
"It",
"takes",
"a",
"Trello",
"ID",
"string",
"and",
"extracts",
"the",
"encoded",
"create",
"time",
"as",
"time",
".",
"Time",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/trello.go#L17-L29 |
6,377 | adlio/trello | list-duration.go | AddDuration | func (l *ListDuration) AddDuration(d time.Duration) {
l.Duration = l.Duration + d
l.TimesInList++
} | go | func (l *ListDuration) AddDuration(d time.Duration) {
l.Duration = l.Duration + d
l.TimesInList++
} | [
"func",
"(",
"l",
"*",
"ListDuration",
")",
"AddDuration",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"l",
".",
"Duration",
"=",
"l",
".",
"Duration",
"+",
"d",
"\n",
"l",
".",
"TimesInList",
"++",
"\n",
"}"
] | // AddDuration takes a duration and adds it to the ListDuration's Duration.
// Also increments TimesInList. | [
"AddDuration",
"takes",
"a",
"duration",
"and",
"adds",
"it",
"to",
"the",
"ListDuration",
"s",
"Duration",
".",
"Also",
"increments",
"TimesInList",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list-duration.go#L21-L24 |
6,378 | adlio/trello | list-duration.go | GetListDurations | func (c *Card) GetListDurations() (durations []*ListDuration, err error) {
var actions ActionCollection
if len(c.Actions) == 0 {
// Get all actions which affected the Card's List
c.client.log("[trello] GetListDurations() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
actions, err = c.GetListChangeActions()
if err != nil {
err = errors.Wrap(err, "GetListChangeActions() call failed.")
return
}
} else {
actions = c.Actions.FilterToListChangeActions()
}
return actions.GetListDurations()
} | go | func (c *Card) GetListDurations() (durations []*ListDuration, err error) {
var actions ActionCollection
if len(c.Actions) == 0 {
// Get all actions which affected the Card's List
c.client.log("[trello] GetListDurations() called on card '%s' without any Card.Actions. Fetching fresh.", c.ID)
actions, err = c.GetListChangeActions()
if err != nil {
err = errors.Wrap(err, "GetListChangeActions() call failed.")
return
}
} else {
actions = c.Actions.FilterToListChangeActions()
}
return actions.GetListDurations()
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"GetListDurations",
"(",
")",
"(",
"durations",
"[",
"]",
"*",
"ListDuration",
",",
"err",
"error",
")",
"{",
"var",
"actions",
"ActionCollection",
"\n",
"if",
"len",
"(",
"c",
".",
"Actions",
")",
"==",
"0",
"{",
"// Get all actions which affected the Card's List",
"c",
".",
"client",
".",
"log",
"(",
"\"",
"\"",
",",
"c",
".",
"ID",
")",
"\n",
"actions",
",",
"err",
"=",
"c",
".",
"GetListChangeActions",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"else",
"{",
"actions",
"=",
"c",
".",
"Actions",
".",
"FilterToListChangeActions",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"actions",
".",
"GetListDurations",
"(",
")",
"\n",
"}"
] | // GetListDurations analyses a Card's actions to figure out how long it was in each List.
// It returns a slice of the ListDurations, one Duration per list, or an error. | [
"GetListDurations",
"analyses",
"a",
"Card",
"s",
"actions",
"to",
"figure",
"out",
"how",
"long",
"it",
"was",
"in",
"each",
"List",
".",
"It",
"returns",
"a",
"slice",
"of",
"the",
"ListDurations",
"one",
"Duration",
"per",
"list",
"or",
"an",
"error",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list-duration.go#L28-L44 |
6,379 | adlio/trello | list-duration.go | GetListDurations | func (actions ActionCollection) GetListDurations() (durations []*ListDuration, err error) {
sort.Sort(actions)
var prevTime time.Time
var prevList *List
durs := make(map[string]*ListDuration)
for _, action := range actions {
if action.DidChangeListForCard() {
if prevList != nil {
duration := action.Date.Sub(prevTime)
_, durExists := durs[prevList.ID]
if !durExists {
durs[prevList.ID] = &ListDuration{ListID: prevList.ID, ListName: prevList.Name, Duration: duration, TimesInList: 1, FirstEntered: prevTime}
} else {
durs[prevList.ID].AddDuration(duration)
}
}
prevList = ListAfterAction(action)
prevTime = action.Date
}
}
if prevList != nil {
duration := time.Now().Sub(prevTime)
_, durExists := durs[prevList.ID]
if !durExists {
durs[prevList.ID] = &ListDuration{ListID: prevList.ID, ListName: prevList.Name, Duration: duration, TimesInList: 1, FirstEntered: prevTime}
} else {
durs[prevList.ID].AddDuration(duration)
}
}
durations = make([]*ListDuration, 0, len(durs))
for _, ld := range durs {
durations = append(durations, ld)
}
sort.Sort(ByFirstEntered(durations))
return durations, nil
} | go | func (actions ActionCollection) GetListDurations() (durations []*ListDuration, err error) {
sort.Sort(actions)
var prevTime time.Time
var prevList *List
durs := make(map[string]*ListDuration)
for _, action := range actions {
if action.DidChangeListForCard() {
if prevList != nil {
duration := action.Date.Sub(prevTime)
_, durExists := durs[prevList.ID]
if !durExists {
durs[prevList.ID] = &ListDuration{ListID: prevList.ID, ListName: prevList.Name, Duration: duration, TimesInList: 1, FirstEntered: prevTime}
} else {
durs[prevList.ID].AddDuration(duration)
}
}
prevList = ListAfterAction(action)
prevTime = action.Date
}
}
if prevList != nil {
duration := time.Now().Sub(prevTime)
_, durExists := durs[prevList.ID]
if !durExists {
durs[prevList.ID] = &ListDuration{ListID: prevList.ID, ListName: prevList.Name, Duration: duration, TimesInList: 1, FirstEntered: prevTime}
} else {
durs[prevList.ID].AddDuration(duration)
}
}
durations = make([]*ListDuration, 0, len(durs))
for _, ld := range durs {
durations = append(durations, ld)
}
sort.Sort(ByFirstEntered(durations))
return durations, nil
} | [
"func",
"(",
"actions",
"ActionCollection",
")",
"GetListDurations",
"(",
")",
"(",
"durations",
"[",
"]",
"*",
"ListDuration",
",",
"err",
"error",
")",
"{",
"sort",
".",
"Sort",
"(",
"actions",
")",
"\n\n",
"var",
"prevTime",
"time",
".",
"Time",
"\n",
"var",
"prevList",
"*",
"List",
"\n\n",
"durs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"ListDuration",
")",
"\n",
"for",
"_",
",",
"action",
":=",
"range",
"actions",
"{",
"if",
"action",
".",
"DidChangeListForCard",
"(",
")",
"{",
"if",
"prevList",
"!=",
"nil",
"{",
"duration",
":=",
"action",
".",
"Date",
".",
"Sub",
"(",
"prevTime",
")",
"\n",
"_",
",",
"durExists",
":=",
"durs",
"[",
"prevList",
".",
"ID",
"]",
"\n",
"if",
"!",
"durExists",
"{",
"durs",
"[",
"prevList",
".",
"ID",
"]",
"=",
"&",
"ListDuration",
"{",
"ListID",
":",
"prevList",
".",
"ID",
",",
"ListName",
":",
"prevList",
".",
"Name",
",",
"Duration",
":",
"duration",
",",
"TimesInList",
":",
"1",
",",
"FirstEntered",
":",
"prevTime",
"}",
"\n",
"}",
"else",
"{",
"durs",
"[",
"prevList",
".",
"ID",
"]",
".",
"AddDuration",
"(",
"duration",
")",
"\n",
"}",
"\n",
"}",
"\n",
"prevList",
"=",
"ListAfterAction",
"(",
"action",
")",
"\n",
"prevTime",
"=",
"action",
".",
"Date",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"prevList",
"!=",
"nil",
"{",
"duration",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"prevTime",
")",
"\n",
"_",
",",
"durExists",
":=",
"durs",
"[",
"prevList",
".",
"ID",
"]",
"\n",
"if",
"!",
"durExists",
"{",
"durs",
"[",
"prevList",
".",
"ID",
"]",
"=",
"&",
"ListDuration",
"{",
"ListID",
":",
"prevList",
".",
"ID",
",",
"ListName",
":",
"prevList",
".",
"Name",
",",
"Duration",
":",
"duration",
",",
"TimesInList",
":",
"1",
",",
"FirstEntered",
":",
"prevTime",
"}",
"\n",
"}",
"else",
"{",
"durs",
"[",
"prevList",
".",
"ID",
"]",
".",
"AddDuration",
"(",
"duration",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"durations",
"=",
"make",
"(",
"[",
"]",
"*",
"ListDuration",
",",
"0",
",",
"len",
"(",
"durs",
")",
")",
"\n",
"for",
"_",
",",
"ld",
":=",
"range",
"durs",
"{",
"durations",
"=",
"append",
"(",
"durations",
",",
"ld",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"ByFirstEntered",
"(",
"durations",
")",
")",
"\n\n",
"return",
"durations",
",",
"nil",
"\n",
"}"
] | // GetListDurations returns a slice of ListDurations based on the receiver Actions. | [
"GetListDurations",
"returns",
"a",
"slice",
"of",
"ListDurations",
"based",
"on",
"the",
"receiver",
"Actions",
"."
] | 5b31feeddcaa230cf9ee2355b4a27e03dca52142 | https://github.com/adlio/trello/blob/5b31feeddcaa230cf9ee2355b4a27e03dca52142/list-duration.go#L47-L87 |
6,380 | AcalephStorage/consul-alerts | consul/interface.go | DefaultAlertConfig | func DefaultAlertConfig() *ConsulAlertConfig {
checks := &ChecksConfig{
Enabled: true,
ChangeThreshold: 60,
}
events := &EventsConfig{
Enabled: true,
Handlers: []string{},
}
email := ¬ifier.EmailNotifier{
ClusterName: "Consul-Alerts",
Enabled: false,
SenderAlias: "Consul Alerts",
Receivers: []string{},
}
log := ¬ifier.LogNotifier{
Enabled: true,
Path: "/tmp/consul-notifications.log",
}
influxdb := ¬ifier.InfluxdbNotifier{
Enabled: false,
SeriesName: "consul-alerts",
}
slack := ¬ifier.SlackNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
mattermost := ¬ifier.MattermostNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
mattermostWebhook := ¬ifier.MattermostWebhookNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
pagerduty := ¬ifier.PagerDutyNotifier{
Enabled: false,
}
hipchat := ¬ifier.HipChatNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
opsgenie := ¬ifier.OpsGenieNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
awsSns := ¬ifier.AwsSnsNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
victorOps := ¬ifier.VictorOpsNotifier{
Enabled: false,
}
ilert := ¬ifier.ILertNotifier{
Enabled: false,
IncidentKeyTemplate: "{{.Node}}:{{.Service}}:{{.Check}}",
}
notifiers := ¬ifier.Notifiers{
Email: email,
Log: log,
Influxdb: influxdb,
Slack: slack,
Mattermost: mattermost,
MattermostWebhook: mattermostWebhook,
PagerDuty: pagerduty,
HipChat: hipchat,
OpsGenie: opsgenie,
AwsSns: awsSns,
VictorOps: victorOps,
ILert: ilert,
Custom: []string{},
}
return &ConsulAlertConfig{
Checks: checks,
Events: events,
Notifiers: notifiers,
}
} | go | func DefaultAlertConfig() *ConsulAlertConfig {
checks := &ChecksConfig{
Enabled: true,
ChangeThreshold: 60,
}
events := &EventsConfig{
Enabled: true,
Handlers: []string{},
}
email := ¬ifier.EmailNotifier{
ClusterName: "Consul-Alerts",
Enabled: false,
SenderAlias: "Consul Alerts",
Receivers: []string{},
}
log := ¬ifier.LogNotifier{
Enabled: true,
Path: "/tmp/consul-notifications.log",
}
influxdb := ¬ifier.InfluxdbNotifier{
Enabled: false,
SeriesName: "consul-alerts",
}
slack := ¬ifier.SlackNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
mattermost := ¬ifier.MattermostNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
mattermostWebhook := ¬ifier.MattermostWebhookNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
pagerduty := ¬ifier.PagerDutyNotifier{
Enabled: false,
}
hipchat := ¬ifier.HipChatNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
opsgenie := ¬ifier.OpsGenieNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
awsSns := ¬ifier.AwsSnsNotifier{
Enabled: false,
ClusterName: "Consul-Alerts",
}
victorOps := ¬ifier.VictorOpsNotifier{
Enabled: false,
}
ilert := ¬ifier.ILertNotifier{
Enabled: false,
IncidentKeyTemplate: "{{.Node}}:{{.Service}}:{{.Check}}",
}
notifiers := ¬ifier.Notifiers{
Email: email,
Log: log,
Influxdb: influxdb,
Slack: slack,
Mattermost: mattermost,
MattermostWebhook: mattermostWebhook,
PagerDuty: pagerduty,
HipChat: hipchat,
OpsGenie: opsgenie,
AwsSns: awsSns,
VictorOps: victorOps,
ILert: ilert,
Custom: []string{},
}
return &ConsulAlertConfig{
Checks: checks,
Events: events,
Notifiers: notifiers,
}
} | [
"func",
"DefaultAlertConfig",
"(",
")",
"*",
"ConsulAlertConfig",
"{",
"checks",
":=",
"&",
"ChecksConfig",
"{",
"Enabled",
":",
"true",
",",
"ChangeThreshold",
":",
"60",
",",
"}",
"\n\n",
"events",
":=",
"&",
"EventsConfig",
"{",
"Enabled",
":",
"true",
",",
"Handlers",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
"email",
":=",
"&",
"notifier",
".",
"EmailNotifier",
"{",
"ClusterName",
":",
"\"",
"\"",
",",
"Enabled",
":",
"false",
",",
"SenderAlias",
":",
"\"",
"\"",
",",
"Receivers",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
"log",
":=",
"&",
"notifier",
".",
"LogNotifier",
"{",
"Enabled",
":",
"true",
",",
"Path",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"influxdb",
":=",
"&",
"notifier",
".",
"InfluxdbNotifier",
"{",
"Enabled",
":",
"false",
",",
"SeriesName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"slack",
":=",
"&",
"notifier",
".",
"SlackNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"mattermost",
":=",
"&",
"notifier",
".",
"MattermostNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"mattermostWebhook",
":=",
"&",
"notifier",
".",
"MattermostWebhookNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"pagerduty",
":=",
"&",
"notifier",
".",
"PagerDutyNotifier",
"{",
"Enabled",
":",
"false",
",",
"}",
"\n\n",
"hipchat",
":=",
"&",
"notifier",
".",
"HipChatNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"opsgenie",
":=",
"&",
"notifier",
".",
"OpsGenieNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"awsSns",
":=",
"&",
"notifier",
".",
"AwsSnsNotifier",
"{",
"Enabled",
":",
"false",
",",
"ClusterName",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"victorOps",
":=",
"&",
"notifier",
".",
"VictorOpsNotifier",
"{",
"Enabled",
":",
"false",
",",
"}",
"\n\n",
"ilert",
":=",
"&",
"notifier",
".",
"ILertNotifier",
"{",
"Enabled",
":",
"false",
",",
"IncidentKeyTemplate",
":",
"\"",
"\"",
",",
"}",
"\n\n",
"notifiers",
":=",
"&",
"notifier",
".",
"Notifiers",
"{",
"Email",
":",
"email",
",",
"Log",
":",
"log",
",",
"Influxdb",
":",
"influxdb",
",",
"Slack",
":",
"slack",
",",
"Mattermost",
":",
"mattermost",
",",
"MattermostWebhook",
":",
"mattermostWebhook",
",",
"PagerDuty",
":",
"pagerduty",
",",
"HipChat",
":",
"hipchat",
",",
"OpsGenie",
":",
"opsgenie",
",",
"AwsSns",
":",
"awsSns",
",",
"VictorOps",
":",
"victorOps",
",",
"ILert",
":",
"ilert",
",",
"Custom",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
"return",
"&",
"ConsulAlertConfig",
"{",
"Checks",
":",
"checks",
",",
"Events",
":",
"events",
",",
"Notifiers",
":",
"notifiers",
",",
"}",
"\n",
"}"
] | // DefaultAlertConfig loads default config settings | [
"DefaultAlertConfig",
"loads",
"default",
"config",
"settings"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/interface.go#L105-L198 |
6,381 | AcalephStorage/consul-alerts | notifier/ilert-notifier.go | sendEvent | func (il *ILertNotifier) sendEvent(event iLertEvent) error {
body, err := json.Marshal(event)
if err != nil {
return err
}
res, err := http.Post(apiEndpoint, "application/json", bytes.NewBuffer(body))
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != 200 {
body, _ := ioutil.ReadAll(res.Body)
return errors.New(fmt.Sprintf("Unexpected HTTP status code: %d (%s)", res.StatusCode, string(body)))
}
return nil
} | go | func (il *ILertNotifier) sendEvent(event iLertEvent) error {
body, err := json.Marshal(event)
if err != nil {
return err
}
res, err := http.Post(apiEndpoint, "application/json", bytes.NewBuffer(body))
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != 200 {
body, _ := ioutil.ReadAll(res.Body)
return errors.New(fmt.Sprintf("Unexpected HTTP status code: %d (%s)", res.StatusCode, string(body)))
}
return nil
} | [
"func",
"(",
"il",
"*",
"ILertNotifier",
")",
"sendEvent",
"(",
"event",
"iLertEvent",
")",
"error",
"{",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"event",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"http",
".",
"Post",
"(",
"apiEndpoint",
",",
"\"",
"\"",
",",
"bytes",
".",
"NewBuffer",
"(",
"body",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"res",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"if",
"res",
".",
"StatusCode",
"!=",
"200",
"{",
"body",
",",
"_",
":=",
"ioutil",
".",
"ReadAll",
"(",
"res",
".",
"Body",
")",
"\n",
"return",
"errors",
".",
"New",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"res",
".",
"StatusCode",
",",
"string",
"(",
"body",
")",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | //sendEvent builds the event JSON and sends it to the iLert API | [
"sendEvent",
"builds",
"the",
"event",
"JSON",
"and",
"sends",
"it",
"to",
"the",
"iLert",
"API"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/notifier/ilert-notifier.go#L96-L115 |
6,382 | AcalephStorage/consul-alerts | consul/client.go | GetReminders | func (c *ConsulAlertClient) GetReminders() []notifier.Message {
remindersList, _, _ := c.api.KV().List("consul-alerts/reminders", nil)
var messages []notifier.Message
for _, kvpair := range remindersList {
var message notifier.Message
json.Unmarshal(kvpair.Value, &message)
messages = append(messages, message)
}
log.Println("Getting reminders")
return messages
} | go | func (c *ConsulAlertClient) GetReminders() []notifier.Message {
remindersList, _, _ := c.api.KV().List("consul-alerts/reminders", nil)
var messages []notifier.Message
for _, kvpair := range remindersList {
var message notifier.Message
json.Unmarshal(kvpair.Value, &message)
messages = append(messages, message)
}
log.Println("Getting reminders")
return messages
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"GetReminders",
"(",
")",
"[",
"]",
"notifier",
".",
"Message",
"{",
"remindersList",
",",
"_",
",",
"_",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"List",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"var",
"messages",
"[",
"]",
"notifier",
".",
"Message",
"\n",
"for",
"_",
",",
"kvpair",
":=",
"range",
"remindersList",
"{",
"var",
"message",
"notifier",
".",
"Message",
"\n",
"json",
".",
"Unmarshal",
"(",
"kvpair",
".",
"Value",
",",
"&",
"message",
")",
"\n",
"messages",
"=",
"append",
"(",
"messages",
",",
"message",
")",
"\n",
"}",
"\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"messages",
"\n",
"}"
] | // GetReminders returns list of reminders | [
"GetReminders",
"returns",
"list",
"of",
"reminders"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L393-L403 |
6,383 | AcalephStorage/consul-alerts | consul/client.go | SetReminder | func (c *ConsulAlertClient) SetReminder(m notifier.Message) {
data, _ := json.Marshal(m)
key := fmt.Sprintf("consul-alerts/reminders/%s/%s", m.Node, m.CheckId)
c.api.KV().Put(&consulapi.KVPair{Key: key, Value: data}, nil)
log.Println("Setting reminder for node: ", m.Node)
} | go | func (c *ConsulAlertClient) SetReminder(m notifier.Message) {
data, _ := json.Marshal(m)
key := fmt.Sprintf("consul-alerts/reminders/%s/%s", m.Node, m.CheckId)
c.api.KV().Put(&consulapi.KVPair{Key: key, Value: data}, nil)
log.Println("Setting reminder for node: ", m.Node)
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"SetReminder",
"(",
"m",
"notifier",
".",
"Message",
")",
"{",
"data",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"m",
")",
"\n",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
".",
"Node",
",",
"m",
".",
"CheckId",
")",
"\n",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Put",
"(",
"&",
"consulapi",
".",
"KVPair",
"{",
"Key",
":",
"key",
",",
"Value",
":",
"data",
"}",
",",
"nil",
")",
"\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"m",
".",
"Node",
")",
"\n",
"}"
] | // SetReminder sets a reminder | [
"SetReminder",
"sets",
"a",
"reminder"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L406-L411 |
6,384 | AcalephStorage/consul-alerts | consul/client.go | DeleteReminder | func (c *ConsulAlertClient) DeleteReminder(node string, checkid string) {
key := fmt.Sprintf("consul-alerts/reminders/%s/%s", node, checkid)
c.api.KV().Delete(key, nil)
log.Println("Deleting reminder for node: ", node)
} | go | func (c *ConsulAlertClient) DeleteReminder(node string, checkid string) {
key := fmt.Sprintf("consul-alerts/reminders/%s/%s", node, checkid)
c.api.KV().Delete(key, nil)
log.Println("Deleting reminder for node: ", node)
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"DeleteReminder",
"(",
"node",
"string",
",",
"checkid",
"string",
")",
"{",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"node",
",",
"checkid",
")",
"\n",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Delete",
"(",
"key",
",",
"nil",
")",
"\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"node",
")",
"\n",
"}"
] | // DeleteReminder deletes a reminder | [
"DeleteReminder",
"deletes",
"a",
"reminder"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L414-L418 |
6,385 | AcalephStorage/consul-alerts | consul/client.go | NewAlerts | func (c *ConsulAlertClient) NewAlerts() []Check {
allChecks, _, _ := c.api.KV().List("consul-alerts/checks", nil)
var alerts []Check
for _, kvpair := range allChecks {
key := kvpair.Key
if strings.HasSuffix(key, "/") {
continue
}
var status Status
json.Unmarshal(kvpair.Value, &status)
if status.ForNotification {
status.ForNotification = false
data, _ := json.Marshal(status)
c.api.KV().Put(&consulapi.KVPair{Key: key, Value: data}, nil)
// check if blacklisted
if !c.IsBlacklisted(status.HealthCheck) {
alerts = append(alerts, *status.HealthCheck)
}
}
}
return alerts
} | go | func (c *ConsulAlertClient) NewAlerts() []Check {
allChecks, _, _ := c.api.KV().List("consul-alerts/checks", nil)
var alerts []Check
for _, kvpair := range allChecks {
key := kvpair.Key
if strings.HasSuffix(key, "/") {
continue
}
var status Status
json.Unmarshal(kvpair.Value, &status)
if status.ForNotification {
status.ForNotification = false
data, _ := json.Marshal(status)
c.api.KV().Put(&consulapi.KVPair{Key: key, Value: data}, nil)
// check if blacklisted
if !c.IsBlacklisted(status.HealthCheck) {
alerts = append(alerts, *status.HealthCheck)
}
}
}
return alerts
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"NewAlerts",
"(",
")",
"[",
"]",
"Check",
"{",
"allChecks",
",",
"_",
",",
"_",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"List",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"var",
"alerts",
"[",
"]",
"Check",
"\n",
"for",
"_",
",",
"kvpair",
":=",
"range",
"allChecks",
"{",
"key",
":=",
"kvpair",
".",
"Key",
"\n",
"if",
"strings",
".",
"HasSuffix",
"(",
"key",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n",
"var",
"status",
"Status",
"\n",
"json",
".",
"Unmarshal",
"(",
"kvpair",
".",
"Value",
",",
"&",
"status",
")",
"\n",
"if",
"status",
".",
"ForNotification",
"{",
"status",
".",
"ForNotification",
"=",
"false",
"\n",
"data",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"status",
")",
"\n",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Put",
"(",
"&",
"consulapi",
".",
"KVPair",
"{",
"Key",
":",
"key",
",",
"Value",
":",
"data",
"}",
",",
"nil",
")",
"\n",
"// check if blacklisted",
"if",
"!",
"c",
".",
"IsBlacklisted",
"(",
"status",
".",
"HealthCheck",
")",
"{",
"alerts",
"=",
"append",
"(",
"alerts",
",",
"*",
"status",
".",
"HealthCheck",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"alerts",
"\n",
"}"
] | // NewAlerts returns a list of checks marked for notification | [
"NewAlerts",
"returns",
"a",
"list",
"of",
"checks",
"marked",
"for",
"notification"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L421-L443 |
6,386 | AcalephStorage/consul-alerts | consul/client.go | CustomNotifiers | func (c *ConsulAlertClient) CustomNotifiers() (customNotifs map[string]string) {
if kvPairs, _, err := c.api.KV().List("consul-alerts/config/notifiers/custom", nil); err == nil {
customNotifs = make(map[string]string)
for _, kvPair := range kvPairs {
rp := regexp.MustCompile("/([^/]*)$")
match := rp.FindStringSubmatch(kvPair.Key)
custNotifName := match[1]
if custNotifName == "" {
continue
}
customNotifs[custNotifName] = string(kvPair.Value)
}
}
return customNotifs
} | go | func (c *ConsulAlertClient) CustomNotifiers() (customNotifs map[string]string) {
if kvPairs, _, err := c.api.KV().List("consul-alerts/config/notifiers/custom", nil); err == nil {
customNotifs = make(map[string]string)
for _, kvPair := range kvPairs {
rp := regexp.MustCompile("/([^/]*)$")
match := rp.FindStringSubmatch(kvPair.Key)
custNotifName := match[1]
if custNotifName == "" {
continue
}
customNotifs[custNotifName] = string(kvPair.Value)
}
}
return customNotifs
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"CustomNotifiers",
"(",
")",
"(",
"customNotifs",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"if",
"kvPairs",
",",
"_",
",",
"err",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"List",
"(",
"\"",
"\"",
",",
"nil",
")",
";",
"err",
"==",
"nil",
"{",
"customNotifs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"_",
",",
"kvPair",
":=",
"range",
"kvPairs",
"{",
"rp",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n",
"match",
":=",
"rp",
".",
"FindStringSubmatch",
"(",
"kvPair",
".",
"Key",
")",
"\n",
"custNotifName",
":=",
"match",
"[",
"1",
"]",
"\n",
"if",
"custNotifName",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"customNotifs",
"[",
"custNotifName",
"]",
"=",
"string",
"(",
"kvPair",
".",
"Value",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"customNotifs",
"\n",
"}"
] | // CustomNotifiers returns a map of all custom notifiers and command path as the key value | [
"CustomNotifiers",
"returns",
"a",
"map",
"of",
"all",
"custom",
"notifiers",
"and",
"command",
"path",
"as",
"the",
"key",
"value"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L446-L460 |
6,387 | AcalephStorage/consul-alerts | consul/client.go | getProfileForEntity | func (c *ConsulAlertClient) getProfileForEntity(entity string, id string) string {
kvPair, _, _ := c.api.KV().Get(
fmt.Sprintf("consul-alerts/config/notif-selection/%ss/%s",
entity, id), nil)
if kvPair != nil {
log.Printf("%s selection key found.\n", entity)
return string(kvPair.Value)
} else if kvPair, _, _ := c.api.KV().Get(
fmt.Sprintf("consul-alerts/config/notif-selection/%ss", entity),
nil); kvPair != nil {
var regexMap map[string]string
json.Unmarshal(kvPair.Value, ®exMap)
for pattern, profile := range regexMap {
matched, err := regexp.MatchString(pattern, id)
if err != nil {
log.Printf("unable to match %s %s against pattern %s. Error: %s\n",
entity, id, pattern, err.Error())
} else if matched {
log.Printf("Regexp matching %s found (%s).\n", entity, pattern)
return profile
}
}
}
return ""
} | go | func (c *ConsulAlertClient) getProfileForEntity(entity string, id string) string {
kvPair, _, _ := c.api.KV().Get(
fmt.Sprintf("consul-alerts/config/notif-selection/%ss/%s",
entity, id), nil)
if kvPair != nil {
log.Printf("%s selection key found.\n", entity)
return string(kvPair.Value)
} else if kvPair, _, _ := c.api.KV().Get(
fmt.Sprintf("consul-alerts/config/notif-selection/%ss", entity),
nil); kvPair != nil {
var regexMap map[string]string
json.Unmarshal(kvPair.Value, ®exMap)
for pattern, profile := range regexMap {
matched, err := regexp.MatchString(pattern, id)
if err != nil {
log.Printf("unable to match %s %s against pattern %s. Error: %s\n",
entity, id, pattern, err.Error())
} else if matched {
log.Printf("Regexp matching %s found (%s).\n", entity, pattern)
return profile
}
}
}
return ""
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"getProfileForEntity",
"(",
"entity",
"string",
",",
"id",
"string",
")",
"string",
"{",
"kvPair",
",",
"_",
",",
"_",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"entity",
",",
"id",
")",
",",
"nil",
")",
"\n",
"if",
"kvPair",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"entity",
")",
"\n",
"return",
"string",
"(",
"kvPair",
".",
"Value",
")",
"\n",
"}",
"else",
"if",
"kvPair",
",",
"_",
",",
"_",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Get",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"entity",
")",
",",
"nil",
")",
";",
"kvPair",
"!=",
"nil",
"{",
"var",
"regexMap",
"map",
"[",
"string",
"]",
"string",
"\n",
"json",
".",
"Unmarshal",
"(",
"kvPair",
".",
"Value",
",",
"&",
"regexMap",
")",
"\n",
"for",
"pattern",
",",
"profile",
":=",
"range",
"regexMap",
"{",
"matched",
",",
"err",
":=",
"regexp",
".",
"MatchString",
"(",
"pattern",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"entity",
",",
"id",
",",
"pattern",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"else",
"if",
"matched",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"entity",
",",
"pattern",
")",
"\n",
"return",
"profile",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // getProfileForEntity returns the profile matching the exact path or the regexp
// entity is either 'service', 'check' or 'host' | [
"getProfileForEntity",
"returns",
"the",
"profile",
"matching",
"the",
"exact",
"path",
"or",
"the",
"regexp",
"entity",
"is",
"either",
"service",
"check",
"or",
"host"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L708-L732 |
6,388 | AcalephStorage/consul-alerts | consul/client.go | GetProfileInfo | func (c *ConsulAlertClient) GetProfileInfo(node, serviceID, checkID, status string) ProfileInfo {
log.Println("Getting profile for node: ", node, " service: ", serviceID, " check: ", checkID)
var profile string
profile = c.getProfileForService(serviceID)
if profile == "" {
profile = c.getProfileForCheck(checkID)
}
if profile == "" {
profile = c.getProfileForNode(node)
}
if profile == "" {
profile = c.getProfileForStatus(status)
}
if profile == "" {
profile = "default"
}
var checkProfile ProfileInfo
key := fmt.Sprintf("consul-alerts/config/notif-profiles/%s", profile)
log.Println("profile key: ", key)
kvPair, _, _ := c.api.KV().Get(key, nil)
if kvPair == nil {
log.Println("profile key not found.")
return checkProfile
}
if err := json.Unmarshal(kvPair.Value, &checkProfile); err != nil {
log.Error("Profile unmarshalling error: ", err.Error())
} else {
log.Println("Interval: ", checkProfile.Interval, " List: ", checkProfile.NotifList)
}
return checkProfile
} | go | func (c *ConsulAlertClient) GetProfileInfo(node, serviceID, checkID, status string) ProfileInfo {
log.Println("Getting profile for node: ", node, " service: ", serviceID, " check: ", checkID)
var profile string
profile = c.getProfileForService(serviceID)
if profile == "" {
profile = c.getProfileForCheck(checkID)
}
if profile == "" {
profile = c.getProfileForNode(node)
}
if profile == "" {
profile = c.getProfileForStatus(status)
}
if profile == "" {
profile = "default"
}
var checkProfile ProfileInfo
key := fmt.Sprintf("consul-alerts/config/notif-profiles/%s", profile)
log.Println("profile key: ", key)
kvPair, _, _ := c.api.KV().Get(key, nil)
if kvPair == nil {
log.Println("profile key not found.")
return checkProfile
}
if err := json.Unmarshal(kvPair.Value, &checkProfile); err != nil {
log.Error("Profile unmarshalling error: ", err.Error())
} else {
log.Println("Interval: ", checkProfile.Interval, " List: ", checkProfile.NotifList)
}
return checkProfile
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"GetProfileInfo",
"(",
"node",
",",
"serviceID",
",",
"checkID",
",",
"status",
"string",
")",
"ProfileInfo",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"node",
",",
"\"",
"\"",
",",
"serviceID",
",",
"\"",
"\"",
",",
"checkID",
")",
"\n\n",
"var",
"profile",
"string",
"\n\n",
"profile",
"=",
"c",
".",
"getProfileForService",
"(",
"serviceID",
")",
"\n",
"if",
"profile",
"==",
"\"",
"\"",
"{",
"profile",
"=",
"c",
".",
"getProfileForCheck",
"(",
"checkID",
")",
"\n",
"}",
"\n",
"if",
"profile",
"==",
"\"",
"\"",
"{",
"profile",
"=",
"c",
".",
"getProfileForNode",
"(",
"node",
")",
"\n",
"}",
"\n",
"if",
"profile",
"==",
"\"",
"\"",
"{",
"profile",
"=",
"c",
".",
"getProfileForStatus",
"(",
"status",
")",
"\n",
"}",
"\n",
"if",
"profile",
"==",
"\"",
"\"",
"{",
"profile",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"checkProfile",
"ProfileInfo",
"\n",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"profile",
")",
"\n",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"kvPair",
",",
"_",
",",
"_",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"Get",
"(",
"key",
",",
"nil",
")",
"\n",
"if",
"kvPair",
"==",
"nil",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"return",
"checkProfile",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"kvPair",
".",
"Value",
",",
"&",
"checkProfile",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"checkProfile",
".",
"Interval",
",",
"\"",
"\"",
",",
"checkProfile",
".",
"NotifList",
")",
"\n",
"}",
"\n\n",
"return",
"checkProfile",
"\n",
"}"
] | // GetProfileInfo returns profile info for check | [
"GetProfileInfo",
"returns",
"profile",
"info",
"for",
"check"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L752-L787 |
6,389 | AcalephStorage/consul-alerts | consul/client.go | IsBlacklisted | func (c *ConsulAlertClient) IsBlacklisted(check *Check) bool {
blacklistExist := func() bool {
kvPairs, _, err := c.api.KV().List("consul-alerts/config/checks/blacklist/", nil)
return len(kvPairs) != 0 && err == nil
}
node := check.Node
nodeCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/nodes/%s", node)
nodeBlacklisted := func() bool {
return c.CheckKeyExists(nodeCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/nodes", node)
}
service := "_"
serviceBlacklisted := func() bool { return false }
if check.ServiceID != "" {
service = check.ServiceID
serviceCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/services/%s", service)
serviceBlacklisted = func() bool {
return c.CheckKeyExists(serviceCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/services", service)
}
}
checkID := check.CheckID
checkCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/checks/%s", checkID)
checkBlacklisted := func() bool {
return c.CheckKeyExists(checkCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/checks", checkID)
}
status := "_"
statusBlacklisted := func() bool { return false }
if check.Status != "" {
status = check.Status
statusCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/status/%s", status)
statusBlacklisted = func() bool {
return c.CheckKeyExists(statusCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/status", status)
}
}
singleKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/single/%s/%s/%s", node, service, checkID)
singleBlacklisted := func() bool { return c.CheckKeyExists(singleKey) }
return blacklistExist() && (nodeBlacklisted() || serviceBlacklisted() || checkBlacklisted() || statusBlacklisted() || singleBlacklisted())
} | go | func (c *ConsulAlertClient) IsBlacklisted(check *Check) bool {
blacklistExist := func() bool {
kvPairs, _, err := c.api.KV().List("consul-alerts/config/checks/blacklist/", nil)
return len(kvPairs) != 0 && err == nil
}
node := check.Node
nodeCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/nodes/%s", node)
nodeBlacklisted := func() bool {
return c.CheckKeyExists(nodeCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/nodes", node)
}
service := "_"
serviceBlacklisted := func() bool { return false }
if check.ServiceID != "" {
service = check.ServiceID
serviceCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/services/%s", service)
serviceBlacklisted = func() bool {
return c.CheckKeyExists(serviceCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/services", service)
}
}
checkID := check.CheckID
checkCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/checks/%s", checkID)
checkBlacklisted := func() bool {
return c.CheckKeyExists(checkCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/checks", checkID)
}
status := "_"
statusBlacklisted := func() bool { return false }
if check.Status != "" {
status = check.Status
statusCheckKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/status/%s", status)
statusBlacklisted = func() bool {
return c.CheckKeyExists(statusCheckKey) || c.CheckKeyMatchesRegexp("consul-alerts/config/checks/blacklist/status", status)
}
}
singleKey := fmt.Sprintf("consul-alerts/config/checks/blacklist/single/%s/%s/%s", node, service, checkID)
singleBlacklisted := func() bool { return c.CheckKeyExists(singleKey) }
return blacklistExist() && (nodeBlacklisted() || serviceBlacklisted() || checkBlacklisted() || statusBlacklisted() || singleBlacklisted())
} | [
"func",
"(",
"c",
"*",
"ConsulAlertClient",
")",
"IsBlacklisted",
"(",
"check",
"*",
"Check",
")",
"bool",
"{",
"blacklistExist",
":=",
"func",
"(",
")",
"bool",
"{",
"kvPairs",
",",
"_",
",",
"err",
":=",
"c",
".",
"api",
".",
"KV",
"(",
")",
".",
"List",
"(",
"\"",
"\"",
",",
"nil",
")",
"\n",
"return",
"len",
"(",
"kvPairs",
")",
"!=",
"0",
"&&",
"err",
"==",
"nil",
"\n",
"}",
"\n\n",
"node",
":=",
"check",
".",
"Node",
"\n",
"nodeCheckKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"node",
")",
"\n",
"nodeBlacklisted",
":=",
"func",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"CheckKeyExists",
"(",
"nodeCheckKey",
")",
"||",
"c",
".",
"CheckKeyMatchesRegexp",
"(",
"\"",
"\"",
",",
"node",
")",
"\n",
"}",
"\n\n",
"service",
":=",
"\"",
"\"",
"\n",
"serviceBlacklisted",
":=",
"func",
"(",
")",
"bool",
"{",
"return",
"false",
"}",
"\n",
"if",
"check",
".",
"ServiceID",
"!=",
"\"",
"\"",
"{",
"service",
"=",
"check",
".",
"ServiceID",
"\n",
"serviceCheckKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"service",
")",
"\n\n",
"serviceBlacklisted",
"=",
"func",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"CheckKeyExists",
"(",
"serviceCheckKey",
")",
"||",
"c",
".",
"CheckKeyMatchesRegexp",
"(",
"\"",
"\"",
",",
"service",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"checkID",
":=",
"check",
".",
"CheckID",
"\n",
"checkCheckKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"checkID",
")",
"\n\n",
"checkBlacklisted",
":=",
"func",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"CheckKeyExists",
"(",
"checkCheckKey",
")",
"||",
"c",
".",
"CheckKeyMatchesRegexp",
"(",
"\"",
"\"",
",",
"checkID",
")",
"\n",
"}",
"\n\n",
"status",
":=",
"\"",
"\"",
"\n",
"statusBlacklisted",
":=",
"func",
"(",
")",
"bool",
"{",
"return",
"false",
"}",
"\n",
"if",
"check",
".",
"Status",
"!=",
"\"",
"\"",
"{",
"status",
"=",
"check",
".",
"Status",
"\n",
"statusCheckKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"status",
")",
"\n",
"statusBlacklisted",
"=",
"func",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"CheckKeyExists",
"(",
"statusCheckKey",
")",
"||",
"c",
".",
"CheckKeyMatchesRegexp",
"(",
"\"",
"\"",
",",
"status",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"singleKey",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"node",
",",
"service",
",",
"checkID",
")",
"\n",
"singleBlacklisted",
":=",
"func",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"CheckKeyExists",
"(",
"singleKey",
")",
"}",
"\n\n",
"return",
"blacklistExist",
"(",
")",
"&&",
"(",
"nodeBlacklisted",
"(",
")",
"||",
"serviceBlacklisted",
"(",
")",
"||",
"checkBlacklisted",
"(",
")",
"||",
"statusBlacklisted",
"(",
")",
"||",
"singleBlacklisted",
"(",
")",
")",
"\n",
"}"
] | // IsBlacklisted gets the blacklist status of check | [
"IsBlacklisted",
"gets",
"the",
"blacklist",
"status",
"of",
"check"
] | 93c4aff94523aee1230fcf177d99d5836550fd40 | https://github.com/AcalephStorage/consul-alerts/blob/93c4aff94523aee1230fcf177d99d5836550fd40/consul/client.go#L790-L834 |
6,390 | schollz/closestmatch | closestmatch.go | New | func New(possible []string, subsetSize []int) *ClosestMatch {
cm := new(ClosestMatch)
cm.SubstringSizes = subsetSize
cm.SubstringToID = make(map[string]map[uint32]struct{})
cm.ID = make(map[uint32]IDInfo)
for i, s := range possible {
substrings := cm.splitWord(strings.ToLower(s))
cm.ID[uint32(i)] = IDInfo{Key: s, NumSubstrings: len(substrings)}
for substring := range substrings {
if _, ok := cm.SubstringToID[substring]; !ok {
cm.SubstringToID[substring] = make(map[uint32]struct{})
}
cm.SubstringToID[substring][uint32(i)] = struct{}{}
}
}
return cm
} | go | func New(possible []string, subsetSize []int) *ClosestMatch {
cm := new(ClosestMatch)
cm.SubstringSizes = subsetSize
cm.SubstringToID = make(map[string]map[uint32]struct{})
cm.ID = make(map[uint32]IDInfo)
for i, s := range possible {
substrings := cm.splitWord(strings.ToLower(s))
cm.ID[uint32(i)] = IDInfo{Key: s, NumSubstrings: len(substrings)}
for substring := range substrings {
if _, ok := cm.SubstringToID[substring]; !ok {
cm.SubstringToID[substring] = make(map[uint32]struct{})
}
cm.SubstringToID[substring][uint32(i)] = struct{}{}
}
}
return cm
} | [
"func",
"New",
"(",
"possible",
"[",
"]",
"string",
",",
"subsetSize",
"[",
"]",
"int",
")",
"*",
"ClosestMatch",
"{",
"cm",
":=",
"new",
"(",
"ClosestMatch",
")",
"\n",
"cm",
".",
"SubstringSizes",
"=",
"subsetSize",
"\n",
"cm",
".",
"SubstringToID",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"uint32",
"]",
"struct",
"{",
"}",
")",
"\n",
"cm",
".",
"ID",
"=",
"make",
"(",
"map",
"[",
"uint32",
"]",
"IDInfo",
")",
"\n",
"for",
"i",
",",
"s",
":=",
"range",
"possible",
"{",
"substrings",
":=",
"cm",
".",
"splitWord",
"(",
"strings",
".",
"ToLower",
"(",
"s",
")",
")",
"\n",
"cm",
".",
"ID",
"[",
"uint32",
"(",
"i",
")",
"]",
"=",
"IDInfo",
"{",
"Key",
":",
"s",
",",
"NumSubstrings",
":",
"len",
"(",
"substrings",
")",
"}",
"\n",
"for",
"substring",
":=",
"range",
"substrings",
"{",
"if",
"_",
",",
"ok",
":=",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
";",
"!",
"ok",
"{",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
"=",
"make",
"(",
"map",
"[",
"uint32",
"]",
"struct",
"{",
"}",
")",
"\n",
"}",
"\n",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
"[",
"uint32",
"(",
"i",
")",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"cm",
"\n",
"}"
] | // New returns a new structure for performing closest matches | [
"New",
"returns",
"a",
"new",
"structure",
"for",
"performing",
"closest",
"matches"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L30-L47 |
6,391 | schollz/closestmatch | closestmatch.go | Load | func Load(filename string) (*ClosestMatch, error) {
cm := new(ClosestMatch)
f, err := os.Open(filename)
defer f.Close()
if err != nil {
return cm, err
}
w, err := gzip.NewReader(f)
if err != nil {
return cm, err
}
err = json.NewDecoder(w).Decode(&cm)
return cm, err
} | go | func Load(filename string) (*ClosestMatch, error) {
cm := new(ClosestMatch)
f, err := os.Open(filename)
defer f.Close()
if err != nil {
return cm, err
}
w, err := gzip.NewReader(f)
if err != nil {
return cm, err
}
err = json.NewDecoder(w).Decode(&cm)
return cm, err
} | [
"func",
"Load",
"(",
"filename",
"string",
")",
"(",
"*",
"ClosestMatch",
",",
"error",
")",
"{",
"cm",
":=",
"new",
"(",
"ClosestMatch",
")",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"defer",
"f",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"cm",
",",
"err",
"\n",
"}",
"\n\n",
"w",
",",
"err",
":=",
"gzip",
".",
"NewReader",
"(",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"cm",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"w",
")",
".",
"Decode",
"(",
"&",
"cm",
")",
"\n",
"return",
"cm",
",",
"err",
"\n",
"}"
] | // Load can load a previously saved ClosestMatch object from disk | [
"Load",
"can",
"load",
"a",
"previously",
"saved",
"ClosestMatch",
"object",
"from",
"disk"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L50-L66 |
6,392 | schollz/closestmatch | closestmatch.go | Add | func (cm *ClosestMatch) Add(possible []string) {
cm.mux.Lock()
for i, s := range possible {
substrings := cm.splitWord(strings.ToLower(s))
cm.ID[uint32(i)] = IDInfo{Key: s, NumSubstrings: len(substrings)}
for substring := range substrings {
if _, ok := cm.SubstringToID[substring]; !ok {
cm.SubstringToID[substring] = make(map[uint32]struct{})
}
cm.SubstringToID[substring][uint32(i)] = struct{}{}
}
}
cm.mux.Unlock()
} | go | func (cm *ClosestMatch) Add(possible []string) {
cm.mux.Lock()
for i, s := range possible {
substrings := cm.splitWord(strings.ToLower(s))
cm.ID[uint32(i)] = IDInfo{Key: s, NumSubstrings: len(substrings)}
for substring := range substrings {
if _, ok := cm.SubstringToID[substring]; !ok {
cm.SubstringToID[substring] = make(map[uint32]struct{})
}
cm.SubstringToID[substring][uint32(i)] = struct{}{}
}
}
cm.mux.Unlock()
} | [
"func",
"(",
"cm",
"*",
"ClosestMatch",
")",
"Add",
"(",
"possible",
"[",
"]",
"string",
")",
"{",
"cm",
".",
"mux",
".",
"Lock",
"(",
")",
"\n",
"for",
"i",
",",
"s",
":=",
"range",
"possible",
"{",
"substrings",
":=",
"cm",
".",
"splitWord",
"(",
"strings",
".",
"ToLower",
"(",
"s",
")",
")",
"\n",
"cm",
".",
"ID",
"[",
"uint32",
"(",
"i",
")",
"]",
"=",
"IDInfo",
"{",
"Key",
":",
"s",
",",
"NumSubstrings",
":",
"len",
"(",
"substrings",
")",
"}",
"\n",
"for",
"substring",
":=",
"range",
"substrings",
"{",
"if",
"_",
",",
"ok",
":=",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
";",
"!",
"ok",
"{",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
"=",
"make",
"(",
"map",
"[",
"uint32",
"]",
"struct",
"{",
"}",
")",
"\n",
"}",
"\n",
"cm",
".",
"SubstringToID",
"[",
"substring",
"]",
"[",
"uint32",
"(",
"i",
")",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"cm",
".",
"mux",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Add more words to ClosestMatch structure | [
"Add",
"more",
"words",
"to",
"ClosestMatch",
"structure"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L69-L82 |
6,393 | schollz/closestmatch | closestmatch.go | Save | func (cm *ClosestMatch) Save(filename string) error {
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
w := gzip.NewWriter(f)
defer w.Close()
enc := json.NewEncoder(w)
// enc.SetIndent("", " ")
return enc.Encode(cm)
} | go | func (cm *ClosestMatch) Save(filename string) error {
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
w := gzip.NewWriter(f)
defer w.Close()
enc := json.NewEncoder(w)
// enc.SetIndent("", " ")
return enc.Encode(cm)
} | [
"func",
"(",
"cm",
"*",
"ClosestMatch",
")",
"Save",
"(",
"filename",
"string",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"f",
".",
"Close",
"(",
")",
"\n",
"w",
":=",
"gzip",
".",
"NewWriter",
"(",
"f",
")",
"\n",
"defer",
"w",
".",
"Close",
"(",
")",
"\n",
"enc",
":=",
"json",
".",
"NewEncoder",
"(",
"w",
")",
"\n",
"// enc.SetIndent(\"\", \" \")",
"return",
"enc",
".",
"Encode",
"(",
"cm",
")",
"\n",
"}"
] | // Save writes the current ClosestSave object as a gzipped JSON file | [
"Save",
"writes",
"the",
"current",
"ClosestSave",
"object",
"as",
"a",
"gzipped",
"JSON",
"file"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L85-L96 |
6,394 | schollz/closestmatch | closestmatch.go | Closest | func (cm *ClosestMatch) Closest(searchWord string) string {
for _, pair := range rankByWordCount(cm.match(searchWord)) {
return pair.Key
}
return ""
} | go | func (cm *ClosestMatch) Closest(searchWord string) string {
for _, pair := range rankByWordCount(cm.match(searchWord)) {
return pair.Key
}
return ""
} | [
"func",
"(",
"cm",
"*",
"ClosestMatch",
")",
"Closest",
"(",
"searchWord",
"string",
")",
"string",
"{",
"for",
"_",
",",
"pair",
":=",
"range",
"rankByWordCount",
"(",
"cm",
".",
"match",
"(",
"searchWord",
")",
")",
"{",
"return",
"pair",
".",
"Key",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // Closest searches for the `searchWord` and returns the closest match | [
"Closest",
"searches",
"for",
"the",
"searchWord",
"and",
"returns",
"the",
"closest",
"match"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L157-L162 |
6,395 | schollz/closestmatch | closestmatch.go | ClosestN | func (cm *ClosestMatch) ClosestN(searchWord string, max int) []string {
matches := make([]string, 0, max)
for i, pair := range rankByWordCount(cm.match(searchWord)) {
if i >= max {
break
}
matches = append(matches, pair.Key)
}
return matches
} | go | func (cm *ClosestMatch) ClosestN(searchWord string, max int) []string {
matches := make([]string, 0, max)
for i, pair := range rankByWordCount(cm.match(searchWord)) {
if i >= max {
break
}
matches = append(matches, pair.Key)
}
return matches
} | [
"func",
"(",
"cm",
"*",
"ClosestMatch",
")",
"ClosestN",
"(",
"searchWord",
"string",
",",
"max",
"int",
")",
"[",
"]",
"string",
"{",
"matches",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"max",
")",
"\n",
"for",
"i",
",",
"pair",
":=",
"range",
"rankByWordCount",
"(",
"cm",
".",
"match",
"(",
"searchWord",
")",
")",
"{",
"if",
"i",
">=",
"max",
"{",
"break",
"\n",
"}",
"\n",
"matches",
"=",
"append",
"(",
"matches",
",",
"pair",
".",
"Key",
")",
"\n",
"}",
"\n",
"return",
"matches",
"\n",
"}"
] | // ClosestN searches for the `searchWord` and returns the n closests matches | [
"ClosestN",
"searches",
"for",
"the",
"searchWord",
"and",
"returns",
"the",
"n",
"closests",
"matches"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/closestmatch.go#L165-L174 |
6,396 | schollz/closestmatch | cmclient/client.go | Open | func Open(address string) (*Connection, error) {
c := new(Connection)
c.Address = address
resp, err := http.Get(c.Address + "/uptime")
if err != nil {
return c, err
}
defer resp.Body.Close()
return c, nil
} | go | func Open(address string) (*Connection, error) {
c := new(Connection)
c.Address = address
resp, err := http.Get(c.Address + "/uptime")
if err != nil {
return c, err
}
defer resp.Body.Close()
return c, nil
} | [
"func",
"Open",
"(",
"address",
"string",
")",
"(",
"*",
"Connection",
",",
"error",
")",
"{",
"c",
":=",
"new",
"(",
"Connection",
")",
"\n",
"c",
".",
"Address",
"=",
"address",
"\n",
"resp",
",",
"err",
":=",
"http",
".",
"Get",
"(",
"c",
".",
"Address",
"+",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"c",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] | // Open will load a connection to BoltDB | [
"Open",
"will",
"load",
"a",
"connection",
"to",
"BoltDB"
] | 1fbe626be92eb4c347d182cae9f8f00a046bf2f4 | https://github.com/schollz/closestmatch/blob/1fbe626be92eb4c347d182cae9f8f00a046bf2f4/cmclient/client.go#L16-L25 |
6,397 | prometheus/common | config/http_config.go | UnmarshalYAML | func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
urlp, err := url.Parse(s)
if err != nil {
return err
}
u.URL = urlp
return nil
} | go | func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
urlp, err := url.Parse(s)
if err != nil {
return err
}
u.URL = urlp
return nil
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"UnmarshalYAML",
"(",
"unmarshal",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"err",
":=",
"unmarshal",
"(",
"&",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"urlp",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"u",
".",
"URL",
"=",
"urlp",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalYAML implements the yaml.Unmarshaler interface for URLs. | [
"UnmarshalYAML",
"implements",
"the",
"yaml",
".",
"Unmarshaler",
"interface",
"for",
"URLs",
"."
] | c873fb1f9420b83ee703b4361c61183b4619f74d | https://github.com/prometheus/common/blob/c873fb1f9420b83ee703b4361c61183b4619f74d/config/http_config.go#L52-L64 |
6,398 | prometheus/common | config/http_config.go | MarshalYAML | func (u URL) MarshalYAML() (interface{}, error) {
if u.URL != nil {
return u.String(), nil
}
return nil, nil
} | go | func (u URL) MarshalYAML() (interface{}, error) {
if u.URL != nil {
return u.String(), nil
}
return nil, nil
} | [
"func",
"(",
"u",
"URL",
")",
"MarshalYAML",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"u",
".",
"URL",
"!=",
"nil",
"{",
"return",
"u",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // MarshalYAML implements the yaml.Marshaler interface for URLs. | [
"MarshalYAML",
"implements",
"the",
"yaml",
".",
"Marshaler",
"interface",
"for",
"URLs",
"."
] | c873fb1f9420b83ee703b4361c61183b4619f74d | https://github.com/prometheus/common/blob/c873fb1f9420b83ee703b4361c61183b4619f74d/config/http_config.go#L67-L72 |
6,399 | prometheus/common | config/http_config.go | Validate | func (c *HTTPClientConfig) Validate() error {
if len(c.BearerToken) > 0 && len(c.BearerTokenFile) > 0 {
return fmt.Errorf("at most one of bearer_token & bearer_token_file must be configured")
}
if c.BasicAuth != nil && (len(c.BearerToken) > 0 || len(c.BearerTokenFile) > 0) {
return fmt.Errorf("at most one of basic_auth, bearer_token & bearer_token_file must be configured")
}
if c.BasicAuth != nil && (string(c.BasicAuth.Password) != "" && c.BasicAuth.PasswordFile != "") {
return fmt.Errorf("at most one of basic_auth password & password_file must be configured")
}
return nil
} | go | func (c *HTTPClientConfig) Validate() error {
if len(c.BearerToken) > 0 && len(c.BearerTokenFile) > 0 {
return fmt.Errorf("at most one of bearer_token & bearer_token_file must be configured")
}
if c.BasicAuth != nil && (len(c.BearerToken) > 0 || len(c.BearerTokenFile) > 0) {
return fmt.Errorf("at most one of basic_auth, bearer_token & bearer_token_file must be configured")
}
if c.BasicAuth != nil && (string(c.BasicAuth.Password) != "" && c.BasicAuth.PasswordFile != "") {
return fmt.Errorf("at most one of basic_auth password & password_file must be configured")
}
return nil
} | [
"func",
"(",
"c",
"*",
"HTTPClientConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"c",
".",
"BearerToken",
")",
">",
"0",
"&&",
"len",
"(",
"c",
".",
"BearerTokenFile",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"BasicAuth",
"!=",
"nil",
"&&",
"(",
"len",
"(",
"c",
".",
"BearerToken",
")",
">",
"0",
"||",
"len",
"(",
"c",
".",
"BearerTokenFile",
")",
">",
"0",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"BasicAuth",
"!=",
"nil",
"&&",
"(",
"string",
"(",
"c",
".",
"BasicAuth",
".",
"Password",
")",
"!=",
"\"",
"\"",
"&&",
"c",
".",
"BasicAuth",
".",
"PasswordFile",
"!=",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates the HTTPClientConfig to check only one of BearerToken,
// BasicAuth and BearerTokenFile is configured. | [
"Validate",
"validates",
"the",
"HTTPClientConfig",
"to",
"check",
"only",
"one",
"of",
"BearerToken",
"BasicAuth",
"and",
"BearerTokenFile",
"is",
"configured",
"."
] | c873fb1f9420b83ee703b4361c61183b4619f74d | https://github.com/prometheus/common/blob/c873fb1f9420b83ee703b4361c61183b4619f74d/config/http_config.go#L90-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.