// Drops the selected policy
        async Task ShowDropPolicy()
        {
            try
            {
                var policy = SelectedRetentionPolicy;
                if (policy == null || string.IsNullOrWhiteSpace(SelectedDatabase))
                {
                    return;
                }
                var wasDefault = policy.Default;

                // Confirm the drop
                if (DialogResult.OK == MessageBox.Show(string.Format("Drop retention policy: {0}?", policy.Name), "Confirm Drop", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                {
                    var response = await InfluxDbClient.DropRetentionPolicyAsync(SelectedDatabase, policy.Name);

                    if (!response.Success)
                    {
                        AppForm.DisplayError(response.Body);
                    }

                    // If this was the default policy and was dropped
                    if (wasDefault)
                    {
                        policies = await InfluxDbClient.GetRetentionPoliciesAsync(SelectedDatabase);

                        if (policies.Count() > 0)
                        {
                            // Try to find the autogen/default
                            var rp = (from r in policies where r.Name.ToLower() == "autogen" select r).FirstOrDefault();

                            // Otherwise try to find another policy with a different name
                            if (rp == null)
                            {
                                rp = (from r in policies where r.Name != policy.Name select r).FirstOrDefault();
                            }

                            if (rp != null)
                            {
                                // If a new retention policy was found, make it the default
                                response = await InfluxDbClient.AlterRetentionPolicyAsync(SelectedDatabase, rp.Name, rp.Duration, rp.ReplicationCopies, true);
                            }
                        }
                    }

                    // Reload latest data
                    await ExecuteRequestAsync();
                }
            }
            catch (Exception ex)
            {
                AppForm.DisplayException(ex);
            }
        }
        // Shows the alter policy dialog
        async Task ShowAlterPolicy()
        {
            try
            {
                var policy = SelectedRetentionPolicy;
                if (policy == null || string.IsNullOrWhiteSpace(SelectedDatabase))
                {
                    return;
                }

                var prevIsDefault = policy.Default;

                // Clear out the dialog values
                policyDialog.ResetPolicyValues();

                // Bind to current policy
                policyDialog.BindToPolicy(SelectedRetentionPolicy);

                if (policyDialog.ShowDialog() == DialogResult.OK)
                {
                    var name        = policyDialog.PolicyName;
                    var duration    = policyDialog.PolicyDuration;
                    var replication = policyDialog.PolicyReplication;
                    var isDefault   = policyDialog.PolicyDefault;

                    var response = await InfluxDbClient.AlterRetentionPolicyAsync(SelectedDatabase, name, duration, replication, isDefault);

                    if (!response.Success)
                    {
                        AppForm.DisplayError(response.Body);
                    }
                    else
                    {
                        // If default status chagned, attempt to update another policy as default
                        if (prevIsDefault != isDefault && !isDefault)
                        {
                            policies = await InfluxDbClient.GetRetentionPoliciesAsync(SelectedDatabase);

                            if (policies.Count() > 0)
                            {
                                // Try to find the autogen/default
                                var rp = (from r in policies where r.Name.ToLower() == "autogen" select r).FirstOrDefault();

                                // Otherwise try to find another policy with a different name
                                if (rp == null)
                                {
                                    rp = (from r in policies where r.Name != policy.Name select r).FirstOrDefault();
                                }

                                if (rp != null)
                                {
                                    // If a new retention policy was found, make it the default
                                    response = await InfluxDbClient.AlterRetentionPolicyAsync(SelectedDatabase, rp.Name, rp.Duration, rp.ReplicationCopies, true);
                                }
                            }
                        }
                    }

                    // Reload latest data
                    await ExecuteRequestAsync();
                }
            }
            catch (Exception ex)
            {
                AppForm.DisplayException(ex);
            }
        }