repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
elastic/go-ucfg
ucfg.go
FlattenedKeys
func (c *Config) FlattenedKeys(opts ...Option) []string { var keys []string normalizedOptions := makeOptions(opts) if normalizedOptions.pathSep == "" { normalizedOptions.pathSep = "." } if c.IsDict() { for _, v := range c.fields.dict() { subcfg, err := v.toConfig(normalizedOptions) if err != nil { ctx := v.Context() p := ctx.path(normalizedOptions.pathSep) keys = append(keys, p) } else { newKeys := subcfg.FlattenedKeys(opts...) keys = append(keys, newKeys...) } } } else if c.IsArray() { for _, a := range c.fields.array() { scfg, err := a.toConfig(normalizedOptions) if err != nil { ctx := a.Context() p := ctx.path(normalizedOptions.pathSep) keys = append(keys, p) } else { newKeys := scfg.FlattenedKeys(opts...) keys = append(keys, newKeys...) } } } sort.Strings(keys) return keys }
go
func (c *Config) FlattenedKeys(opts ...Option) []string { var keys []string normalizedOptions := makeOptions(opts) if normalizedOptions.pathSep == "" { normalizedOptions.pathSep = "." } if c.IsDict() { for _, v := range c.fields.dict() { subcfg, err := v.toConfig(normalizedOptions) if err != nil { ctx := v.Context() p := ctx.path(normalizedOptions.pathSep) keys = append(keys, p) } else { newKeys := subcfg.FlattenedKeys(opts...) keys = append(keys, newKeys...) } } } else if c.IsArray() { for _, a := range c.fields.array() { scfg, err := a.toConfig(normalizedOptions) if err != nil { ctx := a.Context() p := ctx.path(normalizedOptions.pathSep) keys = append(keys, p) } else { newKeys := scfg.FlattenedKeys(opts...) keys = append(keys, newKeys...) } } } sort.Strings(keys) return keys }
[ "func", "(", "c", "*", "Config", ")", "FlattenedKeys", "(", "opts", "...", "Option", ")", "[", "]", "string", "{", "var", "keys", "[", "]", "string", "\n", "normalizedOptions", ":=", "makeOptions", "(", "opts", ")", "\n\n", "if", "normalizedOptions", "."...
// FlattenedKeys return a sorted flattened views of the set keys in the configuration
[ "FlattenedKeys", "return", "a", "sorted", "flattened", "views", "of", "the", "set", "keys", "in", "the", "configuration" ]
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/ucfg.go#L204-L242
train
elastic/go-ucfg
opts.go
Env
func Env(e *Config) Option { return func(o *options) { o.env = append(o.env, e) } }
go
func Env(e *Config) Option { return func(o *options) { o.env = append(o.env, e) } }
[ "func", "Env", "(", "e", "*", "Config", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "env", "=", "append", "(", "o", ".", "env", ",", "e", ")", "\n", "}", "\n", "}" ]
// Env option adds another configuration for variable expansion to be used, if // the path to look up does not exist in the actual configuration. Env can be used // multiple times in order to add more lookup environments.
[ "Env", "option", "adds", "another", "configuration", "for", "variable", "expansion", "to", "be", "used", "if", "the", "path", "to", "look", "up", "does", "not", "exist", "in", "the", "actual", "configuration", ".", "Env", "can", "be", "used", "multiple", "...
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/opts.go#L98-L102
train
elastic/go-ucfg
opts.go
Resolve
func Resolve(fn func(name string) (string, error)) Option { return func(o *options) { o.resolvers = append(o.resolvers, fn) } }
go
func Resolve(fn func(name string) (string, error)) Option { return func(o *options) { o.resolvers = append(o.resolvers, fn) } }
[ "func", "Resolve", "(", "fn", "func", "(", "name", "string", ")", "(", "string", ",", "error", ")", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "resolvers", "=", "append", "(", "o", ".", "resolvers", ",", "...
// Resolve option adds a callback used by variable name expansion. The callback // will be called if a variable can not be resolved from within the actual configuration // or any of its environments.
[ "Resolve", "option", "adds", "a", "callback", "used", "by", "variable", "name", "expansion", ".", "The", "callback", "will", "be", "called", "if", "a", "variable", "can", "not", "be", "resolved", "from", "within", "the", "actual", "configuration", "or", "any...
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/opts.go#L107-L111
train
elastic/go-ucfg
diff/keys.go
String
func (d Diff) String() string { var lines []string for k, values := range d { for _, v := range values { lines = append(lines, fmt.Sprintf("%s | key: %s", k, v)) } } return strings.Join(lines, "\n") }
go
func (d Diff) String() string { var lines []string for k, values := range d { for _, v := range values { lines = append(lines, fmt.Sprintf("%s | key: %s", k, v)) } } return strings.Join(lines, "\n") }
[ "func", "(", "d", "Diff", ")", "String", "(", ")", "string", "{", "var", "lines", "[", "]", "string", "\n\n", "for", "k", ",", "values", ":=", "range", "d", "{", "for", "_", ",", "v", ":=", "range", "values", "{", "lines", "=", "append", "(", "...
// String return a human friendly format of the diff
[ "String", "return", "a", "human", "friendly", "format", "of", "the", "diff" ]
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/diff/keys.go#L53-L63
train
elastic/go-ucfg
diff/keys.go
HasChanged
func (d *Diff) HasChanged() bool { if d.HasKeyAdded() || d.HasKeyRemoved() { return true } return false }
go
func (d *Diff) HasChanged() bool { if d.HasKeyAdded() || d.HasKeyRemoved() { return true } return false }
[ "func", "(", "d", "*", "Diff", ")", "HasChanged", "(", ")", "bool", "{", "if", "d", ".", "HasKeyAdded", "(", ")", "||", "d", ".", "HasKeyRemoved", "(", ")", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HasChanged returns true if we have remove of added new elements in the graph
[ "HasChanged", "returns", "true", "if", "we", "have", "remove", "of", "added", "new", "elements", "in", "the", "graph" ]
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/diff/keys.go#L66-L71
train
elastic/go-ucfg
diff/keys.go
CompareConfigs
func CompareConfigs(old, new *ucfg.Config, opts ...ucfg.Option) Diff { oldKeys := old.FlattenedKeys(opts...) newKeys := new.FlattenedKeys(opts...) difference := make(map[string]Type) // Map for candidates check for _, k := range oldKeys { difference[k] = Remove } for _, nk := range newKeys { if _, ok := difference[nk]; ok { difference[nk] = Keep } else { difference[nk] = Add } } invert := make(Diff) for k, v := range difference { invert[v] = append(invert[v], k) } return invert }
go
func CompareConfigs(old, new *ucfg.Config, opts ...ucfg.Option) Diff { oldKeys := old.FlattenedKeys(opts...) newKeys := new.FlattenedKeys(opts...) difference := make(map[string]Type) // Map for candidates check for _, k := range oldKeys { difference[k] = Remove } for _, nk := range newKeys { if _, ok := difference[nk]; ok { difference[nk] = Keep } else { difference[nk] = Add } } invert := make(Diff) for k, v := range difference { invert[v] = append(invert[v], k) } return invert }
[ "func", "CompareConfigs", "(", "old", ",", "new", "*", "ucfg", ".", "Config", ",", "opts", "...", "ucfg", ".", "Option", ")", "Diff", "{", "oldKeys", ":=", "old", ".", "FlattenedKeys", "(", "opts", "...", ")", "\n", "newKeys", ":=", "new", ".", "Flat...
// CompareConfigs takes two configuration and return the difference between the defined keys
[ "CompareConfigs", "takes", "two", "configuration", "and", "return", "the", "difference", "between", "the", "defined", "keys" ]
c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab
https://github.com/elastic/go-ucfg/blob/c5859d30d9ff1bf630e2dfbe1498ad3d1b7607ab/diff/keys.go#L96-L122
train
cloudfoundry/bytefmt
bytes.go
ToMegabytes
func ToMegabytes(s string) (uint64, error) { bytes, err := ToBytes(s) if err != nil { return 0, err } return bytes / MEGABYTE, nil }
go
func ToMegabytes(s string) (uint64, error) { bytes, err := ToBytes(s) if err != nil { return 0, err } return bytes / MEGABYTE, nil }
[ "func", "ToMegabytes", "(", "s", "string", ")", "(", "uint64", ",", "error", ")", "{", "bytes", ",", "err", ":=", "ToBytes", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "bytes", "/",...
// ToMegabytes parses a string formatted by ByteSize as megabytes.
[ "ToMegabytes", "parses", "a", "string", "formatted", "by", "ByteSize", "as", "megabytes", "." ]
2aa6f33b730c79971cfc3c742f279195b0abc627
https://github.com/cloudfoundry/bytefmt/blob/2aa6f33b730c79971cfc3c742f279195b0abc627/bytes.go#L61-L68
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
NewRules
func NewRules() *Rules { rules := &Rules{} rules.Rule = NewRule() rules.Rule.Name = "default" rules.Init() return rules }
go
func NewRules() *Rules { rules := &Rules{} rules.Rule = NewRule() rules.Rule.Name = "default" rules.Init() return rules }
[ "func", "NewRules", "(", ")", "*", "Rules", "{", "rules", ":=", "&", "Rules", "{", "}", "\n", "rules", ".", "Rule", "=", "NewRule", "(", ")", "\n", "rules", ".", "Rule", ".", "Name", "=", "\"", "\"", "\n", "rules", ".", "Init", "(", ")", "\n\n"...
// NewRules creates a new Rules
[ "NewRules", "creates", "a", "new", "Rules" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L25-L32
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
Freeze
func (rules *Rules) Freeze(format string) error { rules.Errors = []*RuleErrors{} req, err := client.NewJSONRequest( Config, "PUT", fmt.Sprintf( "/papi/v1/properties/%s/versions/%d/rules", rules.PropertyID, rules.PropertyVersion, ), rules, ) if err != nil { return err } req.Header.Set("Content-Type", fmt.Sprintf("application/vnd.akamai.papirules.%s+json", format)) res, err := client.Do(Config, req) if err != nil { return err } if client.IsError(res) { return client.NewAPIError(res) } if err = client.BodyJSON(res, rules); err != nil { return err } if len(rules.Errors) != 0 { return ErrorMap[ErrInvalidRules] } return nil }
go
func (rules *Rules) Freeze(format string) error { rules.Errors = []*RuleErrors{} req, err := client.NewJSONRequest( Config, "PUT", fmt.Sprintf( "/papi/v1/properties/%s/versions/%d/rules", rules.PropertyID, rules.PropertyVersion, ), rules, ) if err != nil { return err } req.Header.Set("Content-Type", fmt.Sprintf("application/vnd.akamai.papirules.%s+json", format)) res, err := client.Do(Config, req) if err != nil { return err } if client.IsError(res) { return client.NewAPIError(res) } if err = client.BodyJSON(res, rules); err != nil { return err } if len(rules.Errors) != 0 { return ErrorMap[ErrInvalidRules] } return nil }
[ "func", "(", "rules", "*", "Rules", ")", "Freeze", "(", "format", "string", ")", "error", "{", "rules", ".", "Errors", "=", "[", "]", "*", "RuleErrors", "{", "}", "\n\n", "req", ",", "err", ":=", "client", ".", "NewJSONRequest", "(", "Config", ",", ...
// Freeze pins a properties rule set to a specific rule set version
[ "Freeze", "pins", "a", "properties", "rule", "set", "to", "a", "specific", "rule", "set", "version" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L152-L189
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
MergeBehavior
func (rule *Rule) MergeBehavior(behavior *Behavior) { for _, existingBehavior := range rule.Behaviors { if existingBehavior.Name == behavior.Name { existingBehavior.MergeOptions(behavior.Options) return } } rule.Behaviors = append(rule.Behaviors, behavior) }
go
func (rule *Rule) MergeBehavior(behavior *Behavior) { for _, existingBehavior := range rule.Behaviors { if existingBehavior.Name == behavior.Name { existingBehavior.MergeOptions(behavior.Options) return } } rule.Behaviors = append(rule.Behaviors, behavior) }
[ "func", "(", "rule", "*", "Rule", ")", "MergeBehavior", "(", "behavior", "*", "Behavior", ")", "{", "for", "_", ",", "existingBehavior", ":=", "range", "rule", ".", "Behaviors", "{", "if", "existingBehavior", ".", "Name", "==", "behavior", ".", "Name", "...
// MergeBehavior merges a behavior into a rule // // If the behavior already exists, it's options are merged with the existing // options.
[ "MergeBehavior", "merges", "a", "behavior", "into", "a", "rule", "If", "the", "behavior", "already", "exists", "it", "s", "options", "are", "merged", "with", "the", "existing", "options", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L225-L234
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
AddBehavior
func (rule *Rule) AddBehavior(behavior *Behavior) { for key, existingBehavior := range rule.Behaviors { if existingBehavior.Name == behavior.Name { rule.Behaviors[key] = behavior return } } rule.Behaviors = append(rule.Behaviors, behavior) }
go
func (rule *Rule) AddBehavior(behavior *Behavior) { for key, existingBehavior := range rule.Behaviors { if existingBehavior.Name == behavior.Name { rule.Behaviors[key] = behavior return } } rule.Behaviors = append(rule.Behaviors, behavior) }
[ "func", "(", "rule", "*", "Rule", ")", "AddBehavior", "(", "behavior", "*", "Behavior", ")", "{", "for", "key", ",", "existingBehavior", ":=", "range", "rule", ".", "Behaviors", "{", "if", "existingBehavior", ".", "Name", "==", "behavior", ".", "Name", "...
// AddBehavior adds a behavior to the rule // // If the behavior already exists it is replaced with the given behavior
[ "AddBehavior", "adds", "a", "behavior", "to", "the", "rule", "If", "the", "behavior", "already", "exists", "it", "is", "replaced", "with", "the", "given", "behavior" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L239-L248
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
MergeCriteria
func (rule *Rule) MergeCriteria(criteria *Criteria) { for _, existingCriteria := range rule.Criteria { if existingCriteria.Name == criteria.Name { existingCriteria.MergeOptions(criteria.Options) return } } rule.Criteria = append(rule.Criteria, criteria) }
go
func (rule *Rule) MergeCriteria(criteria *Criteria) { for _, existingCriteria := range rule.Criteria { if existingCriteria.Name == criteria.Name { existingCriteria.MergeOptions(criteria.Options) return } } rule.Criteria = append(rule.Criteria, criteria) }
[ "func", "(", "rule", "*", "Rule", ")", "MergeCriteria", "(", "criteria", "*", "Criteria", ")", "{", "for", "_", ",", "existingCriteria", ":=", "range", "rule", ".", "Criteria", "{", "if", "existingCriteria", ".", "Name", "==", "criteria", ".", "Name", "{...
// MergeCriteria merges a criteria into a rule // // If the criteria already exists, it's options are merged with the existing // options.
[ "MergeCriteria", "merges", "a", "criteria", "into", "a", "rule", "If", "the", "criteria", "already", "exists", "it", "s", "options", "are", "merged", "with", "the", "existing", "options", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L254-L263
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
AddCriteria
func (rule *Rule) AddCriteria(criteria *Criteria) { for key, existingCriteria := range rule.Criteria { if existingCriteria.Name == criteria.Name { rule.Criteria[key] = criteria return } } rule.Criteria = append(rule.Criteria, criteria) }
go
func (rule *Rule) AddCriteria(criteria *Criteria) { for key, existingCriteria := range rule.Criteria { if existingCriteria.Name == criteria.Name { rule.Criteria[key] = criteria return } } rule.Criteria = append(rule.Criteria, criteria) }
[ "func", "(", "rule", "*", "Rule", ")", "AddCriteria", "(", "criteria", "*", "Criteria", ")", "{", "for", "key", ",", "existingCriteria", ":=", "range", "rule", ".", "Criteria", "{", "if", "existingCriteria", ".", "Name", "==", "criteria", ".", "Name", "{...
// AddCriteria add a criteria to a rule // // If the criteria already exists, it is replaced with the given criteria.
[ "AddCriteria", "add", "a", "criteria", "to", "a", "rule", "If", "the", "criteria", "already", "exists", "it", "is", "replaced", "with", "the", "given", "criteria", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L268-L277
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
MergeChildRule
func (rule *Rule) MergeChildRule(childRule *Rule) { for key, existingChildRule := range rule.Children { if existingChildRule.Name == childRule.Name { for _, behavior := range childRule.Behaviors { rule.Children[key].MergeBehavior(behavior) } for _, criteria := range childRule.Criteria { rule.Children[key].MergeCriteria(criteria) } for _, child := range childRule.Children { rule.Children[key].MergeChildRule(child) } return } } rule.Children = append(rule.Children, childRule) }
go
func (rule *Rule) MergeChildRule(childRule *Rule) { for key, existingChildRule := range rule.Children { if existingChildRule.Name == childRule.Name { for _, behavior := range childRule.Behaviors { rule.Children[key].MergeBehavior(behavior) } for _, criteria := range childRule.Criteria { rule.Children[key].MergeCriteria(criteria) } for _, child := range childRule.Children { rule.Children[key].MergeChildRule(child) } return } } rule.Children = append(rule.Children, childRule) }
[ "func", "(", "rule", "*", "Rule", ")", "MergeChildRule", "(", "childRule", "*", "Rule", ")", "{", "for", "key", ",", "existingChildRule", ":=", "range", "rule", ".", "Children", "{", "if", "existingChildRule", ".", "Name", "==", "childRule", ".", "Name", ...
// MergeChildRule adds a child rule to this rule // // If the rule already exists, criteria, behaviors, and child rules are added to // the existing rule.
[ "MergeChildRule", "adds", "a", "child", "rule", "to", "this", "rule", "If", "the", "rule", "already", "exists", "criteria", "behaviors", "and", "child", "rules", "are", "added", "to", "the", "existing", "rule", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L283-L303
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
AddChildRule
func (rule *Rule) AddChildRule(childRule *Rule) { for key, existingChildRule := range rule.Children { if existingChildRule.Name == childRule.Name { rule.Children[key] = childRule return } } rule.Children = append(rule.Children, childRule) }
go
func (rule *Rule) AddChildRule(childRule *Rule) { for key, existingChildRule := range rule.Children { if existingChildRule.Name == childRule.Name { rule.Children[key] = childRule return } } rule.Children = append(rule.Children, childRule) }
[ "func", "(", "rule", "*", "Rule", ")", "AddChildRule", "(", "childRule", "*", "Rule", ")", "{", "for", "key", ",", "existingChildRule", ":=", "range", "rule", ".", "Children", "{", "if", "existingChildRule", ".", "Name", "==", "childRule", ".", "Name", "...
// AddChildRule adds a rule as a child of this rule // // If the rule already exists, it is replaced by the given rule.
[ "AddChildRule", "adds", "a", "rule", "as", "a", "child", "of", "this", "rule", "If", "the", "rule", "already", "exists", "it", "is", "replaced", "by", "the", "given", "rule", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L308-L318
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
AddVariable
func (rule *Rule) AddVariable(variable *Variable) { for key, existingVariable := range rule.Variables { if existingVariable.Name == variable.Name { rule.Variables[key] = variable return } } rule.Variables = append(rule.Variables, variable) }
go
func (rule *Rule) AddVariable(variable *Variable) { for key, existingVariable := range rule.Variables { if existingVariable.Name == variable.Name { rule.Variables[key] = variable return } } rule.Variables = append(rule.Variables, variable) }
[ "func", "(", "rule", "*", "Rule", ")", "AddVariable", "(", "variable", "*", "Variable", ")", "{", "for", "key", ",", "existingVariable", ":=", "range", "rule", ".", "Variables", "{", "if", "existingVariable", ".", "Name", "==", "variable", ".", "Name", "...
// AddVariable adds a variable as a child of this rule // // If the rule already exists, it is replaced by the given rule.
[ "AddVariable", "adds", "a", "variable", "as", "a", "child", "of", "this", "rule", "If", "the", "rule", "already", "exists", "it", "is", "replaced", "by", "the", "given", "rule", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L323-L333
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
FindBehavior
func (rules *Rules) FindBehavior(path string) (*Behavior, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) behaviorName := strings.ToLower(segments[len(segments)-1]) for _, behavior := range rule.Behaviors { if strings.ToLower(behavior.Name) == behaviorName { return behavior, nil } } return nil, ErrorMap[ErrBehaviorNotFound] }
go
func (rules *Rules) FindBehavior(path string) (*Behavior, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) behaviorName := strings.ToLower(segments[len(segments)-1]) for _, behavior := range rule.Behaviors { if strings.ToLower(behavior.Name) == behaviorName { return behavior, nil } } return nil, ErrorMap[ErrBehaviorNotFound] }
[ "func", "(", "rules", "*", "Rules", ")", "FindBehavior", "(", "path", "string", ")", "(", "*", "Behavior", ",", "error", ")", "{", "if", "len", "(", "path", ")", "<=", "1", "{", "return", "nil", ",", "ErrorMap", "[", "ErrInvalidPath", "]", "\n", "}...
// FindBehavior locates a specific behavior by path
[ "FindBehavior", "locates", "a", "specific", "behavior", "by", "path" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L336-L356
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
FindCriteria
func (rules *Rules) FindCriteria(path string) (*Criteria, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) criteriaName := strings.ToLower(segments[len(segments)-1]) for _, criteria := range rule.Criteria { if strings.ToLower(criteria.Name) == criteriaName { return criteria, nil } } return nil, ErrorMap[ErrCriteriaNotFound] }
go
func (rules *Rules) FindCriteria(path string) (*Criteria, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) criteriaName := strings.ToLower(segments[len(segments)-1]) for _, criteria := range rule.Criteria { if strings.ToLower(criteria.Name) == criteriaName { return criteria, nil } } return nil, ErrorMap[ErrCriteriaNotFound] }
[ "func", "(", "rules", "*", "Rules", ")", "FindCriteria", "(", "path", "string", ")", "(", "*", "Criteria", ",", "error", ")", "{", "if", "len", "(", "path", ")", "<=", "1", "{", "return", "nil", ",", "ErrorMap", "[", "ErrInvalidPath", "]", "\n", "}...
// FindCriteria locates a specific Critieria by path
[ "FindCriteria", "locates", "a", "specific", "Critieria", "by", "path" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L359-L379
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
FindVariable
func (rules *Rules) FindVariable(path string) (*Variable, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) variableName := strings.ToLower(segments[len(segments)-1]) for _, variable := range rule.Variables { if strings.ToLower(variable.Name) == variableName { return variable, nil } } return nil, ErrorMap[ErrVariableNotFound] }
go
func (rules *Rules) FindVariable(path string) (*Variable, error) { if len(path) <= 1 { return nil, ErrorMap[ErrInvalidPath] } rule, err := rules.FindParentRule(path) if err != nil { return nil, err } sep := "/" segments := strings.Split(path, sep) variableName := strings.ToLower(segments[len(segments)-1]) for _, variable := range rule.Variables { if strings.ToLower(variable.Name) == variableName { return variable, nil } } return nil, ErrorMap[ErrVariableNotFound] }
[ "func", "(", "rules", "*", "Rules", ")", "FindVariable", "(", "path", "string", ")", "(", "*", "Variable", ",", "error", ")", "{", "if", "len", "(", "path", ")", "<=", "1", "{", "return", "nil", ",", "ErrorMap", "[", "ErrInvalidPath", "]", "\n", "}...
// FindVariable locates a specific Variable by path
[ "FindVariable", "locates", "a", "specific", "Variable", "by", "path" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L382-L402
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
FindRule
func (rules *Rules) FindRule(path string) (*Rule, error) { if path == "" { return rules.Rule, nil } sep := "/" segments := strings.Split(path, sep) currentRule := rules.Rule for _, segment := range segments { found := false for _, rule := range currentRule.Children { if strings.ToLower(rule.Name) == segment { currentRule = rule found = true } } if found != true { return nil, ErrorMap[ErrRuleNotFound] } } return currentRule, nil }
go
func (rules *Rules) FindRule(path string) (*Rule, error) { if path == "" { return rules.Rule, nil } sep := "/" segments := strings.Split(path, sep) currentRule := rules.Rule for _, segment := range segments { found := false for _, rule := range currentRule.Children { if strings.ToLower(rule.Name) == segment { currentRule = rule found = true } } if found != true { return nil, ErrorMap[ErrRuleNotFound] } } return currentRule, nil }
[ "func", "(", "rules", "*", "Rules", ")", "FindRule", "(", "path", "string", ")", "(", "*", "Rule", ",", "error", ")", "{", "if", "path", "==", "\"", "\"", "{", "return", "rules", ".", "Rule", ",", "nil", "\n", "}", "\n\n", "sep", ":=", "\"", "\...
// FindRule locates a specific rule by path
[ "FindRule", "locates", "a", "specific", "rule", "by", "path" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L405-L428
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/rules.go
FindParentRule
func (rules *Rules) FindParentRule(path string) (*Rule, error) { sep := "/" segments := strings.Split(strings.ToLower(strings.TrimPrefix(path, sep)), sep) parentPath := strings.Join(segments[0:len(segments)-1], sep) return rules.FindRule(parentPath) }
go
func (rules *Rules) FindParentRule(path string) (*Rule, error) { sep := "/" segments := strings.Split(strings.ToLower(strings.TrimPrefix(path, sep)), sep) parentPath := strings.Join(segments[0:len(segments)-1], sep) return rules.FindRule(parentPath) }
[ "func", "(", "rules", "*", "Rules", ")", "FindParentRule", "(", "path", "string", ")", "(", "*", "Rule", ",", "error", ")", "{", "sep", ":=", "\"", "\"", "\n", "segments", ":=", "strings", ".", "Split", "(", "strings", ".", "ToLower", "(", "strings",...
// Find the parent rule for a given rule, criteria, or behavior path
[ "Find", "the", "parent", "rule", "for", "a", "given", "rule", "criteria", "or", "behavior", "path" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/rules.go#L431-L437
train
akamai/AkamaiOPEN-edgegrid-golang
edgegrid/signer.go
AddRequestHeader
func AddRequestHeader(config Config, req *http.Request) *http.Request { if config.Debug { log.SetLevel(log.DebugLevel) } timestamp := makeEdgeTimeStamp() nonce := createNonce() if req.Header.Get("Content-Type") == "" { req.Header.Set("Content-Type", "application/json") } _, AkamaiCliEnvOK := os.LookupEnv("AKAMAI_CLI") AkamaiCliVersionEnv, AkamaiCliVersionEnvOK := os.LookupEnv("AKAMAI_CLI_VERSION") AkamaiCliCommandEnv, AkamaiCliCommandEnvOK := os.LookupEnv("AKAMAI_CLI_COMMAND") AkamaiCliCommandVersionEnv, AkamaiCliCommandVersionEnvOK := os.LookupEnv("AKAMAI_CLI_COMMAND_VERSION") if AkamaiCliEnvOK && AkamaiCliVersionEnvOK { if req.Header.Get("User-Agent") != "" { req.Header.Set("User-Agent", req.Header.Get("User-Agent")+" AkamaiCLI/"+AkamaiCliVersionEnv) } else { req.Header.Set("User-Agent", "AkamaiCLI/"+AkamaiCliVersionEnv) } } if AkamaiCliCommandEnvOK && AkamaiCliCommandVersionEnvOK { if req.Header.Get("User-Agent") != "" { req.Header.Set("User-Agent", req.Header.Get("User-Agent")+" AkamaiCLI-"+AkamaiCliCommandEnv+"/"+AkamaiCliCommandVersionEnv) } else { req.Header.Set("User-Agent", "AkamaiCLI-"+AkamaiCliCommandEnv+"/"+AkamaiCliCommandVersionEnv) } } req.Header.Set("Authorization", createAuthHeader(config, req, timestamp, nonce)) return req }
go
func AddRequestHeader(config Config, req *http.Request) *http.Request { if config.Debug { log.SetLevel(log.DebugLevel) } timestamp := makeEdgeTimeStamp() nonce := createNonce() if req.Header.Get("Content-Type") == "" { req.Header.Set("Content-Type", "application/json") } _, AkamaiCliEnvOK := os.LookupEnv("AKAMAI_CLI") AkamaiCliVersionEnv, AkamaiCliVersionEnvOK := os.LookupEnv("AKAMAI_CLI_VERSION") AkamaiCliCommandEnv, AkamaiCliCommandEnvOK := os.LookupEnv("AKAMAI_CLI_COMMAND") AkamaiCliCommandVersionEnv, AkamaiCliCommandVersionEnvOK := os.LookupEnv("AKAMAI_CLI_COMMAND_VERSION") if AkamaiCliEnvOK && AkamaiCliVersionEnvOK { if req.Header.Get("User-Agent") != "" { req.Header.Set("User-Agent", req.Header.Get("User-Agent")+" AkamaiCLI/"+AkamaiCliVersionEnv) } else { req.Header.Set("User-Agent", "AkamaiCLI/"+AkamaiCliVersionEnv) } } if AkamaiCliCommandEnvOK && AkamaiCliCommandVersionEnvOK { if req.Header.Get("User-Agent") != "" { req.Header.Set("User-Agent", req.Header.Get("User-Agent")+" AkamaiCLI-"+AkamaiCliCommandEnv+"/"+AkamaiCliCommandVersionEnv) } else { req.Header.Set("User-Agent", "AkamaiCLI-"+AkamaiCliCommandEnv+"/"+AkamaiCliCommandVersionEnv) } } req.Header.Set("Authorization", createAuthHeader(config, req, timestamp, nonce)) return req }
[ "func", "AddRequestHeader", "(", "config", "Config", ",", "req", "*", "http", ".", "Request", ")", "*", "http", ".", "Request", "{", "if", "config", ".", "Debug", "{", "log", ".", "SetLevel", "(", "log", ".", "DebugLevel", ")", "\n", "}", "\n", "time...
// AddRequestHeader sets the Authorization header to use Akamai Open API
[ "AddRequestHeader", "sets", "the", "Authorization", "header", "to", "use", "Akamai", "Open", "API" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/edgegrid/signer.go#L25-L58
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/cpcodes.go
ID
func (cpcode *CpCode) ID() int { id, err := strconv.Atoi(strings.TrimPrefix(cpcode.CpcodeID, "cpc_")) if err != nil { return 0 } return id }
go
func (cpcode *CpCode) ID() int { id, err := strconv.Atoi(strings.TrimPrefix(cpcode.CpcodeID, "cpc_")) if err != nil { return 0 } return id }
[ "func", "(", "cpcode", "*", "CpCode", ")", "ID", "(", ")", "int", "{", "id", ",", "err", ":=", "strconv", ".", "Atoi", "(", "strings", ".", "TrimPrefix", "(", "cpcode", ".", "CpcodeID", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", ...
// ID retrieves a CP Codes integer ID // // PAPI Behaviors require the integer ID, rather than the prefixed string returned
[ "ID", "retrieves", "a", "CP", "Codes", "integer", "ID", "PAPI", "Behaviors", "require", "the", "integer", "ID", "rather", "than", "the", "prefixed", "string", "returned" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/cpcodes.go#L217-L224
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/contracts.go
FindContract
func (contracts *Contracts) FindContract(id string) (*Contract, error) { var contract *Contract var contractFound bool for _, contract = range contracts.Contracts.Items { if contract.ContractID == id { contractFound = true break } } if !contractFound { return nil, fmt.Errorf("Unable to find contract: \"%s\"", id) } return contract, nil }
go
func (contracts *Contracts) FindContract(id string) (*Contract, error) { var contract *Contract var contractFound bool for _, contract = range contracts.Contracts.Items { if contract.ContractID == id { contractFound = true break } } if !contractFound { return nil, fmt.Errorf("Unable to find contract: \"%s\"", id) } return contract, nil }
[ "func", "(", "contracts", "*", "Contracts", ")", "FindContract", "(", "id", "string", ")", "(", "*", "Contract", ",", "error", ")", "{", "var", "contract", "*", "Contract", "\n", "var", "contractFound", "bool", "\n", "for", "_", ",", "contract", "=", "...
// FindContract finds a specific contract by ID
[ "FindContract", "finds", "a", "specific", "contract", "by", "ID" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/contracts.go#L79-L94
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/contracts.go
NewContract
func NewContract(parent *Contracts) *Contract { contract := &Contract{ parent: parent, } contract.Init() return contract }
go
func NewContract(parent *Contracts) *Contract { contract := &Contract{ parent: parent, } contract.Init() return contract }
[ "func", "NewContract", "(", "parent", "*", "Contracts", ")", "*", "Contract", "{", "contract", ":=", "&", "Contract", "{", "parent", ":", "parent", ",", "}", "\n", "contract", ".", "Init", "(", ")", "\n", "return", "contract", "\n", "}" ]
// NewContract creates a new Contract
[ "NewContract", "creates", "a", "new", "Contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/contracts.go#L105-L111
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/contracts.go
GetContract
func (contract *Contract) GetContract() error { contracts, err := GetContracts() if err != nil { return err } for _, c := range contracts.Contracts.Items { if c.ContractID == contract.ContractID { contract.parent = c.parent contract.ContractTypeName = c.ContractTypeName contract.Complete <- true return nil } } contract.Complete <- false return fmt.Errorf("contract \"%s\" not found", contract.ContractID) }
go
func (contract *Contract) GetContract() error { contracts, err := GetContracts() if err != nil { return err } for _, c := range contracts.Contracts.Items { if c.ContractID == contract.ContractID { contract.parent = c.parent contract.ContractTypeName = c.ContractTypeName contract.Complete <- true return nil } } contract.Complete <- false return fmt.Errorf("contract \"%s\" not found", contract.ContractID) }
[ "func", "(", "contract", "*", "Contract", ")", "GetContract", "(", ")", "error", "{", "contracts", ",", "err", ":=", "GetContracts", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "for", "_", ",", "c", ":=", "ran...
// GetContract populates a Contract
[ "GetContract", "populates", "a", "Contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/contracts.go#L114-L130
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/contracts.go
GetProducts
func (contract *Contract) GetProducts() (*Products, error) { req, err := client.NewRequest( Config, "GET", fmt.Sprintf( "/papi/v1/products?contractId=%s", contract.ContractID, ), nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) { return nil, client.NewAPIError(res) } products := NewProducts() if err = client.BodyJSON(res, products); err != nil { return nil, err } return products, nil }
go
func (contract *Contract) GetProducts() (*Products, error) { req, err := client.NewRequest( Config, "GET", fmt.Sprintf( "/papi/v1/products?contractId=%s", contract.ContractID, ), nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) { return nil, client.NewAPIError(res) } products := NewProducts() if err = client.BodyJSON(res, products); err != nil { return nil, err } return products, nil }
[ "func", "(", "contract", "*", "Contract", ")", "GetProducts", "(", ")", "(", "*", "Products", ",", "error", ")", "{", "req", ",", "err", ":=", "client", ".", "NewRequest", "(", "Config", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"",...
// GetProducts gets products associated with a contract
[ "GetProducts", "gets", "products", "associated", "with", "a", "contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/contracts.go#L133-L162
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/activations.go
NewActivation
func NewActivation(parent *Activations) *Activation { activation := &Activation{parent: parent} activation.Init() return activation }
go
func NewActivation(parent *Activations) *Activation { activation := &Activation{parent: parent} activation.Init() return activation }
[ "func", "NewActivation", "(", "parent", "*", "Activations", ")", "*", "Activation", "{", "activation", ":=", "&", "Activation", "{", "parent", ":", "parent", "}", "\n", "activation", ".", "Init", "(", ")", "\n\n", "return", "activation", "\n", "}" ]
// NewActivation creates a new Activation
[ "NewActivation", "creates", "a", "new", "Activation" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/activations.go#L138-L143
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/hostnames.go
NewHostname
func (hostnames *Hostnames) NewHostname() *Hostname { hostname := NewHostname(hostnames) hostnames.Hostnames.Items = append(hostnames.Hostnames.Items, hostname) return hostname }
go
func (hostnames *Hostnames) NewHostname() *Hostname { hostname := NewHostname(hostnames) hostnames.Hostnames.Items = append(hostnames.Hostnames.Items, hostname) return hostname }
[ "func", "(", "hostnames", "*", "Hostnames", ")", "NewHostname", "(", ")", "*", "Hostname", "{", "hostname", ":=", "NewHostname", "(", "hostnames", ")", "\n", "hostnames", ".", "Hostnames", ".", "Items", "=", "append", "(", "hostnames", ".", "Hostnames", "....
// NewHostname creates a new Hostname within a given Hostnames
[ "NewHostname", "creates", "a", "new", "Hostname", "within", "a", "given", "Hostnames" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/hostnames.go#L104-L108
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/hostnames.go
Save
func (hostnames *Hostnames) Save() error { req, err := client.NewJSONRequest( Config, "PUT", fmt.Sprintf( "/papi/v1/properties/%s/versions/%d/hostnames?contractId=%s&groupId=%s", hostnames.PropertyID, hostnames.PropertyVersion, hostnames.ContractID, hostnames.GroupID, ), hostnames.Hostnames.Items, ) if err != nil { return err } res, err := client.Do(Config, req) if err != nil { return err } if client.IsError(res) { return client.NewAPIError(res) } if err = client.BodyJSON(res, hostnames); err != nil { return err } return nil }
go
func (hostnames *Hostnames) Save() error { req, err := client.NewJSONRequest( Config, "PUT", fmt.Sprintf( "/papi/v1/properties/%s/versions/%d/hostnames?contractId=%s&groupId=%s", hostnames.PropertyID, hostnames.PropertyVersion, hostnames.ContractID, hostnames.GroupID, ), hostnames.Hostnames.Items, ) if err != nil { return err } res, err := client.Do(Config, req) if err != nil { return err } if client.IsError(res) { return client.NewAPIError(res) } if err = client.BodyJSON(res, hostnames); err != nil { return err } return nil }
[ "func", "(", "hostnames", "*", "Hostnames", ")", "Save", "(", ")", "error", "{", "req", ",", "err", ":=", "client", ".", "NewJSONRequest", "(", "Config", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hostnames", ".", "PropertyID...
// Save updates a properties hostnames
[ "Save", "updates", "a", "properties", "hostnames" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/hostnames.go#L111-L142
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/hostnames.go
NewHostname
func NewHostname(parent *Hostnames) *Hostname { hostname := &Hostname{parent: parent, CnameType: CnameTypeEdgeHostname} hostname.Init() return hostname }
go
func NewHostname(parent *Hostnames) *Hostname { hostname := &Hostname{parent: parent, CnameType: CnameTypeEdgeHostname} hostname.Init() return hostname }
[ "func", "NewHostname", "(", "parent", "*", "Hostnames", ")", "*", "Hostname", "{", "hostname", ":=", "&", "Hostname", "{", "parent", ":", "parent", ",", "CnameType", ":", "CnameTypeEdgeHostname", "}", "\n", "hostname", ".", "Init", "(", ")", "\n\n", "retur...
// NewHostname creates a new Hostname
[ "NewHostname", "creates", "a", "new", "Hostname" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/hostnames.go#L155-L160
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/versions.go
AddVersion
func (versions *Versions) AddVersion(version *Version) { if version.PropertyVersion != 0 { for key, v := range versions.Versions.Items { if v.PropertyVersion == version.PropertyVersion { versions.Versions.Items[key] = version return } } } versions.Versions.Items = append(versions.Versions.Items, version) }
go
func (versions *Versions) AddVersion(version *Version) { if version.PropertyVersion != 0 { for key, v := range versions.Versions.Items { if v.PropertyVersion == version.PropertyVersion { versions.Versions.Items[key] = version return } } } versions.Versions.Items = append(versions.Versions.Items, version) }
[ "func", "(", "versions", "*", "Versions", ")", "AddVersion", "(", "version", "*", "Version", ")", "{", "if", "version", ".", "PropertyVersion", "!=", "0", "{", "for", "key", ",", "v", ":=", "range", "versions", ".", "Versions", ".", "Items", "{", "if",...
// AddVersion adds or replaces a version within the collection
[ "AddVersion", "adds", "or", "replaces", "a", "version", "within", "the", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/versions.go#L47-L58
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/versions.go
NewVersion
func (versions *Versions) NewVersion(createFromVersion *Version, useEtagStrict bool) *Version { if createFromVersion == nil { var err error createFromVersion, err = versions.GetLatestVersion("") if err != nil { return nil } } version := NewVersion(versions) version.CreateFromVersion = createFromVersion.PropertyVersion versions.Versions.Items = append(versions.Versions.Items, version) if useEtagStrict { version.CreateFromVersionEtag = createFromVersion.Etag } return version }
go
func (versions *Versions) NewVersion(createFromVersion *Version, useEtagStrict bool) *Version { if createFromVersion == nil { var err error createFromVersion, err = versions.GetLatestVersion("") if err != nil { return nil } } version := NewVersion(versions) version.CreateFromVersion = createFromVersion.PropertyVersion versions.Versions.Items = append(versions.Versions.Items, version) if useEtagStrict { version.CreateFromVersionEtag = createFromVersion.Etag } return version }
[ "func", "(", "versions", "*", "Versions", ")", "NewVersion", "(", "createFromVersion", "*", "Version", ",", "useEtagStrict", "bool", ")", "*", "Version", "{", "if", "createFromVersion", "==", "nil", "{", "var", "err", "error", "\n", "createFromVersion", ",", ...
// NewVersion creates a new version associated with the Versions collection
[ "NewVersion", "creates", "a", "new", "version", "associated", "with", "the", "Versions", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/versions.go#L137-L156
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/versions.go
NewVersion
func NewVersion(parent *Versions) *Version { version := &Version{parent: parent} version.Init() return version }
go
func NewVersion(parent *Versions) *Version { version := &Version{parent: parent} version.Init() return version }
[ "func", "NewVersion", "(", "parent", "*", "Versions", ")", "*", "Version", "{", "version", ":=", "&", "Version", "{", "parent", ":", "parent", "}", "\n", "version", ".", "Init", "(", ")", "\n\n", "return", "version", "\n", "}" ]
// NewVersion creates a new Version
[ "NewVersion", "creates", "a", "new", "Version" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/versions.go#L176-L181
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/versions.go
HasBeenActivated
func (version *Version) HasBeenActivated(activatedOn NetworkValue) (bool, error) { properties := NewProperties() property := NewProperty(properties) property.PropertyID = version.parent.PropertyID property.Group = NewGroup(NewGroups()) property.Group.GroupID = version.parent.GroupID property.Contract = NewContract(NewContracts()) property.Contract.ContractID = version.parent.ContractID activations, err := property.GetActivations() if err != nil { return false, err } for _, activation := range activations.Activations.Items { if activation.PropertyVersion == version.PropertyVersion && (activatedOn == "" || activation.Network == activatedOn) { return true, nil } } return false, nil }
go
func (version *Version) HasBeenActivated(activatedOn NetworkValue) (bool, error) { properties := NewProperties() property := NewProperty(properties) property.PropertyID = version.parent.PropertyID property.Group = NewGroup(NewGroups()) property.Group.GroupID = version.parent.GroupID property.Contract = NewContract(NewContracts()) property.Contract.ContractID = version.parent.ContractID activations, err := property.GetActivations() if err != nil { return false, err } for _, activation := range activations.Activations.Items { if activation.PropertyVersion == version.PropertyVersion && (activatedOn == "" || activation.Network == activatedOn) { return true, nil } } return false, nil }
[ "func", "(", "version", "*", "Version", ")", "HasBeenActivated", "(", "activatedOn", "NetworkValue", ")", "(", "bool", ",", "error", ")", "{", "properties", ":=", "NewProperties", "(", ")", "\n", "property", ":=", "NewProperty", "(", "properties", ")", "\n",...
// HasBeenActivated determines if a given version has been activated, optionally on a specific network
[ "HasBeenActivated", "determines", "if", "a", "given", "version", "has", "been", "activated", "optionally", "on", "a", "specific", "network" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/versions.go#L235-L258
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/edgehostnames.go
NewEdgeHostname
func (edgeHostnames *EdgeHostnames) NewEdgeHostname() *EdgeHostname { edgeHostname := NewEdgeHostname(edgeHostnames) edgeHostnames.EdgeHostnames.Items = append(edgeHostnames.EdgeHostnames.Items, edgeHostname) return edgeHostname }
go
func (edgeHostnames *EdgeHostnames) NewEdgeHostname() *EdgeHostname { edgeHostname := NewEdgeHostname(edgeHostnames) edgeHostnames.EdgeHostnames.Items = append(edgeHostnames.EdgeHostnames.Items, edgeHostname) return edgeHostname }
[ "func", "(", "edgeHostnames", "*", "EdgeHostnames", ")", "NewEdgeHostname", "(", ")", "*", "EdgeHostname", "{", "edgeHostname", ":=", "NewEdgeHostname", "(", "edgeHostnames", ")", "\n", "edgeHostnames", ".", "EdgeHostnames", ".", "Items", "=", "append", "(", "ed...
// NewEdgeHostname creates a new EdgeHostname within a given EdgeHostnames
[ "NewEdgeHostname", "creates", "a", "new", "EdgeHostname", "within", "a", "given", "EdgeHostnames" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/edgehostnames.go#L51-L55
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/edgehostnames.go
NewEdgeHostname
func NewEdgeHostname(edgeHostnames *EdgeHostnames) *EdgeHostname { edgeHostname := &EdgeHostname{parent: edgeHostnames} edgeHostname.Init() return edgeHostname }
go
func NewEdgeHostname(edgeHostnames *EdgeHostnames) *EdgeHostname { edgeHostname := &EdgeHostname{parent: edgeHostnames} edgeHostname.Init() return edgeHostname }
[ "func", "NewEdgeHostname", "(", "edgeHostnames", "*", "EdgeHostnames", ")", "*", "EdgeHostname", "{", "edgeHostname", ":=", "&", "EdgeHostname", "{", "parent", ":", "edgeHostnames", "}", "\n", "edgeHostname", ".", "Init", "(", ")", "\n", "return", "edgeHostname"...
// NewEdgeHostname creates a new EdgeHostname
[ "NewEdgeHostname", "creates", "a", "new", "EdgeHostname" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/edgehostnames.go#L161-L165
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/properties.go
AddProperty
func (properties *Properties) AddProperty(newProperty *Property) { if newProperty.PropertyID != "" { for key, property := range properties.Properties.Items { if property.PropertyID == newProperty.PropertyID { properties.Properties.Items[key] = newProperty return } } } newProperty.parent = properties properties.Properties.Items = append(properties.Properties.Items, newProperty) }
go
func (properties *Properties) AddProperty(newProperty *Property) { if newProperty.PropertyID != "" { for key, property := range properties.Properties.Items { if property.PropertyID == newProperty.PropertyID { properties.Properties.Items[key] = newProperty return } } } newProperty.parent = properties properties.Properties.Items = append(properties.Properties.Items, newProperty) }
[ "func", "(", "properties", "*", "Properties", ")", "AddProperty", "(", "newProperty", "*", "Property", ")", "{", "if", "newProperty", ".", "PropertyID", "!=", "\"", "\"", "{", "for", "key", ",", "property", ":=", "range", "properties", ".", "Properties", "...
// AddProperty adds a property to the collection, if the property already exists // in the collection it will be replaced.
[ "AddProperty", "adds", "a", "property", "to", "the", "collection", "if", "the", "property", "already", "exists", "in", "the", "collection", "it", "will", "be", "replaced", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/properties.go#L83-L96
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/properties.go
FindProperty
func (properties *Properties) FindProperty(id string) (*Property, error) { var property *Property var propertyFound bool for _, property = range properties.Properties.Items { if property.PropertyID == id { propertyFound = true break } } if !propertyFound { return nil, fmt.Errorf("Unable to find property: \"%s\"", id) } return property, nil }
go
func (properties *Properties) FindProperty(id string) (*Property, error) { var property *Property var propertyFound bool for _, property = range properties.Properties.Items { if property.PropertyID == id { propertyFound = true break } } if !propertyFound { return nil, fmt.Errorf("Unable to find property: \"%s\"", id) } return property, nil }
[ "func", "(", "properties", "*", "Properties", ")", "FindProperty", "(", "id", "string", ")", "(", "*", "Property", ",", "error", ")", "{", "var", "property", "*", "Property", "\n", "var", "propertyFound", "bool", "\n", "for", "_", ",", "property", "=", ...
// FindProperty finds a property by ID within the collection
[ "FindProperty", "finds", "a", "property", "by", "ID", "within", "the", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/properties.go#L99-L114
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/properties.go
NewProperty
func (properties *Properties) NewProperty(contract *Contract, group *Group) *Property { property := NewProperty(properties) properties.AddProperty(property) property.Contract = contract property.Group = group go property.Contract.GetContract() go property.Group.GetGroup() go (func(property *Property) { groupCompleted := <-property.Group.Complete contractCompleted := <-property.Contract.Complete property.Complete <- (groupCompleted && contractCompleted) })(property) return property }
go
func (properties *Properties) NewProperty(contract *Contract, group *Group) *Property { property := NewProperty(properties) properties.AddProperty(property) property.Contract = contract property.Group = group go property.Contract.GetContract() go property.Group.GetGroup() go (func(property *Property) { groupCompleted := <-property.Group.Complete contractCompleted := <-property.Contract.Complete property.Complete <- (groupCompleted && contractCompleted) })(property) return property }
[ "func", "(", "properties", "*", "Properties", ")", "NewProperty", "(", "contract", "*", "Contract", ",", "group", "*", "Group", ")", "*", "Property", "{", "property", ":=", "NewProperty", "(", "properties", ")", "\n\n", "properties", ".", "AddProperty", "(",...
// NewProperty creates a new property associated with the collection
[ "NewProperty", "creates", "a", "new", "property", "associated", "with", "the", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/properties.go#L117-L133
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/properties.go
NewProperty
func NewProperty(parent *Properties) *Property { property := &Property{parent: parent, Group: &Group{}, Contract: &Contract{}} property.Init() return property }
go
func NewProperty(parent *Properties) *Property { property := &Property{parent: parent, Group: &Group{}, Contract: &Contract{}} property.Init() return property }
[ "func", "NewProperty", "(", "parent", "*", "Properties", ")", "*", "Property", "{", "property", ":=", "&", "Property", "{", "parent", ":", "parent", ",", "Group", ":", "&", "Group", "{", "}", ",", "Contract", ":", "&", "Contract", "{", "}", "}", "\n"...
// NewProperty creates a new Property
[ "NewProperty", "creates", "a", "new", "Property" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/properties.go#L156-L160
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/errors.go
NewAPIError
func NewAPIError(response *http.Response) APIError { // TODO: handle this error body, _ := ioutil.ReadAll(response.Body) return NewAPIErrorFromBody(response, body) }
go
func NewAPIError(response *http.Response) APIError { // TODO: handle this error body, _ := ioutil.ReadAll(response.Body) return NewAPIErrorFromBody(response, body) }
[ "func", "NewAPIError", "(", "response", "*", "http", ".", "Response", ")", "APIError", "{", "// TODO: handle this error", "body", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "response", ".", "Body", ")", "\n\n", "return", "NewAPIErrorFromBody", "(", "respon...
// NewAPIError creates a new API error based on a Response, // or http.Response-like.
[ "NewAPIError", "creates", "a", "new", "API", "error", "based", "on", "a", "Response", "or", "http", ".", "Response", "-", "like", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/errors.go#L55-L60
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/errors.go
NewAPIErrorFromBody
func NewAPIErrorFromBody(response *http.Response, body []byte) APIError { error := APIError{} if err := jsonhooks.Unmarshal(body, &error); err == nil { error.Status = response.StatusCode error.Title = response.Status } error.Response = response error.RawBody = string(body) return error }
go
func NewAPIErrorFromBody(response *http.Response, body []byte) APIError { error := APIError{} if err := jsonhooks.Unmarshal(body, &error); err == nil { error.Status = response.StatusCode error.Title = response.Status } error.Response = response error.RawBody = string(body) return error }
[ "func", "NewAPIErrorFromBody", "(", "response", "*", "http", ".", "Response", ",", "body", "[", "]", "byte", ")", "APIError", "{", "error", ":=", "APIError", "{", "}", "\n", "if", "err", ":=", "jsonhooks", ".", "Unmarshal", "(", "body", ",", "&", "erro...
// NewAPIErrorFromBody creates a new API error, allowing you to pass in a body // // This function is intended to be used after the body has already been read for // other purposes.
[ "NewAPIErrorFromBody", "creates", "a", "new", "API", "error", "allowing", "you", "to", "pass", "in", "a", "body", "This", "function", "is", "intended", "to", "be", "used", "after", "the", "body", "has", "already", "been", "read", "for", "other", "purposes", ...
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/errors.go#L66-L77
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/customoverrides.go
PostUnmarshalJSON
func (overrides *CustomOverrides) PostUnmarshalJSON() error { overrides.Init() for key, override := range overrides.CustomOverrides.Items { overrides.CustomOverrides.Items[key].parent = overrides if err := override.PostUnmarshalJSON(); err != nil { return err } } overrides.Complete <- true return nil }
go
func (overrides *CustomOverrides) PostUnmarshalJSON() error { overrides.Init() for key, override := range overrides.CustomOverrides.Items { overrides.CustomOverrides.Items[key].parent = overrides if err := override.PostUnmarshalJSON(); err != nil { return err } } overrides.Complete <- true return nil }
[ "func", "(", "overrides", "*", "CustomOverrides", ")", "PostUnmarshalJSON", "(", ")", "error", "{", "overrides", ".", "Init", "(", ")", "\n\n", "for", "key", ",", "override", ":=", "range", "overrides", ".", "CustomOverrides", ".", "Items", "{", "overrides",...
// PostUnmarshalJSON is called after UnmarshalJSON to setup the // structs internal state. The CustomOverrides.Complete channel is utilized // to communicate full completion.
[ "PostUnmarshalJSON", "is", "called", "after", "UnmarshalJSON", "to", "setup", "the", "structs", "internal", "state", ".", "The", "CustomOverrides", ".", "Complete", "channel", "is", "utilized", "to", "communicate", "full", "completion", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/customoverrides.go#L30-L44
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/products.go
FindProduct
func (products *Products) FindProduct(id string) (*Product, error) { var product *Product var productFound bool for _, product = range products.Products.Items { if product.ProductID == id { productFound = true break } } if !productFound { return nil, fmt.Errorf("Unable to find product: \"%s\"", id) } return product, nil }
go
func (products *Products) FindProduct(id string) (*Product, error) { var product *Product var productFound bool for _, product = range products.Products.Items { if product.ProductID == id { productFound = true break } } if !productFound { return nil, fmt.Errorf("Unable to find product: \"%s\"", id) } return product, nil }
[ "func", "(", "products", "*", "Products", ")", "FindProduct", "(", "id", "string", ")", "(", "*", "Product", ",", "error", ")", "{", "var", "product", "*", "Product", "\n", "var", "productFound", "bool", "\n", "for", "_", ",", "product", "=", "range", ...
// FindProduct finds a specific product by ID
[ "FindProduct", "finds", "a", "specific", "product", "by", "ID" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/products.go#L78-L93
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/products.go
NewProduct
func NewProduct(parent *Products) *Product { product := &Product{parent: parent} product.Init() return product }
go
func NewProduct(parent *Products) *Product { product := &Product{parent: parent} product.Init() return product }
[ "func", "NewProduct", "(", "parent", "*", "Products", ")", "*", "Product", "{", "product", ":=", "&", "Product", "{", "parent", ":", "parent", "}", "\n", "product", ".", "Init", "(", ")", "\n\n", "return", "product", "\n", "}" ]
// NewProduct creates a new Product
[ "NewProduct", "creates", "a", "new", "Product" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/products.go#L104-L109
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetContracts
func GetContracts() (*Contracts, error) { contracts := NewContracts() if err := contracts.GetContracts(); err != nil { return nil, err } return contracts, nil }
go
func GetContracts() (*Contracts, error) { contracts := NewContracts() if err := contracts.GetContracts(); err != nil { return nil, err } return contracts, nil }
[ "func", "GetContracts", "(", ")", "(", "*", "Contracts", ",", "error", ")", "{", "contracts", ":=", "NewContracts", "(", ")", "\n", "if", "err", ":=", "contracts", ".", "GetContracts", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "er...
// GetContracts retrieves all contracts
[ "GetContracts", "retrieves", "all", "contracts" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L22-L29
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetProducts
func GetProducts(contract *Contract) (*Products, error) { products := NewProducts() if err := products.GetProducts(contract); err != nil { return nil, err } return products, nil }
go
func GetProducts(contract *Contract) (*Products, error) { products := NewProducts() if err := products.GetProducts(contract); err != nil { return nil, err } return products, nil }
[ "func", "GetProducts", "(", "contract", "*", "Contract", ")", "(", "*", "Products", ",", "error", ")", "{", "products", ":=", "NewProducts", "(", ")", "\n", "if", "err", ":=", "products", ".", "GetProducts", "(", "contract", ")", ";", "err", "!=", "nil...
// GetProducts retrieves all products
[ "GetProducts", "retrieves", "all", "products" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L32-L39
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetEdgeHostnames
func GetEdgeHostnames(contract *Contract, group *Group, options string) (*EdgeHostnames, error) { edgeHostnames := NewEdgeHostnames() if err := edgeHostnames.GetEdgeHostnames(contract, group, options); err != nil { return nil, err } return edgeHostnames, nil }
go
func GetEdgeHostnames(contract *Contract, group *Group, options string) (*EdgeHostnames, error) { edgeHostnames := NewEdgeHostnames() if err := edgeHostnames.GetEdgeHostnames(contract, group, options); err != nil { return nil, err } return edgeHostnames, nil }
[ "func", "GetEdgeHostnames", "(", "contract", "*", "Contract", ",", "group", "*", "Group", ",", "options", "string", ")", "(", "*", "EdgeHostnames", ",", "error", ")", "{", "edgeHostnames", ":=", "NewEdgeHostnames", "(", ")", "\n", "if", "err", ":=", "edgeH...
// GetEdgeHostnames retrieves all edge hostnames
[ "GetEdgeHostnames", "retrieves", "all", "edge", "hostnames" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L42-L49
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetVersions
func GetVersions(property *Property) (*Versions, error) { versions := NewVersions() if err := versions.GetVersions(property); err != nil { return nil, err } return versions, nil }
go
func GetVersions(property *Property) (*Versions, error) { versions := NewVersions() if err := versions.GetVersions(property); err != nil { return nil, err } return versions, nil }
[ "func", "GetVersions", "(", "property", "*", "Property", ")", "(", "*", "Versions", ",", "error", ")", "{", "versions", ":=", "NewVersions", "(", ")", "\n", "if", "err", ":=", "versions", ".", "GetVersions", "(", "property", ")", ";", "err", "!=", "nil...
// GetVersions retrieves all versions for a given property
[ "GetVersions", "retrieves", "all", "versions", "for", "a", "given", "property" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L74-L81
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/service.go
GetAvailableCriteria
func GetAvailableCriteria(property *Property) (*AvailableCriteria, error) { availableCriteria := NewAvailableCriteria() if err := availableCriteria.GetAvailableCriteria(property); err != nil { return nil, err } return availableCriteria, nil }
go
func GetAvailableCriteria(property *Property) (*AvailableCriteria, error) { availableCriteria := NewAvailableCriteria() if err := availableCriteria.GetAvailableCriteria(property); err != nil { return nil, err } return availableCriteria, nil }
[ "func", "GetAvailableCriteria", "(", "property", "*", "Property", ")", "(", "*", "AvailableCriteria", ",", "error", ")", "{", "availableCriteria", ":=", "NewAvailableCriteria", "(", ")", "\n", "if", "err", ":=", "availableCriteria", ".", "GetAvailableCriteria", "(...
// GetAvailableCriteria retrieves all available criteria for a property
[ "GetAvailableCriteria", "retrieves", "all", "available", "criteria", "for", "a", "property" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/service.go#L94-L101
train
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
NewZone
func NewZone(hostname string) *Zone { zone := &Zone{Token: "new"} zone.Zone.Soa = NewSoaRecord() zone.Zone.Name = hostname return zone }
go
func NewZone(hostname string) *Zone { zone := &Zone{Token: "new"} zone.Zone.Soa = NewSoaRecord() zone.Zone.Name = hostname return zone }
[ "func", "NewZone", "(", "hostname", "string", ")", "*", "Zone", "{", "zone", ":=", "&", "Zone", "{", "Token", ":", "\"", "\"", "}", "\n", "zone", ".", "Zone", ".", "Soa", "=", "NewSoaRecord", "(", ")", "\n", "zone", ".", "Zone", ".", "Name", "=",...
// NewZone creates a new Zone
[ "NewZone", "creates", "a", "new", "Zone" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L55-L60
train
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
GetZone
func GetZone(hostname string) (*Zone, error) { zone := NewZone(hostname) req, err := client.NewRequest( Config, "GET", "/config-dns/v1/zones/"+hostname, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) && res.StatusCode != 404 { return nil, client.NewAPIError(res) } else if res.StatusCode == 404 { return nil, &ZoneError{zoneName: hostname} } else { err = client.BodyJSON(res, zone) if err != nil { return nil, err } return zone, nil } }
go
func GetZone(hostname string) (*Zone, error) { zone := NewZone(hostname) req, err := client.NewRequest( Config, "GET", "/config-dns/v1/zones/"+hostname, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } if client.IsError(res) && res.StatusCode != 404 { return nil, client.NewAPIError(res) } else if res.StatusCode == 404 { return nil, &ZoneError{zoneName: hostname} } else { err = client.BodyJSON(res, zone) if err != nil { return nil, err } return zone, nil } }
[ "func", "GetZone", "(", "hostname", "string", ")", "(", "*", "Zone", ",", "error", ")", "{", "zone", ":=", "NewZone", "(", "hostname", ")", "\n", "req", ",", "err", ":=", "client", ".", "NewRequest", "(", "Config", ",", "\"", "\"", ",", "\"", "\"",...
// GetZone retrieves a DNS Zone for a given hostname
[ "GetZone", "retrieves", "a", "DNS", "Zone", "for", "a", "given", "hostname" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L63-L92
train
akamai/AkamaiOPEN-edgegrid-golang
configdns-v1/zone.go
Save
func (zone *Zone) Save() error { // This lock will restrict the concurrency of API calls // to 1 save request at a time. This is needed for the Soa.Serial value which // is required to be incremented for every subsequent update to a zone // so we have to save just one request at a time to ensure this is always // incremented properly zoneWriteLock.Lock() defer zoneWriteLock.Unlock() valid, f := zone.validateCnames() if valid == false { var msg string for _, v := range f { msg = msg + fmt.Sprintf("\n%s Record '%s' conflicts with CNAME", v.recordType, v.name) } return &ZoneError{ zoneName: zone.Zone.Name, apiErrorMessage: "All CNAMEs must be unique in the zone" + msg, } } req, err := client.NewJSONRequest( Config, "POST", "/config-dns/v1/zones/"+zone.Zone.Name, zone, ) if err != nil { return err } res, err := client.Do(Config, req) // Network error if err != nil { return &ZoneError{ zoneName: zone.Zone.Name, httpErrorMessage: err.Error(), err: err, } } // API error if client.IsError(res) { err := client.NewAPIError(res) return &ZoneError{zoneName: zone.Zone.Name, apiErrorMessage: err.Detail, err: err} } for { updatedZone, err := GetZone(zone.Zone.Name) if err != nil { return err } if updatedZone.Token != zone.Token { *zone = *updatedZone break } time.Sleep(time.Second) } return nil }
go
func (zone *Zone) Save() error { // This lock will restrict the concurrency of API calls // to 1 save request at a time. This is needed for the Soa.Serial value which // is required to be incremented for every subsequent update to a zone // so we have to save just one request at a time to ensure this is always // incremented properly zoneWriteLock.Lock() defer zoneWriteLock.Unlock() valid, f := zone.validateCnames() if valid == false { var msg string for _, v := range f { msg = msg + fmt.Sprintf("\n%s Record '%s' conflicts with CNAME", v.recordType, v.name) } return &ZoneError{ zoneName: zone.Zone.Name, apiErrorMessage: "All CNAMEs must be unique in the zone" + msg, } } req, err := client.NewJSONRequest( Config, "POST", "/config-dns/v1/zones/"+zone.Zone.Name, zone, ) if err != nil { return err } res, err := client.Do(Config, req) // Network error if err != nil { return &ZoneError{ zoneName: zone.Zone.Name, httpErrorMessage: err.Error(), err: err, } } // API error if client.IsError(res) { err := client.NewAPIError(res) return &ZoneError{zoneName: zone.Zone.Name, apiErrorMessage: err.Detail, err: err} } for { updatedZone, err := GetZone(zone.Zone.Name) if err != nil { return err } if updatedZone.Token != zone.Token { *zone = *updatedZone break } time.Sleep(time.Second) } return nil }
[ "func", "(", "zone", "*", "Zone", ")", "Save", "(", ")", "error", "{", "// This lock will restrict the concurrency of API calls", "// to 1 save request at a time. This is needed for the Soa.Serial value which", "// is required to be incremented for every subsequent update to a zone", "//...
// Save updates the Zone
[ "Save", "updates", "the", "Zone" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/configdns-v1/zone.go#L95-L157
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/available.go
NewAvailableBehavior
func NewAvailableBehavior(parent *AvailableBehaviors) *AvailableBehavior { availableBehavior := &AvailableBehavior{parent: parent} availableBehavior.Init() return availableBehavior }
go
func NewAvailableBehavior(parent *AvailableBehaviors) *AvailableBehavior { availableBehavior := &AvailableBehavior{parent: parent} availableBehavior.Init() return availableBehavior }
[ "func", "NewAvailableBehavior", "(", "parent", "*", "AvailableBehaviors", ")", "*", "AvailableBehavior", "{", "availableBehavior", ":=", "&", "AvailableBehavior", "{", "parent", ":", "parent", "}", "\n", "availableBehavior", ".", "Init", "(", ")", "\n\n", "return"...
// NewAvailableBehavior creates a new AvailableBehavior
[ "NewAvailableBehavior", "creates", "a", "new", "AvailableBehavior" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/available.go#L153-L158
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/available.go
GetSchema
func (behavior *AvailableBehavior) GetSchema() (*gojsonschema.Schema, error) { req, err := client.NewRequest( Config, "GET", behavior.SchemaLink, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } schemaBytes, _ := ioutil.ReadAll(res.Body) schemaBody := string(schemaBytes) loader := gojsonschema.NewStringLoader(schemaBody) schema, err := gojsonschema.NewSchema(loader) return schema, err }
go
func (behavior *AvailableBehavior) GetSchema() (*gojsonschema.Schema, error) { req, err := client.NewRequest( Config, "GET", behavior.SchemaLink, nil, ) if err != nil { return nil, err } res, err := client.Do(Config, req) if err != nil { return nil, err } schemaBytes, _ := ioutil.ReadAll(res.Body) schemaBody := string(schemaBytes) loader := gojsonschema.NewStringLoader(schemaBody) schema, err := gojsonschema.NewSchema(loader) return schema, err }
[ "func", "(", "behavior", "*", "AvailableBehavior", ")", "GetSchema", "(", ")", "(", "*", "gojsonschema", ".", "Schema", ",", "error", ")", "{", "req", ",", "err", ":=", "client", ".", "NewRequest", "(", "Config", ",", "\"", "\"", ",", "behavior", ".", ...
// GetSchema retrieves the JSON schema for an available behavior
[ "GetSchema", "retrieves", "the", "JSON", "schema", "for", "an", "available", "behavior" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/available.go#L161-L183
train
akamai/AkamaiOPEN-edgegrid-golang
jsonhooks-v1/jsonhooks.go
ImplementsPreJSONMarshaler
func ImplementsPreJSONMarshaler(v interface{}) bool { value := reflect.ValueOf(v) if !value.IsValid() { return false } _, ok := value.Interface().(PreJSONMarshaler) return ok }
go
func ImplementsPreJSONMarshaler(v interface{}) bool { value := reflect.ValueOf(v) if !value.IsValid() { return false } _, ok := value.Interface().(PreJSONMarshaler) return ok }
[ "func", "ImplementsPreJSONMarshaler", "(", "v", "interface", "{", "}", ")", "bool", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "!", "value", ".", "IsValid", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "_", ",",...
// ImplementsPreJSONMarshaler checks for support for the PreMarshalJSON pre-hook
[ "ImplementsPreJSONMarshaler", "checks", "for", "support", "for", "the", "PreMarshalJSON", "pre", "-", "hook" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/jsonhooks-v1/jsonhooks.go#L45-L53
train
akamai/AkamaiOPEN-edgegrid-golang
jsonhooks-v1/jsonhooks.go
ImplementsPostJSONUnmarshaler
func ImplementsPostJSONUnmarshaler(v interface{}) bool { value := reflect.ValueOf(v) if value.Kind() == reflect.Ptr && value.IsNil() { return false } _, ok := value.Interface().(PostJSONUnmarshaler) return ok }
go
func ImplementsPostJSONUnmarshaler(v interface{}) bool { value := reflect.ValueOf(v) if value.Kind() == reflect.Ptr && value.IsNil() { return false } _, ok := value.Interface().(PostJSONUnmarshaler) return ok }
[ "func", "ImplementsPostJSONUnmarshaler", "(", "v", "interface", "{", "}", ")", "bool", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "value", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "&&", "value", ".", "IsNil", ...
// ImplementsPostJSONUnmarshaler checks for support for the PostUnmarshalJSON post-hook
[ "ImplementsPostJSONUnmarshaler", "checks", "for", "support", "for", "the", "PostUnmarshalJSON", "post", "-", "hook" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/jsonhooks-v1/jsonhooks.go#L61-L69
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
NewRequest
func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error) { var ( baseURL *url.URL err error ) if strings.HasPrefix(config.Host, "https://") { baseURL, err = url.Parse(config.Host) } else { baseURL, err = url.Parse("https://" + config.Host) } if err != nil { return nil, err } rel, err := url.Parse(strings.TrimPrefix(path, "/")) if err != nil { return nil, err } u := baseURL.ResolveReference(rel) req, err := http.NewRequest(method, u.String(), body) if err != nil { return nil, err } req.Header.Add("User-Agent", UserAgent) return req, nil }
go
func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error) { var ( baseURL *url.URL err error ) if strings.HasPrefix(config.Host, "https://") { baseURL, err = url.Parse(config.Host) } else { baseURL, err = url.Parse("https://" + config.Host) } if err != nil { return nil, err } rel, err := url.Parse(strings.TrimPrefix(path, "/")) if err != nil { return nil, err } u := baseURL.ResolveReference(rel) req, err := http.NewRequest(method, u.String(), body) if err != nil { return nil, err } req.Header.Add("User-Agent", UserAgent) return req, nil }
[ "func", "NewRequest", "(", "config", "edgegrid", ".", "Config", ",", "method", ",", "path", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "var", "(", "baseURL", "*", "url", ".", "URL", "\...
// NewRequest creates an HTTP request that can be sent to Akamai APIs. A relative URL can be provided in path, which will be resolved to the // Host specified in Config. If body is specified, it will be sent as the request body.
[ "NewRequest", "creates", "an", "HTTP", "request", "that", "can", "be", "sent", "to", "Akamai", "APIs", ".", "A", "relative", "URL", "can", "be", "provided", "in", "path", "which", "will", "be", "resolved", "to", "the", "Host", "specified", "in", "Config", ...
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L31-L62
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
NewMultiPartFormDataRequest
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error) { file, err := os.Open(filePath) if err != nil { return nil, err } defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) // TODO: make this field name configurable part, err := writer.CreateFormFile("importFile", filepath.Base(filePath)) if err != nil { return nil, err } _, err = io.Copy(part, file) for key, val := range otherFormParams { _ = writer.WriteField(key, val) } err = writer.Close() if err != nil { return nil, err } req, err := NewRequest(config, "POST", uriPath, body) req.Header.Set("Content-Type", writer.FormDataContentType()) return req, err }
go
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error) { file, err := os.Open(filePath) if err != nil { return nil, err } defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) // TODO: make this field name configurable part, err := writer.CreateFormFile("importFile", filepath.Base(filePath)) if err != nil { return nil, err } _, err = io.Copy(part, file) for key, val := range otherFormParams { _ = writer.WriteField(key, val) } err = writer.Close() if err != nil { return nil, err } req, err := NewRequest(config, "POST", uriPath, body) req.Header.Set("Content-Type", writer.FormDataContentType()) return req, err }
[ "func", "NewMultiPartFormDataRequest", "(", "config", "edgegrid", ".", "Config", ",", "uriPath", ",", "filePath", "string", ",", "otherFormParams", "map", "[", "string", "]", "string", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "file", ...
// NewMultiPartFormDataRequest creates an HTTP request that uploads a file to the Akamai API
[ "NewMultiPartFormDataRequest", "creates", "an", "HTTP", "request", "that", "uploads", "a", "file", "to", "the", "Akamai", "API" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L93-L120
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
Do
func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) { Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { req = edgegrid.AddRequestHeader(config, req) return nil } req = edgegrid.AddRequestHeader(config, req) res, err := Client.Do(req) if err != nil { return nil, err } return res, nil }
go
func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) { Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { req = edgegrid.AddRequestHeader(config, req) return nil } req = edgegrid.AddRequestHeader(config, req) res, err := Client.Do(req) if err != nil { return nil, err } return res, nil }
[ "func", "Do", "(", "config", "edgegrid", ".", "Config", ",", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "Client", ".", "CheckRedirect", "=", "func", "(", "req", "*", "http", ".", "Request", "...
// Do performs a given HTTP Request, signed with the Akamai OPEN Edgegrid // Authorization header. An edgegrid.Response or an error is returned.
[ "Do", "performs", "a", "given", "HTTP", "Request", "signed", "with", "the", "Akamai", "OPEN", "Edgegrid", "Authorization", "header", ".", "An", "edgegrid", ".", "Response", "or", "an", "error", "is", "returned", "." ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L124-L137
train
akamai/AkamaiOPEN-edgegrid-golang
client-v1/client.go
BodyJSON
func BodyJSON(r *http.Response, data interface{}) error { if data == nil { return errors.New("You must pass in an interface{}") } body, err := ioutil.ReadAll(r.Body) if err != nil { return err } err = jsonhooks.Unmarshal(body, data) return err }
go
func BodyJSON(r *http.Response, data interface{}) error { if data == nil { return errors.New("You must pass in an interface{}") } body, err := ioutil.ReadAll(r.Body) if err != nil { return err } err = jsonhooks.Unmarshal(body, data) return err }
[ "func", "BodyJSON", "(", "r", "*", "http", ".", "Response", ",", "data", "interface", "{", "}", ")", "error", "{", "if", "data", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "body", ",", "err", ":=", ...
// BodyJSON unmarshals the Response.Body into a given data structure
[ "BodyJSON", "unmarshals", "the", "Response", ".", "Body", "into", "a", "given", "data", "structure" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/client-v1/client.go#L140-L152
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
AddGroup
func (groups *Groups) AddGroup(newGroup *Group) { if newGroup.GroupID != "" { for key, group := range groups.Groups.Items { if group.GroupID == newGroup.GroupID { groups.Groups.Items[key] = newGroup return } } } newGroup.parent = groups groups.Groups.Items = append(groups.Groups.Items, newGroup) }
go
func (groups *Groups) AddGroup(newGroup *Group) { if newGroup.GroupID != "" { for key, group := range groups.Groups.Items { if group.GroupID == newGroup.GroupID { groups.Groups.Items[key] = newGroup return } } } newGroup.parent = groups groups.Groups.Items = append(groups.Groups.Items, newGroup) }
[ "func", "(", "groups", "*", "Groups", ")", "AddGroup", "(", "newGroup", "*", "Group", ")", "{", "if", "newGroup", ".", "GroupID", "!=", "\"", "\"", "{", "for", "key", ",", "group", ":=", "range", "groups", ".", "Groups", ".", "Items", "{", "if", "g...
// AddGroup adds a group to a Groups collection
[ "AddGroup", "adds", "a", "group", "to", "a", "Groups", "collection" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L74-L87
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
FindGroup
func (groups *Groups) FindGroup(id string) (*Group, error) { var group *Group var groupFound bool if id == "" { goto err } for _, group = range groups.Groups.Items { if group.GroupID == id { groupFound = true break } } err: if !groupFound { return nil, fmt.Errorf("Unable to find group: \"%s\"", id) } return group, nil }
go
func (groups *Groups) FindGroup(id string) (*Group, error) { var group *Group var groupFound bool if id == "" { goto err } for _, group = range groups.Groups.Items { if group.GroupID == id { groupFound = true break } } err: if !groupFound { return nil, fmt.Errorf("Unable to find group: \"%s\"", id) } return group, nil }
[ "func", "(", "groups", "*", "Groups", ")", "FindGroup", "(", "id", "string", ")", "(", "*", "Group", ",", "error", ")", "{", "var", "group", "*", "Group", "\n", "var", "groupFound", "bool", "\n\n", "if", "id", "==", "\"", "\"", "{", "goto", "err", ...
// FindGroup finds a specific group by ID
[ "FindGroup", "finds", "a", "specific", "group", "by", "ID" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L90-L111
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
NewGroup
func NewGroup(parent *Groups) *Group { group := &Group{ parent: parent, } group.Init() return group }
go
func NewGroup(parent *Groups) *Group { group := &Group{ parent: parent, } group.Init() return group }
[ "func", "NewGroup", "(", "parent", "*", "Groups", ")", "*", "Group", "{", "group", ":=", "&", "Group", "{", "parent", ":", "parent", ",", "}", "\n", "group", ".", "Init", "(", ")", "\n", "return", "group", "\n", "}" ]
// NewGroup creates a new Group
[ "NewGroup", "creates", "a", "new", "Group" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L124-L130
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetGroup
func (group *Group) GetGroup() { groups, err := GetGroups() if err != nil { return } for _, g := range groups.Groups.Items { if g.GroupID == group.GroupID { group.parent = groups group.ContractIDs = g.ContractIDs group.GroupName = g.GroupName group.ParentGroupID = g.ParentGroupID group.Complete <- true return } } group.Complete <- false }
go
func (group *Group) GetGroup() { groups, err := GetGroups() if err != nil { return } for _, g := range groups.Groups.Items { if g.GroupID == group.GroupID { group.parent = groups group.ContractIDs = g.ContractIDs group.GroupName = g.GroupName group.ParentGroupID = g.ParentGroupID group.Complete <- true return } } group.Complete <- false }
[ "func", "(", "group", "*", "Group", ")", "GetGroup", "(", ")", "{", "groups", ",", "err", ":=", "GetGroups", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "for", "_", ",", "g", ":=", "range", "groups", ".", "Groups",...
// GetGroup populates a Group
[ "GetGroup", "populates", "a", "Group" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L133-L151
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetProperties
func (group *Group) GetProperties(contract *Contract) (*Properties, error) { return GetProperties(contract, group) }
go
func (group *Group) GetProperties(contract *Contract) (*Properties, error) { return GetProperties(contract, group) }
[ "func", "(", "group", "*", "Group", ")", "GetProperties", "(", "contract", "*", "Contract", ")", "(", "*", "Properties", ",", "error", ")", "{", "return", "GetProperties", "(", "contract", ",", "group", ")", "\n", "}" ]
// GetProperties retrieves all properties associated with a given group and contract
[ "GetProperties", "retrieves", "all", "properties", "associated", "with", "a", "given", "group", "and", "contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L154-L156
train
akamai/AkamaiOPEN-edgegrid-golang
papi-v1/groups.go
GetCpCodes
func (group *Group) GetCpCodes(contract *Contract) (*CpCodes, error) { return GetCpCodes(contract, group) }
go
func (group *Group) GetCpCodes(contract *Contract) (*CpCodes, error) { return GetCpCodes(contract, group) }
[ "func", "(", "group", "*", "Group", ")", "GetCpCodes", "(", "contract", "*", "Contract", ")", "(", "*", "CpCodes", ",", "error", ")", "{", "return", "GetCpCodes", "(", "contract", ",", "group", ")", "\n", "}" ]
// GetCpCodes retrieves all CP codes associated with a given group and contract
[ "GetCpCodes", "retrieves", "all", "CP", "codes", "associated", "with", "a", "given", "group", "and", "contract" ]
009960c8b2c7c57a0c5c488a3c8c778c16f3f586
https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/009960c8b2c7c57a0c5c488a3c8c778c16f3f586/papi-v1/groups.go#L159-L161
train
giantswarm/mayu
client/client.go
New
func New(scheme, host string, port uint16) (*Client, error) { client := &Client{ Scheme: scheme, Host: host, Port: port, } return client, nil }
go
func New(scheme, host string, port uint16) (*Client, error) { client := &Client{ Scheme: scheme, Host: host, Port: port, } return client, nil }
[ "func", "New", "(", "scheme", ",", "host", "string", ",", "port", "uint16", ")", "(", "*", "Client", ",", "error", ")", "{", "client", ":=", "&", "Client", "{", "Scheme", ":", "scheme", ",", "Host", ":", "host", ",", "Port", ":", "port", ",", "}"...
// New creates a new configured client to interact with mayu over its network // API.
[ "New", "creates", "a", "new", "configured", "client", "to", "interact", "with", "mayu", "over", "its", "network", "API", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L33-L41
train
giantswarm/mayu
client/client.go
SetProviderId
func (c *Client) SetProviderId(serial, value string) error { data, err := json.Marshal(hostmgr.Host{ ProviderId: value, }) if err != nil { return microerror.Mask(err) } resp, err := httputil.Put(fmt.Sprintf("%s://%s:%d/admin/host/%s/set_provider_id", c.Scheme, c.Host, c.Port, serial), contentType, bytes.NewBuffer(data)) if err != nil { return microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } return nil }
go
func (c *Client) SetProviderId(serial, value string) error { data, err := json.Marshal(hostmgr.Host{ ProviderId: value, }) if err != nil { return microerror.Mask(err) } resp, err := httputil.Put(fmt.Sprintf("%s://%s:%d/admin/host/%s/set_provider_id", c.Scheme, c.Host, c.Port, serial), contentType, bytes.NewBuffer(data)) if err != nil { return microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } return nil }
[ "func", "(", "c", "*", "Client", ")", "SetProviderId", "(", "serial", ",", "value", "string", ")", "error", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "hostmgr", ".", "Host", "{", "ProviderId", ":", "value", ",", "}", ")", "\n", "i...
// SetProviderId sets the provider ID given by value for a node given by serial.
[ "SetProviderId", "sets", "the", "provider", "ID", "given", "by", "value", "for", "a", "node", "given", "by", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L59-L78
train
giantswarm/mayu
client/client.go
List
func (c *Client) List() ([]hostmgr.Host, error) { list := []hostmgr.Host{} resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return list, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return nil, microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return list, microerror.Mask(err) } err = json.Unmarshal(body, &list) if err != nil { return list, microerror.Mask(err) } return list, nil }
go
func (c *Client) List() ([]hostmgr.Host, error) { list := []hostmgr.Host{} resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return list, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return nil, microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return list, microerror.Mask(err) } err = json.Unmarshal(body, &list) if err != nil { return list, microerror.Mask(err) } return list, nil }
[ "func", "(", "c", "*", "Client", ")", "List", "(", ")", "(", "[", "]", "hostmgr", ".", "Host", ",", "error", ")", "{", "list", ":=", "[", "]", "hostmgr", ".", "Host", "{", "}", "\n\n", "resp", ",", "err", ":=", "http", ".", "Get", "(", "fmt",...
// List fetches a list of node information within the current cluster.
[ "List", "fetches", "a", "list", "of", "node", "information", "within", "the", "current", "cluster", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L174-L197
train
giantswarm/mayu
client/client.go
Status
func (c *Client) Status(serial string) (hostmgr.Host, error) { var host hostmgr.Host resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return host, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return host, microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return host, microerror.Mask(err) } list := []hostmgr.Host{} err = json.Unmarshal(body, &list) if err != nil { return host, microerror.Mask(err) } for _, host = range list { if host.Serial == serial { return host, nil } } return host, microerror.Mask(fmt.Errorf("host %s not found", serial)) }
go
func (c *Client) Status(serial string) (hostmgr.Host, error) { var host hostmgr.Host resp, err := http.Get(fmt.Sprintf("%s://%s:%d/admin/hosts", c.Scheme, c.Host, c.Port)) if err != nil { return host, microerror.Mask(err) } defer resp.Body.Close() if resp.StatusCode > 399 { return host, microerror.Mask(fmt.Errorf("invalid status code '%d'", resp.StatusCode)) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return host, microerror.Mask(err) } list := []hostmgr.Host{} err = json.Unmarshal(body, &list) if err != nil { return host, microerror.Mask(err) } for _, host = range list { if host.Serial == serial { return host, nil } } return host, microerror.Mask(fmt.Errorf("host %s not found", serial)) }
[ "func", "(", "c", "*", "Client", ")", "Status", "(", "serial", "string", ")", "(", "hostmgr", ".", "Host", ",", "error", ")", "{", "var", "host", "hostmgr", ".", "Host", "\n\n", "resp", ",", "err", ":=", "http", ".", "Get", "(", "fmt", ".", "Spri...
// Status fetches status information for a node given by serial.
[ "Status", "fetches", "status", "information", "for", "a", "node", "given", "by", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/client/client.go#L200-L230
train
giantswarm/mayu
pxemgr/iputil.go
ipLessThanOrEqual
func ipLessThanOrEqual(ip net.IP, upperBound net.IP) bool { if ip[3] < upperBound[3] { return true } if ip[2] < upperBound[2] { return true } if ip[1] < upperBound[1] { return true } if ip[0] <= upperBound[0] { return true } return false }
go
func ipLessThanOrEqual(ip net.IP, upperBound net.IP) bool { if ip[3] < upperBound[3] { return true } if ip[2] < upperBound[2] { return true } if ip[1] < upperBound[1] { return true } if ip[0] <= upperBound[0] { return true } return false }
[ "func", "ipLessThanOrEqual", "(", "ip", "net", ".", "IP", ",", "upperBound", "net", ".", "IP", ")", "bool", "{", "if", "ip", "[", "3", "]", "<", "upperBound", "[", "3", "]", "{", "return", "true", "\n", "}", "\n", "if", "ip", "[", "2", "]", "<"...
// ip less or equal
[ "ip", "less", "or", "equal" ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/pxemgr/iputil.go#L18-L33
train
giantswarm/mayu
fs/fake.go
NewFakeFilesystemWithFiles
func NewFakeFilesystemWithFiles(fs []FakeFile) FakeFilesystem { fileMap := make(map[string]FakeFile) for _, f := range fs { fileMap[f.Name] = f } return FakeFilesystem{files: fileMap} }
go
func NewFakeFilesystemWithFiles(fs []FakeFile) FakeFilesystem { fileMap := make(map[string]FakeFile) for _, f := range fs { fileMap[f.Name] = f } return FakeFilesystem{files: fileMap} }
[ "func", "NewFakeFilesystemWithFiles", "(", "fs", "[", "]", "FakeFile", ")", "FakeFilesystem", "{", "fileMap", ":=", "make", "(", "map", "[", "string", "]", "FakeFile", ")", "\n", "for", "_", ",", "f", ":=", "range", "fs", "{", "fileMap", "[", "f", ".",...
// NewFakeFilesystemWithFiles creates a new FakeFilesystem // instance bundled with a list of FakeFile instances that // can be passed.
[ "NewFakeFilesystemWithFiles", "creates", "a", "new", "FakeFilesystem", "instance", "bundled", "with", "a", "list", "of", "FakeFile", "instances", "that", "can", "be", "passed", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L25-L32
train
giantswarm/mayu
fs/fake.go
NewFakeFile
func NewFakeFile(name, content string) FakeFile { return FakeFile{ Name: name, Mode: os.FileMode(0777), ModTime: time.Now(), Buffer: bytes.NewReader([]byte(content)), } }
go
func NewFakeFile(name, content string) FakeFile { return FakeFile{ Name: name, Mode: os.FileMode(0777), ModTime: time.Now(), Buffer: bytes.NewReader([]byte(content)), } }
[ "func", "NewFakeFile", "(", "name", ",", "content", "string", ")", "FakeFile", "{", "return", "FakeFile", "{", "Name", ":", "name", ",", "Mode", ":", "os", ".", "FileMode", "(", "0777", ")", ",", "ModTime", ":", "time", ".", "Now", "(", ")", ",", "...
// NewFakeFile creates a new FakeFile instances based on a file name // and it's contents from strings. The content of the new instance will // be stored in an internal bytes.Reader instance. The default file mode // will be 0777 and the last modification time the moment when the // function is called.
[ "NewFakeFile", "creates", "a", "new", "FakeFile", "instances", "based", "on", "a", "file", "name", "and", "it", "s", "contents", "from", "strings", ".", "The", "content", "of", "the", "new", "instance", "will", "be", "stored", "in", "an", "internal", "byte...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L75-L82
train
giantswarm/mayu
fs/fake.go
Read
func (f FakeFile) Read(p []byte) (n int, err error) { return f.Buffer.Read(p) }
go
func (f FakeFile) Read(p []byte) (n int, err error) { return f.Buffer.Read(p) }
[ "func", "(", "f", "FakeFile", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "f", ".", "Buffer", ".", "Read", "(", "p", ")", "\n", "}" ]
// Read wraps io.Reader's functionality around the internal // bytes.Reader instance.
[ "Read", "wraps", "io", ".", "Reader", "s", "functionality", "around", "the", "internal", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L91-L93
train
giantswarm/mayu
fs/fake.go
ReadAt
func (f FakeFile) ReadAt(p []byte, off int64) (n int, err error) { return f.Buffer.ReadAt(p, off) }
go
func (f FakeFile) ReadAt(p []byte, off int64) (n int, err error) { return f.Buffer.ReadAt(p, off) }
[ "func", "(", "f", "FakeFile", ")", "ReadAt", "(", "p", "[", "]", "byte", ",", "off", "int64", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "f", ".", "Buffer", ".", "ReadAt", "(", "p", ",", "off", ")", "\n", "}" ]
// ReadAt wraps io.ReaderAt's functionality around the internalt // bytes.Reader instance.
[ "ReadAt", "wraps", "io", ".", "ReaderAt", "s", "functionality", "around", "the", "internalt", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L97-L99
train
giantswarm/mayu
fs/fake.go
Seek
func (f FakeFile) Seek(offset int64, whence int) (int64, error) { return f.Buffer.Seek(offset, whence) }
go
func (f FakeFile) Seek(offset int64, whence int) (int64, error) { return f.Buffer.Seek(offset, whence) }
[ "func", "(", "f", "FakeFile", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "int64", ",", "error", ")", "{", "return", "f", ".", "Buffer", ".", "Seek", "(", "offset", ",", "whence", ")", "\n", "}" ]
// Seek wraps io.Seeker's functionality around the internalt // bytes.Reader instance.
[ "Seek", "wraps", "io", ".", "Seeker", "s", "functionality", "around", "the", "internalt", "bytes", ".", "Reader", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L103-L105
train
giantswarm/mayu
fs/fake.go
Stat
func (f FakeFile) Stat() (os.FileInfo, error) { return FakeFileInfo{File: f}, nil }
go
func (f FakeFile) Stat() (os.FileInfo, error) { return FakeFileInfo{File: f}, nil }
[ "func", "(", "f", "FakeFile", ")", "Stat", "(", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "return", "FakeFileInfo", "{", "File", ":", "f", "}", ",", "nil", "\n", "}" ]
// Stat returns the FakeFileInfo structure describing the FakeFile // instance.
[ "Stat", "returns", "the", "FakeFileInfo", "structure", "describing", "the", "FakeFile", "instance", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/fs/fake.go#L109-L111
train
giantswarm/mayu
flag.go
ValidateHTTPCertificateUsage
func (g MayuFlags) ValidateHTTPCertificateUsage() (bool, error) { if g.noTLS { return true, nil } if !g.noTLS && g.tlsCertFile != "" && g.tlsKeyFile != "" { return true, nil } return false, ErrNotAllCertFilesProvided }
go
func (g MayuFlags) ValidateHTTPCertificateUsage() (bool, error) { if g.noTLS { return true, nil } if !g.noTLS && g.tlsCertFile != "" && g.tlsKeyFile != "" { return true, nil } return false, ErrNotAllCertFilesProvided }
[ "func", "(", "g", "MayuFlags", ")", "ValidateHTTPCertificateUsage", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "g", ".", "noTLS", "{", "return", "true", ",", "nil", "\n", "}", "\n\n", "if", "!", "g", ".", "noTLS", "&&", "g", ".", "tlsCert...
// ValidateHTTPCertificateUsage checks if the fields HTTPSCertFile and HTTPSKeyFile // of the configuration struct are set whenever the NoTLS is set to false. // This makes sure that users are configuring the needed certificate files when // using TLS encrypted connections.
[ "ValidateHTTPCertificateUsage", "checks", "if", "the", "fields", "HTTPSCertFile", "and", "HTTPSKeyFile", "of", "the", "configuration", "struct", "are", "set", "whenever", "the", "NoTLS", "is", "set", "to", "false", ".", "This", "makes", "sure", "that", "users", ...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/flag.go#L96-L106
train
giantswarm/mayu
flag.go
ValidateHTTPCertificateFileExistance
func (g MayuFlags) ValidateHTTPCertificateFileExistance() (bool, error) { if g.noTLS { return true, nil } if _, err := g.filesystem.Stat(g.tlsCertFile); err != nil { return false, ErrHTTPSCertFileNotRedable } if _, err := g.filesystem.Stat(g.tlsKeyFile); err != nil { return false, ErrHTTPSKeyFileNotReadable } return true, nil }
go
func (g MayuFlags) ValidateHTTPCertificateFileExistance() (bool, error) { if g.noTLS { return true, nil } if _, err := g.filesystem.Stat(g.tlsCertFile); err != nil { return false, ErrHTTPSCertFileNotRedable } if _, err := g.filesystem.Stat(g.tlsKeyFile); err != nil { return false, ErrHTTPSKeyFileNotReadable } return true, nil }
[ "func", "(", "g", "MayuFlags", ")", "ValidateHTTPCertificateFileExistance", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "g", ".", "noTLS", "{", "return", "true", ",", "nil", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "g", ".", "filesyst...
// ValidateHTTPCertificateFileExistance checks if the filenames configured // in the fields HTTPSCertFile and HTTPSKeyFile can be stat'ed to make sure // they actually exist.
[ "ValidateHTTPCertificateFileExistance", "checks", "if", "the", "filenames", "configured", "in", "the", "fields", "HTTPSCertFile", "and", "HTTPSKeyFile", "can", "be", "stat", "ed", "to", "make", "sure", "they", "actually", "exist", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/flag.go#L111-L125
train
giantswarm/mayu
hostmgr/host.go
Commit
func (h *Host) Commit(msg string) error { h.save() return h.maybeGitCommit(h.Serial + ": " + msg) }
go
func (h *Host) Commit(msg string) error { h.save() return h.maybeGitCommit(h.Serial + ": " + msg) }
[ "func", "(", "h", "*", "Host", ")", "Commit", "(", "msg", "string", ")", "error", "{", "h", ".", "save", "(", ")", "\n", "return", "h", ".", "maybeGitCommit", "(", "h", ".", "Serial", "+", "\"", "\"", "+", "msg", ")", "\n", "}" ]
// Commit stores the given msg in git version control.
[ "Commit", "stores", "the", "given", "msg", "in", "git", "version", "control", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/host.go#L51-L54
train
giantswarm/mayu
hostmgr/host.go
HostFromDir
func HostFromDir(hostdir string) (*Host, error) { confPath := path.Join(hostdir, hostConfFile) h := &Host{} err := loadJson(h, confPath) if err != nil { return nil, microerror.Mask(err) } h.hostDir, err = os.Open(hostdir) if err != nil { return nil, microerror.Mask(err) } fi, err := os.Stat(confPath) if err != nil { return nil, microerror.Mask(err) } h.lastModTime = fi.ModTime() return h, nil }
go
func HostFromDir(hostdir string) (*Host, error) { confPath := path.Join(hostdir, hostConfFile) h := &Host{} err := loadJson(h, confPath) if err != nil { return nil, microerror.Mask(err) } h.hostDir, err = os.Open(hostdir) if err != nil { return nil, microerror.Mask(err) } fi, err := os.Stat(confPath) if err != nil { return nil, microerror.Mask(err) } h.lastModTime = fi.ModTime() return h, nil }
[ "func", "HostFromDir", "(", "hostdir", "string", ")", "(", "*", "Host", ",", "error", ")", "{", "confPath", ":=", "path", ".", "Join", "(", "hostdir", ",", "hostConfFile", ")", "\n\n", "h", ":=", "&", "Host", "{", "}", "\n", "err", ":=", "loadJson", ...
// HostFromDir takes a path to a host directory within the cluster directory // and loads the found configuration. Then the corresponding Host is returned.
[ "HostFromDir", "takes", "a", "path", "to", "a", "host", "directory", "within", "the", "cluster", "directory", "and", "loads", "the", "found", "configuration", ".", "Then", "the", "corresponding", "Host", "is", "returned", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/host.go#L67-L88
train
giantswarm/mayu
pxemgr/ignition.go
hasUnrecognizedKeys
func hasUnrecognizedKeys(inCfg interface{}, refType reflect.Type) (warnings bool) { if refType.Kind() == reflect.Ptr { refType = refType.Elem() } switch inCfg.(type) { case map[interface{}]interface{}: ks := inCfg.(map[interface{}]interface{}) keys: for key := range ks { for i := 0; i < refType.NumField(); i++ { sf := refType.Field(i) tv := sf.Tag.Get("yaml") if tv == key { if warn := hasUnrecognizedKeys(ks[key], sf.Type); warn { warnings = true } continue keys } } fmt.Printf("Unrecognized keyword: %v", key) warnings = true } case []interface{}: ks := inCfg.([]interface{}) for i := range ks { if warn := hasUnrecognizedKeys(ks[i], refType.Elem()); warn { warnings = true } } default: } return }
go
func hasUnrecognizedKeys(inCfg interface{}, refType reflect.Type) (warnings bool) { if refType.Kind() == reflect.Ptr { refType = refType.Elem() } switch inCfg.(type) { case map[interface{}]interface{}: ks := inCfg.(map[interface{}]interface{}) keys: for key := range ks { for i := 0; i < refType.NumField(); i++ { sf := refType.Field(i) tv := sf.Tag.Get("yaml") if tv == key { if warn := hasUnrecognizedKeys(ks[key], sf.Type); warn { warnings = true } continue keys } } fmt.Printf("Unrecognized keyword: %v", key) warnings = true } case []interface{}: ks := inCfg.([]interface{}) for i := range ks { if warn := hasUnrecognizedKeys(ks[i], refType.Elem()); warn { warnings = true } } default: } return }
[ "func", "hasUnrecognizedKeys", "(", "inCfg", "interface", "{", "}", ",", "refType", "reflect", ".", "Type", ")", "(", "warnings", "bool", ")", "{", "if", "refType", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "refType", "=", "refType", "."...
// hasUnrecognizedKeys finds unrecognized keys and warns about them on stderr. // returns false when no unrecognized keys were found, true otherwise.
[ "hasUnrecognizedKeys", "finds", "unrecognized", "keys", "and", "warns", "about", "them", "on", "stderr", ".", "returns", "false", "when", "no", "unrecognized", "keys", "were", "found", "true", "otherwise", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/pxemgr/ignition.go#L142-L175
train
giantswarm/mayu
hostmgr/cluster.go
NewCluster
func NewCluster(baseDir string, gitStore bool, logger micrologger.Logger) (*Cluster, error) { if !fileExists(baseDir) { err := os.Mkdir(baseDir, 0755) if err != nil { return nil, microerror.Mask(err) } } if gitStore && !isGitRepo(baseDir) { err := gitInit(baseDir) if err != nil { return nil, microerror.Mask(err) } } c := &Cluster{ baseDir: baseDir, GitStore: gitStore, mu: new(sync.Mutex), Config: ClusterConfig{}, predefinedVals: map[string]map[string]string{}, hostsCache: map[string]*cachedHost{}, logger: logger, } err := c.Commit("initial commit") if err != nil { return nil, microerror.Mask(err) } return c, nil }
go
func NewCluster(baseDir string, gitStore bool, logger micrologger.Logger) (*Cluster, error) { if !fileExists(baseDir) { err := os.Mkdir(baseDir, 0755) if err != nil { return nil, microerror.Mask(err) } } if gitStore && !isGitRepo(baseDir) { err := gitInit(baseDir) if err != nil { return nil, microerror.Mask(err) } } c := &Cluster{ baseDir: baseDir, GitStore: gitStore, mu: new(sync.Mutex), Config: ClusterConfig{}, predefinedVals: map[string]map[string]string{}, hostsCache: map[string]*cachedHost{}, logger: logger, } err := c.Commit("initial commit") if err != nil { return nil, microerror.Mask(err) } return c, nil }
[ "func", "NewCluster", "(", "baseDir", "string", ",", "gitStore", "bool", ",", "logger", "micrologger", ".", "Logger", ")", "(", "*", "Cluster", ",", "error", ")", "{", "if", "!", "fileExists", "(", "baseDir", ")", "{", "err", ":=", "os", ".", "Mkdir", ...
// NewCluster creates a new cluster based on the cluster directory. gitStore // defines whether cluster changes should be tracked using version control or // not.
[ "NewCluster", "creates", "a", "new", "cluster", "based", "on", "the", "cluster", "directory", ".", "gitStore", "defines", "whether", "cluster", "changes", "should", "be", "tracked", "using", "version", "control", "or", "not", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L78-L108
train
giantswarm/mayu
hostmgr/cluster.go
CreateNewHost
func (c *Cluster) CreateNewHost(serial string) (*Host, error) { serial = strings.ToLower(serial) hostDir := path.Join(c.baseDir, strings.ToLower(serial)) newHost, err := createHost(serial, hostDir) if err != nil { return nil, microerror.Mask(err) } if predef, exists := c.predefinedVals[serial]; exists { c.logger.Log("level", "info", "message", fmt.Sprintf("found predefined values for '%s'", serial)) if s, exists := predef["ipmiaddr"]; exists { newHost.IPMIAddr = net.ParseIP(s) c.logger.Log("level", "info", "message", fmt.Sprintf("setting IPMIAdddress for '%s': %s", serial, newHost.IPMIAddr.String())) } if s, exists := predef["internaladdr"]; exists { newHost.InternalAddr = net.ParseIP(s) c.logger.Log("level", "info", "message", fmt.Sprintf("setting internal address for '%s': %s", serial, newHost.InternalAddr.String())) newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4) } if s, exists := predef["etcdclustertoken"]; exists { newHost.EtcdClusterToken = s } } else { c.logger.Log("level", "info", "message", fmt.Sprintf("no predefined values for '%s'", serial)) } machineID := genMachineID() newHost.MachineID = machineID if newHost.InternalAddr != nil { newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4) } c.logger.Log("level", "info", "message", fmt.Sprintf("hostname for '%s' is %s", newHost.InternalAddr.String(), newHost.Hostname)) newHost.Commit("updated with predefined settings") err = c.reindex() if err != nil { return nil, microerror.Mask(err) } return newHost, nil }
go
func (c *Cluster) CreateNewHost(serial string) (*Host, error) { serial = strings.ToLower(serial) hostDir := path.Join(c.baseDir, strings.ToLower(serial)) newHost, err := createHost(serial, hostDir) if err != nil { return nil, microerror.Mask(err) } if predef, exists := c.predefinedVals[serial]; exists { c.logger.Log("level", "info", "message", fmt.Sprintf("found predefined values for '%s'", serial)) if s, exists := predef["ipmiaddr"]; exists { newHost.IPMIAddr = net.ParseIP(s) c.logger.Log("level", "info", "message", fmt.Sprintf("setting IPMIAdddress for '%s': %s", serial, newHost.IPMIAddr.String())) } if s, exists := predef["internaladdr"]; exists { newHost.InternalAddr = net.ParseIP(s) c.logger.Log("level", "info", "message", fmt.Sprintf("setting internal address for '%s': %s", serial, newHost.InternalAddr.String())) newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4) } if s, exists := predef["etcdclustertoken"]; exists { newHost.EtcdClusterToken = s } } else { c.logger.Log("level", "info", "message", fmt.Sprintf("no predefined values for '%s'", serial)) } machineID := genMachineID() newHost.MachineID = machineID if newHost.InternalAddr != nil { newHost.Hostname = strings.Replace(newHost.InternalAddr.String(), ".", "-", 4) } c.logger.Log("level", "info", "message", fmt.Sprintf("hostname for '%s' is %s", newHost.InternalAddr.String(), newHost.Hostname)) newHost.Commit("updated with predefined settings") err = c.reindex() if err != nil { return nil, microerror.Mask(err) } return newHost, nil }
[ "func", "(", "c", "*", "Cluster", ")", "CreateNewHost", "(", "serial", "string", ")", "(", "*", "Host", ",", "error", ")", "{", "serial", "=", "strings", ".", "ToLower", "(", "serial", ")", "\n", "hostDir", ":=", "path", ".", "Join", "(", "c", ".",...
// CreateNewHost creates a new host with the given serial.
[ "CreateNewHost", "creates", "a", "new", "host", "with", "the", "given", "serial", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L111-L153
train
giantswarm/mayu
hostmgr/cluster.go
Update
func (c *Cluster) Update() error { c.mu.Lock() defer c.mu.Unlock() if err := c.cacheHosts(); err != nil { return microerror.Mask(err) } err := c.reindex() if err != nil { return microerror.Mask(err) } return nil }
go
func (c *Cluster) Update() error { c.mu.Lock() defer c.mu.Unlock() if err := c.cacheHosts(); err != nil { return microerror.Mask(err) } err := c.reindex() if err != nil { return microerror.Mask(err) } return nil }
[ "func", "(", "c", "*", "Cluster", ")", "Update", "(", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "err", ":=", "c", ".", "cacheHosts", "(", ")", ";", "err", "...
// Update refreshs the internal host cache based on information within the // cluster directory.
[ "Update", "refreshs", "the", "internal", "host", "cache", "based", "on", "information", "within", "the", "cluster", "directory", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L168-L180
train
giantswarm/mayu
hostmgr/cluster.go
HostWithMacAddress
func (c *Cluster) HostWithMacAddress(macAddr string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the mac address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByMacAddr[strings.ToLower(macAddr)]; exists { return cached.get(), true } else { return nil, false } }
go
func (c *Cluster) HostWithMacAddress(macAddr string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the mac address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByMacAddr[strings.ToLower(macAddr)]; exists { return cached.get(), true } else { return nil, false } }
[ "func", "(", "c", "*", "Cluster", ")", "HostWithMacAddress", "(", "macAddr", "string", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", ".", "Log", ...
// HostWithMacAddress returns the host object given by macAddr based on the // internal cache. In case the host could not be found, host is nil and false // is returned as second return value.
[ "HostWithMacAddress", "returns", "the", "host", "object", "given", "by", "macAddr", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "se...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L185-L198
train
giantswarm/mayu
hostmgr/cluster.go
HostWithInternalAddr
func (c *Cluster) HostWithInternalAddr(ipAddr net.IP) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the ip address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByInternalAddr[ipAddr.String()]; exists { return cached.get(), true } else { return nil, false } }
go
func (c *Cluster) HostWithInternalAddr(ipAddr net.IP) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the ip address using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostByInternalAddr[ipAddr.String()]; exists { return cached.get(), true } else { return nil, false } }
[ "func", "(", "c", "*", "Cluster", ")", "HostWithInternalAddr", "(", "ipAddr", "net", ".", "IP", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", "."...
// HostWithInternalAddr returns the host object given by ipAddr based on the // internal cache. In case the host could not be found, host is nil and false // is returned as second return value.
[ "HostWithInternalAddr", "returns", "the", "host", "object", "given", "by", "ipAddr", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "s...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L203-L216
train
giantswarm/mayu
hostmgr/cluster.go
HostWithSerial
func (c *Cluster) HostWithSerial(serial string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the serial number using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostsCache[strings.ToLower(serial)]; exists { return cached.get(), true } else { return nil, false } }
go
func (c *Cluster) HostWithSerial(serial string) (*Host, bool) { if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the serial number using the internal cache", "stack", err) return nil, false } c.mu.Lock() defer c.mu.Unlock() if cached, exists := c.hostsCache[strings.ToLower(serial)]; exists { return cached.get(), true } else { return nil, false } }
[ "func", "(", "c", "*", "Cluster", ")", "HostWithSerial", "(", "serial", "string", ")", "(", "*", "Host", ",", "bool", ")", "{", "if", "err", ":=", "c", ".", "Update", "(", ")", ";", "err", "!=", "nil", "{", "c", ".", "logger", ".", "Log", "(", ...
// HostWithSerial returns the host object given by serial based on the internal // cache. In case the host could not be found, host is nil and false is // returned as second return value.
[ "HostWithSerial", "returns", "the", "host", "object", "given", "by", "serial", "based", "on", "the", "internal", "cache", ".", "In", "case", "the", "host", "could", "not", "be", "found", "host", "is", "nil", "and", "false", "is", "returned", "as", "second"...
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L221-L234
train
giantswarm/mayu
hostmgr/cluster.go
GetAllHosts
func (c *Cluster) GetAllHosts() []*Host { hosts := make([]*Host, 0, len(c.hostsCache)) if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the list of hosts based on the internal cache: %#v", "stack", err) return hosts } for _, cachedHost := range c.hostsCache { hosts = append(hosts, cachedHost.get()) } return hosts }
go
func (c *Cluster) GetAllHosts() []*Host { hosts := make([]*Host, 0, len(c.hostsCache)) if err := c.Update(); err != nil { c.logger.Log("level", "error", "message", "error getting the list of hosts based on the internal cache: %#v", "stack", err) return hosts } for _, cachedHost := range c.hostsCache { hosts = append(hosts, cachedHost.get()) } return hosts }
[ "func", "(", "c", "*", "Cluster", ")", "GetAllHosts", "(", ")", "[", "]", "*", "Host", "{", "hosts", ":=", "make", "(", "[", "]", "*", "Host", ",", "0", ",", "len", "(", "c", ".", "hostsCache", ")", ")", "\n\n", "if", "err", ":=", "c", ".", ...
// GetAllHosts returns a list of all hosts based on the internal cache.
[ "GetAllHosts", "returns", "a", "list", "of", "all", "hosts", "based", "on", "the", "internal", "cache", "." ]
00428982411d0e1679e86e25287827b3a308a9e4
https://github.com/giantswarm/mayu/blob/00428982411d0e1679e86e25287827b3a308a9e4/hostmgr/cluster.go#L261-L273
train
fatih/color
color.go
New
func New(value ...Attribute) *Color { c := &Color{params: make([]Attribute, 0)} c.Add(value...) return c }
go
func New(value ...Attribute) *Color { c := &Color{params: make([]Attribute, 0)} c.Add(value...) return c }
[ "func", "New", "(", "value", "...", "Attribute", ")", "*", "Color", "{", "c", ":=", "&", "Color", "{", "params", ":", "make", "(", "[", "]", "Attribute", ",", "0", ")", "}", "\n", "c", ".", "Add", "(", "value", "...", ")", "\n", "return", "c", ...
// New returns a newly created color object.
[ "New", "returns", "a", "newly", "created", "color", "object", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L110-L114
train
fatih/color
color.go
Set
func (c *Color) Set() *Color { if c.isNoColorSet() { return c } fmt.Fprintf(Output, c.format()) return c }
go
func (c *Color) Set() *Color { if c.isNoColorSet() { return c } fmt.Fprintf(Output, c.format()) return c }
[ "func", "(", "c", "*", "Color", ")", "Set", "(", ")", "*", "Color", "{", "if", "c", ".", "isNoColorSet", "(", ")", "{", "return", "c", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "Output", ",", "c", ".", "format", "(", ")", ")", "\n", "ret...
// Set sets the SGR sequence.
[ "Set", "sets", "the", "SGR", "sequence", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L135-L142
train
fatih/color
color.go
Sprint
func (c *Color) Sprint(a ...interface{}) string { return c.wrap(fmt.Sprint(a...)) }
go
func (c *Color) Sprint(a ...interface{}) string { return c.wrap(fmt.Sprint(a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprint", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprint", "(", "a", "...", ")", ")", "\n", "}" ]
// Sprint is just like Print, but returns a string instead of printing it.
[ "Sprint", "is", "just", "like", "Print", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L255-L257
train
fatih/color
color.go
Sprintln
func (c *Color) Sprintln(a ...interface{}) string { return c.wrap(fmt.Sprintln(a...)) }
go
func (c *Color) Sprintln(a ...interface{}) string { return c.wrap(fmt.Sprintln(a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprintln", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprintln", "(", "a", "...", ")", ")", "\n", "}" ]
// Sprintln is just like Println, but returns a string instead of printing it.
[ "Sprintln", "is", "just", "like", "Println", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L260-L262
train
fatih/color
color.go
Sprintf
func (c *Color) Sprintf(format string, a ...interface{}) string { return c.wrap(fmt.Sprintf(format, a...)) }
go
func (c *Color) Sprintf(format string, a ...interface{}) string { return c.wrap(fmt.Sprintf(format, a...)) }
[ "func", "(", "c", "*", "Color", ")", "Sprintf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "string", "{", "return", "c", ".", "wrap", "(", "fmt", ".", "Sprintf", "(", "format", ",", "a", "...", ")", ")", "\n", "}" ]
// Sprintf is just like Printf, but returns a string instead of printing it.
[ "Sprintf", "is", "just", "like", "Printf", "but", "returns", "a", "string", "instead", "of", "printing", "it", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L265-L267
train
fatih/color
color.go
wrap
func (c *Color) wrap(s string) string { if c.isNoColorSet() { return s } return c.format() + s + c.unformat() }
go
func (c *Color) wrap(s string) string { if c.isNoColorSet() { return s } return c.format() + s + c.unformat() }
[ "func", "(", "c", "*", "Color", ")", "wrap", "(", "s", "string", ")", "string", "{", "if", "c", ".", "isNoColorSet", "(", ")", "{", "return", "s", "\n", "}", "\n\n", "return", "c", ".", "format", "(", ")", "+", "s", "+", "c", ".", "unformat", ...
// wrap wraps the s string with the colors attributes. The string is ready to // be printed.
[ "wrap", "wraps", "the", "s", "string", "with", "the", "colors", "attributes", ".", "The", "string", "is", "ready", "to", "be", "printed", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L360-L366
train
fatih/color
color.go
Equals
func (c *Color) Equals(c2 *Color) bool { if len(c.params) != len(c2.params) { return false } for _, attr := range c.params { if !c2.attrExists(attr) { return false } } return true }
go
func (c *Color) Equals(c2 *Color) bool { if len(c.params) != len(c2.params) { return false } for _, attr := range c.params { if !c2.attrExists(attr) { return false } } return true }
[ "func", "(", "c", "*", "Color", ")", "Equals", "(", "c2", "*", "Color", ")", "bool", "{", "if", "len", "(", "c", ".", "params", ")", "!=", "len", "(", "c2", ".", "params", ")", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "attr...
// Equals returns a boolean value indicating whether two colors are equal.
[ "Equals", "returns", "a", "boolean", "value", "indicating", "whether", "two", "colors", "are", "equal", "." ]
3f9d52f7176a6927daacff70a3e8d1dc2025c53e
https://github.com/fatih/color/blob/3f9d52f7176a6927daacff70a3e8d1dc2025c53e/color.go#L400-L412
train
BurntSushi/toml
decode.go
PrimitiveDecode
func PrimitiveDecode(primValue Primitive, v interface{}) error { md := MetaData{decoded: make(map[string]bool)} return md.unify(primValue.undecoded, rvalue(v)) }
go
func PrimitiveDecode(primValue Primitive, v interface{}) error { md := MetaData{decoded: make(map[string]bool)} return md.unify(primValue.undecoded, rvalue(v)) }
[ "func", "PrimitiveDecode", "(", "primValue", "Primitive", ",", "v", "interface", "{", "}", ")", "error", "{", "md", ":=", "MetaData", "{", "decoded", ":", "make", "(", "map", "[", "string", "]", "bool", ")", "}", "\n", "return", "md", ".", "unify", "...
// DEPRECATED! // // Use MetaData.PrimitiveDecode instead.
[ "DEPRECATED!", "Use", "MetaData", ".", "PrimitiveDecode", "instead", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L49-L52
train
BurntSushi/toml
decode.go
DecodeFile
func DecodeFile(fpath string, v interface{}) (MetaData, error) { bs, err := ioutil.ReadFile(fpath) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
go
func DecodeFile(fpath string, v interface{}) (MetaData, error) { bs, err := ioutil.ReadFile(fpath) if err != nil { return MetaData{}, err } return Decode(string(bs), v) }
[ "func", "DecodeFile", "(", "fpath", "string", ",", "v", "interface", "{", "}", ")", "(", "MetaData", ",", "error", ")", "{", "bs", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "fpath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "MetaD...
// DecodeFile is just like Decode, except it will automatically read the // contents of the file at `fpath` and decode it for you.
[ "DecodeFile", "is", "just", "like", "Decode", "except", "it", "will", "automatically", "read", "the", "contents", "of", "the", "file", "at", "fpath", "and", "decode", "it", "for", "you", "." ]
3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
https://github.com/BurntSushi/toml/blob/3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005/decode.go#L128-L134
train