/// <summary>
 /// 获取所有 Job
 /// </summary>
 /// <returns></returns>
 public static Dictionary <string, Dictionary <string, object> > Jobs()
 {
     try
     {
         var r        = HttpUtilities.APIWebHelper(APIUrlSelect(APIType.JOBS), HttpUtilities.HttpRequestMethod.GET);
         var baseType = JsonConvert.DeserializeObject <BaseType>(r).@return[0].ToString();
         return(JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, object> > >(baseType));
     }
     catch
     {
         return(null);
     }
 }
        /// <summary>
        /// minion 信息查询
        /// </summary>
        /// <returns>value 需要使用dynamic类型才可调用</returns>
        public static Dictionary <string, DynamicJson> minions()
        {
            var resp   = HttpUtilities.APIWebHelper(APIUrlSelect(APIType.MINIONS), HttpUtilities.HttpRequestMethod.GET);
            var minion = JsonConvert.DeserializeObject <BaseType>(resp);
            Dictionary <string, DynamicJson> minionDictionary = new Dictionary <string, DynamicJson>();
            var allMinion = JsonConvert.DeserializeObject <Dictionary <string, object> >(minion.@return[0].ToString());

            foreach (var m in allMinion.Keys)
            {
                var aa = DynamicJson.Parse(allMinion[m].ToString());
                minionDictionary.Add(m, aa);
            }
            return(minionDictionary);
        }
 /// <summary>
 /// API登陆方法
 /// Token有过期时间,需要偶尔调用一次
 /// </summary>
 /// <param name="lrt">登陆信息</param>
 /// <param name="url">API登陆的Url</param>
 /// <returns></returns>
 public static LoginResponseType Login()
 {
     if (loginRequestInfo != null)
     {
         var json      = JsonConvert.SerializeObject(loginRequestInfo);
         var resp      = JsonConvert.DeserializeObject <BaseType>(HttpUtilities.APIWebHelper(APIUrlSelect(APIType.LOGIN), HttpUtilities.HttpRequestMethod.POST, json));
         var loginInfo = JsonConvert.DeserializeObject <LoginResponseType>(resp.@return[0].ToString());
         RequestType.xAuthToken = loginInfo.token;
         return(loginInfo);
     }
     else
     {
         return(null);
     }
 }
        /// <summary>
        /// 命令执行
        /// </summary>
        /// <param name="rct">命令参数</param>
        /// <param name="rctna">命令参数(不含arg和match)</param>
        /// <returns></returns>
        public static BaseType CmdRun(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }
            var resp = HttpUtilities.APIWebHelper(APIurl, HttpUtilities.HttpRequestMethod.POST, json);

            if (resp.Length == 3)
            {
                return(new BaseType()
                {
                    @return = new List <object> {
                        "ERROR", resp
                    }
                });
            }
            return(JsonConvert.DeserializeObject <BaseType>(resp));
        }
        /// <summary>
        /// 详细查询特定 Job
        /// </summary>
        /// <param name="jid"></param>
        /// <returns></returns>
        public static Dictionary <string, List <Dictionary <string, dynamic> > > job(string jid)
        {
            var r = HttpUtilities.APIWebHelper(APIUrlSelect(APIType.JOBS, jid), HttpUtilities.HttpRequestMethod.GET);

            return(JsonConvert.DeserializeObject <Dictionary <string, List <Dictionary <string, dynamic> > > >(r));
        }
        /// <summary>
        /// 获取 minion 的详细信息
        /// </summary>
        /// <param name="minionName"> minion 名称</param>
        /// <returns></returns>
        public static dynamic MinionDetails(string minionName)
        {
            var r = JsonConvert.DeserializeObject <BaseType>(HttpUtilities.APIWebHelper(APIUrlSelect(APIType.MINIONS, minionName), HttpUtilities.HttpRequestMethod.GET));

            return(DynamicJson.Parse(r.@return[0].ToString()));
        }