本文整理汇总了Golang中github.com/catalyzeio/cli/lib/httpclient.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: List
func (k *SKeys) List() (*[]models.UserKey, error) {
headers := httpclient.GetHeaders(k.Settings.SessionToken, k.Settings.Version, k.Settings.Pod, k.Settings.UsersID)
resp, status, err := httpclient.Get(nil, fmt.Sprintf("%s%s/keys", k.Settings.AuthHost, k.Settings.AuthHostVersion), headers)
if err != nil {
return nil, err
}
keys := []models.UserKey{}
err = httpclient.ConvertResp(resp, status, &keys)
return &keys, err
}
开发者ID:catalyzeio,项目名称:cli,代码行数:11,代码来源:list.go
示例2: Retrieve
func (j *SJobs) Retrieve(jobID, svcID string, includeSpec bool) (*models.Job, error) {
headers := httpclient.GetHeaders(j.Settings.SessionToken, j.Settings.Version, j.Settings.Pod, j.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/jobs/%s?spec=true", j.Settings.PaasHost, j.Settings.PaasHostVersion, j.Settings.EnvironmentID, svcID, jobID), headers)
if err != nil {
return nil, err
}
var job models.Job
err = httpclient.ConvertResp(resp, statusCode, &job)
if err != nil {
return nil, err
}
return &job, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:retrieve.go
示例3: Retrieve
func (w *SWorker) Retrieve(svcID string) (*models.Workers, error) {
headers := httpclient.GetHeaders(w.Settings.SessionToken, w.Settings.Version, w.Settings.Pod, w.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/workers", w.Settings.PaasHost, w.Settings.PaasHostVersion, w.Settings.EnvironmentID, svcID), headers)
if err != nil {
return nil, err
}
var workers models.Workers
err = httpclient.ConvertResp(resp, statusCode, &workers)
if err != nil {
return nil, err
}
return &workers, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:list.go
示例4: RetrieveByStatus
func (j *SJobs) RetrieveByStatus(svcID, status string) (*[]models.Job, error) {
headers := httpclient.GetHeaders(j.Settings.SessionToken, j.Settings.Version, j.Settings.Pod, j.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/jobs?status=%s", j.Settings.PaasHost, j.Settings.PaasHostVersion, j.Settings.EnvironmentID, svcID, status), headers)
if err != nil {
return nil, err
}
var jobs []models.Job
err = httpclient.ConvertResp(resp, statusCode, &jobs)
if err != nil {
return nil, err
}
return &jobs, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:retrieve.go
示例5: List
func (j *SJobs) List(svcID string, page, pageSize int) (*[]models.Job, error) {
headers := httpclient.GetHeaders(j.Settings.SessionToken, j.Settings.Version, j.Settings.Pod, j.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/jobs?pageNumber=%d&pageSize=%d", j.Settings.PaasHost, j.Settings.PaasHostVersion, j.Settings.EnvironmentID, svcID, page, pageSize), headers)
if err != nil {
return nil, err
}
var jobs []models.Job
err = httpclient.ConvertResp(resp, statusCode, &jobs)
if err != nil {
return nil, err
}
return &jobs, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:list.go
示例6: RetrieveServiceMetrics
// RetrieveServiceMetrics retrieves metrics data for the given service.
func (m *SMetrics) RetrieveServiceMetrics(mins int, svcID string) (*models.Metrics, error) {
headers := httpclient.GetHeaders(m.Settings.SessionToken, m.Settings.Version, m.Settings.Pod, m.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/metrics?time=%dm", m.Settings.PaasHost, m.Settings.PaasHostVersion, m.Settings.EnvironmentID, svcID, mins), headers)
if err != nil {
return nil, err
}
var metrics models.Metrics
err = httpclient.ConvertResp(resp, statusCode, &metrics)
if err != nil {
return nil, err
}
return &metrics, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:14,代码来源:metrics.go
示例7: ListRoles
// ListRoles lists all available roles
func (i *SInvites) ListRoles() (*[]models.Role, error) {
headers := httpclient.GetHeaders(i.Settings.SessionToken, i.Settings.Version, i.Settings.Pod, i.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/orgs/roles", i.Settings.AuthHost, i.Settings.AuthHostVersion), headers)
if err != nil {
return nil, err
}
var roles []models.Role
err = httpclient.ConvertResp(resp, statusCode, &roles)
if err != nil {
return nil, err
}
return &roles, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:14,代码来源:list.go
示例8: TempLogsURL
func (d *SDb) TempLogsURL(jobID string, serviceID string) (*models.TempURL, error) {
headers := httpclient.GetHeaders(d.Settings.SessionToken, d.Settings.Version, d.Settings.Pod, d.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/backup-restore-logs-url/%s", d.Settings.PaasHost, d.Settings.PaasHostVersion, d.Settings.EnvironmentID, serviceID, jobID), headers)
if err != nil {
return nil, err
}
var tempURL models.TempURL
err = httpclient.ConvertResp(resp, statusCode, &tempURL)
if err != nil {
return nil, err
}
return &tempURL, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:logs.go
示例9: Verify
// Verify verifies if a given session token is still valid or not. If it is
// valid, the returned error will be nil.
func (a *SAuth) Verify() (*models.User, error) {
headers := httpclient.GetHeaders(a.Settings.SessionToken, a.Settings.Version, a.Settings.Pod, a.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/auth/verify", a.Settings.AuthHost, a.Settings.AuthHostVersion), headers)
if err != nil {
return nil, err
}
var user models.User
err = httpclient.ConvertResp(resp, statusCode, &user)
if err != nil {
return nil, err
}
a.Settings.UsersID = user.UsersID
return &user, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:16,代码来源:signin.go
示例10: Output
func (l *SLogs) Output(queryString, sessionToken, domain string, follow bool, hours, minutes, seconds, from int, startTimestamp, endTimestamp time.Time, env *models.Environment) (int, time.Time, error) {
appLogsIdentifier := "source"
appLogsValue := "app"
if strings.HasPrefix(domain, "pod01") || strings.HasPrefix(domain, "csb01") {
appLogsIdentifier = "syslog_program"
appLogsValue = "supervisord"
}
urlString := fmt.Sprintf("https://%s/__es", domain)
headers := map[string][]string{"Cookie": {"sessionToken=" + url.QueryEscape(sessionToken)}}
logrus.Println(" @timestamp - message")
for {
queryBytes := generateQuery(queryString, appLogsIdentifier, appLogsValue, startTimestamp, from)
resp, statusCode, err := httpclient.Get(queryBytes, fmt.Sprintf("%s/_search", urlString), headers)
if err != nil {
return from, startTimestamp, err
}
var logs models.Logs
err = httpclient.ConvertResp(resp, statusCode, &logs)
if err != nil {
return from, startTimestamp, err
}
end := time.Time{}
for _, lh := range *logs.Hits.Hits {
logrus.Printf("%s - %s", lh.Fields["@timestamp"][0], lh.Fields["message"][0])
end, _ = time.Parse(time.RFC3339Nano, lh.Fields["@timestamp"][0])
}
amount := len(*logs.Hits.Hits)
from += len(*logs.Hits.Hits)
// TODO this will infinite loop if it always retrieves `size` hits
// and it fails to parse the end timestamp. very small window of opportunity.
if amount < size || end.After(endTimestamp) {
break
}
time.Sleep(config.JobPollTime * time.Second)
}
return from, startTimestamp, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:43,代码来源:logs.go
示例11: Retrieve
func (f *SFiles) Retrieve(fileName string, svcID string) (*models.ServiceFile, error) {
files, err := f.List(svcID)
if err != nil {
return nil, err
}
for _, ff := range *files {
if ff.Name == fileName {
headers := httpclient.GetHeaders(f.Settings.SessionToken, f.Settings.Version, f.Settings.Pod, f.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/files/%d", f.Settings.PaasHost, f.Settings.PaasHostVersion, f.Settings.EnvironmentID, svcID, ff.ID), headers)
if err != nil {
return nil, err
}
var file models.ServiceFile
err = httpclient.ConvertResp(resp, statusCode, &file)
if err != nil {
return nil, err
}
return &file, nil
}
}
return nil, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:22,代码来源:download.go
示例12: PollForStatus
func (j *SJobs) PollForStatus(statuses []string, jobID, svcID string) (string, error) {
var job models.Job
failedAttempts := 0
poll:
for {
failed := false
headers := httpclient.GetHeaders(j.Settings.SessionToken, j.Settings.Version, j.Settings.Pod, j.Settings.UsersID)
resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/jobs/%s", j.Settings.PaasHost, j.Settings.PaasHostVersion, j.Settings.EnvironmentID, svcID, jobID), headers)
if err != nil {
failed = true
}
err = httpclient.ConvertResp(resp, statusCode, &job)
if err != nil {
failed = true
}
if failed {
failedAttempts++
}
s := job.Status
switch {
case contains(s, statuses):
break poll
case contains(s, []string{"scheduled", "queued", "started", "running", "stopped", "waiting"}):
if failedAttempts >= 3 {
return "", fmt.Errorf("Error - ended in status '%s'.", job.Status)
}
// all because logrus treats print, println, and printf the same
logrus.StandardLogger().Out.Write([]byte("."))
time.Sleep(config.JobPollTime * time.Second)
default:
return "", fmt.Errorf("Error - ended in status '%s'.", job.Status)
}
}
if !contains(job.Status, statuses) {
return "", fmt.Errorf("Error - ended in status '%s'.", job.Status)
}
return job.Status, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:38,代码来源:poll.go
注:本文中的github.com/catalyzeio/cli/lib/httpclient.Get函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论