repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
rightscale/rsc | ca/cac/codegen_client.go | UserSettingLocator | func (api *API) UserSettingLocator(href string) *UserSettingLocator {
return &UserSettingLocator{Href(href), api}
} | go | func (api *API) UserSettingLocator(href string) *UserSettingLocator {
return &UserSettingLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"UserSettingLocator",
"(",
"href",
"string",
")",
"*",
"UserSettingLocator",
"{",
"return",
"&",
"UserSettingLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // UserSettingLocator builds a locator from the given href. | [
"UserSettingLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/cac/codegen_client.go#L3902-L3904 | test |
rightscale/rsc | recorder/main.go | readAllAsync | func readAllAsync(f io.ReadCloser) (*[]byte, chan struct{}) {
done := make(chan struct{}, 1) // signal that the read is done
var buf []byte // placeholder buffer for the result
go func() {
var err error
buf, err = ioutil.ReadAll(f)
if err != nil {
buf = make([]byte, 0)
}
f.Close()
done... | go | func readAllAsync(f io.ReadCloser) (*[]byte, chan struct{}) {
done := make(chan struct{}, 1) // signal that the read is done
var buf []byte // placeholder buffer for the result
go func() {
var err error
buf, err = ioutil.ReadAll(f)
if err != nil {
buf = make([]byte, 0)
}
f.Close()
done... | [
"func",
"readAllAsync",
"(",
"f",
"io",
".",
"ReadCloser",
")",
"(",
"*",
"[",
"]",
"byte",
",",
"chan",
"struct",
"{",
"}",
")",
"{",
"done",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
"\n",
"var",
"buf",
"[",
"]",
"byte",
... | // Read file asynchronously | [
"Read",
"file",
"asynchronously"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/recorder/main.go#L104-L117 | test |
rightscale/rsc | recorder/main.go | extractArg | func extractArg(name string, args []string) (string, []string) {
var val string
var newArgs []string
var skip bool
for i, a := range args {
if skip {
skip = false
continue
}
if strings.Contains(a, "=") {
elems := strings.SplitN(a, "=", 2)
if elems[0] == name {
val = elems[1]
} else {
ne... | go | func extractArg(name string, args []string) (string, []string) {
var val string
var newArgs []string
var skip bool
for i, a := range args {
if skip {
skip = false
continue
}
if strings.Contains(a, "=") {
elems := strings.SplitN(a, "=", 2)
if elems[0] == name {
val = elems[1]
} else {
ne... | [
"func",
"extractArg",
"(",
"name",
"string",
",",
"args",
"[",
"]",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"var",
"val",
"string",
"\n",
"var",
"newArgs",
"[",
"]",
"string",
"\n",
"var",
"skip",
"bool",
"\n",
"for",
"i",
... | // Extract command line argument with given name and return remaining arguments | [
"Extract",
"command",
"line",
"argument",
"with",
"given",
"name",
"and",
"return",
"remaining",
"arguments"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/recorder/main.go#L120-L144 | test |
rightscale/rsc | recorder/main.go | write | func write(b []byte) {
f, err := os.OpenFile(output, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
fail("failed to open output file")
}
f.Write(b)
f.WriteString("\n")
f.Close()
} | go | func write(b []byte) {
f, err := os.OpenFile(output, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
fail("failed to open output file")
}
f.Write(b)
f.WriteString("\n")
f.Close()
} | [
"func",
"write",
"(",
"b",
"[",
"]",
"byte",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"output",
",",
"os",
".",
"O_APPEND",
"|",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_CREATE",
",",
"0644",
")",
"\n",
"if",
"err",
"!=",
... | // Helper function that appends a string to output file | [
"Helper",
"function",
"that",
"appends",
"a",
"string",
"to",
"output",
"file"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/recorder/main.go#L147-L155 | test |
rightscale/rsc | policy/codegen_client.go | AppliedPolicyLocator | func (api *API) AppliedPolicyLocator(href string) *AppliedPolicyLocator {
return &AppliedPolicyLocator{Href(href), api}
} | go | func (api *API) AppliedPolicyLocator(href string) *AppliedPolicyLocator {
return &AppliedPolicyLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"AppliedPolicyLocator",
"(",
"href",
"string",
")",
"*",
"AppliedPolicyLocator",
"{",
"return",
"&",
"AppliedPolicyLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // AppliedPolicyLocator builds a locator from the given href. | [
"AppliedPolicyLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/codegen_client.go#L94-L96 | test |
rightscale/rsc | policy/codegen_client.go | ApprovalLocator | func (api *API) ApprovalLocator(href string) *ApprovalLocator {
return &ApprovalLocator{Href(href), api}
} | go | func (api *API) ApprovalLocator(href string) *ApprovalLocator {
return &ApprovalLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ApprovalLocator",
"(",
"href",
"string",
")",
"*",
"ApprovalLocator",
"{",
"return",
"&",
"ApprovalLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // ApprovalLocator builds a locator from the given href. | [
"ApprovalLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/codegen_client.go#L399-L401 | test |
rightscale/rsc | policy/codegen_client.go | IncidentLocator | func (api *API) IncidentLocator(href string) *IncidentLocator {
return &IncidentLocator{Href(href), api}
} | go | func (api *API) IncidentLocator(href string) *IncidentLocator {
return &IncidentLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"IncidentLocator",
"(",
"href",
"string",
")",
"*",
"IncidentLocator",
"{",
"return",
"&",
"IncidentLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // IncidentLocator builds a locator from the given href. | [
"IncidentLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/codegen_client.go#L610-L612 | test |
rightscale/rsc | policy/codegen_client.go | PolicyTemplateLocator | func (api *API) PolicyTemplateLocator(href string) *PolicyTemplateLocator {
return &PolicyTemplateLocator{Href(href), api}
} | go | func (api *API) PolicyTemplateLocator(href string) *PolicyTemplateLocator {
return &PolicyTemplateLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"PolicyTemplateLocator",
"(",
"href",
"string",
")",
"*",
"PolicyTemplateLocator",
"{",
"return",
"&",
"PolicyTemplateLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // PolicyTemplateLocator builds a locator from the given href. | [
"PolicyTemplateLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/codegen_client.go#L844-L846 | test |
rightscale/rsc | policy/codegen_client.go | PublishedTemplateLocator | func (api *API) PublishedTemplateLocator(href string) *PublishedTemplateLocator {
return &PublishedTemplateLocator{Href(href), api}
} | go | func (api *API) PublishedTemplateLocator(href string) *PublishedTemplateLocator {
return &PublishedTemplateLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"PublishedTemplateLocator",
"(",
"href",
"string",
")",
"*",
"PublishedTemplateLocator",
"{",
"return",
"&",
"PublishedTemplateLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // PublishedTemplateLocator builds a locator from the given href. | [
"PublishedTemplateLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/codegen_client.go#L1129-L1131 | test |
rightscale/rsc | rl10/codegen_client.go | DebugCookbookPathLocator | func (api *API) DebugCookbookPathLocator(href string) *DebugCookbookPathLocator {
return &DebugCookbookPathLocator{Href(href), api}
} | go | func (api *API) DebugCookbookPathLocator(href string) *DebugCookbookPathLocator {
return &DebugCookbookPathLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"DebugCookbookPathLocator",
"(",
"href",
"string",
")",
"*",
"DebugCookbookPathLocator",
"{",
"return",
"&",
"DebugCookbookPathLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // DebugCookbookPathLocator builds a locator from the given href. | [
"DebugCookbookPathLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L71-L73 | test |
rightscale/rsc | rl10/codegen_client.go | DockerControlLocator | func (api *API) DockerControlLocator(href string) *DockerControlLocator {
return &DockerControlLocator{Href(href), api}
} | go | func (api *API) DockerControlLocator(href string) *DockerControlLocator {
return &DockerControlLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"DockerControlLocator",
"(",
"href",
"string",
")",
"*",
"DockerControlLocator",
"{",
"return",
"&",
"DockerControlLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // DockerControlLocator builds a locator from the given href. | [
"DockerControlLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L202-L204 | test |
rightscale/rsc | rl10/codegen_client.go | EnvLocator | func (api *API) EnvLocator(href string) *EnvLocator {
return &EnvLocator{Href(href), api}
} | go | func (api *API) EnvLocator(href string) *EnvLocator {
return &EnvLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"EnvLocator",
"(",
"href",
"string",
")",
"*",
"EnvLocator",
"{",
"return",
"&",
"EnvLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // EnvLocator builds a locator from the given href. | [
"EnvLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L306-L308 | test |
rightscale/rsc | rl10/codegen_client.go | LoginControlLocator | func (api *API) LoginControlLocator(href string) *LoginControlLocator {
return &LoginControlLocator{Href(href), api}
} | go | func (api *API) LoginControlLocator(href string) *LoginControlLocator {
return &LoginControlLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"LoginControlLocator",
"(",
"href",
"string",
")",
"*",
"LoginControlLocator",
"{",
"return",
"&",
"LoginControlLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // LoginControlLocator builds a locator from the given href. | [
"LoginControlLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L474-L476 | test |
rightscale/rsc | rl10/codegen_client.go | ProcLocator | func (api *API) ProcLocator(href string) *ProcLocator {
return &ProcLocator{Href(href), api}
} | go | func (api *API) ProcLocator(href string) *ProcLocator {
return &ProcLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ProcLocator",
"(",
"href",
"string",
")",
"*",
"ProcLocator",
"{",
"return",
"&",
"ProcLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // ProcLocator builds a locator from the given href. | [
"ProcLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L574-L576 | test |
rightscale/rsc | rl10/codegen_client.go | Rl10Locator | func (api *API) Rl10Locator(href string) *Rl10Locator {
return &Rl10Locator{Href(href), api}
} | go | func (api *API) Rl10Locator(href string) *Rl10Locator {
return &Rl10Locator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"Rl10Locator",
"(",
"href",
"string",
")",
"*",
"Rl10Locator",
"{",
"return",
"&",
"Rl10Locator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // Rl10Locator builds a locator from the given href. | [
"Rl10Locator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L712-L714 | test |
rightscale/rsc | rl10/codegen_client.go | TSSLocator | func (api *API) TSSLocator(href string) *TSSLocator {
return &TSSLocator{Href(href), api}
} | go | func (api *API) TSSLocator(href string) *TSSLocator {
return &TSSLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"TSSLocator",
"(",
"href",
"string",
")",
"*",
"TSSLocator",
"{",
"return",
"&",
"TSSLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // TSSLocator builds a locator from the given href. | [
"TSSLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L877-L879 | test |
rightscale/rsc | rl10/codegen_client.go | TSSControlLocator | func (api *API) TSSControlLocator(href string) *TSSControlLocator {
return &TSSControlLocator{Href(href), api}
} | go | func (api *API) TSSControlLocator(href string) *TSSControlLocator {
return &TSSControlLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"TSSControlLocator",
"(",
"href",
"string",
")",
"*",
"TSSControlLocator",
"{",
"return",
"&",
"TSSControlLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // TSSControlLocator builds a locator from the given href. | [
"TSSControlLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L978-L980 | test |
rightscale/rsc | rl10/codegen_client.go | TSSPluginLocator | func (api *API) TSSPluginLocator(href string) *TSSPluginLocator {
return &TSSPluginLocator{Href(href), api}
} | go | func (api *API) TSSPluginLocator(href string) *TSSPluginLocator {
return &TSSPluginLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"TSSPluginLocator",
"(",
"href",
"string",
")",
"*",
"TSSPluginLocator",
"{",
"return",
"&",
"TSSPluginLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // TSSPluginLocator builds a locator from the given href. | [
"TSSPluginLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/codegen_client.go#L1128-L1130 | test |
rightscale/rsc | gen/writers/angular.go | NewAngularWriter | func NewAngularWriter() (*AngularWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"commandLine": commandLine,
"path": path,
"mandatory": mandatory,
}
resourceT, err := template.New("resource-client").Funcs(funcMap).Parse(angularTmpl)
if err != nil {
return nil, err
}
return... | go | func NewAngularWriter() (*AngularWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"commandLine": commandLine,
"path": path,
"mandatory": mandatory,
}
resourceT, err := template.New("resource-client").Funcs(funcMap).Parse(angularTmpl)
if err != nil {
return nil, err
}
return... | [
"func",
"NewAngularWriter",
"(",
")",
"(",
"*",
"AngularWriter",
",",
"error",
")",
"{",
"funcMap",
":=",
"template",
".",
"FuncMap",
"{",
"\"comment\"",
":",
"comment",
",",
"\"commandLine\"",
":",
"commandLine",
",",
"\"path\"",
":",
"path",
",",
"\"mandat... | // NewAngularWriter creates a new code writer that generates angular.js types. | [
"NewAngularWriter",
"creates",
"a",
"new",
"code",
"writer",
"that",
"generates",
"angular",
".",
"js",
"types",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/angular.go#L17-L31 | test |
rightscale/rsc | gen/writers/angular.go | WriteResource | func (c *AngularWriter) WriteResource(resource *gen.Resource, w io.Writer) error {
return c.angularTmpl.Execute(w, resource)
} | go | func (c *AngularWriter) WriteResource(resource *gen.Resource, w io.Writer) error {
return c.angularTmpl.Execute(w, resource)
} | [
"func",
"(",
"c",
"*",
"AngularWriter",
")",
"WriteResource",
"(",
"resource",
"*",
"gen",
".",
"Resource",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"c",
".",
"angularTmpl",
".",
"Execute",
"(",
"w",
",",
"resource",
")",
"\n",
"}"... | // WriteResource writes the code for a resource. | [
"WriteResource",
"writes",
"the",
"code",
"for",
"a",
"resource",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/angular.go#L34-L36 | test |
rightscale/rsc | gen/writers/angular.go | path | func path(a *gen.Action) string {
pattern := a.PathPatterns[0]
vars := pattern.Variables
ivars := make([]interface{}, len(vars))
for i, v := range vars {
ivars[i] = interface{}(":" + v)
}
return fmt.Sprintf(pattern.Pattern, ivars...)
} | go | func path(a *gen.Action) string {
pattern := a.PathPatterns[0]
vars := pattern.Variables
ivars := make([]interface{}, len(vars))
for i, v := range vars {
ivars[i] = interface{}(":" + v)
}
return fmt.Sprintf(pattern.Pattern, ivars...)
} | [
"func",
"path",
"(",
"a",
"*",
"gen",
".",
"Action",
")",
"string",
"{",
"pattern",
":=",
"a",
".",
"PathPatterns",
"[",
"0",
"]",
"\n",
"vars",
":=",
"pattern",
".",
"Variables",
"\n",
"ivars",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
... | // Path for given action, for now simplify and take first path in PathPatterns.
// In the future we may want to create one "action" in generated JS per path. | [
"Path",
"for",
"given",
"action",
"for",
"now",
"simplify",
"and",
"take",
"first",
"path",
"in",
"PathPatterns",
".",
"In",
"the",
"future",
"we",
"may",
"want",
"to",
"create",
"one",
"action",
"in",
"generated",
"JS",
"per",
"path",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/angular.go#L40-L48 | test |
rightscale/rsc | gen/writers/angular.go | mandatory | func mandatory(a gen.Action, param string) bool {
for _, p := range a.Params {
if p.Name == param {
return p.Mandatory
}
}
panic("praxisgen bug: Unknown param " + param + " for action " + a.Name)
} | go | func mandatory(a gen.Action, param string) bool {
for _, p := range a.Params {
if p.Name == param {
return p.Mandatory
}
}
panic("praxisgen bug: Unknown param " + param + " for action " + a.Name)
} | [
"func",
"mandatory",
"(",
"a",
"gen",
".",
"Action",
",",
"param",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"a",
".",
"Params",
"{",
"if",
"p",
".",
"Name",
"==",
"param",
"{",
"return",
"p",
".",
"Mandatory",
"\n",
"}",
... | // Returns true if parameter with given name is mandatory | [
"Returns",
"true",
"if",
"parameter",
"with",
"given",
"name",
"is",
"mandatory"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/angular.go#L51-L58 | test |
rightscale/rsc | rsapi/rsapi.go | New | func New(host string, auth Authenticator) *API {
client := httpclient.New()
if strings.HasPrefix(host, "http://") {
host = host[7:]
} else if strings.HasPrefix(host, "https://") {
host = host[8:]
}
a := &API{
Auth: auth,
Host: host,
Client: client,
}
if auth != nil {
auth.SetHost(host)
}
return... | go | func New(host string, auth Authenticator) *API {
client := httpclient.New()
if strings.HasPrefix(host, "http://") {
host = host[7:]
} else if strings.HasPrefix(host, "https://") {
host = host[8:]
}
a := &API{
Auth: auth,
Host: host,
Client: client,
}
if auth != nil {
auth.SetHost(host)
}
return... | [
"func",
"New",
"(",
"host",
"string",
",",
"auth",
"Authenticator",
")",
"*",
"API",
"{",
"client",
":=",
"httpclient",
".",
"New",
"(",
")",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"host",
",",
"\"http://\"",
")",
"{",
"host",
"=",
"host",
"["... | // New returns a API client that uses the given authenticator.
// host may be blank in which case client attempts to resolve it using auth. | [
"New",
"returns",
"a",
"API",
"client",
"that",
"uses",
"the",
"given",
"authenticator",
".",
"host",
"may",
"be",
"blank",
"in",
"which",
"case",
"client",
"attempts",
"to",
"resolve",
"it",
"using",
"auth",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/rsapi.go#L44-L60 | test |
rightscale/rsc | rsapi/rsapi.go | FromCommandLine | func FromCommandLine(cmdLine *cmd.CommandLine) (*API, error) {
var client *API
ss := strings.HasPrefix(cmdLine.Command, "ss")
if cmdLine.RL10 {
var err error
if client, err = NewRL10(); err != nil {
return nil, err
}
} else if cmdLine.OAuthToken != "" {
auth := NewOAuthAuthenticator(cmdLine.OAuthToken, c... | go | func FromCommandLine(cmdLine *cmd.CommandLine) (*API, error) {
var client *API
ss := strings.HasPrefix(cmdLine.Command, "ss")
if cmdLine.RL10 {
var err error
if client, err = NewRL10(); err != nil {
return nil, err
}
} else if cmdLine.OAuthToken != "" {
auth := NewOAuthAuthenticator(cmdLine.OAuthToken, c... | [
"func",
"FromCommandLine",
"(",
"cmdLine",
"*",
"cmd",
".",
"CommandLine",
")",
"(",
"*",
"API",
",",
"error",
")",
"{",
"var",
"client",
"*",
"API",
"\n",
"ss",
":=",
"strings",
".",
"HasPrefix",
"(",
"cmdLine",
".",
"Command",
",",
"\"ss\"",
")",
"... | // FromCommandLine builds an API client from the command line. | [
"FromCommandLine",
"builds",
"an",
"API",
"client",
"from",
"the",
"command",
"line",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/rsapi.go#L107-L163 | test |
rightscale/rsc | rsapi/rsapi.go | CanAuthenticate | func (a *API) CanAuthenticate() error {
res := a.Auth.CanAuthenticate(a.Host)
return res
} | go | func (a *API) CanAuthenticate() error {
res := a.Auth.CanAuthenticate(a.Host)
return res
} | [
"func",
"(",
"a",
"*",
"API",
")",
"CanAuthenticate",
"(",
")",
"error",
"{",
"res",
":=",
"a",
".",
"Auth",
".",
"CanAuthenticate",
"(",
"a",
".",
"Host",
")",
"\n",
"return",
"res",
"\n",
"}"
] | // CanAuthenticate makes a test authenticated request to the RightScale API and returns an error
// if it fails. | [
"CanAuthenticate",
"makes",
"a",
"test",
"authenticated",
"request",
"to",
"the",
"RightScale",
"API",
"and",
"returns",
"an",
"error",
"if",
"it",
"fails",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/rsapi.go#L167-L170 | test |
rightscale/rsc | encrypt.go | Encrypt | func Encrypt(text string) (string, error) {
bytes := []byte(text)
key := seekret()
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
b := encodeBase64(bytes)
ciphertext := make([]byte, aes.BlockSize+len(b))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil... | go | func Encrypt(text string) (string, error) {
bytes := []byte(text)
key := seekret()
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
b := encodeBase64(bytes)
ciphertext := make([]byte, aes.BlockSize+len(b))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil... | [
"func",
"Encrypt",
"(",
"text",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"bytes",
":=",
"[",
"]",
"byte",
"(",
"text",
")",
"\n",
"key",
":=",
"seekret",
"(",
")",
"\n",
"block",
",",
"err",
":=",
"aes",
".",
"NewCipher",
"(",
"key",... | // Encrypt encrypts the given text with a hard-coded secret. Not truly secure. | [
"Encrypt",
"encrypts",
"the",
"given",
"text",
"with",
"a",
"hard",
"-",
"coded",
"secret",
".",
"Not",
"truly",
"secure",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/encrypt.go#L29-L45 | test |
rightscale/rsc | encrypt.go | Decrypt | func Decrypt(text string) (string, error) {
if text == "" {
return "", nil
}
key := seekret()
bytes := decodeBase64([]byte(text))
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
if len(bytes) < aes.BlockSize {
return "", errors.New("ciphertext too short")
}
iv := bytes[:aes.BlockSize]
... | go | func Decrypt(text string) (string, error) {
if text == "" {
return "", nil
}
key := seekret()
bytes := decodeBase64([]byte(text))
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}
if len(bytes) < aes.BlockSize {
return "", errors.New("ciphertext too short")
}
iv := bytes[:aes.BlockSize]
... | [
"func",
"Decrypt",
"(",
"text",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"text",
"==",
"\"\"",
"{",
"return",
"\"\"",
",",
"nil",
"\n",
"}",
"\n",
"key",
":=",
"seekret",
"(",
")",
"\n",
"bytes",
":=",
"decodeBase64",
"(",
"[",
... | // Decrypt decrypts the given encrypted string using the hard-coded secret. | [
"Decrypt",
"decrypts",
"the",
"given",
"encrypted",
"string",
"using",
"the",
"hard",
"-",
"coded",
"secret",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/encrypt.go#L48-L66 | test |
rightscale/rsc | gen/goav2gen/definition.go | guessType | func (a *APIAnalyzer) guessType(ec EvalCtx, d *Definition, refID string) string {
// First get the type name and and view from the swagger reference definition
// name -- are a few cases where that's the only place that has the view
if t, ok := a.TypeOverrides[refID]; ok {
return t
}
var name, view string
if st... | go | func (a *APIAnalyzer) guessType(ec EvalCtx, d *Definition, refID string) string {
// First get the type name and and view from the swagger reference definition
// name -- are a few cases where that's the only place that has the view
if t, ok := a.TypeOverrides[refID]; ok {
return t
}
var name, view string
if st... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"guessType",
"(",
"ec",
"EvalCtx",
",",
"d",
"*",
"Definition",
",",
"refID",
"string",
")",
"string",
"{",
"if",
"t",
",",
"ok",
":=",
"a",
".",
"TypeOverrides",
"[",
"refID",
"]",
";",
"ok",
"{",
"return... | // guessType tries to guess the resource name based on the definition and service.
// This info is not stored in the swagger. TBD manual overrides if needed. | [
"guessType",
"tries",
"to",
"guess",
"the",
"resource",
"name",
"based",
"on",
"the",
"definition",
"and",
"service",
".",
"This",
"info",
"is",
"not",
"stored",
"in",
"the",
"swagger",
".",
"TBD",
"manual",
"overrides",
"if",
"needed",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/definition.go#L52-L102 | test |
rightscale/rsc | gen/goav2gen/definition.go | addType | func (a *APIAnalyzer) addType(ec EvalCtx, dt *gen.ObjectDataType, r Ref) {
a.api.NeedJSON = true
if a.refByType[dt.TypeName] == r.ID() {
return
}
if other, ok := a.api.Types[dt.TypeName]; ok {
if !ec.IsResult {
// If its an input parameter, fix the collision by amending this types name
dt.TypeName += "Pa... | go | func (a *APIAnalyzer) addType(ec EvalCtx, dt *gen.ObjectDataType, r Ref) {
a.api.NeedJSON = true
if a.refByType[dt.TypeName] == r.ID() {
return
}
if other, ok := a.api.Types[dt.TypeName]; ok {
if !ec.IsResult {
// If its an input parameter, fix the collision by amending this types name
dt.TypeName += "Pa... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"addType",
"(",
"ec",
"EvalCtx",
",",
"dt",
"*",
"gen",
".",
"ObjectDataType",
",",
"r",
"Ref",
")",
"{",
"a",
".",
"api",
".",
"NeedJSON",
"=",
"true",
"\n",
"if",
"a",
".",
"refByType",
"[",
"dt",
".",... | // addType conditionally adds a new type, trying its best to avoid type
// collisions. This is the downside of swagger 2 vs swagger 3. For swagger 2
// if you the same type like "User" returned in multiple places, each have to
// create their own definition in the swagger "definitions" section for goa
// v2. So they'll... | [
"addType",
"conditionally",
"adds",
"a",
"new",
"type",
"trying",
"its",
"best",
"to",
"avoid",
"type",
"collisions",
".",
"This",
"is",
"the",
"downside",
"of",
"swagger",
"2",
"vs",
"swagger",
"3",
".",
"For",
"swagger",
"2",
"if",
"you",
"the",
"same"... | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/definition.go#L207-L244 | test |
rightscale/rsc | gen/goav2gen/api.go | extractCmdLineParams | func extractCmdLineParams(a *gen.ActionParam, root string, seen map[string]*[]*gen.ActionParam, parentNotMandatory bool) []*gen.ActionParam {
switch t := a.Type.(type) {
case *gen.BasicDataType, *gen.EnumerableDataType, *gen.UploadDataType:
dup := gen.ActionParam{
Name: a.Name,
QueryName: root,
De... | go | func extractCmdLineParams(a *gen.ActionParam, root string, seen map[string]*[]*gen.ActionParam, parentNotMandatory bool) []*gen.ActionParam {
switch t := a.Type.(type) {
case *gen.BasicDataType, *gen.EnumerableDataType, *gen.UploadDataType:
dup := gen.ActionParam{
Name: a.Name,
QueryName: root,
De... | [
"func",
"extractCmdLineParams",
"(",
"a",
"*",
"gen",
".",
"ActionParam",
",",
"root",
"string",
",",
"seen",
"map",
"[",
"string",
"]",
"*",
"[",
"]",
"*",
"gen",
".",
"ActionParam",
",",
"parentNotMandatory",
"bool",
")",
"[",
"]",
"*",
"gen",
".",
... | // extractCmdLineParams generates flags for the command line | [
"extractCmdLineParams",
"generates",
"flags",
"for",
"the",
"command",
"line"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/api.go#L122-L163 | test |
rightscale/rsc | gen/writers/metadata.go | NewMetadataWriter | func NewMetadataWriter() (*MetadataWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"join": strings.Join,
"commandLine": commandLine,
"toStringArray": toStringArray,
"flagType": flagType,
"location": location,
"escapeBackticks": escapeBackticks,
}
... | go | func NewMetadataWriter() (*MetadataWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"join": strings.Join,
"commandLine": commandLine,
"toStringArray": toStringArray,
"flagType": flagType,
"location": location,
"escapeBackticks": escapeBackticks,
}
... | [
"func",
"NewMetadataWriter",
"(",
")",
"(",
"*",
"MetadataWriter",
",",
"error",
")",
"{",
"funcMap",
":=",
"template",
".",
"FuncMap",
"{",
"\"comment\"",
":",
"comment",
",",
"\"join\"",
":",
"strings",
".",
"Join",
",",
"\"commandLine\"",
":",
"commandLin... | // NewMetadataWriter creates a new writer that generates metadata data structures. | [
"NewMetadataWriter",
"creates",
"a",
"new",
"writer",
"that",
"generates",
"metadata",
"data",
"structures",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/metadata.go#L18-L40 | test |
rightscale/rsc | gen/writers/metadata.go | WriteHeader | func (c *MetadataWriter) WriteHeader(pkg string, w io.Writer) error {
return c.headerTmpl.Execute(w, pkg)
} | go | func (c *MetadataWriter) WriteHeader(pkg string, w io.Writer) error {
return c.headerTmpl.Execute(w, pkg)
} | [
"func",
"(",
"c",
"*",
"MetadataWriter",
")",
"WriteHeader",
"(",
"pkg",
"string",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"c",
".",
"headerTmpl",
".",
"Execute",
"(",
"w",
",",
"pkg",
")",
"\n",
"}"
] | // WriteHeader writes the generic header text. | [
"WriteHeader",
"writes",
"the",
"generic",
"header",
"text",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/metadata.go#L43-L45 | test |
rightscale/rsc | gen/writers/metadata.go | WriteMetadata | func (c *MetadataWriter) WriteMetadata(d *gen.APIDescriptor, w io.Writer) error {
resources := make([]*gen.Resource, len(d.ResourceNames))
for i, n := range d.ResourceNames {
resources[i] = d.Resources[n]
}
return c.resourceTmpl.Execute(w, resources)
} | go | func (c *MetadataWriter) WriteMetadata(d *gen.APIDescriptor, w io.Writer) error {
resources := make([]*gen.Resource, len(d.ResourceNames))
for i, n := range d.ResourceNames {
resources[i] = d.Resources[n]
}
return c.resourceTmpl.Execute(w, resources)
} | [
"func",
"(",
"c",
"*",
"MetadataWriter",
")",
"WriteMetadata",
"(",
"d",
"*",
"gen",
".",
"APIDescriptor",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"resources",
":=",
"make",
"(",
"[",
"]",
"*",
"gen",
".",
"Resource",
",",
"len",
"(",
"d"... | // WriteMetadata writes the data structures that describe the API resources and actions. | [
"WriteMetadata",
"writes",
"the",
"data",
"structures",
"that",
"describe",
"the",
"API",
"resources",
"and",
"actions",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/metadata.go#L48-L54 | test |
rightscale/rsc | gen/writers/metadata.go | location | func location(p *gen.ActionParam) string {
switch p.Location {
case gen.PathParam:
return "metadata.PathParam"
case gen.QueryParam:
return "metadata.QueryParam"
case gen.PayloadParam:
return "metadata.PayloadParam"
default:
return ""
}
} | go | func location(p *gen.ActionParam) string {
switch p.Location {
case gen.PathParam:
return "metadata.PathParam"
case gen.QueryParam:
return "metadata.QueryParam"
case gen.PayloadParam:
return "metadata.PayloadParam"
default:
return ""
}
} | [
"func",
"location",
"(",
"p",
"*",
"gen",
".",
"ActionParam",
")",
"string",
"{",
"switch",
"p",
".",
"Location",
"{",
"case",
"gen",
".",
"PathParam",
":",
"return",
"\"metadata.PathParam\"",
"\n",
"case",
"gen",
".",
"QueryParam",
":",
"return",
"\"metad... | // Return code corresponding to param location | [
"Return",
"code",
"corresponding",
"to",
"param",
"location"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/metadata.go#L57-L68 | test |
rightscale/rsc | rl10/rl10.go | New | func New(host string, auth rsapi.Authenticator) *API {
return fromAPI(rsapi.New(host, auth))
} | go | func New(host string, auth rsapi.Authenticator) *API {
return fromAPI(rsapi.New(host, auth))
} | [
"func",
"New",
"(",
"host",
"string",
",",
"auth",
"rsapi",
".",
"Authenticator",
")",
"*",
"API",
"{",
"return",
"fromAPI",
"(",
"rsapi",
".",
"New",
"(",
"host",
",",
"auth",
")",
")",
"\n",
"}"
] | // New returns a client that uses RL10 authentication.
// accountId, host and auth arguments are not used.
// If no HTTP client is specified then the default client is used. | [
"New",
"returns",
"a",
"client",
"that",
"uses",
"RL10",
"authentication",
".",
"accountId",
"host",
"and",
"auth",
"arguments",
"are",
"not",
"used",
".",
"If",
"no",
"HTTP",
"client",
"is",
"specified",
"then",
"the",
"default",
"client",
"is",
"used",
"... | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/rl10.go#L16-L18 | test |
rightscale/rsc | rl10/rl10.go | fromAPI | func fromAPI(api *rsapi.API) *API {
api.Metadata = GenMetadata
return &API{api}
} | go | func fromAPI(api *rsapi.API) *API {
api.Metadata = GenMetadata
return &API{api}
} | [
"func",
"fromAPI",
"(",
"api",
"*",
"rsapi",
".",
"API",
")",
"*",
"API",
"{",
"api",
".",
"Metadata",
"=",
"GenMetadata",
"\n",
"return",
"&",
"API",
"{",
"api",
"}",
"\n",
"}"
] | // Wrap generic client into RL10 client | [
"Wrap",
"generic",
"client",
"into",
"RL10",
"client"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rl10/rl10.go#L41-L44 | test |
rightscale/rsc | cm16/http.go | BuildRequest | func (a *API) BuildRequest(resource, action, href string, params rsapi.APIParams) (*http.Request, error) {
// First lookup metadata
res, ok := GenMetadata[resource]
if !ok {
return nil, fmt.Errorf("No resource with name '%s'", resource)
}
act := res.GetAction(action)
if act == nil {
return nil, fmt.Errorf("No... | go | func (a *API) BuildRequest(resource, action, href string, params rsapi.APIParams) (*http.Request, error) {
// First lookup metadata
res, ok := GenMetadata[resource]
if !ok {
return nil, fmt.Errorf("No resource with name '%s'", resource)
}
act := res.GetAction(action)
if act == nil {
return nil, fmt.Errorf("No... | [
"func",
"(",
"a",
"*",
"API",
")",
"BuildRequest",
"(",
"resource",
",",
"action",
",",
"href",
"string",
",",
"params",
"rsapi",
".",
"APIParams",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"res",
",",
"ok",
":=",
"GenMetadata",
... | // BuildRequest builds a HTTP request from a resource name and href and an action name and
// parameters.
// It is intended for generic clients that need to consume APIs in a generic maner.
// The method builds an HTTP request that can be fed to PerformRequest. | [
"BuildRequest",
"builds",
"a",
"HTTP",
"request",
"from",
"a",
"resource",
"name",
"and",
"href",
"and",
"an",
"action",
"name",
"and",
"parameters",
".",
"It",
"is",
"intended",
"for",
"generic",
"clients",
"that",
"need",
"to",
"consume",
"APIs",
"in",
"... | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm16/http.go#L14-L36 | test |
rightscale/rsc | ca/ca.go | setupMetadata | func setupMetadata() (result map[string]*metadata.Resource) {
result = make(map[string]*metadata.Resource)
for n, r := range cac.GenMetadata {
result[n] = r
}
return
} | go | func setupMetadata() (result map[string]*metadata.Resource) {
result = make(map[string]*metadata.Resource)
for n, r := range cac.GenMetadata {
result[n] = r
}
return
} | [
"func",
"setupMetadata",
"(",
")",
"(",
"result",
"map",
"[",
"string",
"]",
"*",
"metadata",
".",
"Resource",
")",
"{",
"result",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"metadata",
".",
"Resource",
")",
"\n",
"for",
"n",
",",
"r",
":=",... | // Initialize GenMetadata from each CA API generated metadata | [
"Initialize",
"GenMetadata",
"from",
"each",
"CA",
"API",
"generated",
"metadata"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/ca.go#L60-L66 | test |
rightscale/rsc | displayer.go | NewDisplayer | func NewDisplayer(resp *http.Response) (*Displayer, error) {
defer resp.Body.Close()
js, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Failed to read response (%s)", err)
}
disp := Displayer{response: resp, body: string(js)}
if len(js) > 2 {
err = json.Unmarshal(js, &disp.RawOutput)... | go | func NewDisplayer(resp *http.Response) (*Displayer, error) {
defer resp.Body.Close()
js, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Failed to read response (%s)", err)
}
disp := Displayer{response: resp, body: string(js)}
if len(js) > 2 {
err = json.Unmarshal(js, &disp.RawOutput)... | [
"func",
"NewDisplayer",
"(",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"*",
"Displayer",
",",
"error",
")",
"{",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"js",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
... | // NewDisplayer creates a new displayer using the response body. | [
"NewDisplayer",
"creates",
"a",
"new",
"displayer",
"using",
"the",
"response",
"body",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/displayer.go#L22-L36 | test |
rightscale/rsc | displayer.go | ApplySingleExtract | func (d *Displayer) ApplySingleExtract(extract string) error {
if err := d.ApplyExtract(extract, true); err != nil {
return err
}
outputs := d.RawOutput.([]interface{})
if len(outputs) != 1 {
d.RawOutput = nil
return fmt.Errorf("JSON selector '%s' returned %d instead of one value",
extract, len(outputs))
... | go | func (d *Displayer) ApplySingleExtract(extract string) error {
if err := d.ApplyExtract(extract, true); err != nil {
return err
}
outputs := d.RawOutput.([]interface{})
if len(outputs) != 1 {
d.RawOutput = nil
return fmt.Errorf("JSON selector '%s' returned %d instead of one value",
extract, len(outputs))
... | [
"func",
"(",
"d",
"*",
"Displayer",
")",
"ApplySingleExtract",
"(",
"extract",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"d",
".",
"ApplyExtract",
"(",
"extract",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",... | // ApplySingleExtract applies the given JSON selector and returns the results.
// It's an error if the selector yields more than one value. | [
"ApplySingleExtract",
"applies",
"the",
"given",
"JSON",
"selector",
"and",
"returns",
"the",
"results",
".",
"It",
"s",
"an",
"error",
"if",
"the",
"selector",
"yields",
"more",
"than",
"one",
"value",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/displayer.go#L40-L66 | test |
rightscale/rsc | displayer.go | ApplyExtract | func (d *Displayer) ApplyExtract(selector string, js bool) error {
parser, err := jsonselect.CreateParserFromString(d.body)
if err != nil {
return fmt.Errorf("Failed to load response JSON: %s, JSON was:\n%s", err, d.body)
}
outputs, err := parser.GetValues(selector)
if !js {
out := ""
for _, o := range outpu... | go | func (d *Displayer) ApplyExtract(selector string, js bool) error {
parser, err := jsonselect.CreateParserFromString(d.body)
if err != nil {
return fmt.Errorf("Failed to load response JSON: %s, JSON was:\n%s", err, d.body)
}
outputs, err := parser.GetValues(selector)
if !js {
out := ""
for _, o := range outpu... | [
"func",
"(",
"d",
"*",
"Displayer",
")",
"ApplyExtract",
"(",
"selector",
"string",
",",
"js",
"bool",
")",
"error",
"{",
"parser",
",",
"err",
":=",
"jsonselect",
".",
"CreateParserFromString",
"(",
"d",
".",
"body",
")",
"\n",
"if",
"err",
"!=",
"nil... | // ApplyExtract applies selector to js. | [
"ApplyExtract",
"applies",
"selector",
"to",
"js",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/displayer.go#L69-L90 | test |
rightscale/rsc | displayer.go | ApplyHeaderExtract | func (d *Displayer) ApplyHeaderExtract(header string) error {
d.RawOutput = d.response.Header.Get(header)
if d.RawOutput == "" {
return fmt.Errorf("Response does not contain the '%s' header", header)
}
return nil
} | go | func (d *Displayer) ApplyHeaderExtract(header string) error {
d.RawOutput = d.response.Header.Get(header)
if d.RawOutput == "" {
return fmt.Errorf("Response does not contain the '%s' header", header)
}
return nil
} | [
"func",
"(",
"d",
"*",
"Displayer",
")",
"ApplyHeaderExtract",
"(",
"header",
"string",
")",
"error",
"{",
"d",
".",
"RawOutput",
"=",
"d",
".",
"response",
".",
"Header",
".",
"Get",
"(",
"header",
")",
"\n",
"if",
"d",
".",
"RawOutput",
"==",
"\"\"... | // ApplyHeaderExtract reads the value of the given header. | [
"ApplyHeaderExtract",
"reads",
"the",
"value",
"of",
"the",
"given",
"header",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/displayer.go#L93-L99 | test |
rightscale/rsc | displayer.go | Output | func (d *Displayer) Output() string {
output := d.RawOutput
if output == nil {
return ""
}
if outputStr, ok := d.RawOutput.(string); ok {
suffix := ""
if d.prettify {
suffix = "\n"
}
return outputStr + suffix
}
var out string
var err error
if d.prettify {
var b []byte
b, err = json.MarshalInden... | go | func (d *Displayer) Output() string {
output := d.RawOutput
if output == nil {
return ""
}
if outputStr, ok := d.RawOutput.(string); ok {
suffix := ""
if d.prettify {
suffix = "\n"
}
return outputStr + suffix
}
var out string
var err error
if d.prettify {
var b []byte
b, err = json.MarshalInden... | [
"func",
"(",
"d",
"*",
"Displayer",
")",
"Output",
"(",
")",
"string",
"{",
"output",
":=",
"d",
".",
"RawOutput",
"\n",
"if",
"output",
"==",
"nil",
"{",
"return",
"\"\"",
"\n",
"}",
"\n",
"if",
"outputStr",
",",
"ok",
":=",
"d",
".",
"RawOutput",... | // Output returns the current output. | [
"Output",
"returns",
"the",
"current",
"output",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/displayer.go#L107-L140 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | NewAPIAnalyzer | func NewAPIAnalyzer(resources map[string]interface{}, attributeTypes map[string]string) *APIAnalyzer {
return &APIAnalyzer{
rawResources: resources,
attributeTypes: attributeTypes,
rawTypes: make(map[string][]*gen.ObjectDataType),
}
} | go | func NewAPIAnalyzer(resources map[string]interface{}, attributeTypes map[string]string) *APIAnalyzer {
return &APIAnalyzer{
rawResources: resources,
attributeTypes: attributeTypes,
rawTypes: make(map[string][]*gen.ObjectDataType),
}
} | [
"func",
"NewAPIAnalyzer",
"(",
"resources",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"attributeTypes",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"APIAnalyzer",
"{",
"return",
"&",
"APIAnalyzer",
"{",
"rawResources",
":",
"resources",
",",
... | // NewAPIAnalyzer is the factory method for the API analyzer | [
"NewAPIAnalyzer",
"is",
"the",
"factory",
"method",
"for",
"the",
"API",
"analyzer"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L39-L45 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | Analyze | func (a *APIAnalyzer) Analyze() *gen.APIDescriptor {
a.AnalyzeAliases()
var descriptor = &gen.APIDescriptor{
Resources: make(map[string]*gen.Resource),
Types: make(map[string]*gen.ObjectDataType),
}
var rawResourceNames = make([]string, len(a.rawResources))
var idx = 0
for n := range a.rawResources {
ra... | go | func (a *APIAnalyzer) Analyze() *gen.APIDescriptor {
a.AnalyzeAliases()
var descriptor = &gen.APIDescriptor{
Resources: make(map[string]*gen.Resource),
Types: make(map[string]*gen.ObjectDataType),
}
var rawResourceNames = make([]string, len(a.rawResources))
var idx = 0
for n := range a.rawResources {
ra... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"Analyze",
"(",
")",
"*",
"gen",
".",
"APIDescriptor",
"{",
"a",
".",
"AnalyzeAliases",
"(",
")",
"\n",
"var",
"descriptor",
"=",
"&",
"gen",
".",
"APIDescriptor",
"{",
"Resources",
":",
"make",
"(",
"map",
... | // Analyze iterate through all resources and initializes the Resources and ParamTypes fields of
// the APIAnalyzer struct accordingly. | [
"Analyze",
"iterate",
"through",
"all",
"resources",
"and",
"initializes",
"the",
"Resources",
"and",
"ParamTypes",
"fields",
"of",
"the",
"APIAnalyzer",
"struct",
"accordingly",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L49-L68 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | AnalyzeAliases | func (a *APIAnalyzer) AnalyzeAliases() {
for from, to := range aliases {
splits := strings.SplitN(from, "#", 2)
fromResName := splits[0]
fromActionName := splits[1]
splits = strings.SplitN(to, "#", 2)
toResName := splits[0]
toActionName := splits[1]
fromRes := a.rawResources[fromResName]
fromAct := fr... | go | func (a *APIAnalyzer) AnalyzeAliases() {
for from, to := range aliases {
splits := strings.SplitN(from, "#", 2)
fromResName := splits[0]
fromActionName := splits[1]
splits = strings.SplitN(to, "#", 2)
toResName := splits[0]
toActionName := splits[1]
fromRes := a.rawResources[fromResName]
fromAct := fr... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"AnalyzeAliases",
"(",
")",
"{",
"for",
"from",
",",
"to",
":=",
"range",
"aliases",
"{",
"splits",
":=",
"strings",
".",
"SplitN",
"(",
"from",
",",
"\"#\"",
",",
"2",
")",
"\n",
"fromResName",
":=",
"split... | // AnalyzeAliases goes through the aliases and copies the details from original actions to the
// aliased actions. It skips the route field since we have the routes hard-coded in the
// ParseRoute function. | [
"AnalyzeAliases",
"goes",
"through",
"the",
"aliases",
"and",
"copies",
"the",
"details",
"from",
"original",
"actions",
"to",
"the",
"aliased",
"actions",
".",
"It",
"skips",
"the",
"route",
"field",
"since",
"we",
"have",
"the",
"routes",
"hard",
"-",
"cod... | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L73-L91 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | LocatorFunc | func LocatorFunc(attributes []*gen.Attribute, name string) string {
hasLinks := false
for _, a := range attributes {
if a.FieldName == "Links" {
hasLinks = true
break
}
}
if !hasLinks {
return ""
}
return `for _, l := range r.Links {
if l["rel"] == "self" {
return api.` + name + `Locator(l["hre... | go | func LocatorFunc(attributes []*gen.Attribute, name string) string {
hasLinks := false
for _, a := range attributes {
if a.FieldName == "Links" {
hasLinks = true
break
}
}
if !hasLinks {
return ""
}
return `for _, l := range r.Links {
if l["rel"] == "self" {
return api.` + name + `Locator(l["hre... | [
"func",
"LocatorFunc",
"(",
"attributes",
"[",
"]",
"*",
"gen",
".",
"Attribute",
",",
"name",
"string",
")",
"string",
"{",
"hasLinks",
":=",
"false",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"attributes",
"{",
"if",
"a",
".",
"FieldName",
"==",
"... | // LocatorFunc returns the source code for building a locator instance from a resource. | [
"LocatorFunc",
"returns",
"the",
"source",
"code",
"for",
"building",
"a",
"locator",
"instance",
"from",
"a",
"resource",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L341-L358 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | ParseRoute | func ParseRoute(moniker string, routes []string) (pathPatterns []*gen.PathPattern) {
// :(((( some routes are empty
var paths []string
var method string
switch moniker {
case "Deployments#servers":
method, paths = "GET", []string{"/api/deployments/:id/servers"}
case "ServerArrays#current_instances":
method, p... | go | func ParseRoute(moniker string, routes []string) (pathPatterns []*gen.PathPattern) {
// :(((( some routes are empty
var paths []string
var method string
switch moniker {
case "Deployments#servers":
method, paths = "GET", []string{"/api/deployments/:id/servers"}
case "ServerArrays#current_instances":
method, p... | [
"func",
"ParseRoute",
"(",
"moniker",
"string",
",",
"routes",
"[",
"]",
"string",
")",
"(",
"pathPatterns",
"[",
"]",
"*",
"gen",
".",
"PathPattern",
")",
"{",
"var",
"paths",
"[",
"]",
"string",
"\n",
"var",
"method",
"string",
"\n",
"switch",
"monik... | // ParseRoute parses a API 1.5 route and returns corresponding path patterns. | [
"ParseRoute",
"parses",
"a",
"API",
"1",
".",
"5",
"route",
"and",
"returns",
"corresponding",
"path",
"patterns",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L361-L413 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | isDeprecated | func isDeprecated(path string) bool {
return strings.Contains(path, "/api/session") && !strings.Contains(path, "/api/sessions")
} | go | func isDeprecated(path string) bool {
return strings.Contains(path, "/api/session") && !strings.Contains(path, "/api/sessions")
} | [
"func",
"isDeprecated",
"(",
"path",
"string",
")",
"bool",
"{",
"return",
"strings",
".",
"Contains",
"(",
"path",
",",
"\"/api/session\"",
")",
"&&",
"!",
"strings",
".",
"Contains",
"(",
"path",
",",
"\"/api/sessions\"",
")",
"\n",
"}"
] | // true if path is for a deprecated API | [
"true",
"if",
"path",
"is",
"for",
"a",
"deprecated",
"API"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L416-L418 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | isQueryParam | func isQueryParam(a, n string) bool {
return n == "view" || n == "filter" || (a == "index" && (n == "with_deleted" || n == "with_inherited" || n == "latest_only" || n == "lineage"))
} | go | func isQueryParam(a, n string) bool {
return n == "view" || n == "filter" || (a == "index" && (n == "with_deleted" || n == "with_inherited" || n == "latest_only" || n == "lineage"))
} | [
"func",
"isQueryParam",
"(",
"a",
",",
"n",
"string",
")",
"bool",
"{",
"return",
"n",
"==",
"\"view\"",
"||",
"n",
"==",
"\"filter\"",
"||",
"(",
"a",
"==",
"\"index\"",
"&&",
"(",
"n",
"==",
"\"with_deleted\"",
"||",
"n",
"==",
"\"with_inherited\"",
... | // Heuristic to determine whether given param is a query string param
// For now only consider view and filter... | [
"Heuristic",
"to",
"determine",
"whether",
"given",
"param",
"is",
"a",
"query",
"string",
"param",
"For",
"now",
"only",
"consider",
"view",
"and",
"filter",
"..."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L427-L429 | test |
rightscale/rsc | gen/api15gen/api_analyzer.go | isPathParam | func isPathParam(p string, pathPatterns []*gen.PathPattern) bool {
for _, pattern := range pathPatterns {
for _, v := range pattern.Variables {
if p == v {
return true
}
}
}
return false
} | go | func isPathParam(p string, pathPatterns []*gen.PathPattern) bool {
for _, pattern := range pathPatterns {
for _, v := range pattern.Variables {
if p == v {
return true
}
}
}
return false
} | [
"func",
"isPathParam",
"(",
"p",
"string",
",",
"pathPatterns",
"[",
"]",
"*",
"gen",
".",
"PathPattern",
")",
"bool",
"{",
"for",
"_",
",",
"pattern",
":=",
"range",
"pathPatterns",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"pattern",
".",
"Variables"... | // Look in given path patterns to chek whether given parameter name corresponds to a variable
// name. | [
"Look",
"in",
"given",
"path",
"patterns",
"to",
"chek",
"whether",
"given",
"parameter",
"name",
"corresponds",
"to",
"a",
"variable",
"name",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/api15gen/api_analyzer.go#L433-L442 | test |
rightscale/rsc | cm15/examples/auditail/main.go | fetchAuditEntries | func fetchAuditEntries(client *cm15.API, filterEmail string) ([]*cm15.AuditEntry, error) {
auditLocator := client.AuditEntryLocator("/api/audit_entries")
var apiParams = rsapi.APIParams{"filter": []string{"user_email==" + filterEmail}}
auditEntries, err := auditLocator.Index(
tomorrow(), // End date
"100", ... | go | func fetchAuditEntries(client *cm15.API, filterEmail string) ([]*cm15.AuditEntry, error) {
auditLocator := client.AuditEntryLocator("/api/audit_entries")
var apiParams = rsapi.APIParams{"filter": []string{"user_email==" + filterEmail}}
auditEntries, err := auditLocator.Index(
tomorrow(), // End date
"100", ... | [
"func",
"fetchAuditEntries",
"(",
"client",
"*",
"cm15",
".",
"API",
",",
"filterEmail",
"string",
")",
"(",
"[",
"]",
"*",
"cm15",
".",
"AuditEntry",
",",
"error",
")",
"{",
"auditLocator",
":=",
"client",
".",
"AuditEntryLocator",
"(",
"\"/api/audit_entrie... | // Make an API call and fetch the audit entries matching specified criteria | [
"Make",
"an",
"API",
"call",
"and",
"fetch",
"the",
"audit",
"entries",
"matching",
"specified",
"criteria"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L72-L85 | test |
rightscale/rsc | cm15/examples/auditail/main.go | formatTime | func formatTime(tm time.Time) string {
year, month, date := tm.Date()
return time.Date(year, month, date, 0, 0, 0, 0, time.UTC).Format("2006/01/02 15:04:05 -0700")
} | go | func formatTime(tm time.Time) string {
year, month, date := tm.Date()
return time.Date(year, month, date, 0, 0, 0, 0, time.UTC).Format("2006/01/02 15:04:05 -0700")
} | [
"func",
"formatTime",
"(",
"tm",
"time",
".",
"Time",
")",
"string",
"{",
"year",
",",
"month",
",",
"date",
":=",
"tm",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"year",
",",
"month",
",",
"date",
",",
"0",
",",
"0",
","... | // Returns time in RightScale API supported format | [
"Returns",
"time",
"in",
"RightScale",
"API",
"supported",
"format"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L98-L101 | test |
rightscale/rsc | cm15/examples/auditail/main.go | printAudits | func printAudits(entries []*cm15.AuditEntry) {
for _, a := range entries {
fmt.Printf("[%v] <%v>: %v\n", a.UpdatedAt, a.UserEmail, a.Summary)
}
} | go | func printAudits(entries []*cm15.AuditEntry) {
for _, a := range entries {
fmt.Printf("[%v] <%v>: %v\n", a.UpdatedAt, a.UserEmail, a.Summary)
}
} | [
"func",
"printAudits",
"(",
"entries",
"[",
"]",
"*",
"cm15",
".",
"AuditEntry",
")",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"entries",
"{",
"fmt",
".",
"Printf",
"(",
"\"[%v] <%v>: %v\\n\"",
",",
"\\n",
",",
"a",
".",
"UpdatedAt",
",",
"a",
".",
... | // Prints the audit entries to console | [
"Prints",
"the",
"audit",
"entries",
"to",
"console"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L104-L108 | test |
rightscale/rsc | cm15/examples/auditail/main.go | extractUnique | func extractUnique(oldEntries, newEntries []*cm15.AuditEntry) []*cm15.AuditEntry {
var uniqueEntries = make([]*cm15.AuditEntry, 0)
var oldHrefs = make([]string, len(oldEntries))
for i, e := range oldEntries {
oldHrefs[i] = getHref(e)
}
for _, newEntry := range newEntries {
if !stringInSlice(getHref(newEntry), ... | go | func extractUnique(oldEntries, newEntries []*cm15.AuditEntry) []*cm15.AuditEntry {
var uniqueEntries = make([]*cm15.AuditEntry, 0)
var oldHrefs = make([]string, len(oldEntries))
for i, e := range oldEntries {
oldHrefs[i] = getHref(e)
}
for _, newEntry := range newEntries {
if !stringInSlice(getHref(newEntry), ... | [
"func",
"extractUnique",
"(",
"oldEntries",
",",
"newEntries",
"[",
"]",
"*",
"cm15",
".",
"AuditEntry",
")",
"[",
"]",
"*",
"cm15",
".",
"AuditEntry",
"{",
"var",
"uniqueEntries",
"=",
"make",
"(",
"[",
"]",
"*",
"cm15",
".",
"AuditEntry",
",",
"0",
... | // Extract unique audit entries from the newly received list by comparing the href of audit entries
// in the old list. | [
"Extract",
"unique",
"audit",
"entries",
"from",
"the",
"newly",
"received",
"list",
"by",
"comparing",
"the",
"href",
"of",
"audit",
"entries",
"in",
"the",
"old",
"list",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L112-L124 | test |
rightscale/rsc | cm15/examples/auditail/main.go | getHref | func getHref(entry *cm15.AuditEntry) string {
var href string
for _, link := range entry.Links {
if link["rel"] == "self" {
href = link["href"]
break
}
}
return href
} | go | func getHref(entry *cm15.AuditEntry) string {
var href string
for _, link := range entry.Links {
if link["rel"] == "self" {
href = link["href"]
break
}
}
return href
} | [
"func",
"getHref",
"(",
"entry",
"*",
"cm15",
".",
"AuditEntry",
")",
"string",
"{",
"var",
"href",
"string",
"\n",
"for",
"_",
",",
"link",
":=",
"range",
"entry",
".",
"Links",
"{",
"if",
"link",
"[",
"\"rel\"",
"]",
"==",
"\"self\"",
"{",
"href",
... | // Get the href of an audit entry from the Links attribute by inspecting the self link | [
"Get",
"the",
"href",
"of",
"an",
"audit",
"entry",
"from",
"the",
"Links",
"attribute",
"by",
"inspecting",
"the",
"self",
"link"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L127-L136 | test |
rightscale/rsc | cm15/examples/auditail/main.go | fail | func fail(format string, v ...interface{}) {
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
fmt.Println(fmt.Sprintf(format, v...))
os.Exit(1)
} | go | func fail(format string, v ...interface{}) {
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
fmt.Println(fmt.Sprintf(format, v...))
os.Exit(1)
} | [
"func",
"fail",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"format",
",",
"\"\\n\"",
")",
"\\n",
"\n",
"{",
"format",
"+=",
"\"\\n\"",
"\n",
"}",
"\n",
"\\n",
"\n",
"}"
] | // Print error message and exit with code 1 | [
"Print",
"error",
"message",
"and",
"exit",
"with",
"code",
"1"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/examples/auditail/main.go#L149-L155 | test |
rightscale/rsc | gen/writers/helpers.go | parameters | func parameters(a *gen.Action) string {
var m = a.MandatoryParams()
var hasOptional = a.HasOptionalParams()
var countParams = len(m)
if hasOptional {
countParams++
}
var params = make([]string, countParams)
for i, param := range m {
params[i] = fmt.Sprintf("%s %s", fixReserved(param.VarName), param.Signature... | go | func parameters(a *gen.Action) string {
var m = a.MandatoryParams()
var hasOptional = a.HasOptionalParams()
var countParams = len(m)
if hasOptional {
countParams++
}
var params = make([]string, countParams)
for i, param := range m {
params[i] = fmt.Sprintf("%s %s", fixReserved(param.VarName), param.Signature... | [
"func",
"parameters",
"(",
"a",
"*",
"gen",
".",
"Action",
")",
"string",
"{",
"var",
"m",
"=",
"a",
".",
"MandatoryParams",
"(",
")",
"\n",
"var",
"hasOptional",
"=",
"a",
".",
"HasOptionalParams",
"(",
")",
"\n",
"var",
"countParams",
"=",
"len",
"... | // Serialize action parameters | [
"Serialize",
"action",
"parameters"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L90-L106 | test |
rightscale/rsc | gen/writers/helpers.go | paramsInitializer | func paramsInitializer(action *gen.Action, location int, varName string) string {
var fields []string
var optionals []*gen.ActionParam
varName = fixReserved(varName)
for _, param := range action.Params {
if param.Location != location {
continue
}
if param.Mandatory {
name := param.Name
if location ==... | go | func paramsInitializer(action *gen.Action, location int, varName string) string {
var fields []string
var optionals []*gen.ActionParam
varName = fixReserved(varName)
for _, param := range action.Params {
if param.Location != location {
continue
}
if param.Mandatory {
name := param.Name
if location ==... | [
"func",
"paramsInitializer",
"(",
"action",
"*",
"gen",
".",
"Action",
",",
"location",
"int",
",",
"varName",
"string",
")",
"string",
"{",
"var",
"fields",
"[",
"]",
"string",
"\n",
"var",
"optionals",
"[",
"]",
"*",
"gen",
".",
"ActionParam",
"\n",
... | // Produces code that initializes a APIParams struct with the values of parameters for the given
// action and location. | [
"Produces",
"code",
"that",
"initializes",
"a",
"APIParams",
"struct",
"with",
"the",
"values",
"of",
"parameters",
"for",
"the",
"given",
"action",
"and",
"location",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L110-L146 | test |
rightscale/rsc | gen/writers/helpers.go | commandLine | func commandLine() string {
return fmt.Sprintf("$ %s %s", os.Args[0], strings.Join(os.Args[1:], " "))
} | go | func commandLine() string {
return fmt.Sprintf("$ %s %s", os.Args[0], strings.Join(os.Args[1:], " "))
} | [
"func",
"commandLine",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"$ %s %s\"",
",",
"os",
".",
"Args",
"[",
"0",
"]",
",",
"strings",
".",
"Join",
"(",
"os",
".",
"Args",
"[",
"1",
":",
"]",
",",
"\" \"",
")",
")",
"\n",
"... | // Command line used to run tool | [
"Command",
"line",
"used",
"to",
"run",
"tool"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L149-L151 | test |
rightscale/rsc | gen/writers/helpers.go | toVerb | func toVerb(text string) (res string) {
res = strings.ToUpper(string(text[0])) + strings.ToLower(text[1:])
if text == "GET" || text == "POST" {
res += "Raw"
}
return
} | go | func toVerb(text string) (res string) {
res = strings.ToUpper(string(text[0])) + strings.ToLower(text[1:])
if text == "GET" || text == "POST" {
res += "Raw"
}
return
} | [
"func",
"toVerb",
"(",
"text",
"string",
")",
"(",
"res",
"string",
")",
"{",
"res",
"=",
"strings",
".",
"ToUpper",
"(",
"string",
"(",
"text",
"[",
"0",
"]",
")",
")",
"+",
"strings",
".",
"ToLower",
"(",
"text",
"[",
"1",
":",
"]",
")",
"\n"... | // GET => Get | [
"GET",
"=",
">",
"Get"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L174-L180 | test |
rightscale/rsc | gen/writers/helpers.go | escapeBackticks | func escapeBackticks(d string) string {
elems := strings.Split(d, "`")
return strings.Join(elems, "` + `")
} | go | func escapeBackticks(d string) string {
elems := strings.Split(d, "`")
return strings.Join(elems, "` + `")
} | [
"func",
"escapeBackticks",
"(",
"d",
"string",
")",
"string",
"{",
"elems",
":=",
"strings",
".",
"Split",
"(",
"d",
",",
"\"`\"",
")",
"\n",
"return",
"strings",
".",
"Join",
"(",
"elems",
",",
"\"` + `\"",
")",
"\n",
"}"
] | // Escape ` in string to be wrapped in them | [
"Escape",
"in",
"string",
"to",
"be",
"wrapped",
"in",
"them"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L200-L203 | test |
rightscale/rsc | ss/ssc/codegen_client.go | AccountPreferenceLocator | func (api *API) AccountPreferenceLocator(href string) *AccountPreferenceLocator {
return &AccountPreferenceLocator{Href(href), api}
} | go | func (api *API) AccountPreferenceLocator(href string) *AccountPreferenceLocator {
return &AccountPreferenceLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"AccountPreferenceLocator",
"(",
"href",
"string",
")",
"*",
"AccountPreferenceLocator",
"{",
"return",
"&",
"AccountPreferenceLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // AccountPreferenceLocator builds a locator from the given href. | [
"AccountPreferenceLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L87-L89 | test |
rightscale/rsc | ss/ssc/codegen_client.go | ApplicationLocator | func (api *API) ApplicationLocator(href string) *ApplicationLocator {
return &ApplicationLocator{Href(href), api}
} | go | func (api *API) ApplicationLocator(href string) *ApplicationLocator {
return &ApplicationLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ApplicationLocator",
"(",
"href",
"string",
")",
"*",
"ApplicationLocator",
"{",
"return",
"&",
"ApplicationLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // ApplicationLocator builds a locator from the given href. | [
"ApplicationLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L293-L295 | test |
rightscale/rsc | ss/ssc/codegen_client.go | EndUserLocator | func (api *API) EndUserLocator(href string) *EndUserLocator {
return &EndUserLocator{Href(href), api}
} | go | func (api *API) EndUserLocator(href string) *EndUserLocator {
return &EndUserLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"EndUserLocator",
"(",
"href",
"string",
")",
"*",
"EndUserLocator",
"{",
"return",
"&",
"EndUserLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // EndUserLocator builds a locator from the given href. | [
"EndUserLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L756-L758 | test |
rightscale/rsc | ss/ssc/codegen_client.go | NotificationRuleLocator | func (api *API) NotificationRuleLocator(href string) *NotificationRuleLocator {
return &NotificationRuleLocator{Href(href), api}
} | go | func (api *API) NotificationRuleLocator(href string) *NotificationRuleLocator {
return &NotificationRuleLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"NotificationRuleLocator",
"(",
"href",
"string",
")",
"*",
"NotificationRuleLocator",
"{",
"return",
"&",
"NotificationRuleLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // NotificationRuleLocator builds a locator from the given href. | [
"NotificationRuleLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L949-L951 | test |
rightscale/rsc | ss/ssc/codegen_client.go | UserPreferenceLocator | func (api *API) UserPreferenceLocator(href string) *UserPreferenceLocator {
return &UserPreferenceLocator{Href(href), api}
} | go | func (api *API) UserPreferenceLocator(href string) *UserPreferenceLocator {
return &UserPreferenceLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"UserPreferenceLocator",
"(",
"href",
"string",
")",
"*",
"UserPreferenceLocator",
"{",
"return",
"&",
"UserPreferenceLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // UserPreferenceLocator builds a locator from the given href. | [
"UserPreferenceLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L1241-L1243 | test |
rightscale/rsc | ss/ssc/codegen_client.go | UserPreferenceInfoLocator | func (api *API) UserPreferenceInfoLocator(href string) *UserPreferenceInfoLocator {
return &UserPreferenceInfoLocator{Href(href), api}
} | go | func (api *API) UserPreferenceInfoLocator(href string) *UserPreferenceInfoLocator {
return &UserPreferenceInfoLocator{Href(href), api}
} | [
"func",
"(",
"api",
"*",
"API",
")",
"UserPreferenceInfoLocator",
"(",
"href",
"string",
")",
"*",
"UserPreferenceInfoLocator",
"{",
"return",
"&",
"UserPreferenceInfoLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] | // UserPreferenceInfoLocator builds a locator from the given href. | [
"UserPreferenceInfoLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L1487-L1489 | test |
rightscale/rsc | config.go | LoadConfig | func LoadConfig(path string) (*ClientConfig, error) {
content, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var config ClientConfig
err = json.Unmarshal(content, &config)
if err != nil {
return nil, err
}
config.Password, err = Decrypt(config.Password)
if err != nil {
return nil, err
}... | go | func LoadConfig(path string) (*ClientConfig, error) {
content, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var config ClientConfig
err = json.Unmarshal(content, &config)
if err != nil {
return nil, err
}
config.Password, err = Decrypt(config.Password)
if err != nil {
return nil, err
}... | [
"func",
"LoadConfig",
"(",
"path",
"string",
")",
"(",
"*",
"ClientConfig",
",",
"error",
")",
"{",
"content",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // LoadConfig loads the client configuration from disk | [
"LoadConfig",
"loads",
"the",
"client",
"configuration",
"from",
"disk"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/config.go#L20-L36 | test |
rightscale/rsc | config.go | CreateConfig | func CreateConfig(path string) error {
config, _ := LoadConfig(path)
var emailDef, passwordDef, accountDef, hostDef, refreshTokenDef string
if config != nil {
yn := PromptConfirmation("Found existing configuration file %v, overwrite? (y/N): ", path)
if yn != "y" {
PrintSuccess("Exiting")
return nil
}
e... | go | func CreateConfig(path string) error {
config, _ := LoadConfig(path)
var emailDef, passwordDef, accountDef, hostDef, refreshTokenDef string
if config != nil {
yn := PromptConfirmation("Found existing configuration file %v, overwrite? (y/N): ", path)
if yn != "y" {
PrintSuccess("Exiting")
return nil
}
e... | [
"func",
"CreateConfig",
"(",
"path",
"string",
")",
"error",
"{",
"config",
",",
"_",
":=",
"LoadConfig",
"(",
"path",
")",
"\n",
"var",
"emailDef",
",",
"passwordDef",
",",
"accountDef",
",",
"hostDef",
",",
"refreshTokenDef",
"string",
"\n",
"if",
"confi... | // CreateConfig creates a configuration file and saves it to the file at the given path. | [
"CreateConfig",
"creates",
"a",
"configuration",
"file",
"and",
"saves",
"it",
"to",
"the",
"file",
"at",
"the",
"given",
"path",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/config.go#L63-L129 | test |
rightscale/rsc | policy/auth.go | fromAPI | func fromAPI(api *rsapi.API) *API {
api.FileEncoding = rsapi.FileEncodingJSON
api.Host = HostFromLogin(api.Host)
api.Metadata = GenMetadata
api.VersionHeader = "Api-Version"
return &API{api}
} | go | func fromAPI(api *rsapi.API) *API {
api.FileEncoding = rsapi.FileEncodingJSON
api.Host = HostFromLogin(api.Host)
api.Metadata = GenMetadata
api.VersionHeader = "Api-Version"
return &API{api}
} | [
"func",
"fromAPI",
"(",
"api",
"*",
"rsapi",
".",
"API",
")",
"*",
"API",
"{",
"api",
".",
"FileEncoding",
"=",
"rsapi",
".",
"FileEncodingJSON",
"\n",
"api",
".",
"Host",
"=",
"HostFromLogin",
"(",
"api",
".",
"Host",
")",
"\n",
"api",
".",
"Metadat... | // Wrap generic client into API 1.0 client | [
"Wrap",
"generic",
"client",
"into",
"API",
"1",
".",
"0",
"client"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/auth.go#L35-L41 | test |
rightscale/rsc | policy/auth.go | HostFromLogin | func HostFromLogin(host string) string {
urlElems := strings.Split(host, ".")
hostPrefix := urlElems[0]
elems := strings.Split(hostPrefix, "-")
if len(elems) == 1 && elems[0] == "cm" {
// accommodates micromoo host inference, such as "cm.rightscale.local" => "selfservice.rightscale.local"
elems[0] = "governanc... | go | func HostFromLogin(host string) string {
urlElems := strings.Split(host, ".")
hostPrefix := urlElems[0]
elems := strings.Split(hostPrefix, "-")
if len(elems) == 1 && elems[0] == "cm" {
// accommodates micromoo host inference, such as "cm.rightscale.local" => "selfservice.rightscale.local"
elems[0] = "governanc... | [
"func",
"HostFromLogin",
"(",
"host",
"string",
")",
"string",
"{",
"urlElems",
":=",
"strings",
".",
"Split",
"(",
"host",
",",
"\".\"",
")",
"\n",
"hostPrefix",
":=",
"urlElems",
"[",
"0",
"]",
"\n",
"elems",
":=",
"strings",
".",
"Split",
"(",
"host... | // HostFromLogin returns the policy endpoint from its login endpoint.
// The following isn't great but seems better than having to enter by hand. | [
"HostFromLogin",
"returns",
"the",
"policy",
"endpoint",
"from",
"its",
"login",
"endpoint",
".",
"The",
"following",
"isn",
"t",
"great",
"but",
"seems",
"better",
"than",
"having",
"to",
"enter",
"by",
"hand",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/policy/auth.go#L45-L61 | test |
rightscale/rsc | gen/goav2gen/param.go | AnalyzeParam | func (a *APIAnalyzer) AnalyzeParam(ec EvalCtx, p *Parameter) *gen.ActionParam {
location, ok := loc[p.In]
if !ok {
location = -1
}
ap := &gen.ActionParam{
Name: p.Name,
QueryName: p.Name,
Description: cleanDescription(p.Description),
VarName: toVarName(p.Name),
Location: location,
Mand... | go | func (a *APIAnalyzer) AnalyzeParam(ec EvalCtx, p *Parameter) *gen.ActionParam {
location, ok := loc[p.In]
if !ok {
location = -1
}
ap := &gen.ActionParam{
Name: p.Name,
QueryName: p.Name,
Description: cleanDescription(p.Description),
VarName: toVarName(p.Name),
Location: location,
Mand... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"AnalyzeParam",
"(",
"ec",
"EvalCtx",
",",
"p",
"*",
"Parameter",
")",
"*",
"gen",
".",
"ActionParam",
"{",
"location",
",",
"ok",
":=",
"loc",
"[",
"p",
".",
"In",
"]",
"\n",
"if",
"!",
"ok",
"{",
"loca... | // AnalyzeParam analyzes input parameters to methods | [
"AnalyzeParam",
"analyzes",
"input",
"parameters",
"to",
"methods"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/param.go#L15-L38 | test |
rightscale/rsc | gen/praxisgen/type_analysis.go | AnalyzeAttribute | func (a *APIAnalyzer) AnalyzeAttribute(name, query string, attr map[string]interface{}) (*gen.ActionParam, error) {
param := gen.ActionParam{Name: name, QueryName: query, VarName: toVarName(name)}
if d, ok := attr["description"]; ok {
param.Description = removeBlankLines(d.(string))
}
if r, ok := attr["required"]... | go | func (a *APIAnalyzer) AnalyzeAttribute(name, query string, attr map[string]interface{}) (*gen.ActionParam, error) {
param := gen.ActionParam{Name: name, QueryName: query, VarName: toVarName(name)}
if d, ok := attr["description"]; ok {
param.Description = removeBlankLines(d.(string))
}
if r, ok := attr["required"]... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"AnalyzeAttribute",
"(",
"name",
",",
"query",
"string",
",",
"attr",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"*",
"gen",
".",
"ActionParam",
",",
"error",
")",
"{",
"param",
":=",
"gen",... | // AnalyzeAttribute analyzes an attribute creating a corresponding ActionParam. | [
"AnalyzeAttribute",
"analyzes",
"an",
"attribute",
"creating",
"a",
"corresponding",
"ActionParam",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/type_analysis.go#L17-L57 | test |
rightscale/rsc | gen/praxisgen/type_analysis.go | AnalyzeType | func (a *APIAnalyzer) AnalyzeType(typeDef map[string]interface{}, query string) (gen.DataType, error) {
n, ok := typeDef["name"].(string)
if !ok {
n = "Struct" // Assume inline struct (e.g. payload types)
}
if strings.HasSuffix(n, "FileUpload") {
// A little bit hacky but this is to make upload work with restic... | go | func (a *APIAnalyzer) AnalyzeType(typeDef map[string]interface{}, query string) (gen.DataType, error) {
n, ok := typeDef["name"].(string)
if !ok {
n = "Struct" // Assume inline struct (e.g. payload types)
}
if strings.HasSuffix(n, "FileUpload") {
// A little bit hacky but this is to make upload work with restic... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"AnalyzeType",
"(",
"typeDef",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"query",
"string",
")",
"(",
"gen",
".",
"DataType",
",",
"error",
")",
"{",
"n",
",",
"ok",
":=",
"typeDef",
"[",
"\"n... | // AnalyzeType analyzes a type given its JSON definition. | [
"AnalyzeType",
"analyzes",
"a",
"type",
"given",
"its",
"JSON",
"definition",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/type_analysis.go#L60-L184 | test |
rightscale/rsc | gen/praxisgen/type_analysis.go | CreateType | func (a *APIAnalyzer) CreateType(query string, attributes map[string]interface{}) (*gen.ObjectDataType, error) {
name := inflect.Camelize(bracketRegexp.ReplaceAllLiteralString(query, "_") + "_struct")
obj := a.Registry.CreateInlineType(name)
obj.Fields = make([]*gen.ActionParam, len(attributes))
for idx, an := rang... | go | func (a *APIAnalyzer) CreateType(query string, attributes map[string]interface{}) (*gen.ObjectDataType, error) {
name := inflect.Camelize(bracketRegexp.ReplaceAllLiteralString(query, "_") + "_struct")
obj := a.Registry.CreateInlineType(name)
obj.Fields = make([]*gen.ActionParam, len(attributes))
for idx, an := rang... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"CreateType",
"(",
"query",
"string",
",",
"attributes",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"*",
"gen",
".",
"ObjectDataType",
",",
"error",
")",
"{",
"name",
":=",
"inflect",
".",
"... | // CreateType is a helper method that creates or retrieve a object data type given its attributes. | [
"CreateType",
"is",
"a",
"helper",
"method",
"that",
"creates",
"or",
"retrieve",
"a",
"object",
"data",
"type",
"given",
"its",
"attributes",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/type_analysis.go#L187-L206 | test |
rightscale/rsc | gen/goav2gen/swagger.go | Ref | func (d *Doc) Ref(r Ref) *Definition {
if refIF, ok := r["$ref"]; ok {
refKey := strings.TrimPrefix(refIF.(string), "#/definitions/")
return d.Definitions[refKey]
}
return nil
} | go | func (d *Doc) Ref(r Ref) *Definition {
if refIF, ok := r["$ref"]; ok {
refKey := strings.TrimPrefix(refIF.(string), "#/definitions/")
return d.Definitions[refKey]
}
return nil
} | [
"func",
"(",
"d",
"*",
"Doc",
")",
"Ref",
"(",
"r",
"Ref",
")",
"*",
"Definition",
"{",
"if",
"refIF",
",",
"ok",
":=",
"r",
"[",
"\"$ref\"",
"]",
";",
"ok",
"{",
"refKey",
":=",
"strings",
".",
"TrimPrefix",
"(",
"refIF",
".",
"(",
"string",
"... | // Ref gets a definition for a Schema reference, if it exists | [
"Ref",
"gets",
"a",
"definition",
"for",
"a",
"Schema",
"reference",
"if",
"it",
"exists"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L110-L116 | test |
rightscale/rsc | gen/goav2gen/swagger.go | Type | func (r Ref) Type() string {
if _, ok := r["$ref"]; ok {
return "object"
}
if refIF, ok := r["type"]; ok {
return refIF.(string)
}
return ""
} | go | func (r Ref) Type() string {
if _, ok := r["$ref"]; ok {
return "object"
}
if refIF, ok := r["type"]; ok {
return refIF.(string)
}
return ""
} | [
"func",
"(",
"r",
"Ref",
")",
"Type",
"(",
")",
"string",
"{",
"if",
"_",
",",
"ok",
":=",
"r",
"[",
"\"$ref\"",
"]",
";",
"ok",
"{",
"return",
"\"object\"",
"\n",
"}",
"\n",
"if",
"refIF",
",",
"ok",
":=",
"r",
"[",
"\"type\"",
"]",
";",
"ok... | // Type gets a type for a Schema reference, if it exists | [
"Type",
"gets",
"a",
"type",
"for",
"a",
"Schema",
"reference",
"if",
"it",
"exists"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L119-L127 | test |
rightscale/rsc | gen/goav2gen/swagger.go | Required | func (r Ref) Required() []string {
if refIF, ok := r["required"]; ok {
return refIF.([]string)
}
return []string{}
} | go | func (r Ref) Required() []string {
if refIF, ok := r["required"]; ok {
return refIF.([]string)
}
return []string{}
} | [
"func",
"(",
"r",
"Ref",
")",
"Required",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"refIF",
",",
"ok",
":=",
"r",
"[",
"\"required\"",
"]",
";",
"ok",
"{",
"return",
"refIF",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"}",
"\n",
"return",
"[",
... | // Required gets a type for a Schema reference, if it exists | [
"Required",
"gets",
"a",
"type",
"for",
"a",
"Schema",
"reference",
"if",
"it",
"exists"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L130-L135 | test |
rightscale/rsc | gen/goav2gen/swagger.go | ID | func (r Ref) ID() string {
if refIF, ok := r["$ref"]; ok {
return strings.TrimPrefix(refIF.(string), "#/definitions/")
}
return ""
} | go | func (r Ref) ID() string {
if refIF, ok := r["$ref"]; ok {
return strings.TrimPrefix(refIF.(string), "#/definitions/")
}
return ""
} | [
"func",
"(",
"r",
"Ref",
")",
"ID",
"(",
")",
"string",
"{",
"if",
"refIF",
",",
"ok",
":=",
"r",
"[",
"\"$ref\"",
"]",
";",
"ok",
"{",
"return",
"strings",
".",
"TrimPrefix",
"(",
"refIF",
".",
"(",
"string",
")",
",",
"\"#/definitions/\"",
")",
... | // ID of the reference | [
"ID",
"of",
"the",
"reference"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L138-L143 | test |
rightscale/rsc | gen/goav2gen/swagger.go | Service | func (ep *Endpoint) Service() string {
if len(ep.Tags) > 0 {
return ep.Tags[0]
}
if len(ep.OperationID) > 0 {
return strings.Split(ep.OperationID, "#")[0]
}
return ""
} | go | func (ep *Endpoint) Service() string {
if len(ep.Tags) > 0 {
return ep.Tags[0]
}
if len(ep.OperationID) > 0 {
return strings.Split(ep.OperationID, "#")[0]
}
return ""
} | [
"func",
"(",
"ep",
"*",
"Endpoint",
")",
"Service",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"ep",
".",
"Tags",
")",
">",
"0",
"{",
"return",
"ep",
".",
"Tags",
"[",
"0",
"]",
"\n",
"}",
"\n",
"if",
"len",
"(",
"ep",
".",
"OperationID",
")"... | // Service returns the goa.v2 service | [
"Service",
"returns",
"the",
"goa",
".",
"v2",
"service"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L146-L154 | test |
rightscale/rsc | gen/goav2gen/swagger.go | Method | func (ep *Endpoint) Method() string {
if strings.Contains(ep.OperationID, "#") {
return strings.Split(ep.OperationID, "#")[1]
}
return ""
} | go | func (ep *Endpoint) Method() string {
if strings.Contains(ep.OperationID, "#") {
return strings.Split(ep.OperationID, "#")[1]
}
return ""
} | [
"func",
"(",
"ep",
"*",
"Endpoint",
")",
"Method",
"(",
")",
"string",
"{",
"if",
"strings",
".",
"Contains",
"(",
"ep",
".",
"OperationID",
",",
"\"#\"",
")",
"{",
"return",
"strings",
".",
"Split",
"(",
"ep",
".",
"OperationID",
",",
"\"#\"",
")",
... | // Methods returns the goa.v2 method | [
"Methods",
"returns",
"the",
"goa",
".",
"v2",
"method"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/swagger.go#L157-L162 | test |
rightscale/rsc | gen/praxisgen/api_analyzer.go | NewTypeRegistry | func NewTypeRegistry() *TypeRegistry {
return &TypeRegistry{
NamedTypes: make(map[string]*gen.ObjectDataType),
InlineTypes: make(map[string][]*gen.ObjectDataType),
}
} | go | func NewTypeRegistry() *TypeRegistry {
return &TypeRegistry{
NamedTypes: make(map[string]*gen.ObjectDataType),
InlineTypes: make(map[string][]*gen.ObjectDataType),
}
} | [
"func",
"NewTypeRegistry",
"(",
")",
"*",
"TypeRegistry",
"{",
"return",
"&",
"TypeRegistry",
"{",
"NamedTypes",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"gen",
".",
"ObjectDataType",
")",
",",
"InlineTypes",
":",
"make",
"(",
"map",
"[",
"strin... | // NewTypeRegistry creates a type registry. | [
"NewTypeRegistry",
"creates",
"a",
"type",
"registry",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/api_analyzer.go#L83-L88 | test |
rightscale/rsc | gen/praxisgen/api_analyzer.go | GetNamedType | func (reg *TypeRegistry) GetNamedType(name string) *gen.ObjectDataType {
return reg.NamedTypes[toGoTypeName(name)]
} | go | func (reg *TypeRegistry) GetNamedType(name string) *gen.ObjectDataType {
return reg.NamedTypes[toGoTypeName(name)]
} | [
"func",
"(",
"reg",
"*",
"TypeRegistry",
")",
"GetNamedType",
"(",
"name",
"string",
")",
"*",
"gen",
".",
"ObjectDataType",
"{",
"return",
"reg",
".",
"NamedTypes",
"[",
"toGoTypeName",
"(",
"name",
")",
"]",
"\n",
"}"
] | // GetNamedType retrieves a type given its name. | [
"GetNamedType",
"retrieves",
"a",
"type",
"given",
"its",
"name",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/api_analyzer.go#L91-L93 | test |
rightscale/rsc | gen/praxisgen/api_analyzer.go | CreateNamedType | func (reg *TypeRegistry) CreateNamedType(name string) *gen.ObjectDataType {
goName := toGoTypeName(name)
obj := gen.ObjectDataType{TypeName: goName}
if _, ok := reg.NamedTypes[goName]; ok {
panic("BUG: Can't create two named types with same name....")
}
reg.NamedTypes[goName] = &obj
return &obj
} | go | func (reg *TypeRegistry) CreateNamedType(name string) *gen.ObjectDataType {
goName := toGoTypeName(name)
obj := gen.ObjectDataType{TypeName: goName}
if _, ok := reg.NamedTypes[goName]; ok {
panic("BUG: Can't create two named types with same name....")
}
reg.NamedTypes[goName] = &obj
return &obj
} | [
"func",
"(",
"reg",
"*",
"TypeRegistry",
")",
"CreateNamedType",
"(",
"name",
"string",
")",
"*",
"gen",
".",
"ObjectDataType",
"{",
"goName",
":=",
"toGoTypeName",
"(",
"name",
")",
"\n",
"obj",
":=",
"gen",
".",
"ObjectDataType",
"{",
"TypeName",
":",
... | // CreateNamedType returns a new type given a name, the name must be unique. | [
"CreateNamedType",
"returns",
"a",
"new",
"type",
"given",
"a",
"name",
"the",
"name",
"must",
"be",
"unique",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/api_analyzer.go#L96-L104 | test |
rightscale/rsc | gen/praxisgen/api_analyzer.go | CreateInlineType | func (reg *TypeRegistry) CreateInlineType(name string) *gen.ObjectDataType {
goName := toGoTypeName(name)
obj := gen.ObjectDataType{TypeName: goName}
reg.InlineTypes[goName] = append(reg.InlineTypes[goName], &obj)
return &obj
} | go | func (reg *TypeRegistry) CreateInlineType(name string) *gen.ObjectDataType {
goName := toGoTypeName(name)
obj := gen.ObjectDataType{TypeName: goName}
reg.InlineTypes[goName] = append(reg.InlineTypes[goName], &obj)
return &obj
} | [
"func",
"(",
"reg",
"*",
"TypeRegistry",
")",
"CreateInlineType",
"(",
"name",
"string",
")",
"*",
"gen",
".",
"ObjectDataType",
"{",
"goName",
":=",
"toGoTypeName",
"(",
"name",
")",
"\n",
"obj",
":=",
"gen",
".",
"ObjectDataType",
"{",
"TypeName",
":",
... | // CreateInlineType creates a new inline type. | [
"CreateInlineType",
"creates",
"a",
"new",
"inline",
"type",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/api_analyzer.go#L107-L112 | test |
rightscale/rsc | gen/praxisgen/api_analyzer.go | FinalizeTypeNames | func (reg *TypeRegistry) FinalizeTypeNames(d *gen.APIDescriptor) {
for n, named := range reg.NamedTypes {
reg.InlineTypes[n] = append(reg.InlineTypes[n], named)
}
d.FinalizeTypeNames(reg.InlineTypes)
} | go | func (reg *TypeRegistry) FinalizeTypeNames(d *gen.APIDescriptor) {
for n, named := range reg.NamedTypes {
reg.InlineTypes[n] = append(reg.InlineTypes[n], named)
}
d.FinalizeTypeNames(reg.InlineTypes)
} | [
"func",
"(",
"reg",
"*",
"TypeRegistry",
")",
"FinalizeTypeNames",
"(",
"d",
"*",
"gen",
".",
"APIDescriptor",
")",
"{",
"for",
"n",
",",
"named",
":=",
"range",
"reg",
".",
"NamedTypes",
"{",
"reg",
".",
"InlineTypes",
"[",
"n",
"]",
"=",
"append",
... | // FinalizeTypeNames makes sure type names are unique, it should be called after analysis
// has completed. | [
"FinalizeTypeNames",
"makes",
"sure",
"type",
"names",
"are",
"unique",
"it",
"should",
"be",
"called",
"after",
"analysis",
"has",
"completed",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/praxisgen/api_analyzer.go#L116-L121 | test |
rightscale/rsc | gen/data_types.go | Merge | func (d *APIDescriptor) Merge(other *APIDescriptor) error {
if d.Version != other.Version {
return fmt.Errorf("Can't merge API descriptors with different versions")
}
for _, name := range d.ResourceNames {
for _, otherName := range other.ResourceNames {
if name == otherName {
return fmt.Errorf("%s is a re... | go | func (d *APIDescriptor) Merge(other *APIDescriptor) error {
if d.Version != other.Version {
return fmt.Errorf("Can't merge API descriptors with different versions")
}
for _, name := range d.ResourceNames {
for _, otherName := range other.ResourceNames {
if name == otherName {
return fmt.Errorf("%s is a re... | [
"func",
"(",
"d",
"*",
"APIDescriptor",
")",
"Merge",
"(",
"other",
"*",
"APIDescriptor",
")",
"error",
"{",
"if",
"d",
".",
"Version",
"!=",
"other",
".",
"Version",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"Can't merge API descriptors with different versi... | // Merge two descriptors together, make sure there are no duplicate resource names and that
// common types are compatible. | [
"Merge",
"two",
"descriptors",
"together",
"make",
"sure",
"there",
"are",
"no",
"duplicate",
"resource",
"names",
"and",
"that",
"common",
"types",
"are",
"compatible",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L24-L58 | test |
rightscale/rsc | gen/data_types.go | FinalizeTypeNames | func (d *APIDescriptor) FinalizeTypeNames(rawTypes map[string][]*ObjectDataType) {
// 1. Make sure data type names don't clash with resource names
rawTypeNames := make([]string, len(rawTypes))
idx := 0
for n := range rawTypes {
rawTypeNames[idx] = n
idx++
}
sort.Strings(rawTypeNames)
for _, tn := range rawT... | go | func (d *APIDescriptor) FinalizeTypeNames(rawTypes map[string][]*ObjectDataType) {
// 1. Make sure data type names don't clash with resource names
rawTypeNames := make([]string, len(rawTypes))
idx := 0
for n := range rawTypes {
rawTypeNames[idx] = n
idx++
}
sort.Strings(rawTypeNames)
for _, tn := range rawT... | [
"func",
"(",
"d",
"*",
"APIDescriptor",
")",
"FinalizeTypeNames",
"(",
"rawTypes",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"ObjectDataType",
")",
"{",
"rawTypeNames",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"rawTypes",
")",
")",
"\n",... | // FinalizeTypeNames goes through all the types generated by the analyzer and generate unique names. | [
"FinalizeTypeNames",
"goes",
"through",
"all",
"the",
"types",
"generated",
"by",
"the",
"analyzer",
"and",
"generate",
"unique",
"names",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L61-L138 | test |
rightscale/rsc | gen/data_types.go | uniqueTypeName | func (d *APIDescriptor) uniqueTypeName(prefix string) string {
u := fmt.Sprintf("%s%d", prefix, 2)
taken := false
for _, tn := range d.TypeNames {
if tn == u {
taken = true
break
}
}
idx := 3
for taken {
u = fmt.Sprintf("%s%d", prefix, idx)
taken = false
for _, tn := range d.TypeNames {
if tn =... | go | func (d *APIDescriptor) uniqueTypeName(prefix string) string {
u := fmt.Sprintf("%s%d", prefix, 2)
taken := false
for _, tn := range d.TypeNames {
if tn == u {
taken = true
break
}
}
idx := 3
for taken {
u = fmt.Sprintf("%s%d", prefix, idx)
taken = false
for _, tn := range d.TypeNames {
if tn =... | [
"func",
"(",
"d",
"*",
"APIDescriptor",
")",
"uniqueTypeName",
"(",
"prefix",
"string",
")",
"string",
"{",
"u",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"%s%d\"",
",",
"prefix",
",",
"2",
")",
"\n",
"taken",
":=",
"false",
"\n",
"for",
"_",
",",
"tn",
... | // Build unique type name by appending "next available index" to given prefix | [
"Build",
"unique",
"type",
"name",
"by",
"appending",
"next",
"available",
"index",
"to",
"given",
"prefix"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L141-L165 | test |
rightscale/rsc | gen/data_types.go | MandatoryParams | func (a *Action) MandatoryParams() []*ActionParam {
m := make([]*ActionParam, len(a.Params))
i := 0
for _, p := range a.Params {
if p.Mandatory {
m[i] = p
i++
}
}
return m[:i]
} | go | func (a *Action) MandatoryParams() []*ActionParam {
m := make([]*ActionParam, len(a.Params))
i := 0
for _, p := range a.Params {
if p.Mandatory {
m[i] = p
i++
}
}
return m[:i]
} | [
"func",
"(",
"a",
"*",
"Action",
")",
"MandatoryParams",
"(",
")",
"[",
"]",
"*",
"ActionParam",
"{",
"m",
":=",
"make",
"(",
"[",
"]",
"*",
"ActionParam",
",",
"len",
"(",
"a",
".",
"Params",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"_",
... | // MandatoryParams returns the list of all action mandatory parameters | [
"MandatoryParams",
"returns",
"the",
"list",
"of",
"all",
"action",
"mandatory",
"parameters"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L207-L217 | test |
rightscale/rsc | gen/data_types.go | HasOptionalParams | func (a *Action) HasOptionalParams() bool {
for _, param := range a.Params {
if !param.Mandatory {
return true
}
}
return false
} | go | func (a *Action) HasOptionalParams() bool {
for _, param := range a.Params {
if !param.Mandatory {
return true
}
}
return false
} | [
"func",
"(",
"a",
"*",
"Action",
")",
"HasOptionalParams",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"param",
":=",
"range",
"a",
".",
"Params",
"{",
"if",
"!",
"param",
".",
"Mandatory",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
... | // HasOptionalParams returns true if the action takes optional parameters, false otherwise. | [
"HasOptionalParams",
"returns",
"true",
"if",
"the",
"action",
"takes",
"optional",
"parameters",
"false",
"otherwise",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L220-L227 | test |
rightscale/rsc | gen/data_types.go | MakeUniq | func MakeUniq(base string, taken []string) string {
idx := 1
uniq := base
inuse := true
for inuse {
inuse = false
for _, gn := range taken {
if gn == uniq {
inuse = true
break
}
}
if inuse {
idx++
uniq = base + strconv.Itoa(idx)
}
}
return uniq
} | go | func MakeUniq(base string, taken []string) string {
idx := 1
uniq := base
inuse := true
for inuse {
inuse = false
for _, gn := range taken {
if gn == uniq {
inuse = true
break
}
}
if inuse {
idx++
uniq = base + strconv.Itoa(idx)
}
}
return uniq
} | [
"func",
"MakeUniq",
"(",
"base",
"string",
",",
"taken",
"[",
"]",
"string",
")",
"string",
"{",
"idx",
":=",
"1",
"\n",
"uniq",
":=",
"base",
"\n",
"inuse",
":=",
"true",
"\n",
"for",
"inuse",
"{",
"inuse",
"=",
"false",
"\n",
"for",
"_",
",",
"... | // MakeUniq makes a unique name given a prefix and a set of names. | [
"MakeUniq",
"makes",
"a",
"unique",
"name",
"given",
"a",
"prefix",
"and",
"a",
"set",
"of",
"names",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L418-L436 | test |
rightscale/rsc | gen/writers/client.go | NewClientWriter | func NewClientWriter() (*ClientWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"commandLine": commandLine,
"parameters": parameters,
"paramsInitializer": paramsInitializer,
"blankCondition": blankCondition,
"stripStar": stripStar,
}
headerT, err := temp... | go | func NewClientWriter() (*ClientWriter, error) {
funcMap := template.FuncMap{
"comment": comment,
"commandLine": commandLine,
"parameters": parameters,
"paramsInitializer": paramsInitializer,
"blankCondition": blankCondition,
"stripStar": stripStar,
}
headerT, err := temp... | [
"func",
"NewClientWriter",
"(",
")",
"(",
"*",
"ClientWriter",
",",
"error",
")",
"{",
"funcMap",
":=",
"template",
".",
"FuncMap",
"{",
"\"comment\"",
":",
"comment",
",",
"\"commandLine\"",
":",
"commandLine",
",",
"\"parameters\"",
":",
"parameters",
",",
... | // NewClientWriter is the client writer factory. | [
"NewClientWriter",
"is",
"the",
"client",
"writer",
"factory",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L19-L40 | test |
rightscale/rsc | gen/writers/client.go | WriteHeader | func (c *ClientWriter) WriteHeader(pkg, version string, needTime, needJSON bool, w io.Writer) error {
ctx := map[string]interface{}{
"Pkg": pkg,
"APIVersion": version,
"NeedTime": needTime,
"NeedJSON": needJSON,
}
return c.headerTmpl.Execute(w, ctx)
} | go | func (c *ClientWriter) WriteHeader(pkg, version string, needTime, needJSON bool, w io.Writer) error {
ctx := map[string]interface{}{
"Pkg": pkg,
"APIVersion": version,
"NeedTime": needTime,
"NeedJSON": needJSON,
}
return c.headerTmpl.Execute(w, ctx)
} | [
"func",
"(",
"c",
"*",
"ClientWriter",
")",
"WriteHeader",
"(",
"pkg",
",",
"version",
"string",
",",
"needTime",
",",
"needJSON",
"bool",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"ctx",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}"... | // WriteHeader writes the header text. | [
"WriteHeader",
"writes",
"the",
"header",
"text",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L43-L51 | test |
rightscale/rsc | gen/writers/client.go | WriteResourceHeader | func (c *ClientWriter) WriteResourceHeader(name string, w io.Writer) {
fmt.Fprintf(w, "/****** %s ******/\n\n", name)
} | go | func (c *ClientWriter) WriteResourceHeader(name string, w io.Writer) {
fmt.Fprintf(w, "/****** %s ******/\n\n", name)
} | [
"func",
"(",
"c",
"*",
"ClientWriter",
")",
"WriteResourceHeader",
"(",
"name",
"string",
",",
"w",
"io",
".",
"Writer",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"/****** %s ******/\\n\\n\"",
",",
"\\n",
")",
"\n",
"}"
] | // WriteResourceHeader writes the resource header. | [
"WriteResourceHeader",
"writes",
"the",
"resource",
"header",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L54-L56 | test |
rightscale/rsc | gen/writers/client.go | WriteType | func (c *ClientWriter) WriteType(o *gen.ObjectDataType, w io.Writer) {
fields := make([]string, len(o.Fields))
for i, f := range o.Fields {
fields[i] = fmt.Sprintf("%s %s `json:\"%s,omitempty\"`", strings.Title(f.VarName),
f.Signature(), f.Name)
}
decl := fmt.Sprintf("type %s struct {\n%s\n}", o.TypeName,
st... | go | func (c *ClientWriter) WriteType(o *gen.ObjectDataType, w io.Writer) {
fields := make([]string, len(o.Fields))
for i, f := range o.Fields {
fields[i] = fmt.Sprintf("%s %s `json:\"%s,omitempty\"`", strings.Title(f.VarName),
f.Signature(), f.Name)
}
decl := fmt.Sprintf("type %s struct {\n%s\n}", o.TypeName,
st... | [
"func",
"(",
"c",
"*",
"ClientWriter",
")",
"WriteType",
"(",
"o",
"*",
"gen",
".",
"ObjectDataType",
",",
"w",
"io",
".",
"Writer",
")",
"{",
"fields",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"o",
".",
"Fields",
")",
")",
"\n",
... | // WriteType writest the type declaration for a resource action arguments. | [
"WriteType",
"writest",
"the",
"type",
"declaration",
"for",
"a",
"resource",
"action",
"arguments",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L64-L73 | test |
rightscale/rsc | gen/writers/client.go | WriteResource | func (c *ClientWriter) WriteResource(resource *gen.Resource, w io.Writer) error {
return c.resourceTmpl.Execute(w, resource)
} | go | func (c *ClientWriter) WriteResource(resource *gen.Resource, w io.Writer) error {
return c.resourceTmpl.Execute(w, resource)
} | [
"func",
"(",
"c",
"*",
"ClientWriter",
")",
"WriteResource",
"(",
"resource",
"*",
"gen",
".",
"Resource",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"c",
".",
"resourceTmpl",
".",
"Execute",
"(",
"w",
",",
"resource",
")",
"\n",
"}"... | // WriteResource writest the code for a resource. | [
"WriteResource",
"writest",
"the",
"code",
"for",
"a",
"resource",
"."
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L76-L78 | test |
rightscale/rsc | gen/goav2gen/endpoint.go | WithTrail | func (ec EvalCtx) WithTrail(t string) EvalCtx {
newEC := ec
trailCopy := make([]string, 0, len(ec.Trail)+1)
for _, val := range ec.Trail {
trailCopy = append(trailCopy, val)
}
newEC.Trail = append(trailCopy, t)
return newEC
} | go | func (ec EvalCtx) WithTrail(t string) EvalCtx {
newEC := ec
trailCopy := make([]string, 0, len(ec.Trail)+1)
for _, val := range ec.Trail {
trailCopy = append(trailCopy, val)
}
newEC.Trail = append(trailCopy, t)
return newEC
} | [
"func",
"(",
"ec",
"EvalCtx",
")",
"WithTrail",
"(",
"t",
"string",
")",
"EvalCtx",
"{",
"newEC",
":=",
"ec",
"\n",
"trailCopy",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"ec",
".",
"Trail",
")",
"+",
"1",
")",
"\n",
"fo... | // WithTrail creates a new context with trail appended to | [
"WithTrail",
"creates",
"a",
"new",
"context",
"with",
"trail",
"appended",
"to"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/endpoint.go#L23-L31 | test |
rightscale/rsc | gen/goav2gen/endpoint.go | AnalyzeEndpoint | func (a *APIAnalyzer) AnalyzeEndpoint(verb string, path string, ep *Endpoint) error {
path = joinPath(a.Doc.BasePath, path)
dbg("\n------\nDEBUG AnalyzeEndpoint %s %s %+v\n", verb, path, ep)
pattern := toPattern(verb, path)
dbg("DEBUG AnalyzeEndpoint pattern %v\n", pattern)
svc := ep.Service()
// Get Resource --... | go | func (a *APIAnalyzer) AnalyzeEndpoint(verb string, path string, ep *Endpoint) error {
path = joinPath(a.Doc.BasePath, path)
dbg("\n------\nDEBUG AnalyzeEndpoint %s %s %+v\n", verb, path, ep)
pattern := toPattern(verb, path)
dbg("DEBUG AnalyzeEndpoint pattern %v\n", pattern)
svc := ep.Service()
// Get Resource --... | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"AnalyzeEndpoint",
"(",
"verb",
"string",
",",
"path",
"string",
",",
"ep",
"*",
"Endpoint",
")",
"error",
"{",
"path",
"=",
"joinPath",
"(",
"a",
".",
"Doc",
".",
"BasePath",
",",
"path",
")",
"\n",
"dbg",
... | // AnalyzeEndpoint creates an API descriptor from goa v2 generated swagger definition | [
"AnalyzeEndpoint",
"creates",
"an",
"API",
"descriptor",
"from",
"goa",
"v2",
"generated",
"swagger",
"definition"
] | 96079a1ee7238dae9cbb7efa77dd94a479d217bd | https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/endpoint.go#L34-L146 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.