Exemplo n.º 1
0
        /// <summary>
        /// Forces a update
        /// </summary>
        public override RestResponse OnPost(Query query, object payloadObject)
        {
            //get the manager
            RestoreMonitor restorer = GetRestoreMonitor();

            if (restorer == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the restore manager!"));
            }

            //Get the backup
            var restore = restorer.CreateSnapshotAsync(World).Result;

            if (restore == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Restore does not exist."));
            }

            return(new RestResponse(RestStatus.OK, res: restore));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes all the backups
        /// </summary>
        public override RestResponse OnDelete(Query query)
        {
            //get the manager
            RestoreMonitor restorer = GetRestoreMonitor();

            if (restorer == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the restore manager!"));
            }

            //Get the backup
            var task = restorer.DeleteRestoreAsync(World);

            if (query.IsAsync)
            {
                return(RestResponse.Async);
            }

            //Delete the backup
            return(new RestResponse(RestStatus.OK, res: task.Result));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the world backup
        /// </summary>
        public override RestResponse OnGet(Query query)
        {
            //get the manager
            RestoreMonitor restorer = GetRestoreMonitor();

            if (restorer == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the restore manager!"));
            }

            //Get the backup
            var restore = restorer.GetWorldRestoreAsync(World).Result;

            if (restore == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Restore does not exist."));
            }

            //return the world
            return(new RestResponse(RestStatus.OK, res: restore));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Edits the world backup
        /// </summary>
        public override RestResponse OnPatch(Query query, object payloadObject)
        {
            //get the patch
            WorldRestorePatch patch = (WorldRestorePatch)payloadObject;

            //get the manager
            RestoreMonitor restorer = GetRestoreMonitor();

            if (restorer == null)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Could not find the restore manager!"));
            }

            var result = restorer.SetMirrorAsync(World, patch.Mirror != null ? World.Parse(patch.Mirror) : null).Result;

            if (!result)
            {
                return(new RestResponse(RestStatus.ResourceNotFound, msg: "Server failed to patch the world. Does it exist?"));
            }

            return(OnGet(query));
        }