func moveContainersHandler(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	params := map[string]string{}
	err = api.ParseInput(r, &params)
	if err != nil {
		return err
	}
	from := params["from"]
	to := params["to"]
	if from == "" || to == "" {
		return &tsuruErrors.ValidationError{Message: fmt.Sprintf("Invalid params: from: %q - to: %q", from, to)}
	}
	permContexts, err := moveContainersPermissionContexts(from, to)
	if err != nil {
		return err
	}
	if !permission.Check(t, permission.PermNodeUpdateMoveContainers, permContexts...) {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeNode, Value: from},
		Kind:       permission.PermNodeUpdateMoveContainers,
		Owner:      t,
		CustomData: event.FormToCustomData(r.Form),
		Allowed:    event.Allowed(permission.PermPoolReadEvents, permContexts...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := tsuruIo.NewKeepAliveWriter(w, 15*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &tsuruIo.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt.SetLogWriter(writer)
	err = mainDockerProvisioner.MoveContainers(from, to, evt)
	if err != nil {
		return errors.Wrap(err, "Error trying to move containers")
	}
	fmt.Fprintf(evt, "Containers moved successfully!\n")
	return nil
}
func moveContainersHandler(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	params := map[string]string{}
	err = api.ParseInput(r, &params)
	if err != nil {
		return err
	}
	from := params["from"]
	to := params["to"]
	if from == "" || to == "" {
		return &tsuruErrors.ValidationError{Message: fmt.Sprintf("Invalid params: from: %q - to: %q", from, to)}
	}
	permContexts, err := moveContainersPermissionContexts(from, to)
	if err != nil {
		return err
	}
	if !permission.Check(t, permission.PermNodeUpdateMoveContainers, permContexts...) {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypeNode, Value: from},
		Kind:       permission.PermNodeUpdateMoveContainers,
		Owner:      t,
		CustomData: event.FormToCustomData(r.Form),
		Allowed:    event.Allowed(permission.PermPoolReadEvents, permContexts...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := tsuruIo.NewKeepAliveWriter(w, 15*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &tsuruIo.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt.SetLogWriter(writer)
	err = mainDockerProvisioner.MoveContainers(from, to, evt)
	if err != nil {
		return errors.Wrap(err, "Error trying to move containers")
	}
	fmt.Fprintf(evt, "Containers moved successfully!\n")
	return nil
}
func moveContainersHandler ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { params := map [ string ] string { } err = api . ParseInput ( r , & params ) if err != nil { return err } from := params [ " " ] to := params [ " " ] if from == " " || to == " " { return & tsuruErrors . ValidationError { Message : fmt . Sprintf ( " " , from , to ) } } permContexts , err := moveContainersPermissionContexts ( from , to ) if err != nil { return err } if ! permission . Check ( t , permission . PermNodeUpdateMoveContainers , permContexts ... ) { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : event . Target { Type : event . TargetTypeNode , Value : from } , Kind : permission . PermNodeUpdateMoveContainers , Owner : t , CustomData : event . FormToCustomData ( r . Form ) , Allowed : event . Allowed ( permission . PermPoolReadEvents , permContexts ... ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) w . Header ( ) . Set ( " " , " " ) keepAliveWriter := tsuruIo . NewKeepAliveWriter ( w , 15 * time . Second , " " ) defer keepAliveWriter . Stop ( ) writer := & tsuruIo . SimpleJsonMessageEncoderWriter { Encoder : json . NewEncoder ( keepAliveWriter ) } evt . SetLogWriter ( writer ) err = mainDockerProvisioner . MoveContainers ( from , to , evt ) if err != nil { return errors . Wrap ( err , " " ) } fmt . Fprintf ( evt , " \n " ) return nil }
// title: move containers
// path: /docker/containers/move
// method: POST
// consume: application/x-www-form-urlencoded
// produce: application/x-json-stream
// responses:
//   200: Ok
//   400: Invalid data
//   401: Unauthorized
//   404: Not found
title : move containers path : / docker / containers / move method : POST consume : application / x - www - form - urlencoded produce : application / x - json - stream responses : 200 : Ok 400 : Invalid data 401 : Unauthorized 404 : Not found