AdysTech.InfluxDB.Client.Net.InfluxDBClient.GetInfluxDBNamesAsync C# (CSharp) Method

GetInfluxDBNamesAsync() public method

Queries and Gets list of all existing databases in the Influx server instance
When Influx needs authentication, and no user name password is supplied or auth fails all other HTTP exceptions InfluxDB service is not available on the port mentioned
public GetInfluxDBNamesAsync ( ) : Task>
return Task>
        public async Task<List<String>> GetInfluxDBNamesAsync ()
        {
            var dbNames = new List<String> ();

            var dbs = await QueryMultiSeriesAsync (null, "SHOW DATABASES");

            foreach (var db in dbs.FirstOrDefault ()?.Entries)
                dbNames.Add (db?.Name);

            return dbNames;
        }

Usage Example

示例#1
0
 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;
     }
 }
All Usage Examples Of AdysTech.InfluxDB.Client.Net.InfluxDBClient::GetInfluxDBNamesAsync