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
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
13,500 | fabric8-services/fabric8-wit | workitem/workitemtype.go | IsTypeOrSubtypeOf | func (wit WorkItemType) IsTypeOrSubtypeOf(typeID uuid.UUID) bool {
// Check for complete inclusion (e.g. "bar" is contained in "foo.bar.cake")
// and for suffix (e.g. ".cake" is the suffix of "foo.bar.cake").
return uuid.Equal(wit.ID, typeID) || strings.Contains(wit.Path, LtreeSafeID(typeID)+pathSep)
} | go | func (wit WorkItemType) IsTypeOrSubtypeOf(typeID uuid.UUID) bool {
// Check for complete inclusion (e.g. "bar" is contained in "foo.bar.cake")
// and for suffix (e.g. ".cake" is the suffix of "foo.bar.cake").
return uuid.Equal(wit.ID, typeID) || strings.Contains(wit.Path, LtreeSafeID(typeID)+pathSep)
} | [
"func",
"(",
"wit",
"WorkItemType",
")",
"IsTypeOrSubtypeOf",
"(",
"typeID",
"uuid",
".",
"UUID",
")",
"bool",
"{",
"// Check for complete inclusion (e.g. \"bar\" is contained in \"foo.bar.cake\")",
"// and for suffix (e.g. \".cake\" is the suffix of \"foo.bar.cake\").",
"return",
"uuid",
".",
"Equal",
"(",
"wit",
".",
"ID",
",",
"typeID",
")",
"||",
"strings",
".",
"Contains",
"(",
"wit",
".",
"Path",
",",
"LtreeSafeID",
"(",
"typeID",
")",
"+",
"pathSep",
")",
"\n",
"}"
] | // IsTypeOrSubtypeOf returns true if the work item type with the given type ID,
// is of the same type as the current WIT or of it is a subtype; otherwise false
// is returned. | [
"IsTypeOrSubtypeOf",
"returns",
"true",
"if",
"the",
"work",
"item",
"type",
"with",
"the",
"given",
"type",
"ID",
"is",
"of",
"the",
"same",
"type",
"as",
"the",
"current",
"WIT",
"or",
"of",
"it",
"is",
"a",
"subtype",
";",
"otherwise",
"false",
"is",
"returned",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/workitemtype.go#L272-L276 |
13,501 | fabric8-services/fabric8-wit | path/path.go | This | func (p Path) This() uuid.UUID {
if !p.IsEmpty() {
return p[len(p)-1]
}
return uuid.Nil
} | go | func (p Path) This() uuid.UUID {
if !p.IsEmpty() {
return p[len(p)-1]
}
return uuid.Nil
} | [
"func",
"(",
"p",
"Path",
")",
"This",
"(",
")",
"uuid",
".",
"UUID",
"{",
"if",
"!",
"p",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"p",
"[",
"len",
"(",
"p",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"uuid",
".",
"Nil",
"\n",
"}"
] | // This returns last UUID of slice or uuid.Nil if the path is empty. | [
"This",
"returns",
"last",
"UUID",
"of",
"slice",
"or",
"uuid",
".",
"Nil",
"if",
"the",
"path",
"is",
"empty",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L33-L38 |
13,502 | fabric8-services/fabric8-wit | path/path.go | ParentID | func (p Path) ParentID() uuid.UUID {
if len(p) > 1 {
return p[len(p)-2]
}
return uuid.Nil
} | go | func (p Path) ParentID() uuid.UUID {
if len(p) > 1 {
return p[len(p)-2]
}
return uuid.Nil
} | [
"func",
"(",
"p",
"Path",
")",
"ParentID",
"(",
")",
"uuid",
".",
"UUID",
"{",
"if",
"len",
"(",
"p",
")",
">",
"1",
"{",
"return",
"p",
"[",
"len",
"(",
"p",
")",
"-",
"2",
"]",
"\n",
"}",
"\n",
"return",
"uuid",
".",
"Nil",
"\n",
"}"
] | // ParentID returns UUID before the last one or uuid.Nil if this was already the
// parent. | [
"ParentID",
"returns",
"UUID",
"before",
"the",
"last",
"one",
"or",
"uuid",
".",
"Nil",
"if",
"this",
"was",
"already",
"the",
"parent",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L42-L47 |
13,503 | fabric8-services/fabric8-wit | path/path.go | ParentPath | func (p Path) ParentPath() Path {
if len(p) > 1 {
return p[:len(p)-1]
}
return Path{}
} | go | func (p Path) ParentPath() Path {
if len(p) > 1 {
return p[:len(p)-1]
}
return Path{}
} | [
"func",
"(",
"p",
"Path",
")",
"ParentPath",
"(",
")",
"Path",
"{",
"if",
"len",
"(",
"p",
")",
">",
"1",
"{",
"return",
"p",
"[",
":",
"len",
"(",
"p",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"Path",
"{",
"}",
"\n",
"}"
] | // ParentPath returns the path except this one and an empty path if the path was
// empty. | [
"ParentPath",
"returns",
"the",
"path",
"except",
"this",
"one",
"and",
"an",
"empty",
"path",
"if",
"the",
"path",
"was",
"empty",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L51-L56 |
13,504 | fabric8-services/fabric8-wit | path/path.go | Convert | func (p Path) Convert() string {
if len(p) == 0 {
return ""
}
var op []string
for _, id := range p {
op = append(op, id.String())
}
str := strings.Join(op, SepInDatabase)
return strings.Replace(str, "-", "_", -1)
} | go | func (p Path) Convert() string {
if len(p) == 0 {
return ""
}
var op []string
for _, id := range p {
op = append(op, id.String())
}
str := strings.Join(op, SepInDatabase)
return strings.Replace(str, "-", "_", -1)
} | [
"func",
"(",
"p",
"Path",
")",
"Convert",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"var",
"op",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"p",
"{",
"op",
"=",
"append",
"(",
"op",
",",
"id",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"str",
":=",
"strings",
".",
"Join",
"(",
"op",
",",
"SepInDatabase",
")",
"\n",
"return",
"strings",
".",
"Replace",
"(",
"str",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"}"
] | // Convert returns ltree compatible string of UUID slice
// 39fa8c5b_5732_436f_a084_0f2a247f3435.87762c8b_17f9_4cbb_b355_251b6a524f2f | [
"Convert",
"returns",
"ltree",
"compatible",
"string",
"of",
"UUID",
"slice",
"39fa8c5b_5732_436f_a084_0f2a247f3435",
".",
"87762c8b_17f9_4cbb_b355_251b6a524f2f"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L60-L70 |
13,505 | fabric8-services/fabric8-wit | path/path.go | Root | func (p Path) Root() Path {
if len(p) > 0 {
return Path{p[0]}
}
return Path{uuid.Nil}
} | go | func (p Path) Root() Path {
if len(p) > 0 {
return Path{p[0]}
}
return Path{uuid.Nil}
} | [
"func",
"(",
"p",
"Path",
")",
"Root",
"(",
")",
"Path",
"{",
"if",
"len",
"(",
"p",
")",
">",
"0",
"{",
"return",
"Path",
"{",
"p",
"[",
"0",
"]",
"}",
"\n",
"}",
"\n",
"return",
"Path",
"{",
"uuid",
".",
"Nil",
"}",
"\n",
"}"
] | // Root retunrs a Path instance with first element in the UUID slice | [
"Root",
"retunrs",
"a",
"Path",
"instance",
"with",
"first",
"element",
"in",
"the",
"UUID",
"slice"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L88-L93 |
13,506 | fabric8-services/fabric8-wit | path/path.go | ConvertToLtree | func ConvertToLtree(id uuid.UUID) string {
converted := strings.Replace(id.String(), "-", "_", -1)
return converted
} | go | func ConvertToLtree(id uuid.UUID) string {
converted := strings.Replace(id.String(), "-", "_", -1)
return converted
} | [
"func",
"ConvertToLtree",
"(",
"id",
"uuid",
".",
"UUID",
")",
"string",
"{",
"converted",
":=",
"strings",
".",
"Replace",
"(",
"id",
".",
"String",
"(",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"return",
"converted",
"\n",
"}"
] | // ConvertToLtree returns ltree form of given UUID | [
"ConvertToLtree",
"returns",
"ltree",
"form",
"of",
"given",
"UUID"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L96-L99 |
13,507 | fabric8-services/fabric8-wit | path/path.go | Value | func (p Path) Value() (driver.Value, error) {
op := []string{}
for _, x := range p {
op = append(op, ConvertToLtree(x))
}
s := strings.Join(op, SepInDatabase)
return s, nil
} | go | func (p Path) Value() (driver.Value, error) {
op := []string{}
for _, x := range p {
op = append(op, ConvertToLtree(x))
}
s := strings.Join(op, SepInDatabase)
return s, nil
} | [
"func",
"(",
"p",
"Path",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"op",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"x",
":=",
"range",
"p",
"{",
"op",
"=",
"append",
"(",
"op",
",",
"ConvertToLtree",
"(",
"x",
")",
")",
"\n",
"}",
"\n",
"s",
":=",
"strings",
".",
"Join",
"(",
"op",
",",
"SepInDatabase",
")",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // Value helps in implementing Valuer interfae on Path
// This conversion uses Ltree specification | [
"Value",
"helps",
"in",
"implementing",
"Valuer",
"interfae",
"on",
"Path",
"This",
"conversion",
"uses",
"Ltree",
"specification"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L118-L125 |
13,508 | fabric8-services/fabric8-wit | path/path.go | Scan | func (p *Path) Scan(value interface{}) error {
// if value is nil, false
if value == nil {
*p = []uuid.UUID{}
return nil
}
if str, err := driver.String.ConvertValue(value); err == nil {
// if this is a string type
v := ""
for _, m := range str.([]uint8) {
v += string(m)
}
all, err := p.convertFromLtree(v)
if err != nil {
*p = []uuid.UUID{}
return nil
}
*p = all
return nil
}
// otherwise, return an error
return errors.New("failed to scan MyPath")
} | go | func (p *Path) Scan(value interface{}) error {
// if value is nil, false
if value == nil {
*p = []uuid.UUID{}
return nil
}
if str, err := driver.String.ConvertValue(value); err == nil {
// if this is a string type
v := ""
for _, m := range str.([]uint8) {
v += string(m)
}
all, err := p.convertFromLtree(v)
if err != nil {
*p = []uuid.UUID{}
return nil
}
*p = all
return nil
}
// otherwise, return an error
return errors.New("failed to scan MyPath")
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"Scan",
"(",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"// if value is nil, false",
"if",
"value",
"==",
"nil",
"{",
"*",
"p",
"=",
"[",
"]",
"uuid",
".",
"UUID",
"{",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"str",
",",
"err",
":=",
"driver",
".",
"String",
".",
"ConvertValue",
"(",
"value",
")",
";",
"err",
"==",
"nil",
"{",
"// if this is a string type",
"v",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"str",
".",
"(",
"[",
"]",
"uint8",
")",
"{",
"v",
"+=",
"string",
"(",
"m",
")",
"\n",
"}",
"\n",
"all",
",",
"err",
":=",
"p",
".",
"convertFromLtree",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"*",
"p",
"=",
"[",
"]",
"uuid",
".",
"UUID",
"{",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"*",
"p",
"=",
"all",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"// otherwise, return an error",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Scan helps in implementing Scanner interface on Path | [
"Scan",
"helps",
"in",
"implementing",
"Scanner",
"interface",
"on",
"Path"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L128-L150 |
13,509 | fabric8-services/fabric8-wit | path/path.go | MarshalJSON | func (p Path) MarshalJSON() ([]byte, error) {
buffer := bytes.NewBufferString("{")
length := len(p)
count := 0
for key, value := range p {
jsonValue, err := json.Marshal(value)
if err != nil {
return nil, err
}
buffer.WriteString(fmt.Sprintf("\"%d\":%s", key, string(jsonValue)))
count++
if count < length {
buffer.WriteString(",")
}
}
buffer.WriteString("}")
return buffer.Bytes(), nil
} | go | func (p Path) MarshalJSON() ([]byte, error) {
buffer := bytes.NewBufferString("{")
length := len(p)
count := 0
for key, value := range p {
jsonValue, err := json.Marshal(value)
if err != nil {
return nil, err
}
buffer.WriteString(fmt.Sprintf("\"%d\":%s", key, string(jsonValue)))
count++
if count < length {
buffer.WriteString(",")
}
}
buffer.WriteString("}")
return buffer.Bytes(), nil
} | [
"func",
"(",
"p",
"Path",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buffer",
":=",
"bytes",
".",
"NewBufferString",
"(",
"\"",
"\"",
")",
"\n",
"length",
":=",
"len",
"(",
"p",
")",
"\n",
"count",
":=",
"0",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"p",
"{",
"jsonValue",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"buffer",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"key",
",",
"string",
"(",
"jsonValue",
")",
")",
")",
"\n",
"count",
"++",
"\n",
"if",
"count",
"<",
"length",
"{",
"buffer",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"buffer",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"return",
"buffer",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] | // MarshalJSON allows Path to be serialized | [
"MarshalJSON",
"allows",
"Path",
"to",
"be",
"serialized"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L153-L170 |
13,510 | fabric8-services/fabric8-wit | path/path.go | UnmarshalJSON | func (p *Path) UnmarshalJSON(b []byte) error {
var stringMap map[string]string
err := json.Unmarshal(b, &stringMap)
if err != nil {
return err
}
for _, value := range stringMap {
id, err := uuid.FromString(value)
if err != nil {
return err
}
*p = append(*p, id)
}
return nil
} | go | func (p *Path) UnmarshalJSON(b []byte) error {
var stringMap map[string]string
err := json.Unmarshal(b, &stringMap)
if err != nil {
return err
}
for _, value := range stringMap {
id, err := uuid.FromString(value)
if err != nil {
return err
}
*p = append(*p, id)
}
return nil
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"stringMap",
"map",
"[",
"string",
"]",
"string",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"stringMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"stringMap",
"{",
"id",
",",
"err",
":=",
"uuid",
".",
"FromString",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"*",
"p",
"=",
"append",
"(",
"*",
"p",
",",
"id",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // UnmarshalJSON allows Path to be deserialized | [
"UnmarshalJSON",
"allows",
"Path",
"to",
"be",
"deserialized"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L173-L187 |
13,511 | fabric8-services/fabric8-wit | path/path.go | ToExpression | func ToExpression(p Path, this uuid.UUID) string {
converted := strings.Replace(this.String(), "-", "_", -1)
existingPath := p.Convert()
if existingPath == "" {
return converted
}
return fmt.Sprintf("%s.%s", p.Convert(), converted)
} | go | func ToExpression(p Path, this uuid.UUID) string {
converted := strings.Replace(this.String(), "-", "_", -1)
existingPath := p.Convert()
if existingPath == "" {
return converted
}
return fmt.Sprintf("%s.%s", p.Convert(), converted)
} | [
"func",
"ToExpression",
"(",
"p",
"Path",
",",
"this",
"uuid",
".",
"UUID",
")",
"string",
"{",
"converted",
":=",
"strings",
".",
"Replace",
"(",
"this",
".",
"String",
"(",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"existingPath",
":=",
"p",
".",
"Convert",
"(",
")",
"\n",
"if",
"existingPath",
"==",
"\"",
"\"",
"{",
"return",
"converted",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"Convert",
"(",
")",
",",
"converted",
")",
"\n",
"}"
] | // ToExpression returns a string in ltree format.
// Joins UUIDs in the first argument using `.`
// Second argument is converted and appended if needed | [
"ToExpression",
"returns",
"a",
"string",
"in",
"ltree",
"format",
".",
"Joins",
"UUIDs",
"in",
"the",
"first",
"argument",
"using",
".",
"Second",
"argument",
"is",
"converted",
"and",
"appended",
"if",
"needed"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/path/path.go#L192-L199 |
13,512 | fabric8-services/fabric8-wit | design/workitems.go | Reorder | func Reorder(name, description string, data *d.UserTypeDefinition, position *d.UserTypeDefinition) *d.MediaTypeDefinition {
return a.MediaType("application/vnd."+strings.ToLower(name)+"json", func() {
a.UseTrait("jsonapi-media-type")
a.TypeName(name + "Reorder")
a.Description(description)
a.Attribute("data", a.ArrayOf(data))
a.Attribute("position", position)
a.View("default", func() {
a.Attribute("data")
a.Required("data")
})
})
} | go | func Reorder(name, description string, data *d.UserTypeDefinition, position *d.UserTypeDefinition) *d.MediaTypeDefinition {
return a.MediaType("application/vnd."+strings.ToLower(name)+"json", func() {
a.UseTrait("jsonapi-media-type")
a.TypeName(name + "Reorder")
a.Description(description)
a.Attribute("data", a.ArrayOf(data))
a.Attribute("position", position)
a.View("default", func() {
a.Attribute("data")
a.Required("data")
})
})
} | [
"func",
"Reorder",
"(",
"name",
",",
"description",
"string",
",",
"data",
"*",
"d",
".",
"UserTypeDefinition",
",",
"position",
"*",
"d",
".",
"UserTypeDefinition",
")",
"*",
"d",
".",
"MediaTypeDefinition",
"{",
"return",
"a",
".",
"MediaType",
"(",
"\"",
"\"",
"+",
"strings",
".",
"ToLower",
"(",
"name",
")",
"+",
"\"",
"\"",
",",
"func",
"(",
")",
"{",
"a",
".",
"UseTrait",
"(",
"\"",
"\"",
")",
"\n",
"a",
".",
"TypeName",
"(",
"name",
"+",
"\"",
"\"",
")",
"\n",
"a",
".",
"Description",
"(",
"description",
")",
"\n",
"a",
".",
"Attribute",
"(",
"\"",
"\"",
",",
"a",
".",
"ArrayOf",
"(",
"data",
")",
")",
"\n",
"a",
".",
"Attribute",
"(",
"\"",
"\"",
",",
"position",
")",
"\n",
"a",
".",
"View",
"(",
"\"",
"\"",
",",
"func",
"(",
")",
"{",
"a",
".",
"Attribute",
"(",
"\"",
"\"",
")",
"\n",
"a",
".",
"Required",
"(",
"\"",
"\"",
")",
"\n",
"}",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Reorder creates a UserTypeDefinition for Reorder action | [
"Reorder",
"creates",
"a",
"UserTypeDefinition",
"for",
"Reorder",
"action"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/design/workitems.go#L89-L101 |
13,513 | fabric8-services/fabric8-wit | controller/work_item_type_groups.go | NewWorkItemTypeGroupsController | func NewWorkItemTypeGroupsController(service *goa.Service, db application.DB) *WorkItemTypeGroupsController {
return &WorkItemTypeGroupsController{
Controller: service.NewController("WorkItemTypeGroupsController"),
db: db,
}
} | go | func NewWorkItemTypeGroupsController(service *goa.Service, db application.DB) *WorkItemTypeGroupsController {
return &WorkItemTypeGroupsController{
Controller: service.NewController("WorkItemTypeGroupsController"),
db: db,
}
} | [
"func",
"NewWorkItemTypeGroupsController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"db",
"application",
".",
"DB",
")",
"*",
"WorkItemTypeGroupsController",
"{",
"return",
"&",
"WorkItemTypeGroupsController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"",
")",
",",
"db",
":",
"db",
",",
"}",
"\n",
"}"
] | // NewWorkItemTypeGroupsController creates a work_item_type_groups controller. | [
"NewWorkItemTypeGroupsController",
"creates",
"a",
"work_item_type_groups",
"controller",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/work_item_type_groups.go#L20-L25 |
13,514 | fabric8-services/fabric8-wit | controller/tracker.go | NewTrackerController | func NewTrackerController(service *goa.Service, db application.DB, scheduler *remoteworkitem.Scheduler, configuration trackerConfiguration) *TrackerController {
return &TrackerController{
Controller: service.NewController("TrackerController"),
db: db,
scheduler: scheduler,
configuration: configuration}
} | go | func NewTrackerController(service *goa.Service, db application.DB, scheduler *remoteworkitem.Scheduler, configuration trackerConfiguration) *TrackerController {
return &TrackerController{
Controller: service.NewController("TrackerController"),
db: db,
scheduler: scheduler,
configuration: configuration}
} | [
"func",
"NewTrackerController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"db",
"application",
".",
"DB",
",",
"scheduler",
"*",
"remoteworkitem",
".",
"Scheduler",
",",
"configuration",
"trackerConfiguration",
")",
"*",
"TrackerController",
"{",
"return",
"&",
"TrackerController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"",
")",
",",
"db",
":",
"db",
",",
"scheduler",
":",
"scheduler",
",",
"configuration",
":",
"configuration",
"}",
"\n",
"}"
] | // NewTrackerController creates a tracker controller. | [
"NewTrackerController",
"creates",
"a",
"tracker",
"controller",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/tracker.go#L38-L44 |
13,515 | fabric8-services/fabric8-wit | controller/tracker.go | ConvertTrackers | func ConvertTrackers(request *http.Request, trackers []remoteworkitem.Tracker) []*app.Tracker {
var ls = []*app.Tracker{}
for _, i := range trackers {
ls = append(ls, ConvertTracker(request, i))
}
return ls
} | go | func ConvertTrackers(request *http.Request, trackers []remoteworkitem.Tracker) []*app.Tracker {
var ls = []*app.Tracker{}
for _, i := range trackers {
ls = append(ls, ConvertTracker(request, i))
}
return ls
} | [
"func",
"ConvertTrackers",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"trackers",
"[",
"]",
"remoteworkitem",
".",
"Tracker",
")",
"[",
"]",
"*",
"app",
".",
"Tracker",
"{",
"var",
"ls",
"=",
"[",
"]",
"*",
"app",
".",
"Tracker",
"{",
"}",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"trackers",
"{",
"ls",
"=",
"append",
"(",
"ls",
",",
"ConvertTracker",
"(",
"request",
",",
"i",
")",
")",
"\n",
"}",
"\n",
"return",
"ls",
"\n",
"}"
] | // ConvertTrackers from internal to external REST representation | [
"ConvertTrackers",
"from",
"internal",
"to",
"external",
"REST",
"representation"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/tracker.go#L137-L143 |
13,516 | fabric8-services/fabric8-wit | controller/tracker.go | ConvertTracker | func ConvertTracker(request *http.Request, tracker remoteworkitem.Tracker) *app.Tracker {
trackerStringType := remoteworkitem.APIStringTypeTrackers
selfURL := rest.AbsoluteURL(request, app.TrackerHref(tracker.ID))
t := &app.Tracker{
Type: trackerStringType,
ID: &tracker.ID,
Attributes: &app.TrackerAttributes{
URL: tracker.URL,
Type: tracker.Type,
},
Links: &app.GenericLinks{
Self: &selfURL,
},
}
return t
} | go | func ConvertTracker(request *http.Request, tracker remoteworkitem.Tracker) *app.Tracker {
trackerStringType := remoteworkitem.APIStringTypeTrackers
selfURL := rest.AbsoluteURL(request, app.TrackerHref(tracker.ID))
t := &app.Tracker{
Type: trackerStringType,
ID: &tracker.ID,
Attributes: &app.TrackerAttributes{
URL: tracker.URL,
Type: tracker.Type,
},
Links: &app.GenericLinks{
Self: &selfURL,
},
}
return t
} | [
"func",
"ConvertTracker",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"tracker",
"remoteworkitem",
".",
"Tracker",
")",
"*",
"app",
".",
"Tracker",
"{",
"trackerStringType",
":=",
"remoteworkitem",
".",
"APIStringTypeTrackers",
"\n",
"selfURL",
":=",
"rest",
".",
"AbsoluteURL",
"(",
"request",
",",
"app",
".",
"TrackerHref",
"(",
"tracker",
".",
"ID",
")",
")",
"\n",
"t",
":=",
"&",
"app",
".",
"Tracker",
"{",
"Type",
":",
"trackerStringType",
",",
"ID",
":",
"&",
"tracker",
".",
"ID",
",",
"Attributes",
":",
"&",
"app",
".",
"TrackerAttributes",
"{",
"URL",
":",
"tracker",
".",
"URL",
",",
"Type",
":",
"tracker",
".",
"Type",
",",
"}",
",",
"Links",
":",
"&",
"app",
".",
"GenericLinks",
"{",
"Self",
":",
"&",
"selfURL",
",",
"}",
",",
"}",
"\n",
"return",
"t",
"\n",
"}"
] | // ConvertTracker converts from internal to external REST representation | [
"ConvertTracker",
"converts",
"from",
"internal",
"to",
"external",
"REST",
"representation"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/tracker.go#L179-L194 |
13,517 | fabric8-services/fabric8-wit | controller/filter.go | NewFilterController | func NewFilterController(service *goa.Service, config FilterControllerConfiguration) *FilterController {
return &FilterController{
Controller: service.NewController("FilterController"),
config: config,
}
} | go | func NewFilterController(service *goa.Service, config FilterControllerConfiguration) *FilterController {
return &FilterController{
Controller: service.NewController("FilterController"),
config: config,
}
} | [
"func",
"NewFilterController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"config",
"FilterControllerConfiguration",
")",
"*",
"FilterController",
"{",
"return",
"&",
"FilterController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"",
")",
",",
"config",
":",
"config",
",",
"}",
"\n",
"}"
] | // NewFilterController creates a filter controller. | [
"NewFilterController",
"creates",
"a",
"filter",
"controller",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/filter.go#L25-L30 |
13,518 | fabric8-services/fabric8-wit | sentry/sentry.go | WithEnvironment | func WithEnvironment(env string) func(*client) {
return func(c *client) {
c.c.SetEnvironment(env)
}
} | go | func WithEnvironment(env string) func(*client) {
return func(c *client) {
c.c.SetEnvironment(env)
}
} | [
"func",
"WithEnvironment",
"(",
"env",
"string",
")",
"func",
"(",
"*",
"client",
")",
"{",
"return",
"func",
"(",
"c",
"*",
"client",
")",
"{",
"c",
".",
"c",
".",
"SetEnvironment",
"(",
"env",
")",
"\n",
"}",
"\n",
"}"
] | // WithEnvironment helps you set environment the deployed code is
// running in while initializing sentry client using function
// InitializeSentryClient | [
"WithEnvironment",
"helps",
"you",
"set",
"environment",
"the",
"deployed",
"code",
"is",
"running",
"in",
"while",
"initializing",
"sentry",
"client",
"using",
"function",
"InitializeSentryClient"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/sentry/sentry.go#L65-L69 |
13,519 | fabric8-services/fabric8-wit | sentry/sentry.go | CaptureError | func (c *client) CaptureError(ctx context.Context, err error) {
// if method called during test which has uninitialized client
if c == nil {
return
}
// Extract user information. Ignoring error here but then before using the
// object user make sure to check if it wasn't nil.
user, _ := extractUserInfo(ctx)
reqID := log.ExtractRequestID(ctx)
c.sendErr <- func() {
if user != nil {
c.c.SetUserContext(user)
}
additionalContext := make(map[string]string)
if reqID != "" {
additionalContext["req_ID"] = reqID
}
c.c.CaptureError(err, additionalContext)
c.c.ClearContext()
}
} | go | func (c *client) CaptureError(ctx context.Context, err error) {
// if method called during test which has uninitialized client
if c == nil {
return
}
// Extract user information. Ignoring error here but then before using the
// object user make sure to check if it wasn't nil.
user, _ := extractUserInfo(ctx)
reqID := log.ExtractRequestID(ctx)
c.sendErr <- func() {
if user != nil {
c.c.SetUserContext(user)
}
additionalContext := make(map[string]string)
if reqID != "" {
additionalContext["req_ID"] = reqID
}
c.c.CaptureError(err, additionalContext)
c.c.ClearContext()
}
} | [
"func",
"(",
"c",
"*",
"client",
")",
"CaptureError",
"(",
"ctx",
"context",
".",
"Context",
",",
"err",
"error",
")",
"{",
"// if method called during test which has uninitialized client",
"if",
"c",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// Extract user information. Ignoring error here but then before using the",
"// object user make sure to check if it wasn't nil.",
"user",
",",
"_",
":=",
"extractUserInfo",
"(",
"ctx",
")",
"\n",
"reqID",
":=",
"log",
".",
"ExtractRequestID",
"(",
"ctx",
")",
"\n\n",
"c",
".",
"sendErr",
"<-",
"func",
"(",
")",
"{",
"if",
"user",
"!=",
"nil",
"{",
"c",
".",
"c",
".",
"SetUserContext",
"(",
"user",
")",
"\n",
"}",
"\n\n",
"additionalContext",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"reqID",
"!=",
"\"",
"\"",
"{",
"additionalContext",
"[",
"\"",
"\"",
"]",
"=",
"reqID",
"\n",
"}",
"\n\n",
"c",
".",
"c",
".",
"CaptureError",
"(",
"err",
",",
"additionalContext",
")",
"\n",
"c",
".",
"c",
".",
"ClearContext",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // CaptureError sends error 'err' to Sentry, meanwhile also sets user
// information by extracting user information from the context provided | [
"CaptureError",
"sends",
"error",
"err",
"to",
"Sentry",
"meanwhile",
"also",
"sets",
"user",
"information",
"by",
"extracting",
"user",
"information",
"from",
"the",
"context",
"provided"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/sentry/sentry.go#L81-L104 |
13,520 | fabric8-services/fabric8-wit | sentry/sentry.go | extractUserInfo | func extractUserInfo(ctx context.Context) (*raven.User, error) {
m, err := token.ReadManagerFromContext(ctx)
if err != nil {
return nil, err
}
q := *m
token := goajwt.ContextJWT(ctx)
if token == nil {
return nil, fmt.Errorf("no token found in context")
}
t, err := q.ParseToken(ctx, token.Raw)
if err != nil {
return nil, err
}
return &raven.User{
Username: t.Username,
Email: t.Email,
ID: t.Subject,
}, nil
} | go | func extractUserInfo(ctx context.Context) (*raven.User, error) {
m, err := token.ReadManagerFromContext(ctx)
if err != nil {
return nil, err
}
q := *m
token := goajwt.ContextJWT(ctx)
if token == nil {
return nil, fmt.Errorf("no token found in context")
}
t, err := q.ParseToken(ctx, token.Raw)
if err != nil {
return nil, err
}
return &raven.User{
Username: t.Username,
Email: t.Email,
ID: t.Subject,
}, nil
} | [
"func",
"extractUserInfo",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"raven",
".",
"User",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"token",
".",
"ReadManagerFromContext",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"q",
":=",
"*",
"m",
"\n",
"token",
":=",
"goajwt",
".",
"ContextJWT",
"(",
"ctx",
")",
"\n",
"if",
"token",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"t",
",",
"err",
":=",
"q",
".",
"ParseToken",
"(",
"ctx",
",",
"token",
".",
"Raw",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"raven",
".",
"User",
"{",
"Username",
":",
"t",
".",
"Username",
",",
"Email",
":",
"t",
".",
"Email",
",",
"ID",
":",
"t",
".",
"Subject",
",",
"}",
",",
"nil",
"\n",
"}"
] | // extractUserInfo reads the context and returns sentry understandable
// user object's reference and error | [
"extractUserInfo",
"reads",
"the",
"context",
"and",
"returns",
"sentry",
"understandable",
"user",
"object",
"s",
"reference",
"and",
"error"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/sentry/sentry.go#L108-L129 |
13,521 | fabric8-services/fabric8-wit | spacetemplate/importer/repository.go | checkNoWITIsMissing | func (r *GormRepository) checkNoWITIsMissing(ctx context.Context, s *ImportHelper) error {
type idType struct {
ID uuid.UUID `gorm:"column:id" sql:"type:uuid"`
}
var IDs []idType
query := fmt.Sprintf(`SELECT id FROM "%s" WHERE space_template_id = ?`, workitem.WorkItemType{}.TableName())
db := r.db.Raw(query, s.Template.ID.String()).Scan(&IDs)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to load all work item types for space template '%s'", s.Template.ID)
}
toBeFoundIDs := id.Map{}
for _, i := range IDs {
toBeFoundIDs[i.ID] = struct{}{}
}
for _, wit := range s.WITs {
delete(toBeFoundIDs, wit.ID)
}
if len(toBeFoundIDs) > 0 {
return errs.Errorf("work item types to be imported must not remove these existing work item types: %s", toBeFoundIDs)
}
return nil
} | go | func (r *GormRepository) checkNoWITIsMissing(ctx context.Context, s *ImportHelper) error {
type idType struct {
ID uuid.UUID `gorm:"column:id" sql:"type:uuid"`
}
var IDs []idType
query := fmt.Sprintf(`SELECT id FROM "%s" WHERE space_template_id = ?`, workitem.WorkItemType{}.TableName())
db := r.db.Raw(query, s.Template.ID.String()).Scan(&IDs)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to load all work item types for space template '%s'", s.Template.ID)
}
toBeFoundIDs := id.Map{}
for _, i := range IDs {
toBeFoundIDs[i.ID] = struct{}{}
}
for _, wit := range s.WITs {
delete(toBeFoundIDs, wit.ID)
}
if len(toBeFoundIDs) > 0 {
return errs.Errorf("work item types to be imported must not remove these existing work item types: %s", toBeFoundIDs)
}
return nil
} | [
"func",
"(",
"r",
"*",
"GormRepository",
")",
"checkNoWITIsMissing",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"ImportHelper",
")",
"error",
"{",
"type",
"idType",
"struct",
"{",
"ID",
"uuid",
".",
"UUID",
"`gorm:\"column:id\" sql:\"type:uuid\"`",
"\n",
"}",
"\n",
"var",
"IDs",
"[",
"]",
"idType",
"\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"`SELECT id FROM \"%s\" WHERE space_template_id = ?`",
",",
"workitem",
".",
"WorkItemType",
"{",
"}",
".",
"TableName",
"(",
")",
")",
"\n",
"db",
":=",
"r",
".",
"db",
".",
"Raw",
"(",
"query",
",",
"s",
".",
"Template",
".",
"ID",
".",
"String",
"(",
")",
")",
".",
"Scan",
"(",
"&",
"IDs",
")",
"\n",
"if",
"db",
".",
"Error",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrapf",
"(",
"db",
".",
"Error",
",",
"\"",
"\"",
",",
"s",
".",
"Template",
".",
"ID",
")",
"\n",
"}",
"\n",
"toBeFoundIDs",
":=",
"id",
".",
"Map",
"{",
"}",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"IDs",
"{",
"toBeFoundIDs",
"[",
"i",
".",
"ID",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"wit",
":=",
"range",
"s",
".",
"WITs",
"{",
"delete",
"(",
"toBeFoundIDs",
",",
"wit",
".",
"ID",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"toBeFoundIDs",
")",
">",
"0",
"{",
"return",
"errs",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"toBeFoundIDs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // checkNoWITIsMissing returns an error if currently imported work item types
// are missing already existing work item types. | [
"checkNoWITIsMissing",
"returns",
"an",
"error",
"if",
"currently",
"imported",
"work",
"item",
"types",
"are",
"missing",
"already",
"existing",
"work",
"item",
"types",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/spacetemplate/importer/repository.go#L242-L263 |
13,522 | fabric8-services/fabric8-wit | spacetemplate/importer/repository.go | checkNoWILTIsMissing | func (r *GormRepository) checkNoWILTIsMissing(ctx context.Context, s *ImportHelper) error {
type idType struct {
ID uuid.UUID `gorm:"column:id" sql:"type:uuid"`
}
var IDs []idType
query := fmt.Sprintf(`SELECT id FROM "%s" WHERE space_template_id = ?`, link.WorkItemLinkType{}.TableName())
db := r.db.Raw(query, s.Template.ID.String()).Scan(&IDs)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to load all work item link types for space template '%s'", s.Template.ID)
}
toBeFoundIDs := id.Map{}
for _, i := range IDs {
toBeFoundIDs[i.ID] = struct{}{}
}
for _, wilt := range s.WILTs {
delete(toBeFoundIDs, wilt.ID)
}
if len(toBeFoundIDs) > 0 {
return errs.Errorf("work item link types to be imported must not remove these existing work item link types: %s", toBeFoundIDs)
}
return nil
} | go | func (r *GormRepository) checkNoWILTIsMissing(ctx context.Context, s *ImportHelper) error {
type idType struct {
ID uuid.UUID `gorm:"column:id" sql:"type:uuid"`
}
var IDs []idType
query := fmt.Sprintf(`SELECT id FROM "%s" WHERE space_template_id = ?`, link.WorkItemLinkType{}.TableName())
db := r.db.Raw(query, s.Template.ID.String()).Scan(&IDs)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to load all work item link types for space template '%s'", s.Template.ID)
}
toBeFoundIDs := id.Map{}
for _, i := range IDs {
toBeFoundIDs[i.ID] = struct{}{}
}
for _, wilt := range s.WILTs {
delete(toBeFoundIDs, wilt.ID)
}
if len(toBeFoundIDs) > 0 {
return errs.Errorf("work item link types to be imported must not remove these existing work item link types: %s", toBeFoundIDs)
}
return nil
} | [
"func",
"(",
"r",
"*",
"GormRepository",
")",
"checkNoWILTIsMissing",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"ImportHelper",
")",
"error",
"{",
"type",
"idType",
"struct",
"{",
"ID",
"uuid",
".",
"UUID",
"`gorm:\"column:id\" sql:\"type:uuid\"`",
"\n",
"}",
"\n",
"var",
"IDs",
"[",
"]",
"idType",
"\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"`SELECT id FROM \"%s\" WHERE space_template_id = ?`",
",",
"link",
".",
"WorkItemLinkType",
"{",
"}",
".",
"TableName",
"(",
")",
")",
"\n",
"db",
":=",
"r",
".",
"db",
".",
"Raw",
"(",
"query",
",",
"s",
".",
"Template",
".",
"ID",
".",
"String",
"(",
")",
")",
".",
"Scan",
"(",
"&",
"IDs",
")",
"\n",
"if",
"db",
".",
"Error",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrapf",
"(",
"db",
".",
"Error",
",",
"\"",
"\"",
",",
"s",
".",
"Template",
".",
"ID",
")",
"\n",
"}",
"\n",
"toBeFoundIDs",
":=",
"id",
".",
"Map",
"{",
"}",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"IDs",
"{",
"toBeFoundIDs",
"[",
"i",
".",
"ID",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"wilt",
":=",
"range",
"s",
".",
"WILTs",
"{",
"delete",
"(",
"toBeFoundIDs",
",",
"wilt",
".",
"ID",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"toBeFoundIDs",
")",
">",
"0",
"{",
"return",
"errs",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"toBeFoundIDs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // checkNoWILTIsMissing returns an error if currently imported work item link
// types are missing already existing work item link types. | [
"checkNoWILTIsMissing",
"returns",
"an",
"error",
"if",
"currently",
"imported",
"work",
"item",
"link",
"types",
"are",
"missing",
"already",
"existing",
"work",
"item",
"link",
"types",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/spacetemplate/importer/repository.go#L304-L325 |
13,523 | fabric8-services/fabric8-wit | controller/named_work_items.go | NewNamedWorkItemsController | func NewNamedWorkItemsController(service *goa.Service, db application.DB) *NamedWorkItemsController {
return &NamedWorkItemsController{
Controller: service.NewController("NamedWorkItemsController"),
db: db,
}
} | go | func NewNamedWorkItemsController(service *goa.Service, db application.DB) *NamedWorkItemsController {
return &NamedWorkItemsController{
Controller: service.NewController("NamedWorkItemsController"),
db: db,
}
} | [
"func",
"NewNamedWorkItemsController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"db",
"application",
".",
"DB",
")",
"*",
"NamedWorkItemsController",
"{",
"return",
"&",
"NamedWorkItemsController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"",
")",
",",
"db",
":",
"db",
",",
"}",
"\n",
"}"
] | // NewNamedWorkItemsController creates a named_work_items controller. | [
"NewNamedWorkItemsController",
"creates",
"a",
"named_work_items",
"controller",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/named_work_items.go#L19-L24 |
13,524 | fabric8-services/fabric8-wit | workitem/list_type.go | SetDefaultValue | func (t ListType) SetDefaultValue(v interface{}) (FieldType, error) {
if v == nil {
t.DefaultValue = nil
return t, nil
}
defVal, err := t.ComponentType.ConvertToModel(v)
if err != nil {
return nil, errs.Wrapf(err, "failed to set default value of list type to %+v (%[1]T)", v)
}
t.DefaultValue = defVal
return t, nil
} | go | func (t ListType) SetDefaultValue(v interface{}) (FieldType, error) {
if v == nil {
t.DefaultValue = nil
return t, nil
}
defVal, err := t.ComponentType.ConvertToModel(v)
if err != nil {
return nil, errs.Wrapf(err, "failed to set default value of list type to %+v (%[1]T)", v)
}
t.DefaultValue = defVal
return t, nil
} | [
"func",
"(",
"t",
"ListType",
")",
"SetDefaultValue",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"FieldType",
",",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"t",
".",
"DefaultValue",
"=",
"nil",
"\n",
"return",
"t",
",",
"nil",
"\n",
"}",
"\n",
"defVal",
",",
"err",
":=",
"t",
".",
"ComponentType",
".",
"ConvertToModel",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"t",
".",
"DefaultValue",
"=",
"defVal",
"\n",
"return",
"t",
",",
"nil",
"\n",
"}"
] | // SetDefaultValue implements FieldType | [
"SetDefaultValue",
"implements",
"FieldType"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/list_type.go#L44-L55 |
13,525 | fabric8-services/fabric8-wit | workitem/list_type.go | Equal | func (t ListType) Equal(u convert.Equaler) bool {
other, ok := u.(ListType)
if !ok {
return false
}
if !convert.CascadeEqual(t.SimpleType, other.SimpleType) {
return false
}
if !reflect.DeepEqual(t.DefaultValue, other.DefaultValue) {
return false
}
return convert.CascadeEqual(t.ComponentType, other.ComponentType)
} | go | func (t ListType) Equal(u convert.Equaler) bool {
other, ok := u.(ListType)
if !ok {
return false
}
if !convert.CascadeEqual(t.SimpleType, other.SimpleType) {
return false
}
if !reflect.DeepEqual(t.DefaultValue, other.DefaultValue) {
return false
}
return convert.CascadeEqual(t.ComponentType, other.ComponentType)
} | [
"func",
"(",
"t",
"ListType",
")",
"Equal",
"(",
"u",
"convert",
".",
"Equaler",
")",
"bool",
"{",
"other",
",",
"ok",
":=",
"u",
".",
"(",
"ListType",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"convert",
".",
"CascadeEqual",
"(",
"t",
".",
"SimpleType",
",",
"other",
".",
"SimpleType",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"reflect",
".",
"DeepEqual",
"(",
"t",
".",
"DefaultValue",
",",
"other",
".",
"DefaultValue",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"convert",
".",
"CascadeEqual",
"(",
"t",
".",
"ComponentType",
",",
"other",
".",
"ComponentType",
")",
"\n",
"}"
] | // Equal returns true if two ListType objects are equal; otherwise false is returned. | [
"Equal",
"returns",
"true",
"if",
"two",
"ListType",
"objects",
"are",
"equal",
";",
"otherwise",
"false",
"is",
"returned",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/list_type.go#L63-L75 |
13,526 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | NewWorkItemLinkRepository | func NewWorkItemLinkRepository(db *gorm.DB) *GormWorkItemLinkRepository {
return &GormWorkItemLinkRepository{
db: db,
workItemRepo: workitem.NewWorkItemRepository(db),
workItemTypeRepo: workitem.NewWorkItemTypeRepository(db),
workItemLinkTypeRepo: NewWorkItemLinkTypeRepository(db),
revisionRepo: NewRevisionRepository(db),
}
} | go | func NewWorkItemLinkRepository(db *gorm.DB) *GormWorkItemLinkRepository {
return &GormWorkItemLinkRepository{
db: db,
workItemRepo: workitem.NewWorkItemRepository(db),
workItemTypeRepo: workitem.NewWorkItemTypeRepository(db),
workItemLinkTypeRepo: NewWorkItemLinkTypeRepository(db),
revisionRepo: NewRevisionRepository(db),
}
} | [
"func",
"NewWorkItemLinkRepository",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"GormWorkItemLinkRepository",
"{",
"return",
"&",
"GormWorkItemLinkRepository",
"{",
"db",
":",
"db",
",",
"workItemRepo",
":",
"workitem",
".",
"NewWorkItemRepository",
"(",
"db",
")",
",",
"workItemTypeRepo",
":",
"workitem",
".",
"NewWorkItemTypeRepository",
"(",
"db",
")",
",",
"workItemLinkTypeRepo",
":",
"NewWorkItemLinkTypeRepository",
"(",
"db",
")",
",",
"revisionRepo",
":",
"NewRevisionRepository",
"(",
"db",
")",
",",
"}",
"\n",
"}"
] | // NewWorkItemLinkRepository creates a work item link repository based on gorm | [
"NewWorkItemLinkRepository",
"creates",
"a",
"work",
"item",
"link",
"repository",
"based",
"on",
"gorm"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L51-L59 |
13,527 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | HasParent | func (r *GormWorkItemLinkRepository) HasParent(ctx context.Context, childID uuid.UUID, linkType WorkItemLinkType) (bool, error) {
var row *sql.Row
query := fmt.Sprintf(`
SELECT EXISTS (
SELECT 1 FROM %[1]s
WHERE
link_type_id=$1
AND target_id=$2
AND deleted_at IS NULL
)`, WorkItemLink{}.TableName())
row = r.db.CommonDB().QueryRow(query, linkType.ID, childID)
var exists bool
if err := row.Scan(&exists); err != nil {
return false, errs.Wrapf(err, "failed to check if a parent exists for the work item %d", childID)
}
return exists, nil
} | go | func (r *GormWorkItemLinkRepository) HasParent(ctx context.Context, childID uuid.UUID, linkType WorkItemLinkType) (bool, error) {
var row *sql.Row
query := fmt.Sprintf(`
SELECT EXISTS (
SELECT 1 FROM %[1]s
WHERE
link_type_id=$1
AND target_id=$2
AND deleted_at IS NULL
)`, WorkItemLink{}.TableName())
row = r.db.CommonDB().QueryRow(query, linkType.ID, childID)
var exists bool
if err := row.Scan(&exists); err != nil {
return false, errs.Wrapf(err, "failed to check if a parent exists for the work item %d", childID)
}
return exists, nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"HasParent",
"(",
"ctx",
"context",
".",
"Context",
",",
"childID",
"uuid",
".",
"UUID",
",",
"linkType",
"WorkItemLinkType",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"row",
"*",
"sql",
".",
"Row",
"\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"`\n\t\tSELECT EXISTS (\n\t\t\tSELECT 1 FROM %[1]s\n\t\t\tWHERE\n\t\t\t\tlink_type_id=$1\n\t\t\t\tAND target_id=$2\n\t\t\t\tAND deleted_at IS NULL\n\t\t)`",
",",
"WorkItemLink",
"{",
"}",
".",
"TableName",
"(",
")",
")",
"\n",
"row",
"=",
"r",
".",
"db",
".",
"CommonDB",
"(",
")",
".",
"QueryRow",
"(",
"query",
",",
"linkType",
".",
"ID",
",",
"childID",
")",
"\n",
"var",
"exists",
"bool",
"\n",
"if",
"err",
":=",
"row",
".",
"Scan",
"(",
"&",
"exists",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"childID",
")",
"\n",
"}",
"\n",
"return",
"exists",
",",
"nil",
"\n",
"}"
] | // HasParent returns `true` if a link to a work item with the given `childID`
// and of the given `linkType` already exists; `false` otherwise. | [
"HasParent",
"returns",
"true",
"if",
"a",
"link",
"to",
"a",
"work",
"item",
"with",
"the",
"given",
"childID",
"and",
"of",
"the",
"given",
"linkType",
"already",
"exists",
";",
"false",
"otherwise",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L72-L88 |
13,528 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | ValidateTopology | func (r *GormWorkItemLinkRepository) ValidateTopology(ctx context.Context, sourceID uuid.UUID, targetID uuid.UUID, linkType WorkItemLinkType) error {
// check to disallow multiple parents in tree topology
if linkType.Topology == TopologyTree {
parentExists, err := r.HasParent(ctx, targetID, linkType)
if err != nil {
log.Error(ctx, map[string]interface{}{
"wilt_id": linkType.ID,
"target_id": targetID,
"err": err,
}, "failed to check if the work item %s has a parent work item", targetID)
return errs.Wrapf(err, "failed to check if the work item %s has a parent work item", targetID)
}
if parentExists {
log.Error(ctx, map[string]interface{}{
"wilt_id": linkType.ID,
"target_id": targetID,
"err": err,
}, "unable to create/update work item link because a topology of type %q only allows one parent to exist and the target %d already has a parent", TopologyTree, targetID)
return errors.NewBadParameterError("linkTypeID + targetID", fmt.Sprintf("%s + %d", linkType.ID, targetID)).Expected("single parent in tree topology")
}
}
// Check to disallow cycles in tree and dependency topologies
if linkType.Topology == TopologyTree || linkType.Topology == TopologyDependency {
hasCycle, err := r.DetectCycle(ctx, sourceID, targetID, linkType.ID)
if err != nil {
return errs.Wrapf(err, "error during cycle-detection of new link")
}
if hasCycle {
return errors.NewDataConflictError(fmt.Sprintf("linking the work item %s to %s would create a cycle which isn't allowed in a %s topology", sourceID, targetID, linkType.Topology))
}
}
return nil
} | go | func (r *GormWorkItemLinkRepository) ValidateTopology(ctx context.Context, sourceID uuid.UUID, targetID uuid.UUID, linkType WorkItemLinkType) error {
// check to disallow multiple parents in tree topology
if linkType.Topology == TopologyTree {
parentExists, err := r.HasParent(ctx, targetID, linkType)
if err != nil {
log.Error(ctx, map[string]interface{}{
"wilt_id": linkType.ID,
"target_id": targetID,
"err": err,
}, "failed to check if the work item %s has a parent work item", targetID)
return errs.Wrapf(err, "failed to check if the work item %s has a parent work item", targetID)
}
if parentExists {
log.Error(ctx, map[string]interface{}{
"wilt_id": linkType.ID,
"target_id": targetID,
"err": err,
}, "unable to create/update work item link because a topology of type %q only allows one parent to exist and the target %d already has a parent", TopologyTree, targetID)
return errors.NewBadParameterError("linkTypeID + targetID", fmt.Sprintf("%s + %d", linkType.ID, targetID)).Expected("single parent in tree topology")
}
}
// Check to disallow cycles in tree and dependency topologies
if linkType.Topology == TopologyTree || linkType.Topology == TopologyDependency {
hasCycle, err := r.DetectCycle(ctx, sourceID, targetID, linkType.ID)
if err != nil {
return errs.Wrapf(err, "error during cycle-detection of new link")
}
if hasCycle {
return errors.NewDataConflictError(fmt.Sprintf("linking the work item %s to %s would create a cycle which isn't allowed in a %s topology", sourceID, targetID, linkType.Topology))
}
}
return nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"ValidateTopology",
"(",
"ctx",
"context",
".",
"Context",
",",
"sourceID",
"uuid",
".",
"UUID",
",",
"targetID",
"uuid",
".",
"UUID",
",",
"linkType",
"WorkItemLinkType",
")",
"error",
"{",
"// check to disallow multiple parents in tree topology",
"if",
"linkType",
".",
"Topology",
"==",
"TopologyTree",
"{",
"parentExists",
",",
"err",
":=",
"r",
".",
"HasParent",
"(",
"ctx",
",",
"targetID",
",",
"linkType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"linkType",
".",
"ID",
",",
"\"",
"\"",
":",
"targetID",
",",
"\"",
"\"",
":",
"err",
",",
"}",
",",
"\"",
"\"",
",",
"targetID",
")",
"\n",
"return",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"targetID",
")",
"\n",
"}",
"\n",
"if",
"parentExists",
"{",
"log",
".",
"Error",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"linkType",
".",
"ID",
",",
"\"",
"\"",
":",
"targetID",
",",
"\"",
"\"",
":",
"err",
",",
"}",
",",
"\"",
"\"",
",",
"TopologyTree",
",",
"targetID",
")",
"\n",
"return",
"errors",
".",
"NewBadParameterError",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"linkType",
".",
"ID",
",",
"targetID",
")",
")",
".",
"Expected",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// Check to disallow cycles in tree and dependency topologies",
"if",
"linkType",
".",
"Topology",
"==",
"TopologyTree",
"||",
"linkType",
".",
"Topology",
"==",
"TopologyDependency",
"{",
"hasCycle",
",",
"err",
":=",
"r",
".",
"DetectCycle",
"(",
"ctx",
",",
"sourceID",
",",
"targetID",
",",
"linkType",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"hasCycle",
"{",
"return",
"errors",
".",
"NewDataConflictError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sourceID",
",",
"targetID",
",",
"linkType",
".",
"Topology",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ValidateTopology validates the link topology of the work item given its ID. I.e, the given item should not have a parent with the same kind of link
// if the `sourceID` arg is not empty, then the corresponding source item is ignored when checking the existing links of the given type. | [
"ValidateTopology",
"validates",
"the",
"link",
"topology",
"of",
"the",
"work",
"item",
"given",
"its",
"ID",
".",
"I",
".",
"e",
"the",
"given",
"item",
"should",
"not",
"have",
"a",
"parent",
"with",
"the",
"same",
"kind",
"of",
"link",
"if",
"the",
"sourceID",
"arg",
"is",
"not",
"empty",
"then",
"the",
"corresponding",
"source",
"item",
"is",
"ignored",
"when",
"checking",
"the",
"existing",
"links",
"of",
"the",
"given",
"type",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L92-L124 |
13,529 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | acquireLock | func (r *GormWorkItemLinkRepository) acquireLock(spaceID uuid.UUID) error {
// hash the UUID to get a 32 bit value from a 128 UUID that we can then use
// with a PostgreSQL advisory lock.
//
// TODO(kwk): Reducing the 128 bit UUID to a 32 bit number potentially ends
// up in longer wait times for locks because there exists a certain
// potential to have hash collisions for two distinct UUIDs. But currently
// Postgres only allows for 64 bit numbers without the high bit set. That
// effectively limits us to just 32 bit hashes. Once we allow cross-space
// linking we need to revisit the locking.
h := fnv.New32()
h.Write([]byte("links-" + spaceID.String()))
key := h.Sum32()
db := r.db.Exec("SELECT pg_advisory_xact_lock($1)", key)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to acquire pg_advisory_xact_lock(%d)\n", key)
}
return nil
} | go | func (r *GormWorkItemLinkRepository) acquireLock(spaceID uuid.UUID) error {
// hash the UUID to get a 32 bit value from a 128 UUID that we can then use
// with a PostgreSQL advisory lock.
//
// TODO(kwk): Reducing the 128 bit UUID to a 32 bit number potentially ends
// up in longer wait times for locks because there exists a certain
// potential to have hash collisions for two distinct UUIDs. But currently
// Postgres only allows for 64 bit numbers without the high bit set. That
// effectively limits us to just 32 bit hashes. Once we allow cross-space
// linking we need to revisit the locking.
h := fnv.New32()
h.Write([]byte("links-" + spaceID.String()))
key := h.Sum32()
db := r.db.Exec("SELECT pg_advisory_xact_lock($1)", key)
if db.Error != nil {
return errs.Wrapf(db.Error, "failed to acquire pg_advisory_xact_lock(%d)\n", key)
}
return nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"acquireLock",
"(",
"spaceID",
"uuid",
".",
"UUID",
")",
"error",
"{",
"// hash the UUID to get a 32 bit value from a 128 UUID that we can then use",
"// with a PostgreSQL advisory lock.",
"//",
"// TODO(kwk): Reducing the 128 bit UUID to a 32 bit number potentially ends",
"// up in longer wait times for locks because there exists a certain",
"// potential to have hash collisions for two distinct UUIDs. But currently",
"// Postgres only allows for 64 bit numbers without the high bit set. That",
"// effectively limits us to just 32 bit hashes. Once we allow cross-space",
"// linking we need to revisit the locking.",
"h",
":=",
"fnv",
".",
"New32",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
"+",
"spaceID",
".",
"String",
"(",
")",
")",
")",
"\n",
"key",
":=",
"h",
".",
"Sum32",
"(",
")",
"\n\n",
"db",
":=",
"r",
".",
"db",
".",
"Exec",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"db",
".",
"Error",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrapf",
"(",
"db",
".",
"Error",
",",
"\"",
"\\n",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // acquireLock takes a space ID and acquires an advisory lock. It blocks until
// it acquires the lock. | [
"acquireLock",
"takes",
"a",
"space",
"ID",
"and",
"acquires",
"an",
"advisory",
"lock",
".",
"It",
"blocks",
"until",
"it",
"acquires",
"the",
"lock",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L187-L206 |
13,530 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | Load | func (r *GormWorkItemLinkRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "load"}, time.Now())
log.Info(ctx, map[string]interface{}{
"wil_id": ID,
}, "Loading work item link")
result := WorkItemLink{}
db := r.db.Where("id=?", ID).Find(&result)
if db.RecordNotFound() {
log.Error(ctx, map[string]interface{}{
"wil_id": ID,
}, "work item link not found")
return nil, errors.NewNotFoundError("work item link", ID.String())
}
if db.Error != nil {
return nil, errors.NewInternalError(ctx, db.Error)
}
return &result, nil
} | go | func (r *GormWorkItemLinkRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLink, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "load"}, time.Now())
log.Info(ctx, map[string]interface{}{
"wil_id": ID,
}, "Loading work item link")
result := WorkItemLink{}
db := r.db.Where("id=?", ID).Find(&result)
if db.RecordNotFound() {
log.Error(ctx, map[string]interface{}{
"wil_id": ID,
}, "work item link not found")
return nil, errors.NewNotFoundError("work item link", ID.String())
}
if db.Error != nil {
return nil, errors.NewInternalError(ctx, db.Error)
}
return &result, nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"Load",
"(",
"ctx",
"context",
".",
"Context",
",",
"ID",
"uuid",
".",
"UUID",
")",
"(",
"*",
"WorkItemLink",
",",
"error",
")",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n",
"log",
".",
"Info",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"ID",
",",
"}",
",",
"\"",
"\"",
")",
"\n",
"result",
":=",
"WorkItemLink",
"{",
"}",
"\n",
"db",
":=",
"r",
".",
"db",
".",
"Where",
"(",
"\"",
"\"",
",",
"ID",
")",
".",
"Find",
"(",
"&",
"result",
")",
"\n",
"if",
"db",
".",
"RecordNotFound",
"(",
")",
"{",
"log",
".",
"Error",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"ID",
",",
"}",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"errors",
".",
"NewNotFoundError",
"(",
"\"",
"\"",
",",
"ID",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"db",
".",
"Error",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"NewInternalError",
"(",
"ctx",
",",
"db",
".",
"Error",
")",
"\n",
"}",
"\n",
"return",
"&",
"result",
",",
"nil",
"\n",
"}"
] | // Load returns the work item link for the given ID.
// Returns NotFoundError, ConversionError or InternalError | [
"Load",
"returns",
"the",
"work",
"item",
"link",
"for",
"the",
"given",
"ID",
".",
"Returns",
"NotFoundError",
"ConversionError",
"or",
"InternalError"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L279-L296 |
13,531 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | DeleteRelatedLinks | func (r *GormWorkItemLinkRepository) DeleteRelatedLinks(ctx context.Context, wiID uuid.UUID, suppressorID uuid.UUID) error {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "deleteRelatedLinks"}, time.Now())
log.Info(ctx, map[string]interface{}{
"wi_id": wiID,
}, "Deleting the links related to work item")
var workitemLinks = []WorkItemLink{}
r.db.Where("? in (source_id, target_id)", wiID).Find(&workitemLinks)
// delete one by one to trigger the creation of a new work item link revision
locked := false
for _, workitemLink := range workitemLinks {
if !locked {
wiRepo := workitem.NewWorkItemRepository(r.db)
src, err := wiRepo.LoadByID(ctx, workitemLink.SourceID)
if err != nil {
return errs.Wrapf(err, "failed to load source work item for: %s", workitemLink.SourceID)
}
if err := r.acquireLock(src.SpaceID); err != nil {
return errs.Wrap(err, "failed to acquire lock during link deletion")
}
locked = true
}
r.deleteLink(ctx, workitemLink, suppressorID)
}
return nil
} | go | func (r *GormWorkItemLinkRepository) DeleteRelatedLinks(ctx context.Context, wiID uuid.UUID, suppressorID uuid.UUID) error {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "deleteRelatedLinks"}, time.Now())
log.Info(ctx, map[string]interface{}{
"wi_id": wiID,
}, "Deleting the links related to work item")
var workitemLinks = []WorkItemLink{}
r.db.Where("? in (source_id, target_id)", wiID).Find(&workitemLinks)
// delete one by one to trigger the creation of a new work item link revision
locked := false
for _, workitemLink := range workitemLinks {
if !locked {
wiRepo := workitem.NewWorkItemRepository(r.db)
src, err := wiRepo.LoadByID(ctx, workitemLink.SourceID)
if err != nil {
return errs.Wrapf(err, "failed to load source work item for: %s", workitemLink.SourceID)
}
if err := r.acquireLock(src.SpaceID); err != nil {
return errs.Wrap(err, "failed to acquire lock during link deletion")
}
locked = true
}
r.deleteLink(ctx, workitemLink, suppressorID)
}
return nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"DeleteRelatedLinks",
"(",
"ctx",
"context",
".",
"Context",
",",
"wiID",
"uuid",
".",
"UUID",
",",
"suppressorID",
"uuid",
".",
"UUID",
")",
"error",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n",
"log",
".",
"Info",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"wiID",
",",
"}",
",",
"\"",
"\"",
")",
"\n",
"var",
"workitemLinks",
"=",
"[",
"]",
"WorkItemLink",
"{",
"}",
"\n",
"r",
".",
"db",
".",
"Where",
"(",
"\"",
"\"",
",",
"wiID",
")",
".",
"Find",
"(",
"&",
"workitemLinks",
")",
"\n",
"// delete one by one to trigger the creation of a new work item link revision",
"locked",
":=",
"false",
"\n",
"for",
"_",
",",
"workitemLink",
":=",
"range",
"workitemLinks",
"{",
"if",
"!",
"locked",
"{",
"wiRepo",
":=",
"workitem",
".",
"NewWorkItemRepository",
"(",
"r",
".",
"db",
")",
"\n",
"src",
",",
"err",
":=",
"wiRepo",
".",
"LoadByID",
"(",
"ctx",
",",
"workitemLink",
".",
"SourceID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"workitemLink",
".",
"SourceID",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"r",
".",
"acquireLock",
"(",
"src",
".",
"SpaceID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errs",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"locked",
"=",
"true",
"\n",
"}",
"\n",
"r",
".",
"deleteLink",
"(",
"ctx",
",",
"workitemLink",
",",
"suppressorID",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DeleteRelatedLinks deletes all links in which the source or target equals the
// given work item ID. | [
"DeleteRelatedLinks",
"deletes",
"all",
"links",
"in",
"which",
"the",
"source",
"or",
"target",
"equals",
"the",
"given",
"work",
"item",
"ID",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L358-L382 |
13,532 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | ListChildLinks | func (r *GormWorkItemLinkRepository) ListChildLinks(ctx context.Context, linkTypeID uuid.UUID, parentIDs ...uuid.UUID) (WorkItemLinkList, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "list", "children", "ids"}, time.Now())
var results WorkItemLinkList
db := r.db.Model(&WorkItemLink{}).Where("source_id IN (?) AND link_type_id = ?", parentIDs, linkTypeID).Scan(&results)
if db.Error != nil {
log.Error(ctx, map[string]interface{}{
"err": db.Error,
}, "failed to find children for work items: %+v", parentIDs)
return nil, errors.NewInternalError(ctx, errs.Wrapf(db.Error, "failed to find children for work items: %+v", parentIDs))
}
return results, nil
} | go | func (r *GormWorkItemLinkRepository) ListChildLinks(ctx context.Context, linkTypeID uuid.UUID, parentIDs ...uuid.UUID) (WorkItemLinkList, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "list", "children", "ids"}, time.Now())
var results WorkItemLinkList
db := r.db.Model(&WorkItemLink{}).Where("source_id IN (?) AND link_type_id = ?", parentIDs, linkTypeID).Scan(&results)
if db.Error != nil {
log.Error(ctx, map[string]interface{}{
"err": db.Error,
}, "failed to find children for work items: %+v", parentIDs)
return nil, errors.NewInternalError(ctx, errs.Wrapf(db.Error, "failed to find children for work items: %+v", parentIDs))
}
return results, nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"ListChildLinks",
"(",
"ctx",
"context",
".",
"Context",
",",
"linkTypeID",
"uuid",
".",
"UUID",
",",
"parentIDs",
"...",
"uuid",
".",
"UUID",
")",
"(",
"WorkItemLinkList",
",",
"error",
")",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n\n",
"var",
"results",
"WorkItemLinkList",
"\n",
"db",
":=",
"r",
".",
"db",
".",
"Model",
"(",
"&",
"WorkItemLink",
"{",
"}",
")",
".",
"Where",
"(",
"\"",
"\"",
",",
"parentIDs",
",",
"linkTypeID",
")",
".",
"Scan",
"(",
"&",
"results",
")",
"\n",
"if",
"db",
".",
"Error",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"db",
".",
"Error",
",",
"}",
",",
"\"",
"\"",
",",
"parentIDs",
")",
"\n",
"return",
"nil",
",",
"errors",
".",
"NewInternalError",
"(",
"ctx",
",",
"errs",
".",
"Wrapf",
"(",
"db",
".",
"Error",
",",
"\"",
"\"",
",",
"parentIDs",
")",
")",
"\n",
"}",
"\n\n",
"return",
"results",
",",
"nil",
"\n",
"}"
] | // ListChildLinks gets all links to children for the given parents | [
"ListChildLinks",
"gets",
"all",
"links",
"to",
"children",
"for",
"the",
"given",
"parents"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L410-L423 |
13,533 | fabric8-services/fabric8-wit | workitem/link/link_repository.go | WorkItemHasChildren | func (r *GormWorkItemLinkRepository) WorkItemHasChildren(ctx context.Context, parentID uuid.UUID) (bool, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "has", "children"}, time.Now())
query := fmt.Sprintf(`
SELECT EXISTS (
SELECT 1 FROM %[1]s WHERE id in (
SELECT target_id FROM %[2]s
WHERE source_id = $1 AND deleted_at IS NULL AND link_type_id = $2
)
)`,
workitem.WorkItemStorage{}.TableName(),
WorkItemLink{}.TableName())
var hasChildren bool
db := r.db.CommonDB()
stmt, err := db.Prepare(query)
if err != nil {
return false, errs.Wrapf(err, "failed prepare statement: %s", query)
}
defer closeable.Close(ctx, stmt)
err = stmt.QueryRow(parentID.String(), SystemWorkItemLinkTypeParentChildID.String()).Scan(&hasChildren)
if err != nil {
return false, errs.Wrapf(err, "failed to check if work item %s has children: %s", parentID.String(), query)
}
return hasChildren, nil
} | go | func (r *GormWorkItemLinkRepository) WorkItemHasChildren(ctx context.Context, parentID uuid.UUID) (bool, error) {
defer goa.MeasureSince([]string{"goa", "db", "workitemlink", "has", "children"}, time.Now())
query := fmt.Sprintf(`
SELECT EXISTS (
SELECT 1 FROM %[1]s WHERE id in (
SELECT target_id FROM %[2]s
WHERE source_id = $1 AND deleted_at IS NULL AND link_type_id = $2
)
)`,
workitem.WorkItemStorage{}.TableName(),
WorkItemLink{}.TableName())
var hasChildren bool
db := r.db.CommonDB()
stmt, err := db.Prepare(query)
if err != nil {
return false, errs.Wrapf(err, "failed prepare statement: %s", query)
}
defer closeable.Close(ctx, stmt)
err = stmt.QueryRow(parentID.String(), SystemWorkItemLinkTypeParentChildID.String()).Scan(&hasChildren)
if err != nil {
return false, errs.Wrapf(err, "failed to check if work item %s has children: %s", parentID.String(), query)
}
return hasChildren, nil
} | [
"func",
"(",
"r",
"*",
"GormWorkItemLinkRepository",
")",
"WorkItemHasChildren",
"(",
"ctx",
"context",
".",
"Context",
",",
"parentID",
"uuid",
".",
"UUID",
")",
"(",
"bool",
",",
"error",
")",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"`\n\t\tSELECT EXISTS (\n\t\t\tSELECT 1 FROM %[1]s WHERE id in (\n\t\t\t\tSELECT target_id FROM %[2]s\n\t\t\t\tWHERE source_id = $1 AND deleted_at IS NULL AND link_type_id = $2\n\t\t\t)\n\t\t)`",
",",
"workitem",
".",
"WorkItemStorage",
"{",
"}",
".",
"TableName",
"(",
")",
",",
"WorkItemLink",
"{",
"}",
".",
"TableName",
"(",
")",
")",
"\n",
"var",
"hasChildren",
"bool",
"\n",
"db",
":=",
"r",
".",
"db",
".",
"CommonDB",
"(",
")",
"\n",
"stmt",
",",
"err",
":=",
"db",
".",
"Prepare",
"(",
"query",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"query",
")",
"\n",
"}",
"\n",
"defer",
"closeable",
".",
"Close",
"(",
"ctx",
",",
"stmt",
")",
"\n",
"err",
"=",
"stmt",
".",
"QueryRow",
"(",
"parentID",
".",
"String",
"(",
")",
",",
"SystemWorkItemLinkTypeParentChildID",
".",
"String",
"(",
")",
")",
".",
"Scan",
"(",
"&",
"hasChildren",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"errs",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"parentID",
".",
"String",
"(",
")",
",",
"query",
")",
"\n",
"}",
"\n",
"return",
"hasChildren",
",",
"nil",
"\n",
"}"
] | // WorkItemHasChildren returns true if the given parent work item has children;
// otherwise false is returned | [
"WorkItemHasChildren",
"returns",
"true",
"if",
"the",
"given",
"parent",
"work",
"item",
"has",
"children",
";",
"otherwise",
"false",
"is",
"returned"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link_repository.go#L519-L542 |
13,534 | fabric8-services/fabric8-wit | configuration/configuration.go | String | func (c *Registry) String() string {
allSettings := c.v.AllSettings()
y, err := yaml.Marshal(&allSettings)
if err != nil {
log.WithFields(map[string]interface{}{
"settings": allSettings,
"err": err,
}).Panicln("Failed to marshall config to string")
}
return fmt.Sprintf("%s\n", y)
} | go | func (c *Registry) String() string {
allSettings := c.v.AllSettings()
y, err := yaml.Marshal(&allSettings)
if err != nil {
log.WithFields(map[string]interface{}{
"settings": allSettings,
"err": err,
}).Panicln("Failed to marshall config to string")
}
return fmt.Sprintf("%s\n", y)
} | [
"func",
"(",
"c",
"*",
"Registry",
")",
"String",
"(",
")",
"string",
"{",
"allSettings",
":=",
"c",
".",
"v",
".",
"AllSettings",
"(",
")",
"\n",
"y",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"&",
"allSettings",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithFields",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"allSettings",
",",
"\"",
"\"",
":",
"err",
",",
"}",
")",
".",
"Panicln",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"y",
")",
"\n",
"}"
] | // String returns the current configuration as a string | [
"String",
"returns",
"the",
"current",
"configuration",
"as",
"a",
"string"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L20-L30 |
13,535 | fabric8-services/fabric8-wit | configuration/configuration.go | New | func New(configFilePath string) (*Registry, error) {
c := Registry{
v: viper.New(),
}
c.v.SetEnvPrefix("F8")
c.v.AutomaticEnv()
c.v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
c.v.SetTypeByDefaultValue(true)
c.setConfigDefaults()
if configFilePath != "" {
c.v.SetConfigType("yaml")
c.v.SetConfigFile(configFilePath)
err := c.v.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
return nil, errs.Errorf("Fatal error config file: %s \n", err)
}
}
return &c, nil
} | go | func New(configFilePath string) (*Registry, error) {
c := Registry{
v: viper.New(),
}
c.v.SetEnvPrefix("F8")
c.v.AutomaticEnv()
c.v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
c.v.SetTypeByDefaultValue(true)
c.setConfigDefaults()
if configFilePath != "" {
c.v.SetConfigType("yaml")
c.v.SetConfigFile(configFilePath)
err := c.v.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
return nil, errs.Errorf("Fatal error config file: %s \n", err)
}
}
return &c, nil
} | [
"func",
"New",
"(",
"configFilePath",
"string",
")",
"(",
"*",
"Registry",
",",
"error",
")",
"{",
"c",
":=",
"Registry",
"{",
"v",
":",
"viper",
".",
"New",
"(",
")",
",",
"}",
"\n",
"c",
".",
"v",
".",
"SetEnvPrefix",
"(",
"\"",
"\"",
")",
"\n",
"c",
".",
"v",
".",
"AutomaticEnv",
"(",
")",
"\n",
"c",
".",
"v",
".",
"SetEnvKeyReplacer",
"(",
"strings",
".",
"NewReplacer",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
")",
"\n",
"c",
".",
"v",
".",
"SetTypeByDefaultValue",
"(",
"true",
")",
"\n",
"c",
".",
"setConfigDefaults",
"(",
")",
"\n\n",
"if",
"configFilePath",
"!=",
"\"",
"\"",
"{",
"c",
".",
"v",
".",
"SetConfigType",
"(",
"\"",
"\"",
")",
"\n",
"c",
".",
"v",
".",
"SetConfigFile",
"(",
"configFilePath",
")",
"\n",
"err",
":=",
"c",
".",
"v",
".",
"ReadInConfig",
"(",
")",
"// Find and read the config file",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Handle errors reading the config file",
"return",
"nil",
",",
"errs",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"&",
"c",
",",
"nil",
"\n",
"}"
] | // New creates a configuration reader object using a configurable configuration
// file path. | [
"New",
"creates",
"a",
"configuration",
"reader",
"object",
"using",
"a",
"configurable",
"configuration",
"file",
"path",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L127-L146 |
13,536 | fabric8-services/fabric8-wit | configuration/configuration.go | GetEnvironment | func (c *Registry) GetEnvironment() string {
if c.v.IsSet(varEnvironment) {
return c.v.GetString(varEnvironment)
}
// TODO (@surajssd): remove this part of code once above environment
// variable is set in all configuration, following workaround ain't
// needed after that
authURL := c.GetAuthServiceURL()
if strings.Contains(authURL, "prod-preview.openshift.io") {
return "prod-preview"
} else if strings.HasSuffix(authURL, "openshift.io") {
return "production"
}
return "local"
} | go | func (c *Registry) GetEnvironment() string {
if c.v.IsSet(varEnvironment) {
return c.v.GetString(varEnvironment)
}
// TODO (@surajssd): remove this part of code once above environment
// variable is set in all configuration, following workaround ain't
// needed after that
authURL := c.GetAuthServiceURL()
if strings.Contains(authURL, "prod-preview.openshift.io") {
return "prod-preview"
} else if strings.HasSuffix(authURL, "openshift.io") {
return "production"
}
return "local"
} | [
"func",
"(",
"c",
"*",
"Registry",
")",
"GetEnvironment",
"(",
")",
"string",
"{",
"if",
"c",
".",
"v",
".",
"IsSet",
"(",
"varEnvironment",
")",
"{",
"return",
"c",
".",
"v",
".",
"GetString",
"(",
"varEnvironment",
")",
"\n",
"}",
"\n\n",
"// TODO (@surajssd): remove this part of code once above environment",
"// variable is set in all configuration, following workaround ain't",
"// needed after that",
"authURL",
":=",
"c",
".",
"GetAuthServiceURL",
"(",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"authURL",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasSuffix",
"(",
"authURL",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // GetEnvironment returns the current environment application is deployed in
// like 'prod', 'preview', 'local', etc as the value of environment variable
// `F8_ENVIRONMENT` is set. | [
"GetEnvironment",
"returns",
"the",
"current",
"environment",
"application",
"is",
"deployed",
"in",
"like",
"prod",
"preview",
"local",
"etc",
"as",
"the",
"value",
"of",
"environment",
"variable",
"F8_ENVIRONMENT",
"is",
"set",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L377-L392 |
13,537 | fabric8-services/fabric8-wit | configuration/configuration.go | GetKeysEndpoint | func (c *Registry) GetKeysEndpoint() string {
return fmt.Sprintf("%s/api/token/keys", c.v.GetString(varAuthURL))
} | go | func (c *Registry) GetKeysEndpoint() string {
return fmt.Sprintf("%s/api/token/keys", c.v.GetString(varAuthURL))
} | [
"func",
"(",
"c",
"*",
"Registry",
")",
"GetKeysEndpoint",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"v",
".",
"GetString",
"(",
"varAuthURL",
")",
")",
"\n",
"}"
] | // GetKeysEndpoint returns the endpoint to the auth service for key mgmt. | [
"GetKeysEndpoint",
"returns",
"the",
"endpoint",
"to",
"the",
"auth",
"service",
"for",
"key",
"mgmt",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L568-L570 |
13,538 | fabric8-services/fabric8-wit | configuration/configuration.go | GetKeycloakRealm | func (c *Registry) GetKeycloakRealm() string {
if c.v.IsSet(varKeycloakRealm) {
return c.v.GetString(varKeycloakRealm)
}
if c.IsPostgresDeveloperModeEnabled() {
return devModeKeycloakRealm
}
return defaultKeycloakRealm
} | go | func (c *Registry) GetKeycloakRealm() string {
if c.v.IsSet(varKeycloakRealm) {
return c.v.GetString(varKeycloakRealm)
}
if c.IsPostgresDeveloperModeEnabled() {
return devModeKeycloakRealm
}
return defaultKeycloakRealm
} | [
"func",
"(",
"c",
"*",
"Registry",
")",
"GetKeycloakRealm",
"(",
")",
"string",
"{",
"if",
"c",
".",
"v",
".",
"IsSet",
"(",
"varKeycloakRealm",
")",
"{",
"return",
"c",
".",
"v",
".",
"GetString",
"(",
"varKeycloakRealm",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"IsPostgresDeveloperModeEnabled",
"(",
")",
"{",
"return",
"devModeKeycloakRealm",
"\n",
"}",
"\n",
"return",
"defaultKeycloakRealm",
"\n",
"}"
] | // GetKeycloakRealm returns the keycloak realm name | [
"GetKeycloakRealm",
"returns",
"the",
"keycloak",
"realm",
"name"
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L655-L663 |
13,539 | fabric8-services/fabric8-wit | configuration/configuration.go | GetDeploymentsHTTPTimeoutSeconds | func (c *Registry) GetDeploymentsHTTPTimeoutSeconds() time.Duration {
timeout := c.v.GetInt(varDeploymentsHTTPTimeout)
if timeout < minimumDeploymentsHTTPTimeout {
timeout = minimumDeploymentsHTTPTimeout
}
return time.Duration(timeout) * time.Second
} | go | func (c *Registry) GetDeploymentsHTTPTimeoutSeconds() time.Duration {
timeout := c.v.GetInt(varDeploymentsHTTPTimeout)
if timeout < minimumDeploymentsHTTPTimeout {
timeout = minimumDeploymentsHTTPTimeout
}
return time.Duration(timeout) * time.Second
} | [
"func",
"(",
"c",
"*",
"Registry",
")",
"GetDeploymentsHTTPTimeoutSeconds",
"(",
")",
"time",
".",
"Duration",
"{",
"timeout",
":=",
"c",
".",
"v",
".",
"GetInt",
"(",
"varDeploymentsHTTPTimeout",
")",
"\n",
"if",
"timeout",
"<",
"minimumDeploymentsHTTPTimeout",
"{",
"timeout",
"=",
"minimumDeploymentsHTTPTimeout",
"\n",
"}",
"\n",
"return",
"time",
".",
"Duration",
"(",
"timeout",
")",
"*",
"time",
".",
"Second",
"\n",
"}"
] | // GetDeploymentsTimeout returns the amount of seconds until it should timeout. | [
"GetDeploymentsTimeout",
"returns",
"the",
"amount",
"of",
"seconds",
"until",
"it",
"should",
"timeout",
"."
] | 54759c80c42ff2cf29b352e0f6c9330ce4ad7fce | https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/configuration/configuration.go#L885-L891 |
13,540 | go-openapi/errors | headers.go | ValidateName | func (e *Validation) ValidateName(name string) *Validation {
if e.Name == "" && name != "" {
e.Name = name
e.message = name + e.message
}
return e
} | go | func (e *Validation) ValidateName(name string) *Validation {
if e.Name == "" && name != "" {
e.Name = name
e.message = name + e.message
}
return e
} | [
"func",
"(",
"e",
"*",
"Validation",
")",
"ValidateName",
"(",
"name",
"string",
")",
"*",
"Validation",
"{",
"if",
"e",
".",
"Name",
"==",
"\"",
"\"",
"&&",
"name",
"!=",
"\"",
"\"",
"{",
"e",
".",
"Name",
"=",
"name",
"\n",
"e",
".",
"message",
"=",
"name",
"+",
"e",
".",
"message",
"\n",
"}",
"\n",
"return",
"e",
"\n",
"}"
] | // ValidateName produces an error message name for an aliased property | [
"ValidateName",
"produces",
"an",
"error",
"message",
"name",
"for",
"an",
"aliased",
"property"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/headers.go#L42-L48 |
13,541 | go-openapi/errors | headers.go | InvalidContentType | func InvalidContentType(value string, allowed []string) *Validation {
values := make([]interface{}, 0, len(allowed))
for _, v := range allowed {
values = append(values, v)
}
return &Validation{
code: http.StatusUnsupportedMediaType,
Name: "Content-Type",
In: "header",
Value: value,
Values: values,
message: fmt.Sprintf(contentTypeFail, value, allowed),
}
} | go | func InvalidContentType(value string, allowed []string) *Validation {
values := make([]interface{}, 0, len(allowed))
for _, v := range allowed {
values = append(values, v)
}
return &Validation{
code: http.StatusUnsupportedMediaType,
Name: "Content-Type",
In: "header",
Value: value,
Values: values,
message: fmt.Sprintf(contentTypeFail, value, allowed),
}
} | [
"func",
"InvalidContentType",
"(",
"value",
"string",
",",
"allowed",
"[",
"]",
"string",
")",
"*",
"Validation",
"{",
"values",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
",",
"len",
"(",
"allowed",
")",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"allowed",
"{",
"values",
"=",
"append",
"(",
"values",
",",
"v",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"http",
".",
"StatusUnsupportedMediaType",
",",
"Name",
":",
"\"",
"\"",
",",
"In",
":",
"\"",
"\"",
",",
"Value",
":",
"value",
",",
"Values",
":",
"values",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"contentTypeFail",
",",
"value",
",",
"allowed",
")",
",",
"}",
"\n",
"}"
] | // InvalidContentType error for an invalid content type | [
"InvalidContentType",
"error",
"for",
"an",
"invalid",
"content",
"type"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/headers.go#L56-L69 |
13,542 | go-openapi/errors | headers.go | InvalidResponseFormat | func InvalidResponseFormat(value string, allowed []string) *Validation {
values := make([]interface{}, 0, len(allowed))
for _, v := range allowed {
values = append(values, v)
}
return &Validation{
code: http.StatusNotAcceptable,
Name: "Accept",
In: "header",
Value: value,
Values: values,
message: fmt.Sprintf(responseFormatFail, allowed),
}
} | go | func InvalidResponseFormat(value string, allowed []string) *Validation {
values := make([]interface{}, 0, len(allowed))
for _, v := range allowed {
values = append(values, v)
}
return &Validation{
code: http.StatusNotAcceptable,
Name: "Accept",
In: "header",
Value: value,
Values: values,
message: fmt.Sprintf(responseFormatFail, allowed),
}
} | [
"func",
"InvalidResponseFormat",
"(",
"value",
"string",
",",
"allowed",
"[",
"]",
"string",
")",
"*",
"Validation",
"{",
"values",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
",",
"len",
"(",
"allowed",
")",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"allowed",
"{",
"values",
"=",
"append",
"(",
"values",
",",
"v",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"http",
".",
"StatusNotAcceptable",
",",
"Name",
":",
"\"",
"\"",
",",
"In",
":",
"\"",
"\"",
",",
"Value",
":",
"value",
",",
"Values",
":",
"values",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"responseFormatFail",
",",
"allowed",
")",
",",
"}",
"\n",
"}"
] | // InvalidResponseFormat error for an unacceptable response format request | [
"InvalidResponseFormat",
"error",
"for",
"an",
"unacceptable",
"response",
"format",
"request"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/headers.go#L72-L85 |
13,543 | go-openapi/errors | api.go | New | func New(code int32, message string, args ...interface{}) Error {
if len(args) > 0 {
return &apiError{code, fmt.Sprintf(message, args...)}
}
return &apiError{code, message}
} | go | func New(code int32, message string, args ...interface{}) Error {
if len(args) > 0 {
return &apiError{code, fmt.Sprintf(message, args...)}
}
return &apiError{code, message}
} | [
"func",
"New",
"(",
"code",
"int32",
",",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"return",
"&",
"apiError",
"{",
"code",
",",
"fmt",
".",
"Sprintf",
"(",
"message",
",",
"args",
"...",
")",
"}",
"\n",
"}",
"\n",
"return",
"&",
"apiError",
"{",
"code",
",",
"message",
"}",
"\n",
"}"
] | // New creates a new API error with a code and a message | [
"New",
"creates",
"a",
"new",
"API",
"error",
"with",
"a",
"code",
"and",
"a",
"message"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/api.go#L48-L53 |
13,544 | go-openapi/errors | api.go | NotFound | func NotFound(message string, args ...interface{}) Error {
if message == "" {
message = "Not found"
}
return New(http.StatusNotFound, fmt.Sprintf(message, args...))
} | go | func NotFound(message string, args ...interface{}) Error {
if message == "" {
message = "Not found"
}
return New(http.StatusNotFound, fmt.Sprintf(message, args...))
} | [
"func",
"NotFound",
"(",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"if",
"message",
"==",
"\"",
"\"",
"{",
"message",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"New",
"(",
"http",
".",
"StatusNotFound",
",",
"fmt",
".",
"Sprintf",
"(",
"message",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // NotFound creates a new not found error | [
"NotFound",
"creates",
"a",
"new",
"not",
"found",
"error"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/api.go#L56-L61 |
13,545 | go-openapi/errors | api.go | MethodNotAllowed | func MethodNotAllowed(requested string, allow []string) Error {
msg := fmt.Sprintf("method %s is not allowed, but [%s] are", requested, strings.Join(allow, ","))
return &MethodNotAllowedError{code: http.StatusMethodNotAllowed, Allowed: allow, message: msg}
} | go | func MethodNotAllowed(requested string, allow []string) Error {
msg := fmt.Sprintf("method %s is not allowed, but [%s] are", requested, strings.Join(allow, ","))
return &MethodNotAllowedError{code: http.StatusMethodNotAllowed, Allowed: allow, message: msg}
} | [
"func",
"MethodNotAllowed",
"(",
"requested",
"string",
",",
"allow",
"[",
"]",
"string",
")",
"Error",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"requested",
",",
"strings",
".",
"Join",
"(",
"allow",
",",
"\"",
"\"",
")",
")",
"\n",
"return",
"&",
"MethodNotAllowedError",
"{",
"code",
":",
"http",
".",
"StatusMethodNotAllowed",
",",
"Allowed",
":",
"allow",
",",
"message",
":",
"msg",
"}",
"\n",
"}"
] | // MethodNotAllowed creates a new method not allowed error | [
"MethodNotAllowed",
"creates",
"a",
"new",
"method",
"not",
"allowed",
"error"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/api.go#L113-L116 |
13,546 | go-openapi/errors | api.go | ServeError | func ServeError(rw http.ResponseWriter, r *http.Request, err error) {
rw.Header().Set("Content-Type", "application/json")
switch e := err.(type) {
case *CompositeError:
er := flattenComposite(e)
// strips composite errors to first element only
if len(er.Errors) > 0 {
ServeError(rw, r, er.Errors[0])
} else {
// guard against empty CompositeError (invalid construct)
ServeError(rw, r, nil)
}
case *MethodNotAllowedError:
rw.Header().Add("Allow", strings.Join(err.(*MethodNotAllowedError).Allowed, ","))
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(e))
}
case Error:
value := reflect.ValueOf(e)
if value.Kind() == reflect.Ptr && value.IsNil() {
rw.WriteHeader(http.StatusInternalServerError)
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
return
}
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(e))
}
case nil:
rw.WriteHeader(http.StatusInternalServerError)
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
default:
rw.WriteHeader(http.StatusInternalServerError)
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, err.Error())))
}
}
} | go | func ServeError(rw http.ResponseWriter, r *http.Request, err error) {
rw.Header().Set("Content-Type", "application/json")
switch e := err.(type) {
case *CompositeError:
er := flattenComposite(e)
// strips composite errors to first element only
if len(er.Errors) > 0 {
ServeError(rw, r, er.Errors[0])
} else {
// guard against empty CompositeError (invalid construct)
ServeError(rw, r, nil)
}
case *MethodNotAllowedError:
rw.Header().Add("Allow", strings.Join(err.(*MethodNotAllowedError).Allowed, ","))
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(e))
}
case Error:
value := reflect.ValueOf(e)
if value.Kind() == reflect.Ptr && value.IsNil() {
rw.WriteHeader(http.StatusInternalServerError)
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
return
}
rw.WriteHeader(asHTTPCode(int(e.Code())))
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(e))
}
case nil:
rw.WriteHeader(http.StatusInternalServerError)
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, "Unknown error")))
default:
rw.WriteHeader(http.StatusInternalServerError)
if r == nil || r.Method != http.MethodHead {
_, _ = rw.Write(errorAsJSON(New(http.StatusInternalServerError, err.Error())))
}
}
} | [
"func",
"ServeError",
"(",
"rw",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"rw",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"switch",
"e",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"*",
"CompositeError",
":",
"er",
":=",
"flattenComposite",
"(",
"e",
")",
"\n",
"// strips composite errors to first element only",
"if",
"len",
"(",
"er",
".",
"Errors",
")",
">",
"0",
"{",
"ServeError",
"(",
"rw",
",",
"r",
",",
"er",
".",
"Errors",
"[",
"0",
"]",
")",
"\n",
"}",
"else",
"{",
"// guard against empty CompositeError (invalid construct)",
"ServeError",
"(",
"rw",
",",
"r",
",",
"nil",
")",
"\n",
"}",
"\n",
"case",
"*",
"MethodNotAllowedError",
":",
"rw",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"err",
".",
"(",
"*",
"MethodNotAllowedError",
")",
".",
"Allowed",
",",
"\"",
"\"",
")",
")",
"\n",
"rw",
".",
"WriteHeader",
"(",
"asHTTPCode",
"(",
"int",
"(",
"e",
".",
"Code",
"(",
")",
")",
")",
")",
"\n",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodHead",
"{",
"_",
",",
"_",
"=",
"rw",
".",
"Write",
"(",
"errorAsJSON",
"(",
"e",
")",
")",
"\n",
"}",
"\n",
"case",
"Error",
":",
"value",
":=",
"reflect",
".",
"ValueOf",
"(",
"e",
")",
"\n",
"if",
"value",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"&&",
"value",
".",
"IsNil",
"(",
")",
"{",
"rw",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"_",
",",
"_",
"=",
"rw",
".",
"Write",
"(",
"errorAsJSON",
"(",
"New",
"(",
"http",
".",
"StatusInternalServerError",
",",
"\"",
"\"",
")",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"rw",
".",
"WriteHeader",
"(",
"asHTTPCode",
"(",
"int",
"(",
"e",
".",
"Code",
"(",
")",
")",
")",
")",
"\n",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodHead",
"{",
"_",
",",
"_",
"=",
"rw",
".",
"Write",
"(",
"errorAsJSON",
"(",
"e",
")",
")",
"\n",
"}",
"\n",
"case",
"nil",
":",
"rw",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"_",
",",
"_",
"=",
"rw",
".",
"Write",
"(",
"errorAsJSON",
"(",
"New",
"(",
"http",
".",
"StatusInternalServerError",
",",
"\"",
"\"",
")",
")",
")",
"\n",
"default",
":",
"rw",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"Method",
"!=",
"http",
".",
"MethodHead",
"{",
"_",
",",
"_",
"=",
"rw",
".",
"Write",
"(",
"errorAsJSON",
"(",
"New",
"(",
"http",
".",
"StatusInternalServerError",
",",
"err",
".",
"Error",
"(",
")",
")",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // ServeError the error handler interface implementation | [
"ServeError",
"the",
"error",
"handler",
"interface",
"implementation"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/api.go#L119-L157 |
13,547 | go-openapi/errors | schema.go | CompositeValidationError | func CompositeValidationError(errors ...error) *CompositeError {
return &CompositeError{
code: CompositeErrorCode,
Errors: append([]error{}, errors...),
message: "validation failure list",
}
} | go | func CompositeValidationError(errors ...error) *CompositeError {
return &CompositeError{
code: CompositeErrorCode,
Errors: append([]error{}, errors...),
message: "validation failure list",
}
} | [
"func",
"CompositeValidationError",
"(",
"errors",
"...",
"error",
")",
"*",
"CompositeError",
"{",
"return",
"&",
"CompositeError",
"{",
"code",
":",
"CompositeErrorCode",
",",
"Errors",
":",
"append",
"(",
"[",
"]",
"error",
"{",
"}",
",",
"errors",
"...",
")",
",",
"message",
":",
"\"",
"\"",
",",
"}",
"\n",
"}"
] | // CompositeValidationError an error to wrap a bunch of other errors | [
"CompositeValidationError",
"an",
"error",
"to",
"wrap",
"a",
"bunch",
"of",
"other",
"errors"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L120-L126 |
13,548 | go-openapi/errors | schema.go | FailedAllPatternProperties | func FailedAllPatternProperties(name, in, key string) *Validation {
msg := fmt.Sprintf(failedAllPatternProps, name, key, in)
if in == "" {
msg = fmt.Sprintf(failedAllPatternPropsNoIn, name, key)
}
return &Validation{
code: FailedAllPatternPropsCode,
Name: name,
In: in,
Value: key,
message: msg,
}
} | go | func FailedAllPatternProperties(name, in, key string) *Validation {
msg := fmt.Sprintf(failedAllPatternProps, name, key, in)
if in == "" {
msg = fmt.Sprintf(failedAllPatternPropsNoIn, name, key)
}
return &Validation{
code: FailedAllPatternPropsCode,
Name: name,
In: in,
Value: key,
message: msg,
}
} | [
"func",
"FailedAllPatternProperties",
"(",
"name",
",",
"in",
",",
"key",
"string",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"failedAllPatternProps",
",",
"name",
",",
"key",
",",
"in",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"failedAllPatternPropsNoIn",
",",
"name",
",",
"key",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"FailedAllPatternPropsCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"key",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // FailedAllPatternProperties an error for when the property doesn't match a pattern | [
"FailedAllPatternProperties",
"an",
"error",
"for",
"when",
"the",
"property",
"doesn",
"t",
"match",
"a",
"pattern"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L129-L141 |
13,549 | go-openapi/errors | schema.go | PropertyNotAllowed | func PropertyNotAllowed(name, in, key string) *Validation {
msg := fmt.Sprintf(unallowedProperty, name, key, in)
if in == "" {
msg = fmt.Sprintf(unallowedPropertyNoIn, name, key)
}
return &Validation{
code: UnallowedPropertyCode,
Name: name,
In: in,
Value: key,
message: msg,
}
} | go | func PropertyNotAllowed(name, in, key string) *Validation {
msg := fmt.Sprintf(unallowedProperty, name, key, in)
if in == "" {
msg = fmt.Sprintf(unallowedPropertyNoIn, name, key)
}
return &Validation{
code: UnallowedPropertyCode,
Name: name,
In: in,
Value: key,
message: msg,
}
} | [
"func",
"PropertyNotAllowed",
"(",
"name",
",",
"in",
",",
"key",
"string",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"unallowedProperty",
",",
"name",
",",
"key",
",",
"in",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"unallowedPropertyNoIn",
",",
"name",
",",
"key",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"UnallowedPropertyCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"key",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // PropertyNotAllowed an error for when the property doesn't match a pattern | [
"PropertyNotAllowed",
"an",
"error",
"for",
"when",
"the",
"property",
"doesn",
"t",
"match",
"a",
"pattern"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L144-L156 |
13,550 | go-openapi/errors | schema.go | TooFewProperties | func TooFewProperties(name, in string, n int64) *Validation {
msg := fmt.Sprintf(tooFewProperties, name, in, n)
if in == "" {
msg = fmt.Sprintf(tooFewPropertiesNoIn, name, n)
}
return &Validation{
code: TooFewPropertiesCode,
Name: name,
In: in,
Value: n,
message: msg,
}
} | go | func TooFewProperties(name, in string, n int64) *Validation {
msg := fmt.Sprintf(tooFewProperties, name, in, n)
if in == "" {
msg = fmt.Sprintf(tooFewPropertiesNoIn, name, n)
}
return &Validation{
code: TooFewPropertiesCode,
Name: name,
In: in,
Value: n,
message: msg,
}
} | [
"func",
"TooFewProperties",
"(",
"name",
",",
"in",
"string",
",",
"n",
"int64",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"tooFewProperties",
",",
"name",
",",
"in",
",",
"n",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooFewPropertiesNoIn",
",",
"name",
",",
"n",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"TooFewPropertiesCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"n",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooFewProperties an error for an object with too few properties | [
"TooFewProperties",
"an",
"error",
"for",
"an",
"object",
"with",
"too",
"few",
"properties"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L159-L171 |
13,551 | go-openapi/errors | schema.go | TooManyProperties | func TooManyProperties(name, in string, n int64) *Validation {
msg := fmt.Sprintf(tooManyProperties, name, in, n)
if in == "" {
msg = fmt.Sprintf(tooManyPropertiesNoIn, name, n)
}
return &Validation{
code: TooManyPropertiesCode,
Name: name,
In: in,
Value: n,
message: msg,
}
} | go | func TooManyProperties(name, in string, n int64) *Validation {
msg := fmt.Sprintf(tooManyProperties, name, in, n)
if in == "" {
msg = fmt.Sprintf(tooManyPropertiesNoIn, name, n)
}
return &Validation{
code: TooManyPropertiesCode,
Name: name,
In: in,
Value: n,
message: msg,
}
} | [
"func",
"TooManyProperties",
"(",
"name",
",",
"in",
"string",
",",
"n",
"int64",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"tooManyProperties",
",",
"name",
",",
"in",
",",
"n",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooManyPropertiesNoIn",
",",
"name",
",",
"n",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"TooManyPropertiesCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"n",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooManyProperties an error for an object with too many properties | [
"TooManyProperties",
"an",
"error",
"for",
"an",
"object",
"with",
"too",
"many",
"properties"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L174-L186 |
13,552 | go-openapi/errors | schema.go | AdditionalItemsNotAllowed | func AdditionalItemsNotAllowed(name, in string) *Validation {
msg := fmt.Sprintf(noAdditionalItems, name, in)
if in == "" {
msg = fmt.Sprintf(noAdditionalItemsNoIn, name)
}
return &Validation{
code: NoAdditionalItemsCode,
Name: name,
In: in,
message: msg,
}
} | go | func AdditionalItemsNotAllowed(name, in string) *Validation {
msg := fmt.Sprintf(noAdditionalItems, name, in)
if in == "" {
msg = fmt.Sprintf(noAdditionalItemsNoIn, name)
}
return &Validation{
code: NoAdditionalItemsCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"AdditionalItemsNotAllowed",
"(",
"name",
",",
"in",
"string",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"noAdditionalItems",
",",
"name",
",",
"in",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"noAdditionalItemsNoIn",
",",
"name",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"NoAdditionalItemsCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // AdditionalItemsNotAllowed an error for invalid additional items | [
"AdditionalItemsNotAllowed",
"an",
"error",
"for",
"invalid",
"additional",
"items"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L189-L200 |
13,553 | go-openapi/errors | schema.go | InvalidCollectionFormat | func InvalidCollectionFormat(name, in, format string) *Validation {
return &Validation{
code: InvalidTypeCode,
Name: name,
In: in,
Value: format,
message: fmt.Sprintf("the collection format %q is not supported for the %s param %q", format, in, name),
}
} | go | func InvalidCollectionFormat(name, in, format string) *Validation {
return &Validation{
code: InvalidTypeCode,
Name: name,
In: in,
Value: format,
message: fmt.Sprintf("the collection format %q is not supported for the %s param %q", format, in, name),
}
} | [
"func",
"InvalidCollectionFormat",
"(",
"name",
",",
"in",
",",
"format",
"string",
")",
"*",
"Validation",
"{",
"return",
"&",
"Validation",
"{",
"code",
":",
"InvalidTypeCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"format",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"format",
",",
"in",
",",
"name",
")",
",",
"}",
"\n",
"}"
] | // InvalidCollectionFormat another flavor of invalid type error | [
"InvalidCollectionFormat",
"another",
"flavor",
"of",
"invalid",
"type",
"error"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L203-L211 |
13,554 | go-openapi/errors | schema.go | InvalidTypeName | func InvalidTypeName(typeName string) *Validation {
return &Validation{
code: InvalidTypeCode,
Value: typeName,
message: fmt.Sprintf(invalidType, typeName),
}
} | go | func InvalidTypeName(typeName string) *Validation {
return &Validation{
code: InvalidTypeCode,
Value: typeName,
message: fmt.Sprintf(invalidType, typeName),
}
} | [
"func",
"InvalidTypeName",
"(",
"typeName",
"string",
")",
"*",
"Validation",
"{",
"return",
"&",
"Validation",
"{",
"code",
":",
"InvalidTypeCode",
",",
"Value",
":",
"typeName",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"invalidType",
",",
"typeName",
")",
",",
"}",
"\n",
"}"
] | // InvalidTypeName an error for when the type is invalid | [
"InvalidTypeName",
"an",
"error",
"for",
"when",
"the",
"type",
"is",
"invalid"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L214-L220 |
13,555 | go-openapi/errors | schema.go | InvalidType | func InvalidType(name, in, typeName string, value interface{}) *Validation {
var message string
if in != "" {
switch value.(type) {
case string:
message = fmt.Sprintf(typeFailWithData, name, in, typeName, value)
case error:
message = fmt.Sprintf(typeFailWithError, name, in, typeName, value)
default:
message = fmt.Sprintf(typeFail, name, in, typeName)
}
} else {
switch value.(type) {
case string:
message = fmt.Sprintf(typeFailWithDataNoIn, name, typeName, value)
case error:
message = fmt.Sprintf(typeFailWithErrorNoIn, name, typeName, value)
default:
message = fmt.Sprintf(typeFailNoIn, name, typeName)
}
}
return &Validation{
code: InvalidTypeCode,
Name: name,
In: in,
Value: value,
message: message,
}
} | go | func InvalidType(name, in, typeName string, value interface{}) *Validation {
var message string
if in != "" {
switch value.(type) {
case string:
message = fmt.Sprintf(typeFailWithData, name, in, typeName, value)
case error:
message = fmt.Sprintf(typeFailWithError, name, in, typeName, value)
default:
message = fmt.Sprintf(typeFail, name, in, typeName)
}
} else {
switch value.(type) {
case string:
message = fmt.Sprintf(typeFailWithDataNoIn, name, typeName, value)
case error:
message = fmt.Sprintf(typeFailWithErrorNoIn, name, typeName, value)
default:
message = fmt.Sprintf(typeFailNoIn, name, typeName)
}
}
return &Validation{
code: InvalidTypeCode,
Name: name,
In: in,
Value: value,
message: message,
}
} | [
"func",
"InvalidType",
"(",
"name",
",",
"in",
",",
"typeName",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"*",
"Validation",
"{",
"var",
"message",
"string",
"\n\n",
"if",
"in",
"!=",
"\"",
"\"",
"{",
"switch",
"value",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFailWithData",
",",
"name",
",",
"in",
",",
"typeName",
",",
"value",
")",
"\n",
"case",
"error",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFailWithError",
",",
"name",
",",
"in",
",",
"typeName",
",",
"value",
")",
"\n",
"default",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFail",
",",
"name",
",",
"in",
",",
"typeName",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"switch",
"value",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFailWithDataNoIn",
",",
"name",
",",
"typeName",
",",
"value",
")",
"\n",
"case",
"error",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFailWithErrorNoIn",
",",
"name",
",",
"typeName",
",",
"value",
")",
"\n",
"default",
":",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"typeFailNoIn",
",",
"name",
",",
"typeName",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"InvalidTypeCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"value",
",",
"message",
":",
"message",
",",
"}",
"\n\n",
"}"
] | // InvalidType creates an error for when the type is invalid | [
"InvalidType",
"creates",
"an",
"error",
"for",
"when",
"the",
"type",
"is",
"invalid"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L223-L254 |
13,556 | go-openapi/errors | schema.go | DuplicateItems | func DuplicateItems(name, in string) *Validation {
msg := fmt.Sprintf(uniqueFail, name, in)
if in == "" {
msg = fmt.Sprintf(uniqueFailNoIn, name)
}
return &Validation{
code: UniqueFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func DuplicateItems(name, in string) *Validation {
msg := fmt.Sprintf(uniqueFail, name, in)
if in == "" {
msg = fmt.Sprintf(uniqueFailNoIn, name)
}
return &Validation{
code: UniqueFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"DuplicateItems",
"(",
"name",
",",
"in",
"string",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"uniqueFail",
",",
"name",
",",
"in",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"uniqueFailNoIn",
",",
"name",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"UniqueFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // DuplicateItems error for when an array contains duplicates | [
"DuplicateItems",
"error",
"for",
"when",
"an",
"array",
"contains",
"duplicates"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L257-L268 |
13,557 | go-openapi/errors | schema.go | TooManyItems | func TooManyItems(name, in string, max int64) *Validation {
msg := fmt.Sprintf(maxItemsFail, name, in, max)
if in == "" {
msg = fmt.Sprintf(maxItemsFailNoIn, name, max)
}
return &Validation{
code: MaxItemsFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func TooManyItems(name, in string, max int64) *Validation {
msg := fmt.Sprintf(maxItemsFail, name, in, max)
if in == "" {
msg = fmt.Sprintf(maxItemsFailNoIn, name, max)
}
return &Validation{
code: MaxItemsFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"TooManyItems",
"(",
"name",
",",
"in",
"string",
",",
"max",
"int64",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"maxItemsFail",
",",
"name",
",",
"in",
",",
"max",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"maxItemsFailNoIn",
",",
"name",
",",
"max",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"MaxItemsFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooManyItems error for when an array contains too many items | [
"TooManyItems",
"error",
"for",
"when",
"an",
"array",
"contains",
"too",
"many",
"items"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L271-L283 |
13,558 | go-openapi/errors | schema.go | TooFewItems | func TooFewItems(name, in string, min int64) *Validation {
msg := fmt.Sprintf(minItemsFail, name, in, min)
if in == "" {
msg = fmt.Sprintf(minItemsFailNoIn, name, min)
}
return &Validation{
code: MinItemsFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func TooFewItems(name, in string, min int64) *Validation {
msg := fmt.Sprintf(minItemsFail, name, in, min)
if in == "" {
msg = fmt.Sprintf(minItemsFailNoIn, name, min)
}
return &Validation{
code: MinItemsFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"TooFewItems",
"(",
"name",
",",
"in",
"string",
",",
"min",
"int64",
")",
"*",
"Validation",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"minItemsFail",
",",
"name",
",",
"in",
",",
"min",
")",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"minItemsFailNoIn",
",",
"name",
",",
"min",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"MinItemsFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooFewItems error for when an array contains too few items | [
"TooFewItems",
"error",
"for",
"when",
"an",
"array",
"contains",
"too",
"few",
"items"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L286-L297 |
13,559 | go-openapi/errors | schema.go | ExceedsMaximumInt | func ExceedsMaximumInt(name, in string, max int64, exclusive bool) *Validation {
var message string
if in == "" {
m := maxIncFailNoIn
if exclusive {
m = maxExcFailNoIn
}
message = fmt.Sprintf(m, name, max)
} else {
m := maxIncFail
if exclusive {
m = maxExcFail
}
message = fmt.Sprintf(m, name, in, max)
}
return &Validation{
code: MaxFailCode,
Name: name,
In: in,
Value: max,
message: message,
}
} | go | func ExceedsMaximumInt(name, in string, max int64, exclusive bool) *Validation {
var message string
if in == "" {
m := maxIncFailNoIn
if exclusive {
m = maxExcFailNoIn
}
message = fmt.Sprintf(m, name, max)
} else {
m := maxIncFail
if exclusive {
m = maxExcFail
}
message = fmt.Sprintf(m, name, in, max)
}
return &Validation{
code: MaxFailCode,
Name: name,
In: in,
Value: max,
message: message,
}
} | [
"func",
"ExceedsMaximumInt",
"(",
"name",
",",
"in",
"string",
",",
"max",
"int64",
",",
"exclusive",
"bool",
")",
"*",
"Validation",
"{",
"var",
"message",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"m",
":=",
"maxIncFailNoIn",
"\n",
"if",
"exclusive",
"{",
"m",
"=",
"maxExcFailNoIn",
"\n",
"}",
"\n",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"m",
",",
"name",
",",
"max",
")",
"\n",
"}",
"else",
"{",
"m",
":=",
"maxIncFail",
"\n",
"if",
"exclusive",
"{",
"m",
"=",
"maxExcFail",
"\n",
"}",
"\n",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"m",
",",
"name",
",",
"in",
",",
"max",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"MaxFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"max",
",",
"message",
":",
"message",
",",
"}",
"\n",
"}"
] | // ExceedsMaximumInt error for when maxinum validation fails | [
"ExceedsMaximumInt",
"error",
"for",
"when",
"maxinum",
"validation",
"fails"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L300-L322 |
13,560 | go-openapi/errors | schema.go | ExceedsMinimumInt | func ExceedsMinimumInt(name, in string, min int64, exclusive bool) *Validation {
var message string
if in == "" {
m := minIncFailNoIn
if exclusive {
m = minExcFailNoIn
}
message = fmt.Sprintf(m, name, min)
} else {
m := minIncFail
if exclusive {
m = minExcFail
}
message = fmt.Sprintf(m, name, in, min)
}
return &Validation{
code: MinFailCode,
Name: name,
In: in,
Value: min,
message: message,
}
} | go | func ExceedsMinimumInt(name, in string, min int64, exclusive bool) *Validation {
var message string
if in == "" {
m := minIncFailNoIn
if exclusive {
m = minExcFailNoIn
}
message = fmt.Sprintf(m, name, min)
} else {
m := minIncFail
if exclusive {
m = minExcFail
}
message = fmt.Sprintf(m, name, in, min)
}
return &Validation{
code: MinFailCode,
Name: name,
In: in,
Value: min,
message: message,
}
} | [
"func",
"ExceedsMinimumInt",
"(",
"name",
",",
"in",
"string",
",",
"min",
"int64",
",",
"exclusive",
"bool",
")",
"*",
"Validation",
"{",
"var",
"message",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"m",
":=",
"minIncFailNoIn",
"\n",
"if",
"exclusive",
"{",
"m",
"=",
"minExcFailNoIn",
"\n",
"}",
"\n",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"m",
",",
"name",
",",
"min",
")",
"\n",
"}",
"else",
"{",
"m",
":=",
"minIncFail",
"\n",
"if",
"exclusive",
"{",
"m",
"=",
"minExcFail",
"\n",
"}",
"\n",
"message",
"=",
"fmt",
".",
"Sprintf",
"(",
"m",
",",
"name",
",",
"in",
",",
"min",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"MinFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"min",
",",
"message",
":",
"message",
",",
"}",
"\n",
"}"
] | // ExceedsMinimumInt error for when maxinum validation fails | [
"ExceedsMinimumInt",
"error",
"for",
"when",
"maxinum",
"validation",
"fails"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L375-L397 |
13,561 | go-openapi/errors | schema.go | NotMultipleOf | func NotMultipleOf(name, in string, multiple interface{}) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(multipleOfFailNoIn, name, multiple)
} else {
msg = fmt.Sprintf(multipleOfFail, name, in, multiple)
}
return &Validation{
code: MultipleOfFailCode,
Name: name,
In: in,
Value: multiple,
message: msg,
}
} | go | func NotMultipleOf(name, in string, multiple interface{}) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(multipleOfFailNoIn, name, multiple)
} else {
msg = fmt.Sprintf(multipleOfFail, name, in, multiple)
}
return &Validation{
code: MultipleOfFailCode,
Name: name,
In: in,
Value: multiple,
message: msg,
}
} | [
"func",
"NotMultipleOf",
"(",
"name",
",",
"in",
"string",
",",
"multiple",
"interface",
"{",
"}",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"multipleOfFailNoIn",
",",
"name",
",",
"multiple",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"multipleOfFail",
",",
"name",
",",
"in",
",",
"multiple",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"MultipleOfFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"multiple",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // NotMultipleOf error for when multiple of validation fails | [
"NotMultipleOf",
"error",
"for",
"when",
"multiple",
"of",
"validation",
"fails"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L450-L464 |
13,562 | go-openapi/errors | schema.go | EnumFail | func EnumFail(name, in string, value interface{}, values []interface{}) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(enumFailNoIn, name, values)
} else {
msg = fmt.Sprintf(enumFail, name, in, values)
}
return &Validation{
code: EnumFailCode,
Name: name,
In: in,
Value: value,
Values: values,
message: msg,
}
} | go | func EnumFail(name, in string, value interface{}, values []interface{}) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(enumFailNoIn, name, values)
} else {
msg = fmt.Sprintf(enumFail, name, in, values)
}
return &Validation{
code: EnumFailCode,
Name: name,
In: in,
Value: value,
Values: values,
message: msg,
}
} | [
"func",
"EnumFail",
"(",
"name",
",",
"in",
"string",
",",
"value",
"interface",
"{",
"}",
",",
"values",
"[",
"]",
"interface",
"{",
"}",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"enumFailNoIn",
",",
"name",
",",
"values",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"enumFail",
",",
"name",
",",
"in",
",",
"values",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"EnumFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"value",
",",
"Values",
":",
"values",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // EnumFail error for when an enum validation fails | [
"EnumFail",
"error",
"for",
"when",
"an",
"enum",
"validation",
"fails"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L467-L483 |
13,563 | go-openapi/errors | schema.go | Required | func Required(name, in string) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(requiredFailNoIn, name)
} else {
msg = fmt.Sprintf(requiredFail, name, in)
}
return &Validation{
code: RequiredFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func Required(name, in string) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(requiredFailNoIn, name)
} else {
msg = fmt.Sprintf(requiredFail, name, in)
}
return &Validation{
code: RequiredFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"Required",
"(",
"name",
",",
"in",
"string",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"requiredFailNoIn",
",",
"name",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"requiredFail",
",",
"name",
",",
"in",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"RequiredFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // Required error for when a value is missing | [
"Required",
"error",
"for",
"when",
"a",
"value",
"is",
"missing"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L486-L499 |
13,564 | go-openapi/errors | schema.go | TooLong | func TooLong(name, in string, max int64) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(tooLongMessageNoIn, name, max)
} else {
msg = fmt.Sprintf(tooLongMessage, name, in, max)
}
return &Validation{
code: TooLongFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func TooLong(name, in string, max int64) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(tooLongMessageNoIn, name, max)
} else {
msg = fmt.Sprintf(tooLongMessage, name, in, max)
}
return &Validation{
code: TooLongFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"TooLong",
"(",
"name",
",",
"in",
"string",
",",
"max",
"int64",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooLongMessageNoIn",
",",
"name",
",",
"max",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooLongMessage",
",",
"name",
",",
"in",
",",
"max",
")",
"\n",
"}",
"\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"TooLongFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooLong error for when a string is too long | [
"TooLong",
"error",
"for",
"when",
"a",
"string",
"is",
"too",
"long"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L502-L515 |
13,565 | go-openapi/errors | schema.go | TooShort | func TooShort(name, in string, min int64) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(tooShortMessageNoIn, name, min)
} else {
msg = fmt.Sprintf(tooShortMessage, name, in, min)
}
return &Validation{
code: TooShortFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func TooShort(name, in string, min int64) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(tooShortMessageNoIn, name, min)
} else {
msg = fmt.Sprintf(tooShortMessage, name, in, min)
}
return &Validation{
code: TooShortFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"TooShort",
"(",
"name",
",",
"in",
"string",
",",
"min",
"int64",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooShortMessageNoIn",
",",
"name",
",",
"min",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"tooShortMessage",
",",
"name",
",",
"in",
",",
"min",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"TooShortFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // TooShort error for when a string is too short | [
"TooShort",
"error",
"for",
"when",
"a",
"string",
"is",
"too",
"short"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L518-L532 |
13,566 | go-openapi/errors | schema.go | FailedPattern | func FailedPattern(name, in, pattern string) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(patternFailNoIn, name, pattern)
} else {
msg = fmt.Sprintf(patternFail, name, in, pattern)
}
return &Validation{
code: PatternFailCode,
Name: name,
In: in,
message: msg,
}
} | go | func FailedPattern(name, in, pattern string) *Validation {
var msg string
if in == "" {
msg = fmt.Sprintf(patternFailNoIn, name, pattern)
} else {
msg = fmt.Sprintf(patternFail, name, in, pattern)
}
return &Validation{
code: PatternFailCode,
Name: name,
In: in,
message: msg,
}
} | [
"func",
"FailedPattern",
"(",
"name",
",",
"in",
",",
"pattern",
"string",
")",
"*",
"Validation",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"patternFailNoIn",
",",
"name",
",",
"pattern",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"patternFail",
",",
"name",
",",
"in",
",",
"pattern",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Validation",
"{",
"code",
":",
"PatternFailCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // FailedPattern error for when a string fails a regex pattern match
// the pattern that is returned is the ECMA syntax version of the pattern not the golang version. | [
"FailedPattern",
"error",
"for",
"when",
"a",
"string",
"fails",
"a",
"regex",
"pattern",
"match",
"the",
"pattern",
"that",
"is",
"returned",
"is",
"the",
"ECMA",
"syntax",
"version",
"of",
"the",
"pattern",
"not",
"the",
"golang",
"version",
"."
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L536-L550 |
13,567 | go-openapi/errors | schema.go | MultipleOfMustBePositive | func MultipleOfMustBePositive(name, in string, factor interface{}) *Validation {
return &Validation{
code: MultipleOfMustBePositiveCode,
Name: name,
In: in,
Value: factor,
message: fmt.Sprintf(multipleOfMustBePositive, name, factor),
}
} | go | func MultipleOfMustBePositive(name, in string, factor interface{}) *Validation {
return &Validation{
code: MultipleOfMustBePositiveCode,
Name: name,
In: in,
Value: factor,
message: fmt.Sprintf(multipleOfMustBePositive, name, factor),
}
} | [
"func",
"MultipleOfMustBePositive",
"(",
"name",
",",
"in",
"string",
",",
"factor",
"interface",
"{",
"}",
")",
"*",
"Validation",
"{",
"return",
"&",
"Validation",
"{",
"code",
":",
"MultipleOfMustBePositiveCode",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"factor",
",",
"message",
":",
"fmt",
".",
"Sprintf",
"(",
"multipleOfMustBePositive",
",",
"name",
",",
"factor",
")",
",",
"}",
"\n",
"}"
] | // MultipleOfMustBePositive error for when a
// multipleOf factor is negative | [
"MultipleOfMustBePositive",
"error",
"for",
"when",
"a",
"multipleOf",
"factor",
"is",
"negative"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/schema.go#L554-L562 |
13,568 | go-openapi/errors | parsing.go | NewParseError | func NewParseError(name, in, value string, reason error) *ParseError {
var msg string
if in == "" {
msg = fmt.Sprintf(parseErrorTemplContentNoIn, name, value, reason)
} else {
msg = fmt.Sprintf(parseErrorTemplContent, name, in, value, reason)
}
return &ParseError{
code: 400,
Name: name,
In: in,
Value: value,
Reason: reason,
message: msg,
}
} | go | func NewParseError(name, in, value string, reason error) *ParseError {
var msg string
if in == "" {
msg = fmt.Sprintf(parseErrorTemplContentNoIn, name, value, reason)
} else {
msg = fmt.Sprintf(parseErrorTemplContent, name, in, value, reason)
}
return &ParseError{
code: 400,
Name: name,
In: in,
Value: value,
Reason: reason,
message: msg,
}
} | [
"func",
"NewParseError",
"(",
"name",
",",
"in",
",",
"value",
"string",
",",
"reason",
"error",
")",
"*",
"ParseError",
"{",
"var",
"msg",
"string",
"\n",
"if",
"in",
"==",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"parseErrorTemplContentNoIn",
",",
"name",
",",
"value",
",",
"reason",
")",
"\n",
"}",
"else",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"parseErrorTemplContent",
",",
"name",
",",
"in",
",",
"value",
",",
"reason",
")",
"\n",
"}",
"\n",
"return",
"&",
"ParseError",
"{",
"code",
":",
"400",
",",
"Name",
":",
"name",
",",
"In",
":",
"in",
",",
"Value",
":",
"value",
",",
"Reason",
":",
"reason",
",",
"message",
":",
"msg",
",",
"}",
"\n",
"}"
] | // NewParseError creates a new parse error | [
"NewParseError",
"creates",
"a",
"new",
"parse",
"error"
] | df3fda67a4c851b789d9b34a92cb0edef5734e2c | https://github.com/go-openapi/errors/blob/df3fda67a4c851b789d9b34a92cb0edef5734e2c/parsing.go#L44-L59 |
13,569 | karan/vocabulary | vocabulary.go | Word | func (v Vocabulary) Word(w string) (Word, error) {
if w == "" {
return Word{}, Error("word must be non-empty string")
}
if v.c.BigHugeLabsApiKey == "" {
return Word{}, Error("BigHugeLabsApiKey required.")
}
if v.c.WordnikApiKey == "" {
return Word{}, Error("WordnikApiKey required.")
}
meanings, err := v.Meanings(w)
if err != nil {
return Word{}, err
}
synonyms, err := v.Synonyms(w)
if err != nil {
return Word{}, err
}
antonyms, err := v.Antonyms(w)
if err != nil {
return Word{}, err
}
pos, err := v.PartOfSpeech(w)
if err != nil {
return Word{}, err
}
ue, err := v.UsageExample(w)
if err != nil {
return Word{}, err
}
return Word{
Word: w,
Meanings: meanings,
Synonyms: synonyms,
Antonyms: antonyms,
PartOfSpeech: pos,
UsageExample: ue,
}, nil
} | go | func (v Vocabulary) Word(w string) (Word, error) {
if w == "" {
return Word{}, Error("word must be non-empty string")
}
if v.c.BigHugeLabsApiKey == "" {
return Word{}, Error("BigHugeLabsApiKey required.")
}
if v.c.WordnikApiKey == "" {
return Word{}, Error("WordnikApiKey required.")
}
meanings, err := v.Meanings(w)
if err != nil {
return Word{}, err
}
synonyms, err := v.Synonyms(w)
if err != nil {
return Word{}, err
}
antonyms, err := v.Antonyms(w)
if err != nil {
return Word{}, err
}
pos, err := v.PartOfSpeech(w)
if err != nil {
return Word{}, err
}
ue, err := v.UsageExample(w)
if err != nil {
return Word{}, err
}
return Word{
Word: w,
Meanings: meanings,
Synonyms: synonyms,
Antonyms: antonyms,
PartOfSpeech: pos,
UsageExample: ue,
}, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"Word",
"(",
"w",
"string",
")",
"(",
"Word",
",",
"error",
")",
"{",
"if",
"w",
"==",
"\"",
"\"",
"{",
"return",
"Word",
"{",
"}",
",",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"v",
".",
"c",
".",
"BigHugeLabsApiKey",
"==",
"\"",
"\"",
"{",
"return",
"Word",
"{",
"}",
",",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"v",
".",
"c",
".",
"WordnikApiKey",
"==",
"\"",
"\"",
"{",
"return",
"Word",
"{",
"}",
",",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"meanings",
",",
"err",
":=",
"v",
".",
"Meanings",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Word",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"synonyms",
",",
"err",
":=",
"v",
".",
"Synonyms",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Word",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"antonyms",
",",
"err",
":=",
"v",
".",
"Antonyms",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Word",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"pos",
",",
"err",
":=",
"v",
".",
"PartOfSpeech",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Word",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"ue",
",",
"err",
":=",
"v",
".",
"UsageExample",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Word",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"Word",
"{",
"Word",
":",
"w",
",",
"Meanings",
":",
"meanings",
",",
"Synonyms",
":",
"synonyms",
",",
"Antonyms",
":",
"antonyms",
",",
"PartOfSpeech",
":",
"pos",
",",
"UsageExample",
":",
"ue",
",",
"}",
",",
"nil",
"\n",
"}"
] | // Creates a new Word object collecting as much information as possible.
// Requires having all API keys. | [
"Creates",
"a",
"new",
"Word",
"object",
"collecting",
"as",
"much",
"information",
"as",
"possible",
".",
"Requires",
"having",
"all",
"API",
"keys",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L94-L139 |
13,570 | karan/vocabulary | vocabulary.go | Meanings | func (v Vocabulary) Meanings(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(meaningApiUrl, w))
if err != nil {
return []string{}, err
}
var glosbe Glosbe
err = json.Unmarshal(contents, &glosbe)
if err != nil || glosbe.Result != "ok" || len(glosbe.Tuc) == 0 {
return []string{}, err
}
var meanings GlosbeMeanings
err = json.Unmarshal(glosbe.Tuc[0], &meanings)
if err != nil {
return []string{}, err
}
var result []string
for _, gt := range meanings.Things {
result = append(result, gt.Text)
}
return result, nil
} | go | func (v Vocabulary) Meanings(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(meaningApiUrl, w))
if err != nil {
return []string{}, err
}
var glosbe Glosbe
err = json.Unmarshal(contents, &glosbe)
if err != nil || glosbe.Result != "ok" || len(glosbe.Tuc) == 0 {
return []string{}, err
}
var meanings GlosbeMeanings
err = json.Unmarshal(glosbe.Tuc[0], &meanings)
if err != nil {
return []string{}, err
}
var result []string
for _, gt := range meanings.Things {
result = append(result, gt.Text)
}
return result, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"Meanings",
"(",
"w",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"contents",
",",
"err",
":=",
"makeReq",
"(",
"fmt",
".",
"Sprintf",
"(",
"meaningApiUrl",
",",
"w",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"glosbe",
"Glosbe",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"contents",
",",
"&",
"glosbe",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"||",
"glosbe",
".",
"Result",
"!=",
"\"",
"\"",
"||",
"len",
"(",
"glosbe",
".",
"Tuc",
")",
"==",
"0",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"meanings",
"GlosbeMeanings",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"glosbe",
".",
"Tuc",
"[",
"0",
"]",
",",
"&",
"meanings",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"gt",
":=",
"range",
"meanings",
".",
"Things",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"gt",
".",
"Text",
")",
"\n",
"}",
"\n\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Returns a list of strings representing the meanings of the given word. | [
"Returns",
"a",
"list",
"of",
"strings",
"representing",
"the",
"meanings",
"of",
"the",
"given",
"word",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L142-L167 |
13,571 | karan/vocabulary | vocabulary.go | Synonyms | func (v Vocabulary) Synonyms(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(synonymsApiUrl, w))
if err != nil {
return []string{}, err
}
var glosbe Glosbe
err = json.Unmarshal(contents, &glosbe)
if err != nil || glosbe.Result != "ok" || len(glosbe.Tuc) < 2 {
return []string{}, err
}
var result []string
for _, tuc_raw := range glosbe.Tuc[1:] {
var gp GlosbePhrase
err = json.Unmarshal(tuc_raw, &gp)
if err != nil {
return []string{}, err
}
if gp.Thing.Text != "" {
result = append(result, gp.Thing.Text)
}
}
return result, nil
} | go | func (v Vocabulary) Synonyms(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(synonymsApiUrl, w))
if err != nil {
return []string{}, err
}
var glosbe Glosbe
err = json.Unmarshal(contents, &glosbe)
if err != nil || glosbe.Result != "ok" || len(glosbe.Tuc) < 2 {
return []string{}, err
}
var result []string
for _, tuc_raw := range glosbe.Tuc[1:] {
var gp GlosbePhrase
err = json.Unmarshal(tuc_raw, &gp)
if err != nil {
return []string{}, err
}
if gp.Thing.Text != "" {
result = append(result, gp.Thing.Text)
}
}
return result, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"Synonyms",
"(",
"w",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"contents",
",",
"err",
":=",
"makeReq",
"(",
"fmt",
".",
"Sprintf",
"(",
"synonymsApiUrl",
",",
"w",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"glosbe",
"Glosbe",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"contents",
",",
"&",
"glosbe",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"||",
"glosbe",
".",
"Result",
"!=",
"\"",
"\"",
"||",
"len",
"(",
"glosbe",
".",
"Tuc",
")",
"<",
"2",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"tuc_raw",
":=",
"range",
"glosbe",
".",
"Tuc",
"[",
"1",
":",
"]",
"{",
"var",
"gp",
"GlosbePhrase",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"tuc_raw",
",",
"&",
"gp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"gp",
".",
"Thing",
".",
"Text",
"!=",
"\"",
"\"",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"gp",
".",
"Thing",
".",
"Text",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Returns a list of strings representing the synonyms of the given word. | [
"Returns",
"a",
"list",
"of",
"strings",
"representing",
"the",
"synonyms",
"of",
"the",
"given",
"word",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L170-L195 |
13,572 | karan/vocabulary | vocabulary.go | Antonyms | func (v Vocabulary) Antonyms(w string) ([]string, error) {
if v.c.BigHugeLabsApiKey == "" {
return []string{}, Error("BigHugeLabsApiKey required.")
}
contents, err := makeReq(fmt.Sprintf(antonymsApiUrl, v.c.BigHugeLabsApiKey, w))
if err != nil {
return []string{}, err
}
if string(contents) == "" {
return []string{}, nil
}
var result []string
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
b := strings.Split(line, "|")
if len(b) == 3 && b[1] == "ant" && !stringInSlice(b[2], result) {
result = append(result, b[2])
}
}
return result, nil
} | go | func (v Vocabulary) Antonyms(w string) ([]string, error) {
if v.c.BigHugeLabsApiKey == "" {
return []string{}, Error("BigHugeLabsApiKey required.")
}
contents, err := makeReq(fmt.Sprintf(antonymsApiUrl, v.c.BigHugeLabsApiKey, w))
if err != nil {
return []string{}, err
}
if string(contents) == "" {
return []string{}, nil
}
var result []string
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
b := strings.Split(line, "|")
if len(b) == 3 && b[1] == "ant" && !stringInSlice(b[2], result) {
result = append(result, b[2])
}
}
return result, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"Antonyms",
"(",
"w",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"v",
".",
"c",
".",
"BigHugeLabsApiKey",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"contents",
",",
"err",
":=",
"makeReq",
"(",
"fmt",
".",
"Sprintf",
"(",
"antonymsApiUrl",
",",
"v",
".",
"c",
".",
"BigHugeLabsApiKey",
",",
"w",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"string",
"(",
"contents",
")",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"string",
"\n",
"lines",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"contents",
")",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"b",
":=",
"strings",
".",
"Split",
"(",
"line",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"==",
"3",
"&&",
"b",
"[",
"1",
"]",
"==",
"\"",
"\"",
"&&",
"!",
"stringInSlice",
"(",
"b",
"[",
"2",
"]",
",",
"result",
")",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"b",
"[",
"2",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Returns a list of strings representing the antonyms of the given word. | [
"Returns",
"a",
"list",
"of",
"strings",
"representing",
"the",
"antonyms",
"of",
"the",
"given",
"word",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L198-L221 |
13,573 | karan/vocabulary | vocabulary.go | PartOfSpeech | func (v Vocabulary) PartOfSpeech(w string) ([]PartOfSpeech, error) {
if v.c.WordnikApiKey == "" {
return []PartOfSpeech{}, Error("WordnikApiKey required.")
}
contents, err := makeReq(fmt.Sprintf(partOfSpeechApiUrl, w, v.c.WordnikApiKey))
if err != nil {
return []PartOfSpeech{}, err
}
var result []PartOfSpeech
err = json.Unmarshal(contents, &result)
if err != nil {
return []PartOfSpeech{}, err
}
return result, nil
} | go | func (v Vocabulary) PartOfSpeech(w string) ([]PartOfSpeech, error) {
if v.c.WordnikApiKey == "" {
return []PartOfSpeech{}, Error("WordnikApiKey required.")
}
contents, err := makeReq(fmt.Sprintf(partOfSpeechApiUrl, w, v.c.WordnikApiKey))
if err != nil {
return []PartOfSpeech{}, err
}
var result []PartOfSpeech
err = json.Unmarshal(contents, &result)
if err != nil {
return []PartOfSpeech{}, err
}
return result, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"PartOfSpeech",
"(",
"w",
"string",
")",
"(",
"[",
"]",
"PartOfSpeech",
",",
"error",
")",
"{",
"if",
"v",
".",
"c",
".",
"WordnikApiKey",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"PartOfSpeech",
"{",
"}",
",",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"contents",
",",
"err",
":=",
"makeReq",
"(",
"fmt",
".",
"Sprintf",
"(",
"partOfSpeechApiUrl",
",",
"w",
",",
"v",
".",
"c",
".",
"WordnikApiKey",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"PartOfSpeech",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"PartOfSpeech",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"contents",
",",
"&",
"result",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"PartOfSpeech",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Returns a list of PartOfSpeech structs representing the POS of the given word. | [
"Returns",
"a",
"list",
"of",
"PartOfSpeech",
"structs",
"representing",
"the",
"POS",
"of",
"the",
"given",
"word",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L224-L240 |
13,574 | karan/vocabulary | vocabulary.go | UsageExample | func (v Vocabulary) UsageExample(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(usageExampleApiUrl, w))
if err != nil {
return []string{}, err
}
var resp UrbanDictResp
err = json.Unmarshal(contents, &resp)
if err != nil {
return []string{}, err
}
if len(resp.Things) == 0 {
return []string{}, nil
}
var result []string
for _, thing := range resp.Things {
if thing.ThumbsUp > 2*thing.ThumbsDown {
text := strings.Replace(thing.Example, "\r", " ", -1)
text = strings.Replace(thing.Example, "\n", " ", -1)
result = append(result, text)
}
}
return result, nil
} | go | func (v Vocabulary) UsageExample(w string) ([]string, error) {
contents, err := makeReq(fmt.Sprintf(usageExampleApiUrl, w))
if err != nil {
return []string{}, err
}
var resp UrbanDictResp
err = json.Unmarshal(contents, &resp)
if err != nil {
return []string{}, err
}
if len(resp.Things) == 0 {
return []string{}, nil
}
var result []string
for _, thing := range resp.Things {
if thing.ThumbsUp > 2*thing.ThumbsDown {
text := strings.Replace(thing.Example, "\r", " ", -1)
text = strings.Replace(thing.Example, "\n", " ", -1)
result = append(result, text)
}
}
return result, nil
} | [
"func",
"(",
"v",
"Vocabulary",
")",
"UsageExample",
"(",
"w",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"contents",
",",
"err",
":=",
"makeReq",
"(",
"fmt",
".",
"Sprintf",
"(",
"usageExampleApiUrl",
",",
"w",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"resp",
"UrbanDictResp",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"contents",
",",
"&",
"resp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"resp",
".",
"Things",
")",
"==",
"0",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"thing",
":=",
"range",
"resp",
".",
"Things",
"{",
"if",
"thing",
".",
"ThumbsUp",
">",
"2",
"*",
"thing",
".",
"ThumbsDown",
"{",
"text",
":=",
"strings",
".",
"Replace",
"(",
"thing",
".",
"Example",
",",
"\"",
"\\r",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"text",
"=",
"strings",
".",
"Replace",
"(",
"thing",
".",
"Example",
",",
"\"",
"\\n",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"text",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Returns a list of strings representing usage examples of the given word. | [
"Returns",
"a",
"list",
"of",
"strings",
"representing",
"usage",
"examples",
"of",
"the",
"given",
"word",
"."
] | ca7289b4cdf4d4336053b728c1baf2864188b0b8 | https://github.com/karan/vocabulary/blob/ca7289b4cdf4d4336053b728c1baf2864188b0b8/vocabulary.go#L243-L268 |
13,575 | qlik-oss/enigma-go | session_messages.go | SessionMessageChannel | func (e *sessionMessages) SessionMessageChannel(topics ...string) chan SessionMessage {
e.mutex.Lock()
defer e.mutex.Unlock()
channelEntry := &sessionMessageChannelEntry{topics: topics, channel: make(chan SessionMessage, 16+len(e.history))}
e.channels[channelEntry] = true
for _, oldEvent := range e.history {
channelEntry.emitSessionEvent(oldEvent)
}
return channelEntry.channel
} | go | func (e *sessionMessages) SessionMessageChannel(topics ...string) chan SessionMessage {
e.mutex.Lock()
defer e.mutex.Unlock()
channelEntry := &sessionMessageChannelEntry{topics: topics, channel: make(chan SessionMessage, 16+len(e.history))}
e.channels[channelEntry] = true
for _, oldEvent := range e.history {
channelEntry.emitSessionEvent(oldEvent)
}
return channelEntry.channel
} | [
"func",
"(",
"e",
"*",
"sessionMessages",
")",
"SessionMessageChannel",
"(",
"topics",
"...",
"string",
")",
"chan",
"SessionMessage",
"{",
"e",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"channelEntry",
":=",
"&",
"sessionMessageChannelEntry",
"{",
"topics",
":",
"topics",
",",
"channel",
":",
"make",
"(",
"chan",
"SessionMessage",
",",
"16",
"+",
"len",
"(",
"e",
".",
"history",
")",
")",
"}",
"\n",
"e",
".",
"channels",
"[",
"channelEntry",
"]",
"=",
"true",
"\n",
"for",
"_",
",",
"oldEvent",
":=",
"range",
"e",
".",
"history",
"{",
"channelEntry",
".",
"emitSessionEvent",
"(",
"oldEvent",
")",
"\n",
"}",
"\n",
"return",
"channelEntry",
".",
"channel",
"\n",
"}"
] | // SessionMessageChannel returns a channel that receives notifications from Qlik Associative Engine. To only receive
// certain events a list of topics can be supplied. If no topics are supplied all events are received. | [
"SessionMessageChannel",
"returns",
"a",
"channel",
"that",
"receives",
"notifications",
"from",
"Qlik",
"Associative",
"Engine",
".",
"To",
"only",
"receive",
"certain",
"events",
"a",
"list",
"of",
"topics",
"can",
"be",
"supplied",
".",
"If",
"no",
"topics",
"are",
"supplied",
"all",
"events",
"are",
"received",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/session_messages.go#L55-L64 |
13,576 | qlik-oss/enigma-go | session_messages.go | CloseSessionMessageChannel | func (e *sessionMessages) CloseSessionMessageChannel(channel chan SessionMessage) {
e.mutex.Lock()
defer e.mutex.Unlock()
for channelEntry := range e.channels {
if channelEntry.channel == channel {
close(channelEntry.channel)
delete(e.channels, channelEntry)
break
}
}
} | go | func (e *sessionMessages) CloseSessionMessageChannel(channel chan SessionMessage) {
e.mutex.Lock()
defer e.mutex.Unlock()
for channelEntry := range e.channels {
if channelEntry.channel == channel {
close(channelEntry.channel)
delete(e.channels, channelEntry)
break
}
}
} | [
"func",
"(",
"e",
"*",
"sessionMessages",
")",
"CloseSessionMessageChannel",
"(",
"channel",
"chan",
"SessionMessage",
")",
"{",
"e",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"for",
"channelEntry",
":=",
"range",
"e",
".",
"channels",
"{",
"if",
"channelEntry",
".",
"channel",
"==",
"channel",
"{",
"close",
"(",
"channelEntry",
".",
"channel",
")",
"\n",
"delete",
"(",
"e",
".",
"channels",
",",
"channelEntry",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // CloseSessionMessageChannel closes and unregisters the supplied event channel from the session. | [
"CloseSessionMessageChannel",
"closes",
"and",
"unregisters",
"the",
"supplied",
"event",
"channel",
"from",
"the",
"session",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/session_messages.go#L67-L77 |
13,577 | qlik-oss/enigma-go | session_messages.go | SessionState | func (e *sessionMessages) SessionState(ctx context.Context) (string, error) {
channel := e.SessionMessageChannel("OnConnected")
defer e.CloseSessionMessageChannel(channel)
select {
case <-ctx.Done():
return "", ctx.Err()
case message := <-channel:
connectedInfo := &onConnectedEvent{}
err := json.Unmarshal(message.Content, connectedInfo)
if err != nil {
return "", err
}
return connectedInfo.SessionState, nil
}
} | go | func (e *sessionMessages) SessionState(ctx context.Context) (string, error) {
channel := e.SessionMessageChannel("OnConnected")
defer e.CloseSessionMessageChannel(channel)
select {
case <-ctx.Done():
return "", ctx.Err()
case message := <-channel:
connectedInfo := &onConnectedEvent{}
err := json.Unmarshal(message.Content, connectedInfo)
if err != nil {
return "", err
}
return connectedInfo.SessionState, nil
}
} | [
"func",
"(",
"e",
"*",
"sessionMessages",
")",
"SessionState",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"channel",
":=",
"e",
".",
"SessionMessageChannel",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"e",
".",
"CloseSessionMessageChannel",
"(",
"channel",
")",
"\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\"",
"\"",
",",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"message",
":=",
"<-",
"channel",
":",
"connectedInfo",
":=",
"&",
"onConnectedEvent",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"message",
".",
"Content",
",",
"connectedInfo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"connectedInfo",
".",
"SessionState",
",",
"nil",
"\n",
"}",
"\n",
"}"
] | // SessionState returns either SESSION_CREATED or SESSION_ATTACHED to describe the status of the current websocket session | [
"SessionState",
"returns",
"either",
"SESSION_CREATED",
"or",
"SESSION_ATTACHED",
"to",
"describe",
"the",
"status",
"of",
"the",
"current",
"websocket",
"session"
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/session_messages.go#L93-L107 |
13,578 | qlik-oss/enigma-go | qix_generated.go | ClearUndoBuffer | func (obj *Doc) ClearUndoBuffer(ctx context.Context) error {
err := obj.rpc(ctx, "ClearUndoBuffer", nil)
return err
} | go | func (obj *Doc) ClearUndoBuffer(ctx context.Context) error {
err := obj.rpc(ctx, "ClearUndoBuffer", nil)
return err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"ClearUndoBuffer",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Clears entirely the undo and redo buffer. | [
"Clears",
"entirely",
"the",
"undo",
"and",
"redo",
"buffer",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L4715-L4718 |
13,579 | qlik-oss/enigma-go | qix_generated.go | ForwardCount | func (obj *Doc) ForwardCount(ctx context.Context) (int, error) {
result := &struct {
Return int `json:"qReturn"`
} {}
err := obj.rpc(ctx, "ForwardCount", result)
return result.Return, err
} | go | func (obj *Doc) ForwardCount(ctx context.Context) (int, error) {
result := &struct {
Return int `json:"qReturn"`
} {}
err := obj.rpc(ctx, "ForwardCount", result)
return result.Return, err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"ForwardCount",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"int",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"int",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Return",
",",
"err",
"\n",
"}"
] | // Returns the number of entries on the Forward stack. | [
"Returns",
"the",
"number",
"of",
"entries",
"on",
"the",
"Forward",
"stack",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L5747-L5753 |
13,580 | qlik-oss/enigma-go | qix_generated.go | GetFavoriteVariables | func (obj *Doc) GetFavoriteVariables(ctx context.Context) ([]string, error) {
result := &struct {
Names []string `json:"qNames"`
} {}
err := obj.rpc(ctx, "GetFavoriteVariables", result)
return result.Names, err
} | go | func (obj *Doc) GetFavoriteVariables(ctx context.Context) ([]string, error) {
result := &struct {
Names []string `json:"qNames"`
} {}
err := obj.rpc(ctx, "GetFavoriteVariables", result)
return result.Names, err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"GetFavoriteVariables",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Names",
"[",
"]",
"string",
"`json:\"qNames\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Names",
",",
"err",
"\n",
"}"
] | // Retrieves the variables that are tagged as favorite. | [
"Retrieves",
"the",
"variables",
"that",
"are",
"tagged",
"as",
"favorite",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L6258-L6264 |
13,581 | qlik-oss/enigma-go | qix_generated.go | GetLocaleInfo | func (obj *Doc) GetLocaleInfo(ctx context.Context) (*LocaleInfo, error) {
result := &struct {
Return *LocaleInfo `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetLocaleInfo", result)
return result.Return, err
} | go | func (obj *Doc) GetLocaleInfo(ctx context.Context) (*LocaleInfo, error) {
result := &struct {
Return *LocaleInfo `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetLocaleInfo", result)
return result.Return, err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"GetLocaleInfo",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"LocaleInfo",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"*",
"LocaleInfo",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Return",
",",
"err",
"\n",
"}"
] | // Returns locale information. | [
"Returns",
"locale",
"information",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L6806-L6812 |
13,582 | qlik-oss/enigma-go | qix_generated.go | GetScript | func (obj *Doc) GetScript(ctx context.Context) (string, error) {
result := &struct {
Script string `json:"qScript"`
} {}
err := obj.rpc(ctx, "GetScript", result)
return result.Script, err
} | go | func (obj *Doc) GetScript(ctx context.Context) (string, error) {
result := &struct {
Script string `json:"qScript"`
} {}
err := obj.rpc(ctx, "GetScript", result)
return result.Script, err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"GetScript",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Script",
"string",
"`json:\"qScript\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Script",
",",
"err",
"\n",
"}"
] | // Gets values in script. | [
"Gets",
"values",
"in",
"script",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L6977-L6983 |
13,583 | qlik-oss/enigma-go | qix_generated.go | Redo | func (obj *Doc) Redo(ctx context.Context) (bool, error) {
result := &struct {
Success bool `json:"qSuccess"`
} {}
err := obj.rpc(ctx, "Redo", result)
return result.Success, err
} | go | func (obj *Doc) Redo(ctx context.Context) (bool, error) {
result := &struct {
Success bool `json:"qSuccess"`
} {}
err := obj.rpc(ctx, "Redo", result)
return result.Success, err
} | [
"func",
"(",
"obj",
"*",
"Doc",
")",
"Redo",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"bool",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Success",
"bool",
"`json:\"qSuccess\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Success",
",",
"err",
"\n",
"}"
] | // Redoes the previous operation.
//
// The operation is successful if qSuccess is set to true. | [
"Redoes",
"the",
"previous",
"operation",
".",
"The",
"operation",
"is",
"successful",
"if",
"qSuccess",
"is",
"set",
"to",
"true",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L7470-L7476 |
13,584 | qlik-oss/enigma-go | qix_generated.go | GetCardinal | func (obj *Field) GetCardinal(ctx context.Context) (int, error) {
result := &struct {
Return int `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetCardinal", result)
return result.Return, err
} | go | func (obj *Field) GetCardinal(ctx context.Context) (int, error) {
result := &struct {
Return int `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetCardinal", result)
return result.Return, err
} | [
"func",
"(",
"obj",
"*",
"Field",
")",
"GetCardinal",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"int",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"int",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Return",
",",
"err",
"\n",
"}"
] | // Retrieves the number of distinct values in a field. | [
"Retrieves",
"the",
"number",
"of",
"distinct",
"values",
"in",
"a",
"field",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8009-L8015 |
13,585 | qlik-oss/enigma-go | qix_generated.go | GetNxProperties | func (obj *Field) GetNxProperties(ctx context.Context) (*NxFieldProperties, error) {
result := &struct {
Properties *NxFieldProperties `json:"qProperties"`
} {}
err := obj.rpc(ctx, "GetNxProperties", result)
return result.Properties, err
} | go | func (obj *Field) GetNxProperties(ctx context.Context) (*NxFieldProperties, error) {
result := &struct {
Properties *NxFieldProperties `json:"qProperties"`
} {}
err := obj.rpc(ctx, "GetNxProperties", result)
return result.Properties, err
} | [
"func",
"(",
"obj",
"*",
"Field",
")",
"GetNxProperties",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"NxFieldProperties",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Properties",
"*",
"NxFieldProperties",
"`json:\"qProperties\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Properties",
",",
"err",
"\n",
"}"
] | // Gets the properties of a field.
//
// The property OneAndOnlyOne is set to true if one and only value has been selected in the field prior setting the property. | [
"Gets",
"the",
"properties",
"of",
"a",
"field",
".",
"The",
"property",
"OneAndOnlyOne",
"is",
"set",
"to",
"true",
"if",
"one",
"and",
"only",
"value",
"has",
"been",
"selected",
"in",
"the",
"field",
"prior",
"setting",
"the",
"property",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8020-L8026 |
13,586 | qlik-oss/enigma-go | qix_generated.go | Apply | func (obj *GenericBookmark) Apply(ctx context.Context) (bool, error) {
result := &struct {
Success bool `json:"qSuccess"`
} {}
err := obj.rpc(ctx, "Apply", result)
return result.Success, err
} | go | func (obj *GenericBookmark) Apply(ctx context.Context) (bool, error) {
result := &struct {
Success bool `json:"qSuccess"`
} {}
err := obj.rpc(ctx, "Apply", result)
return result.Success, err
} | [
"func",
"(",
"obj",
"*",
"GenericBookmark",
")",
"Apply",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"bool",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Success",
"bool",
"`json:\"qSuccess\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Success",
",",
"err",
"\n",
"}"
] | // Applies a bookmark.
//
// The operation is successful if qSuccess is set to true. | [
"Applies",
"a",
"bookmark",
".",
"The",
"operation",
"is",
"successful",
"if",
"qSuccess",
"is",
"set",
"to",
"true",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8258-L8264 |
13,587 | qlik-oss/enigma-go | qix_generated.go | GetLayout | func (obj *GenericDimension) GetLayout(ctx context.Context) (*GenericDimensionLayout, error) {
result := &struct {
Layout *GenericDimensionLayout `json:"qLayout"`
} {}
err := obj.rpc(ctx, "GetLayout", result)
return result.Layout, err
} | go | func (obj *GenericDimension) GetLayout(ctx context.Context) (*GenericDimensionLayout, error) {
result := &struct {
Layout *GenericDimensionLayout `json:"qLayout"`
} {}
err := obj.rpc(ctx, "GetLayout", result)
return result.Layout, err
} | [
"func",
"(",
"obj",
"*",
"GenericDimension",
")",
"GetLayout",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"GenericDimensionLayout",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Layout",
"*",
"GenericDimensionLayout",
"`json:\"qLayout\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Layout",
",",
"err",
"\n",
"}"
] | // Evaluates a dimension and displays its properties, including the dynamic properties. | [
"Evaluates",
"a",
"dimension",
"and",
"displays",
"its",
"properties",
"including",
"the",
"dynamic",
"properties",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8551-L8557 |
13,588 | qlik-oss/enigma-go | qix_generated.go | GetProperties | func (obj *GenericDimension) GetProperties(ctx context.Context) (*GenericDimensionProperties, error) {
result := &struct {
Prop *GenericDimensionProperties `json:"qProp"`
} {}
err := obj.rpc(ctx, "GetProperties", result)
return result.Prop, err
} | go | func (obj *GenericDimension) GetProperties(ctx context.Context) (*GenericDimensionProperties, error) {
result := &struct {
Prop *GenericDimensionProperties `json:"qProp"`
} {}
err := obj.rpc(ctx, "GetProperties", result)
return result.Prop, err
} | [
"func",
"(",
"obj",
"*",
"GenericDimension",
")",
"GetProperties",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"GenericDimensionProperties",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Prop",
"*",
"GenericDimensionProperties",
"`json:\"qProp\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Prop",
",",
"err",
"\n",
"}"
] | // Shows the properties of an object.
// Returns the identifier and the definition of the dimension.
// If the member delta is set to true in the request object, only the delta is retrieved. | [
"Shows",
"the",
"properties",
"of",
"an",
"object",
".",
"Returns",
"the",
"identifier",
"and",
"the",
"definition",
"of",
"the",
"dimension",
".",
"If",
"the",
"member",
"delta",
"is",
"set",
"to",
"true",
"in",
"the",
"request",
"object",
"only",
"the",
"delta",
"is",
"retrieved",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8589-L8595 |
13,589 | qlik-oss/enigma-go | qix_generated.go | UnApprove | func (obj *GenericDimension) UnApprove(ctx context.Context) error {
err := obj.rpc(ctx, "UnApprove", nil)
return err
} | go | func (obj *GenericDimension) UnApprove(ctx context.Context) error {
err := obj.rpc(ctx, "UnApprove", nil)
return err
} | [
"func",
"(",
"obj",
"*",
"GenericDimension",
")",
"UnApprove",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Removes the generic dimension from the list of approved objects
// This operation is possible only in Qlik Sense Enterprise. | [
"Removes",
"the",
"generic",
"dimension",
"from",
"the",
"list",
"of",
"approved",
"objects",
"This",
"operation",
"is",
"possible",
"only",
"in",
"Qlik",
"Sense",
"Enterprise",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8639-L8642 |
13,590 | qlik-oss/enigma-go | qix_generated.go | GetLayout | func (obj *GenericMeasure) GetLayout(ctx context.Context) (*GenericMeasureLayout, error) {
result := &struct {
Layout *GenericMeasureLayout `json:"qLayout"`
} {}
err := obj.rpc(ctx, "GetLayout", result)
return result.Layout, err
} | go | func (obj *GenericMeasure) GetLayout(ctx context.Context) (*GenericMeasureLayout, error) {
result := &struct {
Layout *GenericMeasureLayout `json:"qLayout"`
} {}
err := obj.rpc(ctx, "GetLayout", result)
return result.Layout, err
} | [
"func",
"(",
"obj",
"*",
"GenericMeasure",
")",
"GetLayout",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"GenericMeasureLayout",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Layout",
"*",
"GenericMeasureLayout",
"`json:\"qLayout\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Layout",
",",
"err",
"\n",
"}"
] | // Evaluates a measure and displays its properties, including the dynamic properties. | [
"Evaluates",
"a",
"measure",
"and",
"displays",
"its",
"properties",
"including",
"the",
"dynamic",
"properties",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L8706-L8712 |
13,591 | qlik-oss/enigma-go | qix_generated.go | GetEffectiveProperties | func (obj *GenericObject) GetEffectiveProperties(ctx context.Context) (*GenericObjectProperties, error) {
result := &struct {
Prop *GenericObjectProperties `json:"qProp"`
} {}
err := obj.rpc(ctx, "GetEffectiveProperties", result)
return result.Prop, err
} | go | func (obj *GenericObject) GetEffectiveProperties(ctx context.Context) (*GenericObjectProperties, error) {
result := &struct {
Prop *GenericObjectProperties `json:"qProp"`
} {}
err := obj.rpc(ctx, "GetEffectiveProperties", result)
return result.Prop, err
} | [
"func",
"(",
"obj",
"*",
"GenericObject",
")",
"GetEffectiveProperties",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"GenericObjectProperties",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Prop",
"*",
"GenericObjectProperties",
"`json:\"qProp\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Prop",
",",
"err",
"\n",
"}"
] | // Returns the identifier, the type and the properties of the object.
// If the object contains some soft properties, the soft properties are returned.
// If the object is linked to another object, the properties of the linking object are returned.
// GetEffectiveProperties method
// Returns the identifier, the type and the properties of the object.
// If the object contains some soft properties, the soft properties are returned.
// If the object is linked to another object, the properties of the linking object are returned. | [
"Returns",
"the",
"identifier",
"the",
"type",
"and",
"the",
"properties",
"of",
"the",
"object",
".",
"If",
"the",
"object",
"contains",
"some",
"soft",
"properties",
"the",
"soft",
"properties",
"are",
"returned",
".",
"If",
"the",
"object",
"is",
"linked",
"to",
"another",
"object",
"the",
"properties",
"of",
"the",
"linking",
"object",
"are",
"returned",
".",
"GetEffectiveProperties",
"method",
"Returns",
"the",
"identifier",
"the",
"type",
"and",
"the",
"properties",
"of",
"the",
"object",
".",
"If",
"the",
"object",
"contains",
"some",
"soft",
"properties",
"the",
"soft",
"properties",
"are",
"returned",
".",
"If",
"the",
"object",
"is",
"linked",
"to",
"another",
"object",
"the",
"properties",
"of",
"the",
"linking",
"object",
"are",
"returned",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L9331-L9337 |
13,592 | qlik-oss/enigma-go | qix_generated.go | GetParent | func (obj *GenericObject) GetParent(ctx context.Context) (*GenericObject, error) {
result := &struct {
Return *ObjectInterface `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetParent", result)
if err != nil {
return nil, err
}
return &GenericObject{obj.session.getRemoteObject(result.Return)}, err
} | go | func (obj *GenericObject) GetParent(ctx context.Context) (*GenericObject, error) {
result := &struct {
Return *ObjectInterface `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetParent", result)
if err != nil {
return nil, err
}
return &GenericObject{obj.session.getRemoteObject(result.Return)}, err
} | [
"func",
"(",
"obj",
"*",
"GenericObject",
")",
"GetParent",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"GenericObject",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"*",
"ObjectInterface",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"GenericObject",
"{",
"obj",
".",
"session",
".",
"getRemoteObject",
"(",
"result",
".",
"Return",
")",
"}",
",",
"err",
"\n",
"}"
] | // Returns the type of the object and the corresponding handle to the parent object in the hiearchy. | [
"Returns",
"the",
"type",
"of",
"the",
"object",
"and",
"the",
"corresponding",
"handle",
"to",
"the",
"parent",
"object",
"in",
"the",
"hiearchy",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L10113-L10122 |
13,593 | qlik-oss/enigma-go | qix_generated.go | GetActiveDoc | func (obj *Global) GetActiveDoc(ctx context.Context) (*Doc, error) {
result := &struct {
Return *ObjectInterface `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetActiveDoc", result)
if err != nil {
return nil, err
}
return &Doc{obj.session.getRemoteObject(result.Return)}, err
} | go | func (obj *Global) GetActiveDoc(ctx context.Context) (*Doc, error) {
result := &struct {
Return *ObjectInterface `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetActiveDoc", result)
if err != nil {
return nil, err
}
return &Doc{obj.session.getRemoteObject(result.Return)}, err
} | [
"func",
"(",
"obj",
"*",
"Global",
")",
"GetActiveDoc",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"Doc",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"*",
"ObjectInterface",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"Doc",
"{",
"obj",
".",
"session",
".",
"getRemoteObject",
"(",
"result",
".",
"Return",
")",
"}",
",",
"err",
"\n",
"}"
] | // Returns the handle of the current app. | [
"Returns",
"the",
"handle",
"of",
"the",
"current",
"app",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L11419-L11428 |
13,594 | qlik-oss/enigma-go | qix_generated.go | GetAuthenticatedUser | func (obj *Global) GetAuthenticatedUser(ctx context.Context) (string, error) {
result := &struct {
Return string `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetAuthenticatedUser", result)
return result.Return, err
} | go | func (obj *Global) GetAuthenticatedUser(ctx context.Context) (string, error) {
result := &struct {
Return string `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetAuthenticatedUser", result)
return result.Return, err
} | [
"func",
"(",
"obj",
"*",
"Global",
")",
"GetAuthenticatedUser",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"string",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Return",
",",
"err",
"\n",
"}"
] | // Retrieves information about the authenticated user. | [
"Retrieves",
"information",
"about",
"the",
"authenticated",
"user",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L11469-L11475 |
13,595 | qlik-oss/enigma-go | qix_generated.go | GetDefaultAppFolder | func (obj *Global) GetDefaultAppFolder(ctx context.Context) (string, error) {
result := &struct {
Path string `json:"qPath"`
} {}
err := obj.rpc(ctx, "GetDefaultAppFolder", result)
return result.Path, err
} | go | func (obj *Global) GetDefaultAppFolder(ctx context.Context) (string, error) {
result := &struct {
Path string `json:"qPath"`
} {}
err := obj.rpc(ctx, "GetDefaultAppFolder", result)
return result.Path, err
} | [
"func",
"(",
"obj",
"*",
"Global",
")",
"GetDefaultAppFolder",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Path",
"string",
"`json:\"qPath\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Path",
",",
"err",
"\n",
"}"
] | // Returns the folder where the apps are stored.
// This method applies only if running Qlik Sense Desktop. | [
"Returns",
"the",
"folder",
"where",
"the",
"apps",
"are",
"stored",
".",
"This",
"method",
"applies",
"only",
"if",
"running",
"Qlik",
"Sense",
"Desktop",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L11693-L11699 |
13,596 | qlik-oss/enigma-go | qix_generated.go | GetUniqueID | func (obj *Global) GetUniqueID(ctx context.Context) (string, error) {
result := &struct {
UniqueID string `json:"qUniqueID"`
} {}
err := obj.rpc(ctx, "GetUniqueID", result)
return result.UniqueID, err
} | go | func (obj *Global) GetUniqueID(ctx context.Context) (string, error) {
result := &struct {
UniqueID string `json:"qUniqueID"`
} {}
err := obj.rpc(ctx, "GetUniqueID", result)
return result.UniqueID, err
} | [
"func",
"(",
"obj",
"*",
"Global",
")",
"GetUniqueID",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"UniqueID",
"string",
"`json:\"qUniqueID\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"UniqueID",
",",
"err",
"\n",
"}"
] | // Returns the unique identifier of the endpoint for the current user in the current app.
// This unique identifier can be used for logging purposes. | [
"Returns",
"the",
"unique",
"identifier",
"of",
"the",
"endpoint",
"for",
"the",
"current",
"user",
"in",
"the",
"current",
"app",
".",
"This",
"unique",
"identifier",
"can",
"be",
"used",
"for",
"logging",
"purposes",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L12115-L12121 |
13,597 | qlik-oss/enigma-go | qix_generated.go | GetRawContent | func (obj *Variable) GetRawContent(ctx context.Context) (string, error) {
result := &struct {
Return string `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetRawContent", result)
return result.Return, err
} | go | func (obj *Variable) GetRawContent(ctx context.Context) (string, error) {
result := &struct {
Return string `json:"qReturn"`
} {}
err := obj.rpc(ctx, "GetRawContent", result)
return result.Return, err
} | [
"func",
"(",
"obj",
"*",
"Variable",
")",
"GetRawContent",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"&",
"struct",
"{",
"Return",
"string",
"`json:\"qReturn\"`",
"\n",
"}",
"{",
"}",
"\n",
"err",
":=",
"obj",
".",
"rpc",
"(",
"ctx",
",",
"\"",
"\"",
",",
"result",
")",
"\n",
"return",
"result",
".",
"Return",
",",
"err",
"\n",
"}"
] | // Returns the raw value of a variable. | [
"Returns",
"the",
"raw",
"value",
"of",
"a",
"variable",
"."
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/qix_generated.go#L12401-L12407 |
13,598 | qlik-oss/enigma-go | websocket_traffic_log.go | Sent | func (t *fileTrafficLog) Sent(message []byte) {
t.mutex.Lock()
defer t.mutex.Unlock()
t.Messages = append(t.Messages, trafficLogRow{Sent: message})
} | go | func (t *fileTrafficLog) Sent(message []byte) {
t.mutex.Lock()
defer t.mutex.Unlock()
t.Messages = append(t.Messages, trafficLogRow{Sent: message})
} | [
"func",
"(",
"t",
"*",
"fileTrafficLog",
")",
"Sent",
"(",
"message",
"[",
"]",
"byte",
")",
"{",
"t",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"t",
".",
"Messages",
"=",
"append",
"(",
"t",
".",
"Messages",
",",
"trafficLogRow",
"{",
"Sent",
":",
"message",
"}",
")",
"\n",
"}"
] | // Sent implements the TrafficLogger interface | [
"Sent",
"implements",
"the",
"TrafficLogger",
"interface"
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/websocket_traffic_log.go#L28-L32 |
13,599 | qlik-oss/enigma-go | websocket_traffic_log.go | Closed | func (t *fileTrafficLog) Closed() {
bytes, _ := json.MarshalIndent(t.Messages, "", "\t")
ioutil.WriteFile(t.FileName, bytes, 0644)
} | go | func (t *fileTrafficLog) Closed() {
bytes, _ := json.MarshalIndent(t.Messages, "", "\t")
ioutil.WriteFile(t.FileName, bytes, 0644)
} | [
"func",
"(",
"t",
"*",
"fileTrafficLog",
")",
"Closed",
"(",
")",
"{",
"bytes",
",",
"_",
":=",
"json",
".",
"MarshalIndent",
"(",
"t",
".",
"Messages",
",",
"\"",
"\"",
",",
"\"",
"\\t",
"\"",
")",
"\n",
"ioutil",
".",
"WriteFile",
"(",
"t",
".",
"FileName",
",",
"bytes",
",",
"0644",
")",
"\n",
"}"
] | // Closed implements the TrafficLogger interface | [
"Closed",
"implements",
"the",
"TrafficLogger",
"interface"
] | 7fdea27298e888663c973c15dbbfba2c0a1ec085 | https://github.com/qlik-oss/enigma-go/blob/7fdea27298e888663c973c15dbbfba2c0a1ec085/websocket_traffic_log.go#L42-L45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.