public async Task <ArangoVertexResponse <ArangoVoid> > ReplaceAsync <T>(ArangoHandle database, string graph,
                                                                         string collection, string key, T doc,
                                                                         bool?waitForSync = null, bool?keepNull = null, bool?returnNew = null, bool?returnOld = null,
                                                                         CancellationToken cancellationToken = default)
 {
     return(await ReplaceAsync <T, ArangoVoid>(database, graph, collection, key, doc, waitForSync, keepNull,
                                               returnNew, returnOld, cancellationToken));
 }
Esempio n. 2
0
 public async Task DeleteAsync(ArangoHandle database,
                               string analyzer, bool force         = false,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <QueryResponse <ArangoVoid> >(HttpMethod.Delete,
                                                   ApiPath(database, $"analyzer/{UrlEncode(analyzer)}?force={(force ? "true" : "false")}"),
                                                   cancellationToken : cancellationToken);
 }
 public async Task <ArangoVertexResponse <ArangoVoid> > RemoveAsync(ArangoHandle database, string graph,
                                                                    string collection, string key,
                                                                    bool?waitForSync = null, bool?returnOld = null,
                                                                    CancellationToken cancellationToken = default)
 {
     return(await RemoveAsync <ArangoVoid>(database, graph, collection, key, waitForSync, returnOld,
                                           cancellationToken));
 }
 public async Task <ArangoVertexResponse <ArangoVoid> > CreateAsync <T>(ArangoHandle database, string graph,
                                                                        string collection, T doc,
                                                                        bool?waitForSync = null, bool?returnNew = null,
                                                                        CancellationToken cancellationToken = default)
 {
     return(await CreateAsync <T, ArangoVoid>(database, graph, collection, doc, waitForSync, returnNew,
                                              cancellationToken));
 }
Esempio n. 5
0
 public async Task CreateAsync(ArangoHandle database, ArangoCollection collection,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <JObject>(HttpMethod.Post,
                               ApiPath(database, "collection"),
                               JsonConvert.SerializeObject(collection, ArangoContext.JsonSerializerSettings),
                               cancellationToken : cancellationToken);
 }
