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

Golang kumoru.New函数代码示例

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

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



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

示例1: Show

//Show requests account details from Kumoru and marshals the data into the Account type.
func (a *Account) Show() (*Account, *http.Response, []error) {
	k := kumoru.New()

	k.Get(fmt.Sprintf("%v/v1/accounts/%v", k.EndPoint.Authorization, a.Email))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
		return a, resp, errs
	}

	err := json.Unmarshal([]byte(body), &a)

	if err != nil {
		errs = append(errs, err)
		return a, resp, errs
	}

	return a, resp, nil
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:27,代码来源:authorization.go


示例2: Show

//Show is a method on an Application which retrieves a particular Application from Kumoru.
func (a *Application) Show() (*Application, *http.Response, []error) {
	k := kumoru.New()

	k.Get(fmt.Sprintf("%s/v1/applications/%s", k.EndPoint.Application, a.UUID))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	err := json.Unmarshal([]byte(body), &a)

	if err != nil {
		errs = append(errs, fmt.Errorf("%s", err))
		return a, resp, errs
	}

	return a, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:26,代码来源:application.go


示例3: List

//List retreives all secrets a role has access to
func List() ([]*Secret, *http.Response, []error) {
	apps := []*Secret{}
	k := kumoru.New()

	k.Get(fmt.Sprintf("%s/v1/secrets/", k.EndPoint.Authorization))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return nil, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	err := json.Unmarshal([]byte(body), &apps)

	if err != nil {
		errs = append(errs, fmt.Errorf("%s", err))
	}

	return apps, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:26,代码来源:secrets.go


示例4: CreateAcct

//CreateAcct requests a particular account be made in Kumoru.
//It returns the updated Account.
func (a *Account) CreateAcct(password string) (*Account, *http.Response, []error) {
	k := kumoru.New()

	k.Put(fmt.Sprintf("%s/v1/accounts/%s", k.EndPoint.Authorization, a.Email))
	k.Send(fmt.Sprintf("given_name=%s&surname=%s&password=%s", a.GivenName, a.Surname, password))

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	err := json.Unmarshal([]byte(body), &a)

	if err != nil {
		errs = append(errs, err)
		return a, resp, errs
	}

	return a, resp, nil
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:27,代码来源:authorization.go


示例5: Create

//Create is a method on an Application which requests that the application be drafted in Kumoru.
func (a *Application) Create() (*Application, *http.Response, []error) {
	var errs []error
	k := kumoru.New()

	k.Post(fmt.Sprintf("%s/v1/applications/", k.EndPoint.Application))
	k.TargetType = "json"
	s, err := json.Marshal(*a)

	if err != nil {
		errs = append(errs, fmt.Errorf("%s", err))
		return a, nil, errs
	}

	k.RawString = string(s)
	k.SignRequest(true)

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	err = json.Unmarshal([]byte(body), &a)

	if err != nil {
		errs = append(errs, err)
		return a, resp, errs
	}

	return a, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:36,代码来源:application.go


示例6: List

// List retrieves a list of Applications a role has access to.
func List() (*http.Response, string, []error) {
	k := kumoru.New()

	k.Get(fmt.Sprintf("%s/v1/applications/", k.EndPoint.Application))
	k.SignRequest(true)
	return k.End()
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:8,代码来源:application.go


示例7: Patch

// Patch is a method on an application which will modify an Application.
func (a *Application) Patch(certificates, name, image, metaData string, envVars, rules, ports, sslPorts []string) (*http.Response, string, []error) {
	k := kumoru.New()

	k.Patch(fmt.Sprintf("%s/v1/applications/%s", k.EndPoint.Application, a.UUID))
	k.Send(genParameters(certificates, name, image, metaData, envVars, rules, ports, sslPorts))
	k.SignRequest(true)
	return k.End()
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:9,代码来源:application.go


示例8: ResetPassword

//ResetPassword requests the password be reset for a given Account.
func (a *Account) ResetPassword() (*Account, *http.Response, []error) {
	k := kumoru.New()

	k.Get(fmt.Sprintf("%v/v1/accounts/%v/password/resets/", k.EndPoint.Authorization, a.Email))
	resp, _, errs := k.End()

	return a, resp, errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:9,代码来源:authorization.go


示例9: GetTokens

//GetTokens generates a new token(uuid), stores this token in Kumoru and retrieves the private half of the token.
func GetTokens(username, password string) (string, *http.Response, string, []error) {
	k := kumoru.New()

	token := uuid.New()

	k.Put(fmt.Sprintf("%v/v1/tokens/%v", k.EndPoint.Authorization, token))
	k.SetBasicAuth(username, password)
	resp, body, errs := k.End()

	return token, resp, body, errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:12,代码来源:authorization.go


示例10: Find

//Find is a method which will search for Locations based on inputs
func (l *Location) Find() (string, []error) {
	k := kumoru.New()

	k.Get(l.buildFindPath(k.EndPoint.Location))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if resp.StatusCode != 200 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	return string(body), errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:15,代码来源:location.go


示例11: Delete

//Delete will request that a particular Location be removed
func (l *Location) Delete() []error {
	k := kumoru.New()

	k.Delete(fmt.Sprintf("%s/v1/locations/%s/%s", k.EndPoint.Location, l.Provider, l.Region))
	k.SignRequest(true)

	resp, _, errs := k.End()

	if resp.StatusCode != 204 {
		errs = append(errs, fmt.Errorf("s", resp.Status))
	}

	return errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:15,代码来源:location.go


示例12: Create

//Create is a method which will request a Location be created
func (l *Location) Create() (string, []error) {
	k := kumoru.New()

	k.Put(fmt.Sprintf("%s/v1/locations/%s/%s", k.EndPoint.Location, l.Provider, l.Region))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if resp.StatusCode != 201 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	return string(body), errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:15,代码来源:location.go


示例13: Patch

// Patch is a method on an application which will modify an existing Application.
func (a *Application) Patch(patchedApplication *Application) (*Application, *http.Response, []error) {
	o, err := json.Marshal(a)
	if err != nil {
		return nil, nil, []error{err}
	}

	p, err := json.Marshal(patchedApplication)
	if err != nil {
		return nil, nil, []error{err}
	}

	patch, err := jsonpatch.CreatePatch([]byte(o), []byte(p))
	if err != nil {
		fmt.Printf("Error creating JSON patch:%v", err)
		return nil, nil, []error{err}
	}

	patchBytes, err := json.Marshal(patch)
	if err != nil {
		return nil, nil, []error{err}
	}
	k := kumoru.New()

	k.Logger.Debugf("Patch string: %s", patchBytes)

	k.Patch(fmt.Sprintf("%s/v1/applications/%s", k.EndPoint.Application, a.UUID))
	k.TargetType = "json-patch+json"
	k.RawString = string(string(patchBytes))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	pApp := Application{}
	err = json.Unmarshal([]byte(body), &pApp)

	if err != nil {
		errs = append(errs, err)
		return a, resp, errs
	}

	return &pApp, resp, nil
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:51,代码来源:application.go


示例14: Delete

//Delete is a method on a Location that will remove Kumoru resources from the provider region
func (l *Location) Delete(uuid string) (*Location, *http.Response, []error) {
	k := kumoru.New()

	k.Delete(fmt.Sprintf("%v/v1/pools/%s", k.EndPoint.Pool, uuid))
	k.SignRequest(true)

	resp, _, errs := k.End()

	if errs != nil {
		return l, resp, errs
	}

	return l, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:15,代码来源:pools.go


示例15: Delete

//Delete is a method on an Application which request an Application be deleted in Kumoru.
func (a *Application) Delete() (*Application, *http.Response, []error) {
	k := kumoru.New()

	k.Delete(fmt.Sprintf("%s/v1/applications/%s", k.EndPoint.Application, a.UUID))
	k.SignRequest(true)

	resp, _, errs := k.End()

	if len(errs) > 0 {
		return a, resp, errs
	}

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
	}

	return a, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:19,代码来源:application.go


示例16: Show

// Show is a method will call the appropriate URI and return a specific deployment
func (d *Deployment) Show(applicationUuid, deploymentUuid string) (*Deployment, *http.Response, []error) {
	deployment := Deployment{}
	k := kumoru.New()

	k.Get(fmt.Sprintf("%s/v1/applications/%s/deployments/%s", k.EndPoint.Application, applicationUuid, deploymentUuid))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if errs != nil {
		return &deployment, resp, errs
	}

	err := json.Unmarshal([]byte(body), &deployment)

	if err != nil {
		errs = append(errs, err)
		return &deployment, resp, errs
	}

	return &deployment, resp, errs
}
开发者ID:kumoru,项目名称:kumoru-sdk-go,代码行数:23,代码来源:deployments.go


示例17: Show

// Show is a Secret method will call the appropriate URI and return a specific secret
func (s *Secret) Show(secretUuid *string) (*Secret, *http.Response, []error) {
	secret := Secret{}
	k := kumoru.New()

	k.Get(fmt.Sprintf("%s/v1/secrets/%s", k.EndPoint.Authorization, *secretUuid))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if errs != nil {
		return &secret, resp, errs
	}

	err := json.Unmarshal([]byte(body), &secret)

	if err != nil {
		errs = append(errs, err)
		return &secret, resp, errs
	}

	return &secret, resp, errs
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:23,代码来源:secrets.go


示例18: Create

// Create is a Secret method that will create a secret with the specified value
func (s *Secret) Create() (*Secret, *http.Response, []error) {
	k := kumoru.New()

	k.Post(fmt.Sprintf("%v/v1/secrets/", k.EndPoint.Authorization))
	k.Send(genParameters(s.Value, s.Labels))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if errs != nil {
		return s, resp, errs
	}

	err := json.Unmarshal([]byte(body), &s)

	if err != nil {
		errs = append(errs, err)
		return s, resp, errs
	}

	return s, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:23,代码来源:secrets.go


示例19: Show

//Show is a method on a Location that will show all the details of a particular Location
func (l *Location) Show() (*Location, *http.Response, []error) {
	k := kumoru.New()

	k.Get(fmt.Sprintf("%v/v1/pools/%s", k.EndPoint.Pool, l.Uuid))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
		return l, resp, errs
	}

	err := json.Unmarshal([]byte(body), l)

	if err != nil {
		errs = append(errs, err)
		return l, resp, errs
	}

	return l, resp, errs

}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:24,代码来源:pools.go


示例20: List

//List is a method on a Location that will list all Locations an user has access to
func (l *Location) List() (*[]Location, *http.Response, []error) {
	locations := []Location{}
	k := kumoru.New()

	k.Get(fmt.Sprintf("%v/v1/pools/", k.EndPoint.Pool))
	k.SignRequest(true)

	resp, body, errs := k.End()

	if resp.StatusCode >= 400 {
		errs = append(errs, fmt.Errorf("%s", resp.Status))
		return &locations, resp, errs
	}

	err := json.Unmarshal([]byte(body), &locations)

	if err != nil {
		errs = append(errs, err)
		return &locations, resp, errs
	}

	return &locations, resp, nil
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:24,代码来源:pools.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang application.Application类代码示例发布时间:2022-05-23
下一篇:
Golang cascadia.MustCompile函数代码示例发布时间: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