public TransactionApiClientTest(TransactionApiClientTestFixture fixture) { _adb = fixture.ArangoDBClient; _adb.Collection.TruncateCollectionAsync(fixture.TestCollection1).Wait(); _adb.Collection.TruncateCollectionAsync(fixture.TestCollection2).Wait(); _adb.Transaction.ThrowErrorsAsExceptions = false; }
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); }
public CollectionApiClientTest(CollectionApiClientTestFixture fixture) { _adb = fixture.ArangoDBClient; _collectionApi = _adb.Collection; _testCollection = fixture.TestCollection; // Truncate TestCollection before each test _collectionApi.TruncateCollectionAsync(fixture.TestCollection) .GetAwaiter() .GetResult(); }
public override async Task InitializeAsync() { await CreateDatabase(DbName, new List <DatabaseUser> { new DatabaseUser { Username = Username, Passwd = Password, Active = true } }); ArangoDBClient = GetArangoDBClient(DbName); }
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)); } }
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); }
public DocumentApiClientTest(DocumentApiClientTestFixture fixture) { _adb = fixture.ArangoDBClient; _docClient = _adb.Document; _testCollection = fixture.TestCollection; }
private void Init() { transport = HttpApiTransport.UsingBasicAuth(new Uri(settings.Uri), settings.Database, settings.UserId, settings.Password); Client = new ArangoDBClient(transport); }
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) { }
/// <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) { }
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)); }
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) } } }); }
public void CloseConnection() { Client?.Dispose(); Client = null; }
public CollectionApiClientTest(CollectionApiClientTestFixture fixture) { _adb = fixture.ArangoDBClient; _collectionApi = _adb.Collection; _testCollection = fixture.TestCollection; }
public ArangoDBGraphAlgorithms(ArangoDBClient arangoDBClient) { this.arangoDBClient = arangoDBClient ?? throw new ArgumentNullException(nameof(arangoDBClient)); }