當前位置: 首頁>>代碼示例>>Golang>>正文


Golang kumoru.New函數代碼示例

本文整理匯總了Golang中github.com/kumoru/kumoru-sdk-go/pkg/kumoru.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/kumoru/kumoru-sdk-go/pkg/kumoru.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。