/// <summary> /// Delete a document based on its document ID. /// </summary> /// <param name="documentId"></param> /// <param name="query"></param> /// <param name="headers">The <see cref="DocumentHeaderProperties"/> values.</param> /// <returns></returns> public virtual async Task <DeleteDocumentResponse <T> > DeleteDocumentAsync <T>( string documentId, DeleteDocumentQuery query = null, DocumentHeaderProperties headers = null) { ValidateDocumentId(documentId); string uri = _docApiPath + "/" + documentId; if (query != null) { uri += "?" + query.ToQueryString(); } var headerCollection = GetHeaderCollection(headers); using (var response = await _client.DeleteAsync(uri, headerCollection).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); var responseModel = DeserializeJsonFromStream <DeleteDocumentResponse <T> >(stream); return(responseModel); } throw await GetApiErrorException(response).ConfigureAwait(false); } }
/// <summary> /// Delete a user permanently. /// You need Administrate for the server access level in order to execute this REST call. /// </summary> /// <param name="username">The name of the user.</param> /// <returns></returns> public virtual async Task <DeleteUserResponse> DeleteUserAsync(string username) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username); using (var response = await _client.DeleteAsync(uri)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <DeleteUserResponse>(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Deletes an existing graph object by name. /// Optionally all collections not used by other /// graphs can be deleted as well, using <see cref = "DeleteGraphQuery" ></ see >. /// DELETE /_api/gharial/{graph-name} /// </summary> /// <param name="graphName"></param> /// <param name="body"></param> /// <returns></returns> public async Task <DeleteGraphResponse> DeleteGraphAsync(string graphName, DeleteGraphQuery query = null) { string uriString = _graphApiPath + "/" + WebUtility.UrlEncode(graphName); if (query != null) { uriString += "?" + query.ToQueryString(); } using (var response = await _transport.DeleteAsync(uriString)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <DeleteGraphResponse>(stream)); } throw await GetApiErrorException(response); } }
public async Task <DeleteDatabaseResponse> DeleteDatabaseAsync(string dbName) { using (var response = await _client.DeleteAsync(_databaseApiPath + "/" + WebUtility.UrlEncode(dbName))) { if (response.IsSuccessStatusCode) { return(new DeleteDatabaseResponse((int)response.StatusCode)); } throw await GetApiErrorException(response); } }
public async Task <DeleteCursorResponse> DeleteCursorAsync(string cursorId) { using (var response = await _client.DeleteAsync(_cursorApiPath + "/" + cursorId)) { if (response.IsSuccessStatusCode) { return(new DeleteCursorResponse((int)response.StatusCode)); } throw await GetApiErrorException(response); } }
/// <summary> /// Delete a document based on its document ID. /// </summary> /// <param name="documentId"></param> /// <param name="options"></param> /// <returns></returns> public async Task <DeleteDocumentResponse <T> > DeleteDocumentAsync <T>(string documentId, DeleteDocumentsQuery query = null) { ValidateDocumentId(documentId); string uri = _docApiPath + "/" + documentId; if (query != null) { uri += "?" + query.ToQueryString(); } using (var response = await _client.DeleteAsync(uri)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); var responseModel = DeserializeJsonFromStream <DeleteDocumentResponse <T> >(stream); return(responseModel); } throw await GetApiErrorException(response); } }
public virtual async Task <DeleteCollectionResponse> DeleteCollectionAsync(string collectionName) { using (var response = await _transport.DeleteAsync(_collectionApiPath + "/" + WebUtility.UrlEncode(collectionName))) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <DeleteCollectionResponse>(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Delete a database. Dropping a database is only possible from within the _system database. /// The _system database itself cannot be dropped. /// DELETE /_api/database/{database-name} /// </summary> /// <param name="databaseName"></param> /// <returns></returns> public async Task <DeleteDatabaseResponse> DeleteDatabaseAsync(string databaseName) { using (var response = await _client.DeleteAsync(_databaseApiPath + "/" + WebUtility.UrlEncode(databaseName))) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <DeleteDatabaseResponse>(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Deletes an existing cursor and frees the resources associated with it. /// DELETE /_api/cursor/{cursor-identifier} /// </summary> /// <param name="cursorId">The id of the cursor to delete.</param> /// <returns></returns> public virtual async Task <DeleteCursorResponse> DeleteCursorAsync(string cursorId) { using (var response = await _client.DeleteAsync(_cursorApiPath + "/" + WebUtility.UrlEncode(cursorId)).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); return(DeserializeJsonFromStream <DeleteCursorResponse>(stream)); } throw await GetApiErrorException(response).ConfigureAwait(false); } }
/// <summary> /// Abort a stream transaction by DELETE. /// </summary> /// /// <remarks> /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#abort-transaction /// </remarks> /// <param name="transactionId">The transaction identifier.</param> /// <exception cref="ApiErrorException"> /// With ErrorNum 1653 if the transaction cannot be aborted. /// With ErrorNum 10 if the transaction is not found. /// </exception> /// <returns>Response from ArangoDB after aborting a transaction.</returns> public virtual async Task <StreamTransactionResponse> AbortTransaction(string transactionId) { string completeAbortTransactionPath = string.Format(_streamTransactionApiPath, transactionId); using (var response = await _client.DeleteAsync(completeAbortTransactionPath).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { return(DeserializeJsonFromStream <StreamTransactionResponse>(stream)); } var error = DeserializeJsonFromStream <ApiErrorResponse>(stream); throw new ApiErrorException(error); } }
/// <summary> /// Removes an existing AQL user function or function group, identified by name. /// DELETE /_api/aqlfunction/{name} /// </summary> /// <param name="name">The name of the function or function group (namespace).</param> /// <param name="query">The query parameters of the request.</param> /// <returns></returns> public virtual async Task <DeleteAqlFunctionResponse> DeleteAqlFunctionAsync( string name, DeleteAqlFunctionQuery query = null) { string uri = _apiPath + '/' + WebUtility.UrlEncode(name); if (query != null) { uri += "?" + query.ToQueryString(); } using (var response = await _transport.DeleteAsync(uri)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <DeleteAqlFunctionResponse>(stream)); } throw await GetApiErrorException(response); } }