public TransactionApiClientTest(TransactionApiClientTestFixture fixture)
 {
     _adb = fixture.ArangoDBClient;
     _adb.Collection.TruncateCollectionAsync(fixture.TestCollection1).Wait();
     _adb.Collection.TruncateCollectionAsync(fixture.TestCollection2).Wait();
     _adb.Transaction.ThrowErrorsAsExceptions = false;
 }
Ejemplo n.º 2
0
        public DocumentApiClientTest(DocumentApiClientTestFixture fixture)
        {
            _adb       = fixture.ArangoDBClient;
            _docClient = _adb.Document;

            // Truncate TestCollection before each test
            _adb.Collection.TruncateCollectionAsync(fixture.TestCollection)
            .GetAwaiter()
            .GetResult();
        }
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            string dbName = nameof(CursorApiClientTest);

            await CreateDatabase(dbName);

            ArangoDBClient = GetArangoDBClient(dbName);
        }
Ejemplo n.º 4
0
        public CollectionApiClientTest(CollectionApiClientTestFixture fixture)
        {
            _adb            = fixture.ArangoDBClient;
            _collectionApi  = _adb.Collection;
            _testCollection = fixture.TestCollection;

            // Truncate TestCollection before each test
            _collectionApi.TruncateCollectionAsync(fixture.TestCollection)
            .GetAwaiter()
            .GetResult();
        }
Ejemplo n.º 5
0
        public override async Task InitializeAsync()
        {
            await CreateDatabase(DbName, new List <DatabaseUser>
            {
                new DatabaseUser
                {
                    Username = Username,
                    Passwd   = Password,
                    Active   = true
                }
            });

            ArangoDBClient = GetArangoDBClient(DbName);
        }
Ejemplo n.º 6
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
        {
            try
            {
                using var transport = await GetTransport(_options);

                using var adb = new ArangoDBClient(transport);
                var databases = await adb.Database.GetCurrentDatabaseInfoAsync();

                return(databases.Error
                    ? new HealthCheckResult(context.Registration.FailureStatus, $"HealthCheck failed with status code: {databases.Code}.")
                    : HealthCheckResult.Healthy());
            }
            catch (Exception ex)
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, ex.Message, ex));
            }
        }
Ejemplo n.º 7
0
        public ArangoDBClient OpenConnection(string dbName = "_system", bool root = false)
        {
            if (Client != null)
            {
                return(Client);
            }

            var user     = root ? _databaseSettings.User : _databaseSettings.DbUser;
            var password = root ? _databaseSettings.Password : _databaseSettings.DbPassword;
            // We must use the _system database to create databases
            var systemDbTransport = HttpApiTransport.UsingBasicAuth(
                new Uri(_databaseSettings.Url),
                dbName,
                password,
                user
                );

            return(Client = new ArangoDBClient(systemDbTransport));
        }
        public static IServiceCollection AddArangoDB(this IServiceCollection serviceDescriptors)
        {
            var transport = HttpApiTransport.UsingBasicAuth(
                new Uri("http://185.239.107.111:8529"),
                "_system",
                "root",
                "6600068167");

            var arangoDBClient = new ArangoDBClient(transport);

            serviceDescriptors.AddAutoMapper(typeof(ServiceCollectionExtension), typeof(MappingProfile));

            serviceDescriptors.AddTransient <IEntityInstanceRepository, ArangoDBEntityInstanceRepository>();
            serviceDescriptors.AddTransient <ILinkInstanceRepository, ArangoDBLinkInstanceRepository>();
            serviceDescriptors.AddTransient <IGraphAlgorithms, ArangoDBGraphAlgorithms>();
            serviceDescriptors.AddSingleton(arangoDBClient);

            return(serviceDescriptors);
        }
Ejemplo n.º 9
0
 public DocumentApiClientTest(DocumentApiClientTestFixture fixture)
 {
     _adb            = fixture.ArangoDBClient;
     _docClient      = _adb.Document;
     _testCollection = fixture.TestCollection;
 }
Ejemplo n.º 10
0
 private void Init()
 {
     transport =
         HttpApiTransport.UsingBasicAuth(new Uri(settings.Uri), settings.Database, settings.UserId, settings.Password);
     Client = new ArangoDBClient(transport);
 }
Ejemplo n.º 11
0
 public TransactionApiClientTest(TransactionApiClientTestFixture fixture)
 {
     _adb = fixture.ArangoDBClient;
     _adb.Collection.TruncateCollectionAsync(fixture.TestCollection1).Wait();
     _adb.Collection.TruncateCollectionAsync(fixture.TestCollection2).Wait();
 }
 public ArangoDBLinkInstanceRepository(ArangoDBClient arangoDBClient, IMapper mapper) :
     base(arangoDBClient, mapper, ArangoDBConsts.LinksCollectionName)
 {
 }
