id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c180800
&BudgetAlertLocator{Href(href), api} }
c180801
&CloudBillLocator{Href(href), api} }
c180802
&CloudBillMetricLocator{Href(href), api} }
c180803
&CurrentUserLocator{Href(href), api} }
c180804
{ return &InstanceCombinationLocator{Href(href), api} }
c180805
&InstanceMetricLocator{Href(href), api} }
c180806
{ return &InstanceUsagePeriodLocator{Href(href), api} }
c180807
&PatternLocator{Href(href), api} }
c180808
&ReservedInstanceLocator{Href(href), api} }
c180809
{ return &ReservedInstancePurchaseLocator{Href(href), api} }
c180810
&ScenarioLocator{Href(href), api} }
c180811
&ScheduledReportLocator{Href(href), api} }
c180812
&TempInstancePriceLocator{Href(href), api} }
c180813
&UserSettingLocator{Href(href), api} }
c180814
// 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 <- struct{}{} }() return &buf, done }
c180815
= append(newArgs, a) } } else if a == name && len(args) > (i+1) { val = args[i+1] skip = true } else { newArgs = append(newArgs, a) } } return val, newArgs }
c180816
fail("failed to open output file") } f.Write(b) f.WriteString("\n") f.Close() }
c180817
&AppliedPolicyLocator{Href(href), api} }
c180818
&ApprovalLocator{Href(href), api} }
c180819
&IncidentLocator{Href(href), api} }
c180820
&PolicyTemplateLocator{Href(href), api} }
c180821
&PublishedTemplateLocator{Href(href), api} }
c180822
&DebugCookbookPathLocator{Href(href), api} }
c180823
&DockerControlLocator{Href(href), api} }
c180824
&EnvLocator{Href(href), api} }
c180825
&LoginControlLocator{Href(href), api} }
c180826
&ProcLocator{Href(href), api} }
c180827
&Rl10Locator{Href(href), api} }
c180828
&TSSLocator{Href(href), api} }
c180829
&TSSControlLocator{Href(href), api} }
c180830
&TSSPluginLocator{Href(href), api} }
c180831
path, "mandatory": mandatory, } resourceT, err := template.New("resource-client").Funcs(funcMap).Parse(angularTmpl) if err != nil { return nil, err } return &AngularWriter{ angularTmpl: resourceT, }, nil }
c180832
return c.angularTmpl.Execute(w, resource) }
c180833
make([]interface{}, len(vars)) for i, v := range vars { ivars[i] = interface{}(":" + v) } return fmt.Sprintf(pattern.Pattern, ivars...) }
c180834
== param { return p.Mandatory } } panic("praxisgen bug: Unknown param " + param + " for action " + a.Name) }
c180835
Auth: auth, Host: host, Client: client, } if auth != nil { auth.SetHost(host) } return a }
c180836
true } if !cmdLine.ShowHelp && !cmdLine.NoAuth { if cmdLine.OAuthToken == "" && cmdLine.OAuthAccessToken == "" && cmdLine.APIToken == "" && cmdLine.Username == "" && !cmdLine.RL10 { return nil, fmt.Errorf("Missing authentication information, use '--email EMAIL --password PWD', '--token TOKEN' or 'setup'") } if cmdLine.Verbose || cmdLine.Dump == "debug" { httpclient.DumpFormat = httpclient.Debug } if cmdLine.Dump == "json" { httpclient.DumpFormat = httpclient.JSON } if cmdLine.Dump == "record" { httpclient.DumpFormat = httpclient.JSON | httpclient.Record } if cmdLine.Verbose { httpclient.DumpFormat |= httpclient.Verbose } client.FetchLocationResource = cmdLine.FetchResource } return client, nil }
c180837
a.Auth.CanAuthenticate(a.Host) return res }
c180838
return "", err } cfb := cipher.NewCFBEncrypter(block, iv) cfb.XORKeyStream(ciphertext[aes.BlockSize:], b) return string(encodeBase64(ciphertext)), nil }
c180839
too short") } iv := bytes[:aes.BlockSize] bytes = bytes[aes.BlockSize:] cfb := cipher.NewCFBDecrypter(block, iv) cfb.XORKeyStream(bytes, bytes) return string(decodeBase64(bytes)), nil }
c180840
bits[len(bits)-1] attrs := mediaTypeAttrs(d.Title) if attrs["type"] != "" { name += "_" + attrs["type"] } if attrs["view"] != "" && attrs["view"] != "default" { name += "_" + attrs["view"] } else if view != "" { name += "_" + view } dbg("DEBUG media type refID:%#v title:%#v name:%#v view:%#v -> type:%#v\n", refID, d.Title, name, view, name) return toTypeName(name) } else if strings.Contains(mt, "text/") { return "string" } else { fail("Don't know how to handle media type %s", mt) } } if view != "" { return name + "_" + view } return name }
c180841
other.Fields { oldFields = append(oldFields, f.Name) } for _, f := range dt.Fields { newFields = append(newFields, f.Name) } use := "Old" if len(newFields) > len(oldFields) { use = "New" } if strings.Join(oldFields, ",") != strings.Join(newFields, ",") { warn("Warning: Type collision when adding new type %s!\n New: id %s fields %v\n Old: id %s fields %v\n Using %s, which has more fields\n", dt.TypeName, r.ID(), newFields, a.refByType[dt.TypeName], oldFields, use) } if use == "Old" { return } } dbg("DEBUG NEW TYPE %s\n", prettify(dt)) a.refByType[dt.TypeName] = r.ID() a.api.Types[dt.TypeName] = dt }
c180842
eq = &[]*gen.ActionParam{} seen[p.Name] = eq *eq = extractCmdLineParams(p, root+"[]", seen, parentNotMandatory || !a.Mandatory) } return *eq case *gen.ObjectDataType: params := []*gen.ActionParam{} for _, f := range t.Fields { eq, ok := seen[f.Name] if !ok { eq = &[]*gen.ActionParam{} seen[f.Name] = eq *eq = extractCmdLineParams(f, fmt.Sprintf("%s[%s]", root, f.Name), seen, parentNotMandatory || !a.Mandatory) } params = append(params, *eq...) } return params } return nil }
c180843
{ return nil, err } resourceT, err := template.New("resource-metadata").Funcs(funcMap).Parse(resourceMetadataTmpl) if err != nil { return nil, err } return &MetadataWriter{ headerTmpl: headerT, resourceTmpl: resourceT, }, nil }
c180844
return c.headerTmpl.Execute(w, pkg) }
c180845
resources[i] = d.Resources[n] } return c.resourceTmpl.Execute(w, resources) }
c180846
gen.PayloadParam: return "metadata.PayloadParam" default: return "" } }
c180847
fromAPI(rsapi.New(host, auth)) }
c180848
GenMetadata return &API{api} }
c180849
err != nil { return nil, err } actionURL, err := act.URL(vars) if err != nil { return nil, err } _, queryParams := rsapi.IdentifyParams(act, params) return a.BuildHTTPRequest("GET", actionURL.Path, "1.6", queryParams, nil) }
c180850
= make(map[string]*metadata.Resource) for n, r := range cac.GenMetadata { result[n] = r } return }
c180851
2 { err = json.Unmarshal(js, &disp.RawOutput) if err != nil { disp.RawOutput = string(js) } } return &disp, nil }
c180852
{ case nil: d.RawOutput = "" case float64, bool: d.RawOutput = fmt.Sprint(v) case string: d.RawOutput = v default: d.RawOutput = v } d.RawOutput = outputs[0] } return nil }
c180853
} d.RawOutput = out } else { d.RawOutput = outputs } if err != nil { return fmt.Errorf("Failed to apply JSON selector '%s' to response: %s, JSON was:\n%s", selector, err, d.body) } return nil }
c180854
fmt.Errorf("Response does not contain the '%s' header", header) } return nil }
c180855
out = string(b) + "\n" } } else { var b []byte b, err = json.Marshal(output) out = string(b) } if err != nil { fm := "%v" if d.prettify { fm += "\n" } return fmt.Sprintf(fm, output) } return out }
c180856
resources, attributeTypes: attributeTypes, rawTypes: make(map[string][]*gen.ObjectDataType), } }
c180857
len(a.rawResources)) var idx = 0 for n := range a.rawResources { rawResourceNames[idx] = n idx++ } sort.Strings(rawResourceNames) for _, name := range rawResourceNames { var resource = a.rawResources[name] a.AnalyzeResource(name, resource, descriptor) } descriptor.FinalizeTypeNames(a.rawTypes) return descriptor }
c180858
fromAct := fromRes.(map[string]interface{})["methods"].(map[string]interface{})[fromActionName].(map[string]interface{}) toRes := a.rawResources[toResName] toAct := toRes.(map[string]interface{})["methods"].(map[string]interface{})[toActionName].(map[string]interface{}) fromAct["parameters"] = toAct["parameters"] fromAct["status_code"] = toAct["status_code"] fromAct["access_rules"] = toAct["access_rules"] } }
c180859
hasLinks = true break } } if !hasLinks { return "" } return `for _, l := range r.Links { if l["rel"] == "self" { return api.` + name + `Locator(l["href"]) } } return nil` }
c180860
continue } paths = append(paths, path) } } pathPatterns = make([]*gen.PathPattern, len(paths)) for i, p := range paths { rx := routeVariablesRegexp.ReplaceAllLiteralString(regexp.QuoteMeta(p), `/([^/]+)`) rx = fmt.Sprintf("^%s$", rx) pattern := gen.PathPattern{ HTTPMethod: method, Path: p, Pattern: routeVariablesRegexp.ReplaceAllLiteralString(p, "/%s"), Regexp: rx, } matches := routeVariablesRegexp.FindAllStringSubmatch(p, -1) if len(matches) > 0 { pattern.Variables = make([]string, len(matches)) for i, m := range matches { pattern.Variables[i] = m[1] } } pathPatterns[i] = &pattern } return }
c180861
!strings.Contains(path, "/api/sessions") }
c180862
n == "with_inherited" || n == "latest_only" || n == "lineage")) }
c180863
:= range pattern.Variables { if p == v { return true } } } return false }
c180864
// Limit yesterday(), // Start date apiParams, ) if err != nil { return auditEntries, err } return auditEntries, nil }
c180865
return time.Date(year, month, date, 0, 0, 0, 0, time.UTC).Format("2006/01/02 15:04:05 -0700") }
c180866
range entries { fmt.Printf("[%v] <%v>: %v\n", a.UpdatedAt, a.UserEmail, a.Summary) } }
c180867
newEntry := range newEntries { if !stringInSlice(getHref(newEntry), oldHrefs) { uniqueEntries = append(uniqueEntries, newEntry) } } return uniqueEntries }
c180868
"self" { href = link["href"] break } } return href }
c180869
fmt.Println(fmt.Sprintf(format, v...)) os.Exit(1) }
c180870
fixReserved(param.VarName), param.Signature()) } if hasOptional { params[countParams-1] = "options rsapi.APIParams" } return strings.Join(params, ", ") }
c180871
} } if len(fields) == 0 && len(optionals) == 0 { return "" } var paramsDecl = fmt.Sprintf("rsapi.APIParams{\n%s\n}", strings.Join(fields, "\n\t")) if len(optionals) == 0 { return fmt.Sprintf("\n%s = %s", varName, paramsDecl) } var inits = make([]string, len(optionals)) for i, opt := range optionals { name := opt.Name if location == 1 { // QueryParam name = opt.QueryName } inits[i] = fmt.Sprintf("\tvar %sOpt = options[\"%s\"]\n\tif %sOpt != nil {\n\t\t%s[\"%s\"] = %sOpt\n\t}", opt.VarName, opt.Name, opt.VarName, varName, name, opt.VarName) } var paramsInits = strings.Join(inits, "\n\t") return fmt.Sprintf("\n%s = %s\n%s", varName, paramsDecl, paramsInits) }
c180872
%s %s", os.Args[0], strings.Join(os.Args[1:], " ")) }
c180873
text == "GET" || text == "POST" { res += "Raw" } return }
c180874
return strings.Join(elems, "` + `") }
c180875
&AccountPreferenceLocator{Href(href), api} }
c180876
&ApplicationLocator{Href(href), api} }
c180877
&EndUserLocator{Href(href), api} }
c180878
&NotificationRuleLocator{Href(href), api} }
c180879
&UserPreferenceLocator{Href(href), api} }
c180880
&UserPreferenceInfoLocator{Href(href), api} }
c180881
err = Decrypt(config.Password) if err != nil { return nil, err } config.RefreshToken, err = Decrypt(config.RefreshToken) return &config, err }
c180882
config.Email = newEmail } fmt.Fprintf(out, "Login password%v: ", passwordDef) var newPassword string fmt.Fscanln(in, &newPassword) if newPassword != "" { config.Password = newPassword } fmt.Fprintf(out, "API Login host%v: ", hostDef) var newLoginHost string fmt.Fscanln(in, &newLoginHost) if newLoginHost != "" { config.LoginHost = newLoginHost } fmt.Fprintf(out, "API Refresh Token%v: ", refreshTokenDef) var newRefreshToken string fmt.Fscanln(in, &newRefreshToken) if newRefreshToken != "" { config.RefreshToken = newRefreshToken } err := config.Save(path) if err != nil { return fmt.Errorf("Failed to save config: %s", err) } return nil }
c180883
api.Host = HostFromLogin(api.Host) api.Metadata = GenMetadata api.VersionHeader = "Api-Version" return &API{api} }
c180884
elems[0] = "governance" } else if len(elems) < 2 { // don't know how to compute this policy host; use the cm host return host } else { elems[len(elems)-2] = "governance" } policyHostPrefix := strings.Join(elems, "-") return strings.Join(append([]string{policyHostPrefix}, urlElems[1:]...), ".") }
c180885
VarName: toVarName(p.Name), Location: location, Mandatory: p.Required, NonBlank: p.Required || p.Pattern != "", Regexp: p.Pattern, ValidValues: p.Enum, } if p.Schema != nil { ap.Type = a.typeForRef(ec, p.Schema) } else { ap.Type = basicType(p.Type) } return ap }
c180886
} } } } if values, ok := attr["values"]; ok { param.ValidValues = values.([]interface{}) } t := attr["type"].(map[string]interface{}) dataType, err := a.AnalyzeType(t, query) if err != nil { return nil, err } param.Type = dataType switch dataType.(type) { case *gen.ArrayDataType: param.QueryName += "[]" } return &param, nil }
c180887
!ok { return nil, fmt.Errorf("Failed to retrieve attributes of struct for %s", prettify(typeDef)) } obj, err := a.CreateType(query, attrs) if err != nil { return nil, err } dataType = obj case "Hash": keys, ok := typeDef["keys"].(map[string]interface{}) if !ok { dataType = new(gen.EnumerableDataType) } else { obj, err := a.CreateType(query, keys) if err != nil { return nil, err } dataType = obj } default: // First check if we already analyzed that type if t := a.Registry.GetNamedType(n); t != nil { return t, nil } // No then analyze it t, ok := a.RawTypes[n] if !ok { return nil, fmt.Errorf("Unknown type %s for %s", n, prettify(typeDef)) } attrs, ok := t["attributes"] if !ok { // No attribute, it's a string s := gen.BasicDataType("string") dataType = &s } else { att := attrs.(map[string]interface{}) obj := a.Registry.CreateNamedType(n) obj.Fields = make([]*gen.ActionParam, len(att)) for idx, an := range sortedKeys(att) { at := att[an] aq := fmt.Sprintf("%s[%s]", query, an) ap, err := a.AnalyzeAttribute(an, aq, at.(map[string]interface{})) if err != nil { return nil, err } obj.Fields[idx] = ap } // We're done dataType = obj } } return dataType, nil }
c180888
childQ = fmt.Sprintf("%s[%s]", query, an) } att, err := a.AnalyzeAttribute(an, childQ, at.(map[string]interface{})) if err != nil { return nil, fmt.Errorf("Failed to compute type of attribute %s: %s", an, err) } obj.Fields[idx] = att } return obj, nil }
c180889
refKey := strings.TrimPrefix(refIF.(string), "#/definitions/") return d.Definitions[refKey] } return nil }
c180890
"object" } if refIF, ok := r["type"]; ok { return refIF.(string) } return "" }
c180891
:= r["required"]; ok { return refIF.([]string) } return []string{} }
c180892
return strings.TrimPrefix(refIF.(string), "#/definitions/") } return "" }
c180893
return strings.Split(ep.OperationID, "#")[0] } return "" }
c180894
return strings.Split(ep.OperationID, "#")[1] } return "" }
c180895
InlineTypes: make(map[string][]*gen.ObjectDataType), } }
c180896
reg.NamedTypes[toGoTypeName(name)] }
c180897
panic("BUG: Can't create two named types with same name....") } reg.NamedTypes[goName] = &obj return &obj }
c180898
goName} reg.InlineTypes[goName] = append(reg.InlineTypes[goName], &obj) return &obj }
c180899
range reg.NamedTypes { reg.InlineTypes[n] = append(reg.InlineTypes[n], named) } d.FinalizeTypeNames(reg.InlineTypes) }