/// <summary>
        /// Updates the data of the specific vertex based on its document ID.
        /// </summary>
        /// <exception cref="ArgumentException">Provided document ID is invalid.</exception>
        /// <typeparam name="T">Type of the patch object</typeparam>
        /// <typeparam name="U">Type of the returned document, only applies when
        /// <see cref="PatchVertexQuery.ReturnNew"/> or <see cref="PatchVertexQuery.ReturnOld"/>
        /// are used.</typeparam>
        /// <param name="graphName">The name of the graph in which to update the vertex.</param>
        /// <param name="documentId">The document ID of the vertex to update.</param>
        /// <param name="body"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public virtual async Task <PatchVertexResponse <U> > PatchVertexAsync <T, U>(
            string graphName,
            string documentId,
            T body,
            PatchVertexQuery query = null)
        {
            ValidateDocumentId(documentId);

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

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

            var content = GetContent(body, new ApiClientSerializationOptions(false, false));

            using (var response = await _transport.PatchAsync(uri, content))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <PatchVertexResponse <U> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
        /// <summary>
        /// Updates the data of the specific vertex in the collection.
        /// PATCH/_api/gharial/{graph}/vertex/{collection}/{vertex}
        /// </summary>
        /// <typeparam name="T">Type of the patch object</typeparam>
        /// <typeparam name="U">Type of the returned document, only applies when
        /// <see cref="PatchVertexQuery.ReturnNew"/> or <see cref="PatchVertexQuery.ReturnOld"/>
        /// are used.</typeparam>
        /// <param name="graphName"></param>
        /// <param name="collectionName"></param>
        /// <param name="vertexKey"></param>
        /// <param name="body"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <PatchVertexResponse <U> > PatchVertexAsync <T, U>(
            string graphName,
            string collectionName,
            string vertexKey,
            T body,
            PatchVertexQuery query = null)
        {
            string uri = _graphApiPath + '/' + WebUtility.UrlEncode(graphName) +
                         "/vertex/" + WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(vertexKey);

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }
            var content = GetContent(body, false, false);

            using (var response = await _transport.PatchAsync(uri, content))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <PatchVertexResponse <U> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
Example #3
0
 /// <summary>
 /// Updates the data of the specific vertex in the collection.
 /// PATCH/_api/gharial/{graph}/vertex/{collection}/{vertex}
 /// </summary>
 /// <typeparam name="T">Type of the patch object</typeparam>
 /// <typeparam name="TReturned">Type of the returned document, only applies when
 /// <see cref="PatchVertexQuery.ReturnNew"/> or <see cref="PatchVertexQuery.ReturnOld"/>
 /// are used.</typeparam>
 /// <param name="graphName"></param>
 /// <param name="collectionName"></param>
 /// <param name="vertexKey"></param>
 /// <param name="body"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual async Task <PatchVertexResponse <TReturned> > PatchVertexAsync <TPatch, TReturned>(
     string graphName,
     string collectionName,
     string vertexKey,
     TPatch body,
     PatchVertexQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(await PatchRequestAsync(ApiRootPath + '/' + WebUtility.UrlEncode(graphName) +
                                    "/vertex/" + WebUtility.UrlEncode(collectionName) + "/" +
                                    WebUtility.UrlEncode(vertexKey),
                                    response => new PatchVertexResponse <TReturned>(response), body, query, cancellationToken));
 }
 /// <summary>
 /// Updates the data of the specific vertex in the collection.
 /// PATCH/_api/gharial/{graph}/vertex/{collection}/{vertex}
 /// </summary>
 /// <typeparam name="T">Type of the patch object</typeparam>
 /// <typeparam name="U">Type of the returned document, only applies when
 /// <see cref="PatchVertexQuery.ReturnNew"/> or <see cref="PatchVertexQuery.ReturnOld"/>
 /// are used.</typeparam>
 /// <param name="graphName"></param>
 /// <param name="collectionName"></param>
 /// <param name="vertexKey"></param>
 /// <param name="body"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual Task <PatchVertexResponse <U> > PatchVertexAsync <T, U>(
     string graphName,
     string collectionName,
     string vertexKey,
     T body,
     PatchVertexQuery query = null)
 {
     return(PatchVertexAsync <T, U>(
                graphName,
                WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(vertexKey),
                body,
                query));
 }