/// <summary> /// Replaces the data of an edge based on its document ID. /// </summary> /// <exception cref="ArgumentException">Provided document ID is invalid.</exception> /// <typeparam name="T">Type of the document used for the update.</typeparam> /// <param name="graphName">The name of the graph in which to replace the edge.</param> /// <param name="documentId">The document ID of the edge to replace.</param> /// <param name="edge"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PutEdgeResponse <T> > PutEdgeAsync <T>( string graphName, string documentId, T edge, PutEdgeQuery query = null) { ValidateDocumentId(documentId); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge/" + documentId; if (query != null) { uri += "?" + query.ToQueryString(); } var content = GetContent(edge, new ApiClientSerializationOptions(false, false)); using (var response = await _transport.PutAsync(uri, content)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <PutEdgeResponse <T> >(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Replaces the data of an edge in the collection. /// PUT /_api/gharial/{graph}/edge/{collection}/{edge} /// </summary> /// <typeparam name="T">Type of the document used for the update.</typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="edgeKey"></param> /// <param name="edge"></param> /// <param name="query"></param> /// <returns></returns> public async Task <PutEdgeResponse <T> > PutEdgeAsync <T>( string graphName, string collectionName, string edgeKey, T edge, PutEdgeQuery query = null) { var content = GetContent(edge, false, false); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge/" + WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey); if (query != null) { uri += "?" + query.ToQueryString(); } using (var response = await _transport.PutAsync(uri, content)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <PutEdgeResponse <T> >(stream)); } throw await GetApiErrorException(response); } }
/// <summary> /// Replaces the data of an edge in the collection. /// PUT /_api/gharial/{graph}/edge/{collection}/{edge} /// </summary> /// <typeparam name="T">Type of the document used for the update.</typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="edgeKey"></param> /// <param name="edge"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PutEdgeResponse <T> > PutEdgeAsync <T>( string graphName, string collectionName, string edgeKey, T edge, PutEdgeQuery query = null, CancellationToken cancellationToken = default) { return(await PutRequestAsync( $"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/edge/{WebUtility.UrlEncode(collectionName)}/{WebUtility.UrlEncode(edgeKey)}", response => new PutEdgeResponse <T>(response), edge, query, cancellationToken)); }
/// <summary> /// Replaces the data of an edge in the collection. /// PUT /_api/gharial/{graph}/edge/{collection}/{edge} /// </summary> /// <typeparam name="T">Type of the document used for the update.</typeparam> /// <param name="graphName"></param> /// <param name="collectionName"></param> /// <param name="edgeKey"></param> /// <param name="edge"></param> /// <param name="query"></param> /// <returns></returns> public virtual Task <PutEdgeResponse <T> > PutEdgeAsync <T>( string graphName, string collectionName, string edgeKey, T edge, PutEdgeQuery query = null) { return(PutEdgeAsync <T>( graphName, WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey), edge, query)); }