func installHostAdd(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	allowed := permission.Check(t, permission.PermInstallManage)
	if !allowed {
		return permission.ErrUnauthorized
	}
	var host *install.Host
	err = ParseInput(r, &host)
	if err != nil {
		return err
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeInstallHost, Value: host.Name},
		Kind:       permission.PermInstallManage,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermInstallManage),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	var rawDriver map[string]interface{}
	err = json.Unmarshal([]byte(r.Form.Get("driver")), &rawDriver)
	if err != nil {
		return err
	}
	host.Driver = rawDriver
	err = install.AddHost(host)
	if err != nil {
		return err
	}
	w.WriteHeader(http.StatusCreated)
	return nil
}
func installHostAdd(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	allowed := permission.Check(t, permission.PermInstallManage)
	if !allowed {
		return permission.ErrUnauthorized
	}
	var host *install.Host
	err = ParseInput(r, &host)
	if err != nil {
		return err
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeInstallHost, Value: host.Name},
		Kind:       permission.PermInstallManage,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermInstallManage),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	var rawDriver map[string]interface{}
	err = json.Unmarshal([]byte(r.Form.Get("driver")), &rawDriver)
	if err != nil {
		return err
	}
	host.Driver = rawDriver
	err = install.AddHost(host)
	if err != nil {
		return err
	}
	w.WriteHeader(http.StatusCreated)
	return nil
}
func installHostAdd ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { allowed := permission . Check ( t , permission . PermInstallManage ) if ! allowed { return permission . ErrUnauthorized } var host * install . Host err = ParseInput ( r , & host ) if err != nil { return err } evt , err := event . New ( & event . Opts { Target : event . Target { Type : event . TargetTypeInstallHost , Value : host . Name } , Kind : permission . PermInstallManage , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermInstallManage ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) var rawDriver map [ string ] interface { } err = json . Unmarshal ( [ ] byte ( r . Form . Get ( " " ) ) , & rawDriver ) if err != nil { return err } host . Driver = rawDriver err = install . AddHost ( host ) if err != nil { return err } w . WriteHeader ( http . StatusCreated ) return nil }
// title: add install host
// path: /install/hosts
// method: POST
// consume: application/x-www-form-urlencoded
// produce: application/json
// responses:
//   201: Host added
//   401: Unauthorized
title : add install host path : / install / hosts method : POST consume : application / x - www - form - urlencoded produce : application / json responses : 201 : Host added 401 : Unauthorized