func tokenDelete(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	tokenID := r.URL.Query().Get(":token_id")
	teamToken, err := servicemanager.TeamToken.FindByTokenID(tokenID)
	if err != nil {
		if err == authTypes.ErrTeamTokenNotFound {
			return &errors.HTTP{
				Code:    http.StatusNotFound,
				Message: err.Error(),
			}
		}
		return err
	}
	teamName := teamToken.Team
	allowed := permission.Check(t, permission.PermTeamTokenDelete,
		permission.Context(permTypes.CtxTeam, teamName),
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     teamTarget(teamName),
		Kind:       permission.PermTeamTokenDelete,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermTeamReadEvents, permission.Context(permTypes.CtxTeam, teamName)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	err = servicemanager.TeamToken.Delete(tokenID)
	if err == authTypes.ErrTeamTokenNotFound {
		return &errors.HTTP{
			Code:    http.StatusNotFound,
			Message: err.Error(),
		}
	}
	return err
}
func tokenDelete(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	tokenID := r.URL.Query().Get(":token_id")
	teamToken, err := servicemanager.TeamToken.FindByTokenID(tokenID)
	if err != nil {
		if err == authTypes.ErrTeamTokenNotFound {
			return &errors.HTTP{
				Code:    http.StatusNotFound,
				Message: err.Error(),
			}
		}
		return err
	}
	teamName := teamToken.Team
	allowed := permission.Check(t, permission.PermTeamTokenDelete,
		permission.Context(permTypes.CtxTeam, teamName),
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     teamTarget(teamName),
		Kind:       permission.PermTeamTokenDelete,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermTeamReadEvents, permission.Context(permTypes.CtxTeam, teamName)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	err = servicemanager.TeamToken.Delete(tokenID)
	if err == authTypes.ErrTeamTokenNotFound {
		return &errors.HTTP{
			Code:    http.StatusNotFound,
			Message: err.Error(),
		}
	}
	return err
}
func tokenDelete ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { tokenID := r . URL . Query ( ) . Get ( " " ) teamToken , err := servicemanager . TeamToken . FindByTokenID ( tokenID ) if err != nil { if err == authTypes . ErrTeamTokenNotFound { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) , } } return err } teamName := teamToken . Team allowed := permission . Check ( t , permission . PermTeamTokenDelete , permission . Context ( permTypes . CtxTeam , teamName ) , ) if ! allowed { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : teamTarget ( teamName ) , Kind : permission . PermTeamTokenDelete , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermTeamReadEvents , permission . Context ( permTypes . CtxTeam , teamName ) ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) err = servicemanager . TeamToken . Delete ( tokenID ) if err == authTypes . ErrTeamTokenNotFound { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) , } } return err }
// title: token delete
// path: /tokens/{token_id}
// method: DELETE
// produce: application/json
// responses:
//   200: Token created
//   401: Unauthorized
//   404: Token not found
title : token delete path : / tokens / { token_id } method : DELETE produce : application / json responses : 200 : Token created 401 : Unauthorized 404 : Token not found