Esempio n. 6
0
 public async Task UpdateAsync(ArangoHandle database, string collection, ArangoCollectionUpdate update,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <JObject>(HttpMethod.Put,
                               ApiPath(database, $"collection/{collection}/properties"),
                               Serialize(update),
                               cancellationToken : cancellationToken);
 }
        public async Task <T> SingleOrDefaultAsync <T>(ArangoHandle database, string collection, FormattableString filter,
                                                       string projection = null, CancellationToken cancellationToken = default) where T : new()
        {
            var results = await FindAsync <T>(database, collection, filter, projection, 2, cancellationToken);

            if (results.Count == 0)
            {
                return(default);
 public async Task <T> DeleteAsync <T>(ArangoHandle database, string mount,
                                       IDictionary <string, string> queryParams = null,
                                       CancellationToken cancellationToken      = default)
 {
     return(await SendAsync <T>(database, HttpMethod.Delete,
                                FoxxPath(database, mount, queryParams),
                                cancellationToken : cancellationToken));
 }
 public async Task DropAsync(ArangoHandle database,
                             string name,
                             CancellationToken cancellationToken = default)
 {
     await SendAsync <JObject>(HttpMethod.Delete,
                               ApiPath(database, $"view/{UrlEncode(name)}"),
                               cancellationToken : cancellationToken);
 }
Esempio n. 10
0
 public async Task CreateAsync(ArangoHandle database, ArangoView view,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <JObject>(HttpMethod.Post,
                               ApiPath(database, "view"),
                               Serialize(view),
                               cancellationToken : cancellationToken);
 }
Esempio n. 11
0
 public async Task CreateAsync(ArangoHandle database, ArangoView view,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <ArangoVoid>(HttpMethod.Post,
                                  ApiPath(database, "view"),
                                  view,
                                  cancellationToken : cancellationToken);
 }
        public async IAsyncEnumerable <List <T> > ExportAsync <T>(ArangoHandle database,
                                                                  string collection, bool?flush = null, int?flushWait = null, int?batchSize = null, int?ttl = null,
                                                                  [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            if (database.Batches != null)
            {
                throw new NotSupportedException("no batch support");
            }

            var parameter = new Dictionary <string, string>
            {
                ["collection"] = collection
            };

            var query = AddQueryString(
                ApiPath(database, "export"), parameter);

            var firstResult = await SendAsync <QueryResponse <T> >(database, HttpMethod.Post,
                                                                   query,
                                                                   new ExportRequest
            {
                Flush     = flush,
                FlushWait = flushWait,
                BatchSize = batchSize ?? Context.Configuration.BatchSize,
                Ttl       = ttl
            }, cancellationToken : cancellationToken);

            yield return(firstResult.Result);

            if (firstResult.HasMore)
            {
                while (true)
                {
                    var res = await SendAsync <QueryResponse <T> >(database, HttpMethod.Put,
                                                                   ApiPath(database, $"cursor/{firstResult.Id}"),
                                                                   cancellationToken : cancellationToken);

                    yield return(res.Result);

                    if (!res.HasMore)
                    {
                        break;
                    }
                }

                try
                {
                    await SendAsync <ArangoVoid>(database, HttpMethod.Delete,
                                                 ApiPath(database, $"cursor/{firstResult.Id}"),
                                                 cancellationToken : cancellationToken);
                }
                catch
                {
                    //
                }
            }
        }
Esempio n. 13
0
 public async Task CreateAsync(ArangoHandle database,
                               ArangoAnalyzer analyzer,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <QueryResponse <JObject> >(HttpMethod.Post,
                                                ApiPath(database, "analyzer"),
                                                Serialize(analyzer),
                                                cancellationToken : cancellationToken);
 }
        public async Task <TR> GetAsync <TR>(ArangoHandle database, string graph, string collection, string key,
                                             CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <ArangoVertexResponse <TR> >(HttpMethod.Get,
                                                                   ApiPath(database, $"gharial/{UrlEncode(graph)}/vertex/{UrlEncode(collection)}"),
                                                                   cancellationToken : cancellationToken);

            return(res.Vertex);
        }
Esempio n. 15
0
        public async Task DropAllAsync(ArangoHandle database, CancellationToken cancellationToken = default)
        {
            var views = await ListAsync(database, cancellationToken);

            foreach (var view in views)
            {
                await DropAsync(database, view.Name, cancellationToken);
            }
        }
Esempio n. 16
0
        public async Task <IReadOnlyCollection <ArangoViewInformation> > ListAsync(ArangoHandle database,
                                                                                   CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <QueryResponse <ArangoViewInformation> >(database, HttpMethod.Get,
                                                                               ApiPath(database, "view"),
                                                                               cancellationToken : cancellationToken);

            return(res.Result);
        }
Esempio n. 17
0
        public async Task <List <T> > FindAsync <T>(ArangoHandle database, string collection, FormattableString filter,
                                                    string projection = null, int limit = 1000, CancellationToken cancellationToken = default)
        {
            var filterExp = Parameterize(filter, out var parameter);

            return(await ExecuteAsync <T>(database,
                                          $"FOR x IN {collection} FILTER {filterExp} LIMIT {limit} RETURN {projection ?? "x"}",
                                          parameter, cancellationToken : cancellationToken));
        }
Esempio n. 18
0
 public async Task CreateAsync(ArangoHandle database,
                               ArangoAnalyzer analyzer,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <QueryResponse <ArangoVoid> >(database, HttpMethod.Post,
                                                   ApiPath(database, "analyzer"),
                                                   analyzer,
                                                   cancellationToken : cancellationToken);
 }
        /// <summary>
        ///     Clear the database access level, revert back to the default access level
        /// </summary>
        public async Task <bool> DeleteDatabaseAccessAsync(ArangoHandle handle, string user,
                                                           CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <ArangoVoid>(null, HttpMethod.Delete,
                                                   ApiPath($"user/{UrlEncode(user)}/database/{RealmPrefix(handle)}"),
                                                   cancellationToken : cancellationToken);

            return(res != null);
        }
Esempio n. 20
0
        public async Task <List <string> > ListAsync(ArangoHandle database,
                                                     CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <QueryResponse <ArangoCollection> >(HttpMethod.Get,
                                                                          ApiPath(database, "collection?excludeSystem=true"),
                                                                          cancellationToken : cancellationToken);

            return(res.Result.Select(x => x.Name).ToList());
        }
        public async Task <int> RemoveAsync(ArangoHandle database, string name, bool?group = false,
                                            CancellationToken cancellationToken            = default)
        {
            var res = await SendAsync <FunctionRemoveResponse>(HttpMethod.Delete,
                                                               ApiPath(database, $"{API}/{name}?group={(group ?? false).ToString().ToLowerInvariant()}"),
                                                               cancellationToken : cancellationToken);

            return(res.DeletedCount);
        }
Esempio n. 22
0
        public async Task <List <string> > ListAsync(ArangoHandle database,
                                                     CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <JObject>(HttpMethod.Get,
                                                ApiPath(database, "view"),
                                                cancellationToken : cancellationToken);

            return(res.GetValue("result")
                   .Select(x => x.Value <string>("name")).ToList());
        }
Esempio n. 23
0
        public async Task AbortAsync(ArangoHandle database, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(database.Transaction))
            {
                throw new ArangoException("no transaction handle");
            }

            await SendAsync <ArangoVoid>(null, HttpMethod.Delete,
                                         ApiPath(database, $"transaction/{database.Transaction}"),
                                         cancellationToken : cancellationToken);
        }
Esempio n. 24
0
        public async Task <ArangoHandle> BeginAsync(ArangoHandle database, ArangoTransaction request,
                                                    CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <SingleResult <TransactionResponse> >(null, HttpMethod.Post,
                                                                            ApiPath(database, "transaction/begin"),
                                                                            request, cancellationToken : cancellationToken);

            var transaction = res.Result.Id;

            return(new ArangoHandle(database, transaction));
        }
Esempio n. 25
0
 public async Task RenameAsync(ArangoHandle database, string oldname, string newname,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <ArangoVoid>(HttpMethod.Put,
                                  ApiPath(database, $"collection/{oldname}/rename"),
                                  new
     {
         name = newname
     },
                                  cancellationToken : cancellationToken);
 }
Esempio n. 26
0
 public async Task CreateAsync(ArangoHandle database, string collection, ArangoCollectionType type,
                               CancellationToken cancellationToken = default)
 {
     await SendAsync <ArangoVoid>(HttpMethod.Post,
                                  ApiPath(database, "collection"),
                                  new ArangoCollection
     {
         Name = collection,
         Type = type
     }, cancellationToken : cancellationToken);
 }
Esempio n. 27
0
        protected string FoxxPath(ArangoHandle handle, string path, IDictionary <string, string> parameter = null)
        {
            var req = $"/_db/{RealmPrefix(handle)}{path}";

            if (parameter?.Any() == true)
            {
                req = AddQueryString(req, parameter);
            }

            return(req);
        }
Esempio n. 28
0
        public async Task DisableDevelopmentModeAsync(ArangoHandle database, string mount,
                                                      CancellationToken cancellationToken = default)
        {
            var parameter = new Dictionary <string, string> {
                { "mount", mount }
            };

            await SendAsync <ArangoVoid>(HttpMethod.Delete,
                                         ApiPath(database, "foxx/development", parameter),
                                         cancellationToken : cancellationToken);
        }
Esempio n. 29
0
        public async Task <T> GetDependenciesAsync <T>(ArangoHandle database, string mount,
                                                       CancellationToken cancellationToken = default)
        {
            var parameter = new Dictionary <string, string> {
                { "mount", mount }
            };

            return(await SendAsync <T>(HttpMethod.Get,
                                       ApiPath(database, "foxx/dependencies", parameter),
                                       cancellationToken : cancellationToken));
        }
        public async Task <bool> CreateAsync(ArangoHandle name, CancellationToken cancellationToken = default)
        {
            var res = await SendAsync <ArangoVoid>(HttpMethod.Post,
                                                   ApiPath("_system", "database"),
                                                   new
            {
                name = RealmPrefix(name)
            }, throwOnError : false, cancellationToken : cancellationToken);

            return(res != null);
        }