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

GetServerVersionAsync() public method

InfluxDB engine version
public GetServerVersionAsync ( ) : Task
return Task
        public async Task<string> GetServerVersionAsync ()
        {
            var querybaseUrl = new Uri ($"{InfluxUrl}/ping");
            var builder = new UriBuilder (querybaseUrl);

            try
            {
                HttpResponseMessage response = await _client.GetAsync (builder.Uri);

                if (response.StatusCode == HttpStatusCode.NoContent)
                {
                    return response.Headers.GetValues ("X-Influxdb-Version").FirstOrDefault ();
                }
                else if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.BadGateway || (response.StatusCode == HttpStatusCode.InternalServerError && response.ReasonPhrase == "INKApi Error")) //502 Connection refused
                    throw new UnauthorizedAccessException ("InfluxDB needs authentication. Check uname, pwd parameters");

            }
            catch (HttpRequestException e)
            {
                if (e.InnerException.Message == "Unable to connect to the remote server")
                    throw new ServiceUnavailableException ();
            }
            return "Unknown";
        }