/// <summary> /// Send a document to the database server /// </summary> /// <param name="doc">The document you want to send</param> /// <param name="log">The log you want to send your document to</param> /// <param name="addedUuidDescription">The description that the automatically generated UuidObject in the Manager will get</param> /// <param name="method">Sending method</param> public void PostDocument(Document doc, UuidObject log, string addedUuidDescription, Method method = Method.Post) { string transaction = (CurrentTransaction == "NONE") ? "" : $"/transaction/{CurrentTransaction}"; string json = JsonConvert.SerializeObject(doc); string resp; if (method == Method.Post) { resp = NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"document/{log.Id}{transaction}", json, "POST"); } else { resp = NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"document/{log.Id}{transaction}", json, "PUT"); } UuidManager.Add(resp, addedUuidDescription, UuidObject.UuidType.Key); }
/// <summary> /// End an established session with the database server /// </summary> public void Logout() { NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"auth/logout", "", "POST"); }
/// <summary> /// Start a session with the database server /// </summary> /// <param name="auth">Authentication data wich is specified in the config file of your database</param> public void Login(Authentication auth) { string json = JsonConvert.SerializeObject(auth); NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"auth/login", json, "POST"); }
/// <summary> /// Delete a specified document from the database server /// </summary> /// <param name="log">The log that stores your document</param> /// <param name="file">The key of your document</param> /// <returns>The server response</returns> public string DeleteDocument(UuidObject log, UuidObject file) { return(NetworkHandler.Delete(this.NodeLocation.HttpAddress(), $"document/{log.Id}/{file.Id}")); }