func volumeDelete(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	volumeName := r.URL.Query().Get(":name")
	dbVolume, err := volume.Load(volumeName)
	if err != nil {
		if err == volume.ErrVolumeNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	canDelete := permission.Check(t, permission.PermVolumeDelete, contextsForVolume(dbVolume)...)
	if !canDelete {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeVolume, Value: volumeName},
		Kind:       permission.PermVolumeDelete,
		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 dbVolume.Delete()
}
func volumeDelete(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	volumeName := r.URL.Query().Get(":name")
	dbVolume, err := volume.Load(volumeName)
	if err != nil {
		if err == volume.ErrVolumeNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	canDelete := permission.Check(t, permission.PermVolumeDelete, contextsForVolume(dbVolume)...)
	if !canDelete {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeVolume, Value: volumeName},
		Kind:       permission.PermVolumeDelete,
		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 dbVolume.Delete()
}
func volumeDelete ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { volumeName := r . URL . Query ( ) . Get ( " " ) dbVolume , err := volume . Load ( volumeName ) if err != nil { if err == volume . ErrVolumeNotFound { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } return err } canDelete := permission . Check ( t , permission . PermVolumeDelete , contextsForVolume ( dbVolume ) ... ) if ! canDelete { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : event . Target { Type : event . TargetTypeVolume , Value : volumeName } , Kind : permission . PermVolumeDelete , 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 dbVolume . Delete ( ) }
// title: volume delete
// path: /volumes/{name}
// method: DELETE
// produce: application/json
// responses:
//   200: Volume deleted
//   401: Unauthorized
//   404: Volume not found
title : volume delete path : / volumes / { name } method : DELETE produce : application / json responses : 200 : Volume deleted 401 : Unauthorized 404 : Volume not found