private static void CreateNewCheck(PingdomConfiguration pingdomConfiguration, string hostName, string checkName, string tags, IEnumerable <Check> allChecks) { // var allchecks = GetAllChecks(pingdomConfiguration); var alreadyExists = allChecks.Any(x => x.hostname == hostName); if (!alreadyExists) { Logger.Info("Adding Check to Pingdom"); var check = new CheckCreateDto { host = hostName, name = checkName, type = "http", encryption = true, port = 443, sendtoemail = true, resolution = 1, tags = tags }; var pp = new PingdomProcesser(pingdomConfiguration); var jsonOutput = pp.CreateNewCheck(check); Logger.Info($"{Environment.NewLine}{jsonOutput}"); } else { Logger.Info("Check already exists"); } }
public string CreateNewCheck(CheckCreateDto check) { var fd = (from x in check.GetType().GetProperties() select x).ToDictionary(x => x.Name, x => (x.GetGetMethod().Invoke(check, null) == null ? "" : x.GetGetMethod().Invoke(check, null).ToString())); var response = ConfigClientForChecks(Method.POST, "checks", fd); var content = response.Content; // raw content as string return(content); //var newCheck = new { name = check.name, type = check.type, host = check.hostname }; //var createNewCheckResponse = await Pingdom.Client.Checks.CreateNewCheck(newCheck); }