func removeTeam(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	allowed := permission.Check(t, permission.PermTeamDelete,
		permission.Context(permTypes.CtxTeam, name),
	)
	if !allowed {
		return &errors.HTTP{Code: http.StatusNotFound, Message: fmt.Sprintf(`Team "%s" not found.`, name)}
	}
	evt, err := event.New(&event.Opts{
		Target:     teamTarget(name),
		Kind:       permission.PermTeamDelete,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermTeamReadEvents, permission.Context(permTypes.CtxTeam, name)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	err = servicemanager.Team.Remove(name)
	if err != nil {
		if _, ok := err.(*authTypes.ErrTeamStillUsed); ok {
			msg := fmt.Sprintf("This team cannot be removed because there are still references to it:\n%s", err)
			return &errors.HTTP{Code: http.StatusForbidden, Message: msg}
		}
		if err == authTypes.ErrTeamNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: fmt.Sprintf(`Team "%s" not found.`, name)}
		}
		return err
	}
	return nil
}
func removeTeam(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	allowed := permission.Check(t, permission.PermTeamDelete,
		permission.Context(permTypes.CtxTeam, name),
	)
	if !allowed {
		return &errors.HTTP{Code: http.StatusNotFound, Message: fmt.Sprintf(`Team "%s" not found.`, name)}
	}
	evt, err := event.New(&event.Opts{
		Target:     teamTarget(name),
		Kind:       permission.PermTeamDelete,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermTeamReadEvents, permission.Context(permTypes.CtxTeam, name)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	err = servicemanager.Team.Remove(name)
	if err != nil {
		if _, ok := err.(*authTypes.ErrTeamStillUsed); ok {
			msg := fmt.Sprintf("This team cannot be removed because there are still references to it:\n%s", err)
			return &errors.HTTP{Code: http.StatusForbidden, Message: msg}
		}
		if err == authTypes.ErrTeamNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: fmt.Sprintf(`Team "%s" not found.`, name)}
		}
		return err
	}
	return nil
}
func removeTeam ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { name := r . URL . Query ( ) . Get ( " " ) allowed := permission . Check ( t , permission . PermTeamDelete , permission . Context ( permTypes . CtxTeam , name ) , ) if ! allowed { return & errors . HTTP { Code : http . StatusNotFound , Message : fmt . Sprintf ( `Team "%s" not found.` , name ) } } evt , err := event . New ( & event . Opts { Target : teamTarget ( name ) , Kind : permission . PermTeamDelete , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermTeamReadEvents , permission . Context ( permTypes . CtxTeam , name ) ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) err = servicemanager . Team . Remove ( name ) if err != nil { if _ , ok := err . ( * authTypes . ErrTeamStillUsed ) ; ok { msg := fmt . Sprintf ( " \n " , err ) return & errors . HTTP { Code : http . StatusForbidden , Message : msg } } if err == authTypes . ErrTeamNotFound { return & errors . HTTP { Code : http . StatusNotFound , Message : fmt . Sprintf ( `Team "%s" not found.` , name ) } } return err } return nil }
// title: remove team
// path: /teams/{name}
// method: DELETE
// responses:
//   200: Team removed
//   401: Unauthorized
//   403: Forbidden
//   404: Not found
title : remove team path : / teams / { name } method : DELETE responses : 200 : Team removed 401 : Unauthorized 403 : Forbidden 404 : Not found