/// <summary>
 /// Creates an InfluxDB client using the given InfluxDB connection information.
 /// </summary>
 /// <param name="connection">The InfluxDB connection configuration to use with the client.</param>
 public InfluxDbClient(InfluxDbConnection connection)
 {
     if (connection == null)
     {
         throw new ArgumentNullException("connection");
     }
     Connection = connection;
 }
        /// <summary>
        /// Creates an InfluxDB client using the given InfluxDB connection information.
        /// </summary>
        /// <param name="connection">The InfluxDB connection configuration to use with the client.</param>
        public InfluxDataNetClient(InfluxDbConnection connection) :
            base(connection)
        {
            // Create the underlying concrete client
            var c = connection;

            influx = new InfluxData.Net.InfluxDb.InfluxDbClient(c.HttpConnectionString,
                                                                c.Username, c.Password, InfluxDbVersion.Latest);
        }
        /// <summary>
        /// Creates a new <see cref="InfluxDbClient">InfluxDB client</see> using the default client implementation.
        /// </summary>
        /// <param name="connection">The connection information to use when creating the client.</param>
        /// <returns>An InfluxDB client that can be used to communicate with the InfluxDB server API.</returns>
        public static InfluxDbClient Create(InfluxDbConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            // TODO Support config/dependency injected concrete client type
            return(new InfluxDataNetClient(connection));
        }
        /// <summary>
        /// Creates an InfluxDB client using the given InfluxDB connection information.
        /// </summary>
        /// <param name="connection">The InfluxDB connection configuration to use with the client.</param>
        public InfluxDataNetClient(InfluxDbConnection connection) :
            base(connection)
        {
            // Create the underlying concrete client
            var c = connection;

            // trust any certificate
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, cert, chain, sslPolicyErrors) => { return(true); };

            influx = new InfluxData.Net.InfluxDb.InfluxDbClient(c.HttpConnectionString,
                                                                c.Username, c.Password, InfluxDbVersion.Latest);
        }