/// <summary> /// Returns an object reference to the tag with the specified name in the specified namespace /// </summary> /// <param name="c"></param> /// <param name="f_namespace"></param> /// <param name="name"></param> /// <param name="returnDescription"></param> /// <returns></returns> public static FluidTag GetTag(FluidConnector c, FluidNamespace f_namespace, string name, bool returnDescription) { Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("returnDescription", returnDescription.ToString()); // send get request with parameters in URI (.net does not allow you to use the payload string path = "/tags/" + (f_namespace != null ? f_namespace.Name + "/" : "") + name; HttpWebResponse r = c.Call(METHOD.GET, path, parameters, null); if (r.StatusCode == HttpStatusCode.OK) { Dictionary<string, object> response = c.GetJsonResultDictionary(r); FluidTag t = new FluidTag(c, (f_namespace != null ? f_namespace.Name + "/" : "") + name); if (returnDescription) { t.Description = response["description"].ToString(); } t.ID = new FluidDBGUID(response["id"].ToString()); t.Indexed = bool.Parse(response["indexed"].ToString()); return t; } else { return null; } }
private FluidNamespace(FluidConnector c, string name) { Connection = c; Name = name; Tags = new ObservableCollection<FluidTag>(); Namespaces = new ObservableCollection<FluidNamespace>(); }
/// <summary> /// Gets information for specified namespace /// <param name="c">The FluidConnector instance to make calls to</param> /// <param name="fl_namespace">The namespace to query, can be empty or null for top-level namespace</param> /// <param name="returnDescription">Whether to return a description of the namespace</param> /// <param name="returnNamespaces">Whether to return all namespaces within this namespace</param> /// <param name="returnTags">Whether or not to return all tags for this namespace</param> /// </summary> public static FluidNamespace GetNamespace(FluidConnector connection, string name, bool returnDescription, bool returnNamespaces, bool returnTags) { Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("returnDescription", returnDescription.ToString()); parameters.Add("returnNamespaces", returnNamespaces.ToString()); parameters.Add("returnTags", returnTags.ToString()); HttpWebResponse r = connection.Call(METHOD.GET, "/namespaces/" + name, parameters, null); if (r.StatusCode == HttpStatusCode.OK) { FluidNamespace n = new FluidNamespace(connection, name); Dictionary<string, object> response = connection.GetJsonResultDictionary(r); n.ID = new FluidDBGUID(response["id"] as string); if (returnDescription) { n.Description = response["description"].ToString(); } if (returnNamespaces) { ArrayList namespaces = response["namespaceNames"] as ArrayList; n.Namespaces.Clear(); foreach (object o in namespaces) { n.Namespaces.Add(new FluidNamespace(connection, o.ToString())); } } if (returnTags) { ArrayList tags = response["tagNames"] as ArrayList; n.Tags.Clear(); foreach (object o in tags) { FluidTag t = new FluidTag(connection, o.ToString()); n.Tags.Add(t); } } return n; } else { return null; } }
/// <summary> /// Creates the tag in the namespace /// </summary> public static FluidTag CreateTag(FluidConnector c, FluidNamespace f_namespace, string name, string description, bool indexed) { Dictionary<string, object> parameters = new Dictionary<string,object>(); parameters.Add("description", description); parameters.Add("indexed", indexed); parameters.Add("name", name); HttpWebResponse r = c.Call(METHOD.POST, "/tags/" + f_namespace.Name, null, parameters); if (r.StatusCode == HttpStatusCode.Created) { Dictionary<string, object> d = c.GetJsonResultDictionary(r); FluidTag t = new FluidTag(c, f_namespace + "/" + name); t.Description = description; t.Indexed = indexed; t.ID = new FluidDBGUID(d["id"].ToString()); return t; } else { return null; } }
/// <summary> /// Creates a new namespace in the current users namespace /// </summary> /// <param name="c"></param> /// <param name="namesp"></param> /// <param name="description"></param> internal static FluidNamespace CreateNamespace(FluidConnector c, string namesp, string description) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("description", description); parameters.Add("name", namesp); HttpWebResponse r = c.Call(METHOD.POST, "/namespaces/" + c.Username, null, parameters); if (r.StatusCode == HttpStatusCode.Created) { Dictionary<string, object> d= c.GetJsonResultDictionary(r); FluidNamespace n = new FluidNamespace(c, c.Username + "/" + namesp); n.ID = new FluidDBGUID(d["id"].ToString()); return n; } return null; }
internal FluidTag(FluidConnector c, string name) { Connection = c; Name = name; }