public string addStreams(int number, bool addrules) { for (int i = 0; i < number; i++) { //create a stream object stream newStream = new stream(); newStream.name = "thisisastream - " + rand + "- " + i; TimeSpan responsetime = DateTime.Now.TimeOfDay; //serialise and post it and get the object back as a response string result = qrsClient.Post("/qrs/stream", JsonConvert.SerializeObject(newStream, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); //deserialise the response so we can get its ID newStream = JsonConvert.DeserializeObject <stream>(result); if (addrules) { //Create a Read Accessrule for the stream and post it systemrule rule = new systemrule(); rule.name = "Stream_read_" + newStream.name; rule.resourceFilter = "Stream_" + newStream.ID; rule.comment = "Generated rule to control [read] access for Stream " + newStream.name; rule.rule = "resource.resourcetype=\"Stream\" and (" + Environment.NewLine + "(user.country=\"United States\"))"; rule.actions = "2"; rule.category = "Security"; result = qrsClient.Post("/qrs/systemrule", JsonConvert.SerializeObject(rule, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); //Create a publish Accessrule for the stream and post it rule = new systemrule(); rule.name = "Stream_publish_" + newStream.name; rule.resourceFilter = "Stream_" + newStream.ID; rule.comment = "Generated rule to control [publish] access for Stream " + newStream.name; rule.rule = "resource.resourcetype=\"Stream\" and (" + Environment.NewLine + "(user.userId=\"" + Environment.UserName + "\"))"; rule.actions = "32"; rule.category = "Security"; result = qrsClient.Post("/qrs/systemrule", JsonConvert.SerializeObject(rule, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); } responsetime = DateTime.Now.TimeOfDay - responsetime; writeresult("Add", "Stream", responsetime); } return(number + " streams added"); }
public string addLicenceConfig(int number, bool addrules) { for (int i = 0; i < number; i++) { LoginLicenceType newRule = new LoginLicenceType(); newRule.name = "Allocation of Logins - " + rand + "- " + i; newRule.assignedTokens = "1"; TimeSpan responsetime = DateTime.Now.TimeOfDay; string result = qrsClient.Post("/qrs/license/loginaccesstype", JsonConvert.SerializeObject(newRule, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); newRule = JsonConvert.DeserializeObject <LoginLicenceType>(result); if (addrules) { //Create an Accessrule for the type and post it systemrule rule = new systemrule(); rule.name = "License.LoginAccessType_useaccesstype_" + newRule.name; rule.resourceFilter = "License.LoginAccessType_" + newRule.ID; rule.comment = "Generated rule to control [useaccesstype] access for License.LoginAccessType " + newRule.name; rule.rule = "resource.resourcetype=\"License.LoginAccessType\" and (" + Environment.NewLine + "(user.userDirectory=\"xx\"))"; rule.actions = "1"; rule.category = "License"; result = qrsClient.Post("/qrs/systemrule", JsonConvert.SerializeObject(rule, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); } responsetime = DateTime.Now.TimeOfDay - responsetime; writeresult("Add", "LicenceRule", responsetime); } return(number + " licence allocations added"); }