• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang httpclient.ConvertResp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/catalyzeio/cli/lib/httpclient.ConvertResp函数的典型用法代码示例。如果您正苦于以下问题:Golang ConvertResp函数的具体用法?Golang ConvertResp怎么用?Golang ConvertResp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ConvertResp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Create

func (f *SFiles) Create(svcID, filePath, name, mode string) (*models.ServiceFile, error) {
	b, err := ioutil.ReadFile(filePath)
	if err != nil {
		return nil, err
	}
	sf := models.ServiceFile{
		Contents:       string(b),
		GID:            0,
		Mode:           mode,
		Name:           name,
		UID:            0,
		EnableDownload: true,
	}
	body, err := json.Marshal(sf)
	if err != nil {
		return nil, err
	}
	headers := httpclient.GetHeaders(f.Settings.SessionToken, f.Settings.Version, f.Settings.Pod, f.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(body, fmt.Sprintf("%s%s/environments/%s/services/%s/files", f.Settings.PaasHost, f.Settings.PaasHostVersion, f.Settings.EnvironmentID, svcID), headers)
	if err != nil {
		return nil, err
	}
	var svcFile models.ServiceFile
	err = httpclient.ConvertResp(resp, statusCode, &svcFile)
	if err != nil {
		return nil, err
	}
	return &svcFile, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:29,代码来源:create.go


示例2: signInWithCredentials

func (a *SAuth) signInWithCredentials() (*signinResponse, error) {
	login := models.Login{
		Identifier: a.Settings.Username,
		Password:   a.Settings.Password,
	}
	if a.Settings.Username == "" || a.Settings.Password == "" {
		username, password, err := a.Prompts.UsernamePassword()
		if err != nil {
			return nil, err
		}
		login = models.Login{
			Identifier: username,
			Password:   password,
		}
	}

	b, err := json.Marshal(login)
	if err != nil {
		return nil, err
	}
	headers := httpclient.GetHeaders(a.Settings.SessionToken, a.Settings.Version, a.Settings.Pod, a.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(b, fmt.Sprintf("%s%s/auth/signin", a.Settings.AuthHost, a.Settings.AuthHostVersion), headers)
	if err != nil {
		return nil, err
	}
	signinResp := &signinResponse{}
	return signinResp, httpclient.ConvertResp(resp, statusCode, signinResp)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:28,代码来源:signin.go


示例3: Rm

func (d *SDeployKeys) Rm(name, keyType, svcID string) error {
	headers := httpclient.GetHeaders(d.Settings.SessionToken, d.Settings.Version, d.Settings.Pod, d.Settings.UsersID)
	resp, statusCode, err := httpclient.Delete(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/ssh_keys/%s/type/%s", d.Settings.PaasHost, d.Settings.PaasHostVersion, d.Settings.EnvironmentID, svcID, name, keyType), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:8,代码来源:rm.go


示例4: Delete

func (j *SJobs) Delete(jobID, svcID string) error {
	headers := httpclient.GetHeaders(j.Settings.SessionToken, j.Settings.Version, j.Settings.Pod, j.Settings.UsersID)
	resp, statusCode, err := httpclient.Delete(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 {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:8,代码来源:delete.go


示例5: Unset

// Unset deletes an environment variable. Any changes to environment variables
// will not take effect until the service is redeployed by pushing new code
// or via `catalyze redeploy`.
func (v *SVars) Unset(svcID, variable string) error {
	headers := httpclient.GetHeaders(v.Settings.SessionToken, v.Settings.Version, v.Settings.Pod, v.Settings.UsersID)
	resp, statusCode, err := httpclient.Delete(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/env/%s", v.Settings.PaasHost, v.Settings.PaasHostVersion, v.Settings.EnvironmentID, svcID, variable), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:11,代码来源:unset.go


示例6: Signout

// Signout signs out a user by their session token.
func (a *SAuth) Signout() error {
	headers := httpclient.GetHeaders(a.Settings.SessionToken, a.Settings.Version, a.Settings.Pod, a.Settings.UsersID)
	resp, statusCode, err := httpclient.Delete(nil, fmt.Sprintf("%s%s/auth/signout", a.Settings.AuthHost, a.Settings.AuthHostVersion), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:9,代码来源:signin.go


示例7: 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


示例8: Update

func (w *SWorker) Update(svcID string, workers *models.Workers) error {
	b, err := json.Marshal(workers)
	if err != nil {
		return err
	}
	headers := httpclient.GetHeaders(w.Settings.SessionToken, w.Settings.Version, w.Settings.Pod, w.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(b, fmt.Sprintf("%s%s/environments/%s/services/%s/workers", w.Settings.PaasHost, w.Settings.PaasHostVersion, w.Settings.EnvironmentID, svcID), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:12,代码来源:scale.go


示例9: Update

func (e *SEnvironments) Update(envID string, updates map[string]string) error {
	b, err := json.Marshal(updates)
	if err != nil {
		return err
	}
	headers := httpclient.GetHeaders(e.Settings.SessionToken, e.Settings.Version, e.Settings.Pod, e.Settings.UsersID)
	resp, statusCode, err := httpclient.Put(b, fmt.Sprintf("%s%s/environments/%s", e.Settings.PaasHost, e.Settings.PaasHostVersion, envID), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:12,代码来源:rename.go


示例10: Set

// Set adds a new environment variables or updates the value of an existing
// environment variables. Any changes to environment variables will not take
// effect until the service is redeployed by pushing new code or via
// `catalyze redeploy`.
func (v *SVars) Set(svcID string, envVarsMap map[string]string) error {
	b, err := json.Marshal(envVarsMap)
	if err != nil {
		return err
	}
	headers := httpclient.GetHeaders(v.Settings.SessionToken, v.Settings.Version, v.Settings.Pod, v.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(b, fmt.Sprintf("%s%s/environments/%s/services/%s/env", v.Settings.PaasHost, v.Settings.PaasHostVersion, v.Settings.EnvironmentID, svcID), headers)
	if err != nil {
		return err
	}
	return httpclient.ConvertResp(resp, statusCode, nil)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:16,代码来源:set.go


示例11: signInWithKey

func (a *SAuth) signInWithKey() (*signinResponse, error) {
	body := struct {
		PublicKey string `json:"publicKey"`
		Signature string `json:"signature"`
	}{}

	bytes, err := ioutil.ReadFile(a.Settings.PrivateKeyPath)
	if err != nil {
		return nil, err
	}
	block, _ := pem.Decode(bytes)
	if block == nil {
		return nil, errors.New("Private key is not PEM-encoded")
	}
	bytes = block.Bytes
	if x509.IsEncryptedPEMBlock(block) {
		passphrase := a.Prompts.KeyPassphrase(a.Settings.PrivateKeyPath)
		bytes, err = x509.DecryptPEMBlock(block, []byte(passphrase))
		if err != nil {
			return nil, err
		}
	}
	privateKey, err := x509.ParsePKCS1PrivateKey(bytes)
	if err != nil {
		return nil, err
	}
	publicKey, err := ioutil.ReadFile(a.Settings.PrivateKeyPath + ".pub")
	if err != nil {
		return nil, err
	}
	body.PublicKey = string(publicKey)

	headers := httpclient.GetHeaders(a.Settings.SessionToken, a.Settings.Version, a.Settings.Pod, a.Settings.UsersID)
	message := fmt.Sprintf("%s&%s", headers["X-Request-Nonce"][0], headers["X-Request-Timestamp"][0])
	hashedMessage := sha256.Sum256([]byte(message))
	signature, err := privateKey.Sign(rand.Reader, hashedMessage[:], crypto.SHA256)
	if err != nil {
		return nil, err
	}
	body.Signature = base64.StdEncoding.EncodeToString(signature)

	b, err := json.Marshal(body)
	if err != nil {
		return nil, err
	}
	resp, statusCode, err := httpclient.Post(b, fmt.Sprintf("%s%s/auth/signin/key", a.Settings.AuthHost, a.Settings.AuthHostVersion), headers)
	if err != nil {
		return nil, err
	}
	signinResp := &signinResponse{}
	return signinResp, httpclient.ConvertResp(resp, statusCode, signinResp)
}
开发者ID:catalyzeio,项目名称:cli,代码行数:52,代码来源:signin.go


示例12: Backup

// Backup creates a new backup
func (d *SDb) Backup(service *models.Service) (*models.Job, error) {
	headers := httpclient.GetHeaders(d.Settings.SessionToken, d.Settings.Version, d.Settings.Pod, d.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/backup", d.Settings.PaasHost, d.Settings.PaasHostVersion, d.Settings.EnvironmentID, service.ID), 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,代码行数:14,代码来源:backup.go


示例13: 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


示例14: RetrieveTokens

func (c *SConsole) RetrieveTokens(jobID string, service *models.Service) (*models.ConsoleCredentials, error) {
	headers := httpclient.GetHeaders(c.Settings.SessionToken, c.Settings.Version, c.Settings.Pod, c.Settings.UsersID)
	resp, statusCode, err := httpclient.Post(nil, fmt.Sprintf("%s%s/environments/%s/services/%s/jobs/%s/console-token", c.Settings.PaasHost, c.Settings.PaasHostVersion, c.Settings.EnvironmentID, service.ID, jobID), headers)
	if err != nil {
		return nil, err
	}
	var credentials models.ConsoleCredentials
	err = httpclient.ConvertResp(resp, statusCode, &credentials)
	if err != nil {
		return nil, err
	}
	return &credentials, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:console.go


示例15: List

func (p *SPods) List() (*[]models.Pod, error) {
	headers := httpclient.GetHeaders(p.Settings.SessionToken, p.Settings.Version, p.Settings.Pod, p.Settings.UsersID)
	resp, statusCode, err := httpclient.Get(nil, fmt.Sprintf("%s%s/pods", p.Settings.PaasHost, p.Settings.PaasHostVersion), headers)
	if err != nil {
		return nil, err
	}
	var podWrapper models.PodWrapper
	err = httpclient.ConvertResp(resp, statusCode, &podWrapper)
	if err != nil {
		return nil, err
	}
	return podWrapper.Pods, nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:13,代码来源:list.go


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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



注:本文中的github.com/catalyzeio/cli/lib/httpclient.ConvertResp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang httpclient.Get函数代码示例发布时间:2022-05-23
下一篇:
Golang services.IServices类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap