terraform/vendor/github.com/cloudflare/cloudflare-go/user.go

36 lines
789 B
Go
Raw Normal View History

2016-05-03 18:54:47 +02:00
package cloudflare
import (
"encoding/json"
"github.com/pkg/errors"
)
// UserDetails provides information about the logged-in user.
// API reference:
// https://api.cloudflare.com/#user-user-details
// GET /user
func (api *API) UserDetails() (User, error) {
2016-05-03 18:54:47 +02:00
var r UserResponse
res, err := api.makeRequest("GET", "/user", nil)
if err != nil {
return User{}, errors.Wrap(err, errMakeRequestError)
}
2016-05-03 18:54:47 +02:00
err = json.Unmarshal(res, &r)
if err != nil {
return User{}, errors.Wrap(err, errUnmarshalError)
}
2016-05-03 18:54:47 +02:00
return r.Result, nil
}
// UpdateUser updates the properties of the given user.
// API reference:
// https://api.cloudflare.com/#user-update-user
// PATCH /user
func (api *API) UpdateUser() (User, error) {
2016-05-03 18:54:47 +02:00
// api.makeRequest("PATCH", "/user", user)
return User{}, nil
}