/// <summary>
        /// Gets 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 get the vertex from.</param>
        /// <param name="documentId">The document ID of the vertex to retrieve.</param>
        /// <param name="query"></param>
        /// <returns></returns>
        public virtual async Task <GetVertexResponse <T> > GetVertexAsync <T>(
            string graphName,
            string documentId,
            GetVertexQuery query = null)
        {
            ValidateDocumentId(documentId);

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

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

                    return(DeserializeJsonFromStream <GetVertexResponse <T> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
Ejemplo n.º 2
0
 /// Gets a vertex from the given collection.
 /// GET/_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 <GetVertexResponse <T> > GetVertexAsync <T>(
     string graphName,
     string collectionName,
     string vertexKey,
     GetVertexQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(await GetRequestAsync(ApiRootPath + '/' + WebUtility.UrlEncode(graphName) +
                                  "/vertex/" + WebUtility.UrlEncode(collectionName) + "/" + vertexKey,
                                  response => new GetVertexResponse <T>(response), query, cancellationToken));
 }
 /// <summary>
 /// Gets a vertex from the given collection.
 /// GET/_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 <GetVertexResponse <T> > GetVertexAsync <T>(
     string graphName,
     string collectionName,
     string vertexKey,
     GetVertexQuery query = null)
 {
     return(GetVertexAsync <T>(
                graphName,
                WebUtility.UrlEncode(collectionName) + "/" + vertexKey,
                query));
 }