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

GetInfluxDBStructureAsync() public method

Gets the whole DB structure for the given databse in Influx.
When Influx needs authentication, and no user name password is supplied or auth fails all other HTTP exceptions
public GetInfluxDBStructureAsync ( string dbName ) : Task
dbName string Name of the database
return Task
        public async Task<IInfluxDatabase> GetInfluxDBStructureAsync (string dbName)
        {
            var dbStructure = new InfluxDatabase (dbName);
            var fields = await QueryMultiSeriesAsync (dbName, "SHOW FIELD KEYS");
            foreach (var s in fields)
            {
                var measurement = new InfluxMeasurement (s.SeriesName);
                foreach (var e in s.Entries)
                    measurement.Fields.Add (e.FieldKey);
                dbStructure.Measurements.Add (measurement);
            }

            var tags = await QueryMultiSeriesAsync (dbName, "SHOW TAG KEYS");
            foreach (var t in tags)
            {
                var measurement = dbStructure.Measurements.FirstOrDefault (x => x.Name == t.SeriesName);
                foreach (var e in t.Entries)
                    measurement.Tags.Add (e.TagKey);
            }

            return dbStructure;
        }

Usage Example

        public async Task TestGetInfluxDBStructureAsync()
        {
            try
            {

                var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
                var r = await client.GetInfluxDBStructureAsync ("InvalidDB");
                Assert.IsTrue (r != null && r.Count == 0, "GetInfluxDBNamesAsync retunred null or non empty collection");
            }
            catch ( Exception e )
            {
                Assert.Fail ("Unexpected exception of type {0} caught: {1}",
                            e.GetType (), e.Message);
                return;
            }
        }
All Usage Examples Of AdysTech.InfluxDB.Client.Net.InfluxDBClient::GetInfluxDBStructureAsync