Exemple #1
0
 /// <summary>
 /// Gets an edge from the given graph using the edge's document-handle.
 /// GET /_api/gharial/{graph}/edge/{collection}/{edge}
 /// </summary>
 /// <typeparam name="T">The type of the edge document to deserialize to.</typeparam>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="edgeHandle">The document-handle of the edge document.</param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual async Task <GetEdgeResponse <T> > GetEdgeAsync <T>(
     string graphName,
     string edgeHandle,
     GetEdgeQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(await GetRequestAsync($"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/edge/{edgeHandle}",
                                  response => new GetEdgeResponse <T>(response), query, cancellationToken));
 }
 /// <summary>
 /// Gets an edge from the given graph using the edge collection and _key attribute.
 /// </summary>
 /// <typeparam name="T">The type of the edge document to deserialize to.</typeparam>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="collectionName">The name of the edge collection the edge belongs to.</param>
 /// <param name="edgeKey">The _key attribute of the edge.</param>
 /// <param name="query"></param>
 /// <returns></returns>
 public Task <GetEdgeResponse <T> > GetEdgeAsync <T>(
     string graphName,
     string collectionName,
     string edgeKey,
     GetEdgeQuery query = null)
 {
     return(GetEdgeAsync <T>(
                graphName,
                WebUtility.UrlEncode(collectionName) + '/' + WebUtility.UrlEncode(edgeKey),
                query));
 }
Exemple #3
0
 /// <summary>
 /// Gets an edge from the given graph using the edge collection and _key attribute.
 /// </summary>
 /// <typeparam name="T">The type of the edge document to deserialize to.</typeparam>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="collectionName">The name of the edge collection the edge belongs to.</param>
 /// <param name="edgeKey">The _key attribute of the edge.</param>
 /// <param name="query"></param>
 /// <returns></returns>
 public Task <GetEdgeResponse <T> > GetEdgeAsync <T>(
     string graphName,
     string collectionName,
     string edgeKey,
     GetEdgeQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(GetEdgeAsync <T>(
                graphName,
                WebUtility.UrlEncode(collectionName) + '/' + WebUtility.UrlEncode(edgeKey),
                query, cancellationToken));
 }
        /// <summary>
        /// Gets an edge from the given graph using the edge's document-handle.
        /// GET /_api/gharial/{graph}/edge/{collection}/{edge}
        /// </summary>
        /// <typeparam name="T">The type of the edge document to deserialize to.</typeparam>
        /// <param name="graphName">The name of the graph.</param>
        /// <param name="edgeHandle">The document-handle of the edge document.</param>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <GetEdgeResponse <T> > GetEdgeAsync <T>(
            string graphName,
            string edgeHandle,
            GetEdgeQuery query = null)
        {
            string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) +
                         "/edge/" + edgeHandle;

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

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

                    return(DeserializeJsonFromStream <GetEdgeResponse <T> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }