Exemple #1
0
        public ActionResult TestDatabaseConnection()
        {
            if (ServerState.Instance.ServerOnline || ServerState.Instance.ServerStarting)
            {
                return(APIStatus.BadRequest("You may only do this before server init"));
            }
            return(APIStatus.NotImplemented()); //TODO: Needs to be redone for EFCore.

            /*if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.MySQL,
             *      StringComparison.InvariantCultureIgnoreCase) && new MySQL().TestConnection())
             *  return APIStatus.OK();
             *
             * if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.SqlServer,
             *      StringComparison.InvariantCultureIgnoreCase) && new SQLServer().TestConnection())
             *  return APIStatus.OK();
             *
             * if (ServerSettings.Instance.Database.Type.Equals(Constants.DatabaseType.Sqlite,
             *  StringComparison.InvariantCultureIgnoreCase))
             *  return APIStatus.OK();*/

            //return APIStatus.BadRequest("Failed to Connect");
        }
Exemple #2
0
 public ActionResult TraktNotImplemented() => APIStatus.NotImplemented();
Exemple #3
0
 private object GetCloudAccounts()
 {
     // TODO APIv2: Cloud
     return(APIStatus.NotImplemented());
 }
Exemple #4
0
 private object DeleteCloudAccount()
 {
     // TODO APIv2: Cloud
     return(APIStatus.NotImplemented());
 }
Exemple #5
0
        public Core() : base("/api")
        {
            // As this module requireAuthentication all request need to have apikey in header.

            this.RequiresAuthentication();

            #region 01.Settings

            Post["/config/port/set", true] = async(x, ct) => await Task.Factory.StartNew(SetPort, ct);

            Get["/config/port/get", true] = async(x, ct) => await Task.Factory.StartNew(GetPort, ct);

            Post["/config/imagepath/set", true] = async(x, ct) => await Task.Factory.StartNew(SetImagepath, ct);

            Get["/config/imagepath/get", true] = async(x, ct) => await Task.Factory.StartNew(GetImagepath, ct);

            Get["/config/export", true] = async(x, ct) => await Task.Factory.StartNew(ExportConfig, ct);

            Post["/config/import", true] = async(x, ct) => await Task.Factory.StartNew(ImportConfig, ct);

            Post["/config/set", true] = async(x, ct) => await Task.Factory.StartNew(SetSetting, ct);

            Post["/config/get", true] = async(x, ct) => await Task.Factory.StartNew(GetSetting, ct);

            #endregion

            #region 02.AniDB

            Post["/anidb/set", true] = async(x, ct) => await Task.Factory.StartNew(SetAniDB, ct);

            Get["/anidb/get", true] = async(x, ct) => await Task.Factory.StartNew(GetAniDB, ct);

            Get["/anidb/test", true] = async(x, ct) => await Task.Factory.StartNew(TestAniDB, ct);

            Get["/anidb/votes/sync", true] = async(x, ct) => await Task.Factory.StartNew(SyncAniDBVotes, ct);

            Get["/anidb/list/sync", true] = async(x, ct) => await Task.Factory.StartNew(SyncAniDBList, ct);

            Get["/anidb/update", true] = async(x, ct) => await Task.Factory.StartNew(UpdateAllAniDB, ct);

            Get["/anidb/updatemissingcache", true] = async(x, ct) => await Task.Factory.StartNew(UpdateMissingAniDBXML, ct);

            #endregion

            #region 04.Trakt

            Post["/trakt/set"]      = x => APIStatus.NotImplemented();
            Get["/trakt/get", true] = async(x, ct) => await Task.Factory.StartNew(GetTrakt, ct);

            Get["/trakt/create"]     = x => APIStatus.NotImplemented();
            Get["/trakt/sync", true] = async(x, ct) => await Task.Factory.StartNew(SyncTrakt, ct);

            Get["/trakt/update", true] = async(x, ct) => await Task.Factory.StartNew(ScanTrakt, ct);

            Get["/trakt/code", true] = async(x, ct) => await Task.Factory.StartNew(GetTraktCode, ct);

            #endregion

            #region 05.TvDB

            Get["/tvdb/update", true] = async(x, ct) => await Task.Factory.StartNew(ScanTvDB, ct);

            Get["/tvdb/regenlinks", true] = async(x, ct) => await Task.Factory.StartNew(RegenerateAllEpisodeLinks, ct);

            Get["/tvdb/checklinks", true] = async(x, ct) => await Task.Factory.StartNew(CheckAllEpisodeLinksAgainstCurrent, ct);

            #endregion

            #region 06.MovieDB

            Get["/moviedb/update", true] = async(x, ct) => await Task.Factory.StartNew(ScanMovieDB, ct);

            #endregion

            #region 07.User

            Get["/user/list", true] = async(x, ct) => await Task.Factory.StartNew(GetUsers, ct);

            Post["/user/create", true] = async(x, ct) => await Task.Factory.StartNew(CreateUser, ct);

            Post["/user/delete", true] = async(x, ct) => await Task.Factory.StartNew(DeleteUser, ct);

            Post["/user/password", true] = async(x, ct) => await Task.Factory.StartNew(ChangePassword, ct);

            Post["/user/password/{uid}", true] = async(x, ct) => await Task.Factory.StartNew(() => ChangePassword(x.uid), ct);

            #endregion

            #region 08.OS-based operations

            Get["/os/folder/base", true] = async(x, ct) => await Task.Factory.StartNew(GetOSBaseFolder, ct);

            Post["/os/folder", true] = async(x, ct) => await Task.Factory.StartNew(() => GetOSFolder(x.folder), ct);

            Get["/os/drives", true] = async(x, ct) => await Task.Factory.StartNew(GetOSDrives, ct);

            #endregion

            #region 09.Cloud accounts

            Get["/cloud/list", true] = async(x, ct) => await Task.Factory.StartNew(GetCloudAccounts, ct);

            Get["/cloud/count", true] = async(x, ct) => await Task.Factory.StartNew(GetCloudAccountsCount, ct);

            Post["/cloud/add", true] = async(x, ct) => await Task.Factory.StartNew(AddCloudAccount, ct);

            Post["/cloud/delete", true] = async(x, ct) => await Task.Factory.StartNew(DeleteCloudAccount, ct);

            Get["/cloud/import", true] = async(x, ct) => await Task.Factory.StartNew(RunCloudImport, ct);

            #endregion

            #region 10.Logs

            Get["/log/get", true] = async(x, ct) => await Task.Factory.StartNew(() => GetLog(10, 0), ct);

            Get["/log/get/{max}/{position}", true] = async(x, ct) => await Task.Factory.StartNew(() => GetLog((int)x.max, (int)x.position), ct);

            Post["/log/rotate", true] = async(x, ct) => await Task.Factory.StartNew(SetRotateLogs, ct);

            Get["/log/rotate", true] = async(x, ct) => await Task.Factory.StartNew(GetRotateLogs, ct);

            Get["/log/rotate/start", true] = async(x, ct) => await Task.Factory.StartNew(StartRotateLogs, ct);

            #endregion

            #region 11. Image Actions
            Get["/images/update", true] = async(x, ct) => await Task.Factory.StartNew(() => UpdateImages());

            #endregion
        }