/// <summary>
        /// Removes a vertex from the collection.
        /// DELETE/_api/gharial/{graph}/vertex/{collection}/{vertex}
        /// </summary>
        /// <param name="graphName"></param>
        /// <param name="collectionName"></param>
        /// <param name="vertexKey"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <DeleteVertexResponse <T> > DeleteVertexAsync <T>(
            string graphName,
            string collectionName,
            string vertexKey,
            DeleteVertexQuery query = null)
        {
            string uri = _graphApiPath + '/' + WebUtility.UrlEncode(graphName) +
                         "/vertex/" + WebUtility.UrlEncode(collectionName) + "/" +
                         WebUtility.UrlEncode(vertexKey);

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }
            using (var response = await _transport.DeleteAsync(uri))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <DeleteVertexResponse <T> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
        /// <summary>
        /// Removes a vertex based on its document ID.
        /// </summary>
        /// <exception cref="ArgumentException">Provided document ID is invalid.</exception>
        /// <param name="graphName">The name of the graph to delete the vertex from.</param>
        /// <param name="documentId">The document ID of the vertex to delete.</param>
        /// <param name="query"></param>
        /// <returns></returns>
        public virtual async Task <DeleteVertexResponse <T> > DeleteVertexAsync <T>(
            string graphName,
            string documentId,
            DeleteVertexQuery query = null)
        {
            ValidateDocumentId(documentId);

            string uri = _graphApiPath + '/' + WebUtility.UrlEncode(graphName) +
                         "/vertex/" + documentId;

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }

            using (var response = await _transport.DeleteAsync(uri).ConfigureAwait(false))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

                    return(DeserializeJsonFromStream <DeleteVertexResponse <T> >(stream));
                }
                throw await GetApiErrorException(response).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Removes a vertex from the collection.
 /// DELETE/_api/gharial/{graph}/vertex/{collection}/{vertex}
 /// </summary>
 /// <param name="graphName"></param>
 /// <param name="collectionName"></param>
 /// <param name="vertexKey"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual async Task <DeleteVertexResponse <T> > DeleteVertexAsync <T>(
     string graphName,
     string collectionName,
     string vertexKey,
     DeleteVertexQuery query             = null,
     CancellationToken cancellationToken = default)
 {
     return(await DeleteRequestAsync(
                $"{ApiRootPath}{'/'}{WebUtility.UrlEncode(graphName)}/vertex/{WebUtility.UrlEncode(collectionName)}/{WebUtility.UrlEncode(vertexKey)}",
                response => new DeleteVertexResponse <T>(response), query, cancellationToken));
 }
 /// <summary>
 /// Removes a vertex from the collection.
 /// DELETE/_api/gharial/{graph}/vertex/{collection}/{vertex}
 /// </summary>
 /// <param name="graphName"></param>
 /// <param name="collectionName"></param>
 /// <param name="vertexKey"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual Task <DeleteVertexResponse <T> > DeleteVertexAsync <T>(
     string graphName,
     string collectionName,
     string vertexKey,
     DeleteVertexQuery query = null)
 {
     return(DeleteVertexAsync <T>(
                graphName,
                WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(vertexKey),
                query));
 }