CreateDatabaseAsync() public method

Creates the specified database
When Influx needs authentication, and no user name password is supplied or auth fails all other HTTP exceptions
public CreateDatabaseAsync ( string dbName ) : Task
dbName string
return Task
コード例 #1
0
ファイル: InfluxerTests.cs プロジェクト: AdysTech/Influxer
 private static async Task<InfluxDBClient> GetClientAsync (InfluxerConfigSection settings)
 {
     var client = new InfluxDBClient (settings.InfluxDB.InfluxUri, settings.InfluxDB.UserName, settings.InfluxDB.Password);
     var dbNames = await client.GetInfluxDBNamesAsync ();
     if (dbNames.Contains (settings.InfluxDB.DatabaseName))
         return client;
     else
     {
         await client.CreateDatabaseAsync (settings.InfluxDB.DatabaseName);
         return client;
     }
 }
コード例 #2
0
        public async Task TestCreateDatabaseAsync()
        {
            try
            {

                var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
                var r = await client.CreateDatabaseAsync (dbName);
                Assert.IsTrue (r, "CreateDatabaseAsync retunred false");
            }
            catch ( InvalidOperationException e )
            {
                StringAssert.Equals (e.Message, "database already exists");
            }
            catch ( Exception e )
            {

                Assert.Fail ("Unexpected exception of type {0} caught: {1}",
                            e.GetType (), e.Message);
                return;
            }
        }
コード例 #3
0
 public async Task TestCreateDatabaseAsync_InvalidName()
 {
     var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
     var r = await client.CreateDatabaseAsync (invalidDbName);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: AdysTech/Influxer
 private static async Task<bool> VerifyDatabaseAsync (InfluxDBClient client, string DBName)
 {
     try
     {
         //verify DB exists, create if not
         var dbNames = await client.GetInfluxDBNamesAsync ();
         if (dbNames.Contains (DBName))
             return true;
         else
         {
             var filter = settings.FileFormat == FileFormats.Perfmon ? settings.PerfmonFile.Filter : settings.GenericFile.Filter;
             if (filter == Filters.Measurement || filter == Filters.Field)
             {
                 Logger.LogLine (LogLevel.Info, "Measurement/Field filtering is not applicable for new database!!");
                 filter = Filters.None;
             }
             return await client.CreateDatabaseAsync (DBName);
         }
     }
     catch (Exception e)
     {
         Logger.LogLine (LogLevel.Info, "Unexpected exception of type {0} caught: {1}",
                     e.GetType (), e.Message);
     }
     return false;
 }