func webhookCreate(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	var webhook eventTypes.Webhook
	err := ParseInput(r, &webhook)
	if err != nil {
		return err
	}
	if webhook.TeamOwner == "" {
		webhook.TeamOwner, err = autoTeamOwner(t, permission.PermWebhookCreate)
		if err != nil {
			return err
		}
	}
	ctx := permission.Context(permTypes.CtxTeam, webhook.TeamOwner)
	if !permission.Check(t, permission.PermWebhookCreate, ctx) {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeWebhook, Value: webhook.Name},
		Kind:       permission.PermWebhookCreate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermWebhookReadEvents, ctx),
	})
	if err != nil {
		return err
	}
	defer func() {
		evt.Done(err)
	}()
	err = servicemanager.Webhook.Create(webhook)
	if err == eventTypes.ErrWebhookAlreadyExists {
		w.WriteHeader(http.StatusConflict)
	}
	return err
}
func webhookCreate(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	var webhook eventTypes.Webhook
	err := ParseInput(r, &webhook)
	if err != nil {
		return err
	}
	if webhook.TeamOwner == "" {
		webhook.TeamOwner, err = autoTeamOwner(t, permission.PermWebhookCreate)
		if err != nil {
			return err
		}
	}
	ctx := permission.Context(permTypes.CtxTeam, webhook.TeamOwner)
	if !permission.Check(t, permission.PermWebhookCreate, ctx) {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeWebhook, Value: webhook.Name},
		Kind:       permission.PermWebhookCreate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermWebhookReadEvents, ctx),
	})
	if err != nil {
		return err
	}
	defer func() {
		evt.Done(err)
	}()
	err = servicemanager.Webhook.Create(webhook)
	if err == eventTypes.ErrWebhookAlreadyExists {
		w.WriteHeader(http.StatusConflict)
	}
	return err
}
func webhookCreate ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { var webhook eventTypes . Webhook err := ParseInput ( r , & webhook ) if err != nil { return err } if webhook . TeamOwner == " " { webhook . TeamOwner , err = autoTeamOwner ( t , permission . PermWebhookCreate ) if err != nil { return err } } ctx := permission . Context ( permTypes . CtxTeam , webhook . TeamOwner ) if ! permission . Check ( t , permission . PermWebhookCreate , ctx ) { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : event . Target { Type : event . TargetTypeWebhook , Value : webhook . Name } , Kind : permission . PermWebhookCreate , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermWebhookReadEvents , ctx ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) err = servicemanager . Webhook . Create ( webhook ) if err == eventTypes . ErrWebhookAlreadyExists { w . WriteHeader ( http . StatusConflict ) } return err }
// title: webhook create
// path: /events/webhooks
// method: POST
// responses:
//   200: Webhook created
//   401: Unauthorized
//   400: Invalid webhook
//   409: Webhook already exists
title : webhook create path : / events / webhooks method : POST responses : 200 : Webhook created 401 : Unauthorized 400 : Invalid webhook 409 : Webhook already exists