/// <summary>
        /// Insert multiple edges into the database using a TPL Dataflow block.
        /// This call uses the SQL API to insert the edges as a document.
        /// </summary>
        /// <param name="edges">Edges to insert</param>
        /// <param name="reportingCallback">[Optional] Method to be called based on the <paramref name="reportingInterval"/>. Generally used to provide a progress update to callers. Defaults to null./></param>
        /// <param name="reportingInterval">[Optional] interval in seconds to to call the reporting callback. Defaults to 10s</param>
        /// <param name="threads">[Optional] Number of threads to use for the paralel execution. Defaults to 4</param>
        /// <param name="cancellationToken">Cancellation token to cancel the operation</param>
        /// <exception cref="InvalidOperationException">Throws invalid operation exception if the GraphClient was initialized without a <see cref="CosmosClientSql"/>.</exception>
        /// <example>
        /// <![CDATA[
        /// await _client.UpsertVertex(elements, (partial) => { Console.WriteLine($"upserted {partial.Count()} vertices");
        /// ]]>
        /// </example>
        /// <returns><see cref="CosmosResponse"/> that tracks success status along with various performance parameters.</returns>
        public Task <IEnumerable <CosmosResponse> > InsertEdges(IEnumerable <EdgeDefinition> edges, Action <IEnumerable <CosmosResponse> > reportingCallback = null, TimeSpan?reportingInterval = null, int threads = 4, CancellationToken cancellationToken = default(CancellationToken))
        {
            EnsureCosmosSqlClient();

            //Could've used InsertVertex instead of the lambda, but I don't want to the EnsureCosmosClient() for every call
            return(CosmosSqlClient.ProcessMultipleDocuments(edges, (EdgeDefinition edgeDef) => { return CosmosSqlClient.InsertDocumentInternal(CosmosSerializer.ToGraphEdge(edgeDef.EdgeEntity, edgeDef.SourceVertex, edgeDef.TargetVertex, edgeDef.Single)); }, reportingCallback, reportingInterval, threads, cancellationToken));
        }
 /// <summary>
 /// Insert multiple vertices into the database using a TPL Dataflow block.
 /// This call uses the SQL API to insert the vertices as documents.
 /// </summary>
 /// <param name="entities">Entites to insert</param>
 /// <param name="reportingCallback">[Optional] Method to be called based on the <paramref name="reportingInterval"/>. Generally used to provide a progress update to callers. Defaults to null./></param>
 /// <param name="reportingInterval">[Optional] interval in seconds to to call the reporting callback. Defaults to 10s</param>
 /// <param name="threads">[Optional] Number of threads to use for the paralel execution. Defaults to 4</param>
 /// <param name="cancellationToken">Cancellation token to cancel the operation</param>
 /// <exception cref="InvalidOperationException">Throws invalid operation exception if the GraphClient was initialized without a <see cref="CosmosClientSql"/>.</exception>
 /// <example>
 /// <![CDATA[
 /// await _client.InsertVertex(elements, (partial) => { Console.WriteLine($"inserted {partial.Count()} vertices");
 /// ]]>
 /// </example>
 /// <returns><see cref="CosmosResponse"/> that tracks success status along with various performance parameters.</returns>
 public Task <IEnumerable <CosmosResponse> > InsertVertex <T>(IEnumerable <T> entities, Action <IEnumerable <CosmosResponse> > reportingCallback = null, TimeSpan?reportingInterval = null, int threads = 4, CancellationToken cancellationToken = default(CancellationToken))
 {
     EnsureCosmosSqlClient();
     //Could've used InsertVertex instead of the lambda, but I don't want to the EnsureCosmosClient() for every call
     return(CosmosSqlClient.ProcessMultipleDocuments(entities, (T entity) => { return CosmosSqlClient.InsertDocumentInternal(CosmosSerializer.ToGraphVertex <T>(entity)); }, reportingCallback, reportingInterval, threads, cancellationToken));
 }
 /// <summary>
 /// Insert an edge into the database by referencing the source and target vertices just by their base properties (id, partitionKey, label).
 /// This call uses the SQL API to insert the edge as a document.
 /// </summary>
 /// <param name="edge">Edge entity to insert</param>
 /// <param name="source">Source vertex of the edge</param>
 /// <param name="target">Target vertex of the edge</param>
 /// <param name="single">
 /// [Optional] Indicates if there can only be one edge of this kind between the 2 vertices. Defaults to false.
 /// i.e an edge defining a 'isFriend' relationship between 2 people needs to be singe:true because only one friend edge makes sense.
 /// i.e an edge defining a 'visited' relationship between a person and a restaurant needs to be single:false because a person can visit the restaurant multiple times
 /// </param>
 /// <exception cref="InvalidOperationException">Throws invalid operation exception if the GraphClient was initialized without a CosmosSQLClient</exception>
 /// <remarks>Inserting the same edge twice with single:false will succeed and generate a new edge instance, while with single:true it will fail.</remarks>
 /// <returns><see cref="CosmosResponse"/> that tracks success status along with various performance parameters</returns>
 public Task <CosmosResponse> InsertEdge <T>(T edge, GraphItemBase source, GraphItemBase target, bool single = false)
 {
     EnsureCosmosSqlClient();
     return(CosmosSqlClient.InsertDocumentInternal(CosmosSerializer.ToGraphEdge(edge, source, target, single)));
 }
        //TODO: Fluent API -> when CosmosDB gets bytecode support
        //public GraphTraversalSource GetGraphTraversalSource()
        //{
        //    using (var gremlinClient = GetGremlinClient())
        //    {
        //        var start = DateTime.Now;
        //        var g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(gremlinClient));
        //        return g;
        //    }
        //}

        #endregion

        #region CosmosSQL calls - calls into a CosmosDB Graph using SQL API

        /// <summary>
        /// Insert a vertex into the database.
        /// This call uses the SQL API to insert the vertex as a document.
        /// </summary>
        /// <param name="entity">Entity to insert</param>
        /// <exception cref="InvalidOperationException">Throws invalid operation exception if the GraphClient was initialized without a CosmosSQLClient</exception>
        /// <returns><see cref="CosmosResponse"/> that tracks success status along with various performance parameters</returns>
        public Task <CosmosResponse> InsertVertex <T>(T entity)
        {
            EnsureCosmosSqlClient();
            return(CosmosSqlClient.InsertDocumentInternal(CosmosSerializer.ToGraphVertex <T>(entity)));
        }