func platformRollback(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	image := InputValue(r, "image")
	if image == "" {
		return &tErrors.HTTP{
			Code:    http.StatusBadRequest,
			Message: "you cannot rollback without an image name",
		}
	}
	canUpdatePlatform := permission.Check(t, permission.PermPlatformUpdate)
	if !canUpdatePlatform {
		return permission.ErrUnauthorized
	}
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := io.NewKeepAliveWriter(w, 30*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &io.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypePlatform, Value: name},
		Kind:       permission.PermPlatformUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermPlatformReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	evt.SetLogWriter(writer)
	ctx, cancel := evt.CancelableContext(context.Background())
	err = servicemanager.Platform.Rollback(appTypes.PlatformOptions{
		Name:      name,
		ImageName: image,
		Output:    evt,
		Ctx:       ctx,
	})
	cancel()
	if err == appTypes.ErrPlatformNotFound {
		return &tErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if err != nil {
		return err
	}
	writer.Write([]byte("Platform successfully updated!\n"))
	return nil
}
func platformRollback(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	image := InputValue(r, "image")
	if image == "" {
		return &tErrors.HTTP{
			Code:    http.StatusBadRequest,
			Message: "you cannot rollback without an image name",
		}
	}
	canUpdatePlatform := permission.Check(t, permission.PermPlatformUpdate)
	if !canUpdatePlatform {
		return permission.ErrUnauthorized
	}
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := io.NewKeepAliveWriter(w, 30*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &io.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypePlatform, Value: name},
		Kind:       permission.PermPlatformUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermPlatformReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	evt.SetLogWriter(writer)
	ctx, cancel := evt.CancelableContext(context.Background())
	err = servicemanager.Platform.Rollback(appTypes.PlatformOptions{
		Name:      name,
		ImageName: image,
		Output:    evt,
		Ctx:       ctx,
	})
	cancel()
	if err == appTypes.ErrPlatformNotFound {
		return &tErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if err != nil {
		return err
	}
	writer.Write([]byte("Platform successfully updated!\n"))
	return nil
}
func platformRollback ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { name := r . URL . Query ( ) . Get ( " " ) image := InputValue ( r , " " ) if image == " " { return & tErrors . HTTP { Code : http . StatusBadRequest , Message : " " , } } canUpdatePlatform := permission . Check ( t , permission . PermPlatformUpdate ) if ! canUpdatePlatform { return permission . ErrUnauthorized } w . Header ( ) . Set ( " " , " " ) keepAliveWriter := io . NewKeepAliveWriter ( w , 30 * time . Second , " " ) defer keepAliveWriter . Stop ( ) writer := & io . SimpleJsonMessageEncoderWriter { Encoder : json . NewEncoder ( keepAliveWriter ) } evt , err := event . New ( & event . Opts { Target : event . Target { Type : event . TargetTypePlatform , Value : name } , Kind : permission . PermPlatformUpdate , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermPlatformReadEvents ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) evt . SetLogWriter ( writer ) ctx , cancel := evt . CancelableContext ( context . Background ( ) ) err = servicemanager . Platform . Rollback ( appTypes . PlatformOptions { Name : name , ImageName : image , Output : evt , Ctx : ctx , } ) cancel ( ) if err == appTypes . ErrPlatformNotFound { return & tErrors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } if err != nil { return err } writer . Write ( [ ] byte ( " \n " ) ) return nil }
// title: rollback platform
// path: /platforms/{name}/rollback
// method: POST
// produce: application/x-json-stream
// responses:
//   200: OK
//   400: BadRequest
//   401: Unauthorized
//   404: Not found
title : rollback platform path : / platforms / { name } / rollback method : POST produce : application / x - json - stream responses : 200 : OK 400 : BadRequest 401 : Unauthorized 404 : Not found