api/volume.go
func volumeUpdate(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	var inputVolume volume.Volume
	err = ParseInput(r, &inputVolume)
	if err != nil {
		return err
	}
	inputVolume.Plan.Opts = nil
	inputVolume.Status = ""
	inputVolume.Name = r.URL.Query().Get(":name")
	dbVolume, err := volume.Load(inputVolume.Name)
	if err != nil {
		if err == volume.ErrVolumeNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	canUpdate := permission.Check(t, permission.PermVolumeUpdate, contextsForVolume(dbVolume)...)
	if !canUpdate {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeVolume, Value: inputVolume.Name},
		Kind:       permission.PermVolumeUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermVolumeReadEvents, contextsForVolume(dbVolume)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	return inputVolume.Update()
}
func volumeUpdate(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	var inputVolume volume.Volume
	err = ParseInput(r, &inputVolume)
	if err != nil {
		return err
	}
	inputVolume.Plan.Opts = nil
	inputVolume.Status = ""
	inputVolume.Name = r.URL.Query().Get(":name")
	dbVolume, err := volume.Load(inputVolume.Name)
	if err != nil {
		if err == volume.ErrVolumeNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	canUpdate := permission.Check(t, permission.PermVolumeUpdate, contextsForVolume(dbVolume)...)
	if !canUpdate {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeVolume, Value: inputVolume.Name},
		Kind:       permission.PermVolumeUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermVolumeReadEvents, contextsForVolume(dbVolume)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	return inputVolume.Update()
}
// title: volume update
// path: /volumes/{name}
// method: POST
// produce: application/json
// responses:
//   200: Volume updated
//   401: Unauthorized
//   404: Volume not found