func RevertResize(client *gophercloud.ServiceClient, id string) ActionResult {
	var res ActionResult
	_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody: map[string]interface{}{"revertResize": nil},
		OkCodes:  []int{202},
	})
	return res
}
RevertResize cancels a previous resize operation on a server.
See Resize() for more details.
package servers
import (
	"encoding/base64"
	"errors"
	"fmt"
	"github.com/rackspace/gophercloud"
	"github.com/rackspace/gophercloud/pagination"
)
type ListOptsBuilder interface {
	ToServerListQuery() (string, error)
}
type ListOpts struct {
	ChangesSince string `q:"changes-since"`
	Image string `q:"image"`
	Flavor string `q:"flavor"`
	Name string `q:"name"`
	Status string `q:"status"`
	Host string `q:"host"`
	Marker string `q:"marker"`
	Limit int `q:"limit"`
}
func (opts ListOpts) ToServerListQuery() (string, error) {
	q, err := gophercloud.BuildQueryString(opts)
	if err != nil {
		return "", err
	}
	return q.String(), nil
}
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
	url := listDetailURL(client)
	if opts != nil {
		query, err := opts.ToServerListQuery()
		if err != nil {
			return pagination.Pager{Err: err}
		}
		url += query
	}
	createPageFn := func(r pagination.PageResult) pagination.Page {
		return ServerPage{pagination.LinkedPageBase{PageResult: r}}
	}
	return pagination.NewPager(client, url, createPageFn)
}
type CreateOptsBuilder interface {
	ToServerCreateMap() (map[string]interface{}, error)
}
type Network struct {
	UUID string
	Port string
	FixedIP string
}
type CreateOpts struct {
	Name string
	ImageRef string
	FlavorRef string
	SecurityGroups []string
	UserData []byte
	AvailabilityZone string
	Networks []Network
	Metadata map[string]string
	Personality []byte
	ConfigDrive bool
	AdminPass string
	AccessIPv4 string
	AccessIPv6 string
}
func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error) {
	server := make(map[string]interface{})
	server["name"] = opts.Name
	server["imageRef"] = opts.ImageRef
	server["flavorRef"] = opts.FlavorRef
	if opts.UserData != nil {
		encoded := base64.StdEncoding.EncodeToString(opts.UserData)
		server["user_data"] = &encoded
	}
	if opts.Personality != nil {
		encoded := base64.StdEncoding.EncodeToString(opts.Personality)
		server["personality"] = &encoded
	}
	if opts.ConfigDrive {
		server["config_drive"] = "true"
	}
	if opts.AvailabilityZone != "" {
		server["availability_zone"] = opts.AvailabilityZone
	}
	if opts.Metadata != nil {
		server["metadata"] = opts.Metadata
	}
	if opts.AdminPass != "" {
		server["adminPass"] = opts.AdminPass
	}
	if opts.AccessIPv4 != "" {
		server["accessIPv4"] = opts.AccessIPv4
	}
	if opts.AccessIPv6 != "" {
		server["accessIPv6"] = opts.AccessIPv6
	}
	if len(opts.SecurityGroups) > 0 {
		securityGroups := make([]map[string]interface{}, len(opts.SecurityGroups))
		for i, groupName := range opts.SecurityGroups {
			securityGroups[i] = map[string]interface{}{"name": groupName}
		}
		server["security_groups"] = securityGroups
	}
	if len(opts.Networks) > 0 {
		networks := make([]map[string]interface{}, len(opts.Networks))
		for i, net := range opts.Networks {
			networks[i] = make(map[string]interface{})
			if net.UUID != "" {
				networks[i]["uuid"] = net.UUID
			}
			if net.Port != "" {
				networks[i]["port"] = net.Port
			}
			if net.FixedIP != "" {
				networks[i]["fixed_ip"] = net.FixedIP
			}
		}
		server["networks"] = networks
	}
	return map[string]interface{}{"server": server}, nil
}
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
	var res CreateResult
	reqBody, err := opts.ToServerCreateMap()
	if err != nil {
		res.Err = err
		return res
	}
	_, res.Err = client.Request("POST", listURL(client), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
		JSONBody:     reqBody,
		OkCodes:      []int{202},
	})
	return res
}
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
	var res DeleteResult
	_, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
		OkCodes: []int{204},
	})
	return res
}
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var result GetResult
	_, result.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
		JSONResponse: &result.Body,
		OkCodes:      []int{200, 203},
	})
	return result
}
type UpdateOptsBuilder interface {
	ToServerUpdateMap() map[string]interface{}
}
type UpdateOpts struct {
	Name string
	AccessIPv4 string
	AccessIPv6 string
}
func (opts UpdateOpts) ToServerUpdateMap() map[string]interface{} {
	server := make(map[string]string)
	if opts.Name != "" {
		server["name"] = opts.Name
	}
	if opts.AccessIPv4 != "" {
		server["accessIPv4"] = opts.AccessIPv4
	}
	if opts.AccessIPv6 != "" {
		server["accessIPv6"] = opts.AccessIPv6
	}
	return map[string]interface{}{"server": server}
}
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
	var result UpdateResult
	_, result.Err = client.Request("PUT", updateURL(client, id), gophercloud.RequestOpts{
		JSONResponse: &result.Body,
		JSONBody:     opts.ToServerUpdateMap(),
	})
	return result
}
func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) ActionResult {
	var req struct {
		ChangePassword struct {
			AdminPass string `json:"adminPass"`
		} `json:"changePassword"`
	}
	req.ChangePassword.AdminPass = newPassword
	var res ActionResult
	_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody: req,
		OkCodes:  []int{202},
	})
	return res
}
type ErrArgument struct {
	Function, Argument string
	Value              interface{}
}
func (e *ErrArgument) Error() string {
	return fmt.Sprintf("Bad argument in call to %s, formal parameter %s, value %#v", e.Function, e.Argument, e.Value)
}
func (e *ErrArgument) String() string {
	return e.Error()
}
type RebootMethod string
const (
	SoftReboot RebootMethod = "SOFT"
	HardReboot RebootMethod = "HARD"
	OSReboot                = SoftReboot
	PowerCycle              = HardReboot
)
func Reboot(client *gophercloud.ServiceClient, id string, how RebootMethod) ActionResult {
	var res ActionResult
	if (how != SoftReboot) && (how != HardReboot) {
		res.Err = &ErrArgument{
			Function: "Reboot",
			Argument: "how",
			Value:    how,
		}
		return res
	}
	_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody: struct {
			C map[string]string `json:"reboot"`
		}{
			map[string]string{"type": string(how)},
		},
		OkCodes: []int{202},
	})
	return res
}
type RebuildOptsBuilder interface {
	ToServerRebuildMap() (map[string]interface{}, error)
}
type RebuildOpts struct {
	ImageID string
	Name string
	AdminPass string
	AccessIPv4 string
	AccessIPv6 string
	Metadata map[string]string
	Personality []byte
}
func (opts RebuildOpts) ToServerRebuildMap() (map[string]interface{}, error) {
	var err error
	server := make(map[string]interface{})
	if opts.AdminPass == "" {
		err = fmt.Errorf("AdminPass is required")
	}
	if opts.ImageID == "" {
		err = fmt.Errorf("ImageID is required")
	}
	if err != nil {
		return server, err
	}
	server["name"] = opts.Name
	server["adminPass"] = opts.AdminPass
	server["imageRef"] = opts.ImageID
	if opts.AccessIPv4 != "" {
		server["accessIPv4"] = opts.AccessIPv4
	}
	if opts.AccessIPv6 != "" {
		server["accessIPv6"] = opts.AccessIPv6
	}
	if opts.Metadata != nil {
		server["metadata"] = opts.Metadata
	}
	if opts.Personality != nil {
		encoded := base64.StdEncoding.EncodeToString(opts.Personality)
		server["personality"] = &encoded
	}
	return map[string]interface{}{"rebuild": server}, nil
}
func Rebuild(client *gophercloud.ServiceClient, id string, opts RebuildOptsBuilder) RebuildResult {
	var result RebuildResult
	if id == "" {
		result.Err = fmt.Errorf("ID is required")
		return result
	}
	reqBody, err := opts.ToServerRebuildMap()
	if err != nil {
		result.Err = err
		return result
	}
	_, result.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody:     &reqBody,
		JSONResponse: &result.Body,
		OkCodes:      []int{202},
	})
	return result
}
type ResizeOptsBuilder interface {
	ToServerResizeMap() (map[string]interface{}, error)
}
type ResizeOpts struct {
	FlavorRef string
}
func (opts ResizeOpts) ToServerResizeMap() (map[string]interface{}, error) {
	resize := map[string]interface{}{
		"flavorRef": opts.FlavorRef,
	}
	return map[string]interface{}{"resize": resize}, nil
}
func Resize(client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) ActionResult {
	var res ActionResult
	reqBody, err := opts.ToServerResizeMap()
	if err != nil {
		res.Err = err
		return res
	}
	_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody: reqBody,
		OkCodes:  []int{202},
	})
	return res
}
func ConfirmResize(client *gophercloud.ServiceClient, id string) ActionResult {
	var res ActionResult
	_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
		JSONBody: map[string]interface{}{"confirmResize": nil},
		OkCodes:  []int{204},
	})
	return res
}