/// <summary> /// Replaces the data of a vertex based on its document ID. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="graphName">The name of the graph in which to replace the vertex.</param> /// <param name="documentId">The document ID of the vertex to replace.</param> /// <param name="vertex"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PutVertexResponse <T> > PutVertexAsync <T>( string graphName, string documentId, T vertex, PutVertexQuery query = null) { ValidateDocumentId(documentId); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/vertex/" + documentId; if (query != null) { uri += "?" + query.ToQueryString(); } var content = GetContent(vertex, new ApiClientSerializationOptions(true, true)); using (var response = await _transport.PutAsync(uri, content)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <PutVertexResponse <T> >(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Replaces the data of a vertex in the collection. /// PUT/_api/gharial/{graph}/vertex/{collection}/{vertex} /// </summary> /// <typeparam name="T"></typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="key"></param> /// <param name="vertex"></param> /// <param name="query"></param> /// <returns></returns> public async Task <PutVertexResponse <T> > PutVertexAsync <T>( string graphName, string collectionName, string key, T vertex, PutVertexQuery query = null) { string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/vertex/" + WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(key); if (query != null) { uri += "?" + query.ToQueryString(); } var content = GetContent(vertex, true, true); using (var response = await _transport.PutAsync(uri, content)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <PutVertexResponse <T> >(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Replaces the data of a vertex in the collection. /// PUT/_api/gharial/{graph}/vertex/{collection}/{vertex} /// </summary> /// <typeparam name="T"></typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="key"></param> /// <param name="vertex"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PutVertexResponse <T> > PutVertexAsync <T>( string graphName, string collectionName, string key, T vertex, PutVertexQuery query = null, CancellationToken cancellationToken = default) { return(await PutRequestAsync( $"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/vertex/{WebUtility.UrlEncode(collectionName)}/{WebUtility.UrlEncode(key)}", response => new PutVertexResponse <T>(response), vertex, query, cancellationToken)); }
/// <summary> /// Replaces the data of a vertex in the collection. /// PUT/_api/gharial/{graph}/vertex/{collection}/{vertex} /// </summary> /// <typeparam name="T"></typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="key"></param> /// <param name="vertex"></param> /// <param name="query"></param> /// <returns></returns> public virtual Task <PutVertexResponse <T> > PutVertexAsync <T>( string graphName, string collectionName, string key, T vertex, PutVertexQuery query = null) { return(PutVertexAsync <T>( graphName, WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(key), vertex, query)); }