/// <summary>
        /// Verify that the Cloud SDK is installed and at the right version. Optionally also verify that the given
        /// component is installed.
        /// </summary>
        /// <param name="component">The component to check, optional.</param>
        /// <returns>True if the Cloud SDK installation is valid.</returns>
        public static async Task <bool> VerifyGCloudDependencies(GCloudComponent component = GCloudComponent.None)
        {
            var result = await GCloudWrapper.ValidateGCloudAsync(component);

            if (result.IsValid)
            {
                return(true);
            }

            if (!result.IsCloudSdkInstalled)
            {
                LinkPromptDialogWindow.PromptUser(
                    Resources.GcloudMissingGcloudErrorTitle,
                    Resources.GcloudMissingCloudSdkErrorMessage,
                    new LinkInfo(link: "https://cloud.google.com/sdk/", caption: Resources.GcloudInstallLinkCaption));
            }
            else if (!result.IsCloudSdkUpdated)
            {
                UserPromptUtils.ErrorPrompt(
                    message: String.Format(
                        Resources.GCloudWrapperUtilsOldCloudSdkMessage,
                        result.CloudSdkVersion,
                        GCloudWrapper.GCloudSdkMinimumVersion),
                    title: Resources.GCloudWrapperUtilsOldCloudSdkTitle);
            }
            else
            {
                UserPromptUtils.ErrorPrompt(
                    message: String.Format(Resources.GcloudMissingComponentErrorMessage, component),
                    title: Resources.GcloudMissingComponentTitle);
            }

            return(false);
        }
        /// <summary>
        /// Validates that gcloud is installed with the minimum version and that the given component
        /// for gcloud is installed.
        /// </summary>
        /// <param name="component">the component to check, optional. If no component is provided only gcloud is checked.</param>
        /// <returns></returns>
        public static async Task <GCloudValidationResult> ValidateGCloudAsync(GCloudComponent component = GCloudComponent.None)
        {
            if (!IsGCloudCliInstalled())
            {
                return(new GCloudValidationResult(isCloudSdkInstalled: false));
            }

            var cloudSdkVersion = await GetInstalledCloudSdkVersionAsync();

            if (cloudSdkVersion < s_minimumVersion)
            {
                return(new GCloudValidationResult(isCloudSdkInstalled: true, isCloudSdkUpdated: false, cloudSdkVersion: cloudSdkVersion));
            }

            if (component != GCloudComponent.None && !await IsComponentInstalledAsync(component))
            {
                return(new GCloudValidationResult(
                           isCloudSdkInstalled: true,
                           isCloudSdkUpdated: true,
                           isRequiredComponentInstalled: false,
                           cloudSdkVersion: cloudSdkVersion));
            }

            return(new GCloudValidationResult(
                       isCloudSdkInstalled: true,
                       isCloudSdkUpdated: true,
                       isRequiredComponentInstalled: true,
                       cloudSdkVersion: cloudSdkVersion));
        }
        /// <summary>
        /// Verify that the Cloud SDK is installed and at the right version. Optionally also verify that the given
        /// component is installed.
        /// </summary>
        /// <param name="component">The component to check, optional.</param>
        /// <returns>True if the Cloud SDK installation is valid.</returns>
        public static async Task <bool> VerifyGCloudDependenciesAsync(GCloudComponent component = GCloudComponent.None)
        {
            GCloudValidationResult result = await GCloudWrapper.ValidateGCloudAsync(component);

            if (result.IsValid)
            {
                return(true);
            }

            if (!result.IsCloudSdkInstalled)
            {
                LinkPromptDialogWindow.PromptUser(
                    Resources.GcloudMissingGcloudErrorTitle,
                    Resources.GcloudMissingCloudSdkErrorMessage,
                    new LinkInfo(link: "https://cloud.google.com/sdk/", caption: Resources.GcloudInstallLinkCaption));
            }
            else if (result.IsObsolete)
            {
                UserPromptService.Default.ErrorPrompt(
                    message: string.Format(
                        Resources.GCloudWrapperUtilsOldCloudSdkMessage,
                        result.CloudSdkVersion,
                        GCloud.GCloudWrapper.GCloudSdkMinimumVersion),
                    title: Resources.GCloudWrapperUtilsOldCloudSdkTitle);
            }
            else
            {
                ShowCopyablePrompt(
                    Resources.GcloudMissingComponentTitle,
                    string.Format(Resources.GcloudMissingComponentErrorMessage, component),
                    string.Format(Resources.GcloudMissingComponentInstallCommand, component.ToString().ToLower()));
            }

            return(false);
        }
        private static async Task <bool> IsComponentInstalledAsync(GCloudComponent component)
        {
            if (!IsGCloudCliInstalled())
            {
                return(false);
            }
            IList <string> installedComponents = await GetInstalledComponentsAsync();

            return(installedComponents.Contains(s_componentNames[component]));
        }
        /// <summary>
        /// Validates that gcloud is installed with the minimum version and that the given component
        /// for gcloud is installed.
        /// </summary>
        /// <param name="component">the component to check, optional. If no component is provided only gcloud is checked.</param>
        /// <returns></returns>
        public static async Task <GCloudValidationResult> ValidateGCloudAsync(GCloudComponent component = GCloudComponent.None)
        {
            if (!IsGCloudCliInstalled())
            {
                return(GCloudValidationResult.NotInstalled);
            }

            Version cloudSdkVersion = await GetInstalledCloudSdkVersionAsync();

            if (cloudSdkVersion < s_minimumVersion)
            {
                return(GCloudValidationResult.GetObsoleteVersion(cloudSdkVersion));
            }

            if (component != GCloudComponent.None && !await IsComponentInstalledAsync(component))
            {
                return(GCloudValidationResult.MissingComponent);
            }

            return(GCloudValidationResult.Valid);
        }