Пример #1
0
 /// <summary>
 /// Adds an additional edge definition to the graph.
 /// This edge definition has to contain a collection and an array of
 /// each from and to vertex collections. An edge definition can only
 /// be added if this definition is either not used in any other graph, or
 /// it is used with exactly the same definition. It is not possible to
 /// store a definition “e” from “v1” to “v2” in the one graph, and “e”
 /// from “v2” to “v1” in the other graph.
 /// POST /_api/gharial/{graph}/edge
 /// </summary>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="body">The information of the edge definition.</param>
 /// <returns></returns>
 public virtual async Task <PostEdgeDefinitionResponse> PostEdgeDefinitionAsync(
     string graphName,
     PostEdgeDefinitionBody body,
     CancellationToken cancellationToken = default)
 {
     return(await PostRequestAsync($"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/edge",
                                   response => new PostEdgeDefinitionResponse(response), body, null, cancellationToken));
 }
Пример #2
0
        /// <summary>
        /// Adds an additional edge definition to the graph.
        /// This edge definition has to contain a collection and an array of
        /// each from and to vertex collections. An edge definition can only
        /// be added if this definition is either not used in any other graph, or
        /// it is used with exactly the same definition. It is not possible to
        /// store a definition “e” from “v1” to “v2” in the one graph, and “e”
        /// from “v2” to “v1” in the other graph.
        /// POST /_api/gharial/{graph}/edge
        /// </summary>
        /// <param name="graphName">The name of the graph.</param>
        /// <param name="body">The information of the edge definition.</param>
        /// <returns></returns>
        public async Task <PostEdgeDefinitionResponse> PostEdgeDefinitionAsync(
            string graphName,
            PostEdgeDefinitionBody body)
        {
            var content = GetContent(body, true, true);

            string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge";

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

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