Ejemplo n.º 13
0
        /// <summary>
        /// The function body here is intended for use in "Quick Start" usage documentation.
        /// </summary>
        /// <returns></returns>
        private async Task QuickStartDoc()
        {
            // You must use the system database to create databases!
            using (var systemDbTransport = HttpApiTransport.UsingBasicAuth(
                       new Uri($"http://{_arangoDbHost}:8529/"),
                       "_system",
                       "root",
                       "root"))
            {
                var systemDb = new DatabaseApiClient(systemDbTransport);

                // Create a new database with one user.
                await systemDb.PostDatabaseAsync(
                    new PostDatabaseBody
                {
                    Name  = "arangodb-net-standard",
                    Users = new List <DatabaseUser>
                    {
                        new DatabaseUser
                        {
                            Username = "******",
                            Passwd   = "yoko123"
                        }
                    }
                });
            }

            // Use our new database, with basic auth credentials for the user jlennon.
            var transport = HttpApiTransport.UsingBasicAuth(
                new Uri($"http://{_arangoDbHost}:8529"),
                "arangodb-net-standard",
                "jlennon",
                "yoko123");

            var adb = new ArangoDBClient(transport);

            // Create a collection in the database
            await adb.Collection.PostCollectionAsync(
                new PostCollectionBody
            {
                Name = "MyCollection"
                       // A whole heap of other options exist to define key options,
                       // sharding options, etc
            });

            // Create document in the collection using anonymous type
            await adb.Document.PostDocumentAsync(
                "MyCollection",
                new
            {
                MyProperty = "Value"
            });

            // Create document in the collection using strong type
            await adb.Document.PostDocumentAsync(
                "MyCollection",
                new MyClass
            {
                ItemNumber  = 123456,
                Description = "Some item"
            });

            // Run AQL query (create a query cursor)
            var response = await adb.Cursor.PostCursorAsync <MyClassDocument>(
                @"FOR doc IN MyCollection 
                  FILTER doc.ItemNumber == 123456 
                  RETURN doc");

            MyClassDocument item = response.Result.First();

            // Partially update document
            await adb.Document.PatchDocumentAsync <object, object>(
                "MyCollection",
                item._key,
                new { Description = "More description" });

            // Fully update document
            item.Description = "Some item with some more description";
            await adb.Document.PutDocumentAsync(
                $"MyCollection/{item._key}",
                item);
        }
 public ArangoDBEntityInstanceRepository(ArangoDBClient arangoDBClient, IMapper mapper) :
     base(arangoDBClient, mapper, ArangoDBConsts.EntitiesCollectionName)
 {
 }
Ejemplo n.º 15
0
 public ArangoDBBaseInstanceRepository(ArangoDBClient arangoDBClient, IMapper mapper, string collectionName)
 {
     this.arangoDBClient = arangoDBClient ?? throw new ArgumentNullException(nameof(arangoDBClient));
     this.mapper         = mapper ?? throw new ArgumentNullException(nameof(mapper));
     this.collectionName = collectionName ?? throw new ArgumentNullException(nameof(collectionName));
 }
Ejemplo n.º 16
0
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            string dbName = nameof(GraphApiClientTest);

            await CreateDatabase(dbName);

            ArangoDBClient = GetArangoDBClient(dbName);

            try
            {
                var response = await ArangoDBClient.Collection.PostCollectionAsync(
                    new PostCollectionBody
                {
                    Name = TestCollection
                });
            }
            catch (ApiErrorException ex) when(ex.ApiError.ErrorNum == 1207)
            {
                // The collection must exist already, carry on...
                Console.WriteLine(ex.Message);
            }

            // create a graph
            await ArangoDBClient.Graph.PostGraphAsync(new PostGraphBody
            {
                Name            = TestGraph,
                EdgeDefinitions = new List <EdgeDefinition>
                {
                    new EdgeDefinition
                    {
                        From       = new string[] { "fromclx" },
                        To         = new string[] { "toclx" },
                        Collection = "clx"
                    }
                }
            });

            // A separate database is required as a workaround for a bug discovered
            // in ArangoDB 3.4.6-3.4.8 (and possibly other versions), affecting Windows only.
            // This is reportedly fixed in ArangoDB 3.5.3.
            await CreateDatabase(nameof(GraphApiClientTest.PutEdgeDefinitionAsync_ShouldSucceed));

            PutEdgeDefinitionAsync_ShouldSucceed_ArangoDBClient = GetArangoDBClient(
                nameof(GraphApiClientTest.PutEdgeDefinitionAsync_ShouldSucceed));

            await PutEdgeDefinitionAsync_ShouldSucceed_ArangoDBClient.Graph.PostGraphAsync(new PostGraphBody
            {
                Name            = TestGraph,
                EdgeDefinitions = new List <EdgeDefinition>
                {
                    new EdgeDefinition
                    {
                        From       = new string[] { "fromclx" },
                        To         = new string[] { "toclx" },
                        Collection = nameof(GraphApiClientTest.PutEdgeDefinitionAsync_ShouldSucceed)
                    }
                }
            });
        }
Ejemplo n.º 17
0
 public void CloseConnection()
 {
     Client?.Dispose();
     Client = null;
 }
 public CollectionApiClientTest(CollectionApiClientTestFixture fixture)
 {
     _adb            = fixture.ArangoDBClient;
     _collectionApi  = _adb.Collection;
     _testCollection = fixture.TestCollection;
 }
Ejemplo n.º 19
0
 public ArangoDBGraphAlgorithms(ArangoDBClient arangoDBClient)
 {
     this.arangoDBClient = arangoDBClient ?? throw new ArgumentNullException(nameof(arangoDBClient));
 }