private PSIntegrationRuntime CreateSelfHostedIntegrationRuntime(
            IntegrationRuntimeResource integrationRuntime,
            string resourceGroupName,
            string dataFactoryName)
        {
            PSIntegrationRuntime psIntegrationRuntime = null;
            var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime;

            if (selfHosted != null)
            {
                if (selfHosted.LinkedInfo != null)
                {
                    psIntegrationRuntime = new PSLinkedIntegrationRuntime(integrationRuntime,
                                                                          resourceGroupName,
                                                                          dataFactoryName)
                    {
                        AuthorizationType = selfHosted.LinkedInfo is LinkedIntegrationRuntimeKey
                            ? Constants.LinkedIntegrationRuntimeKeyAuth
                            : Constants.LinkedIntegrationRuntimeRbacAuth
                    };
                }
                else
                {
                    psIntegrationRuntime = new PSSelfHostedIntegrationRuntime(integrationRuntime,
                                                                              resourceGroupName,
                                                                              dataFactoryName);
                }
            }

            return(psIntegrationRuntime);
        }
        public virtual PSIntegrationRuntime CreateOrUpdateIntegrationRuntime(CreatePSIntegrationRuntimeParameters parameters)
        {
            PSIntegrationRuntime psIntegrationRuntime = null;

            Action createOrUpdateIntegrationRuntime = () =>
            {
                var integrationRuntime = this.CreateOrUpdateIntegrationRuntimeAsync(
                    parameters.ResourceGroupName,
                    parameters.DataFactoryName,
                    parameters.Name,
                    parameters.IntegrationRuntimeResource).ConfigureAwait(true).GetAwaiter().GetResult();

                var managed = integrationRuntime.Properties as ManagedIntegrationRuntime;
                if (managed != null)
                {
                    psIntegrationRuntime = new PSManagedIntegrationRuntime(integrationRuntime,
                                                                           parameters.ResourceGroupName,
                                                                           parameters.DataFactoryName);
                }
                else
                {
                    var selfHosted = integrationRuntime.Properties as SelfHostedIntegrationRuntime;
                    if (selfHosted != null)
                    {
                        psIntegrationRuntime = new PSSelfHostedIntegrationRuntime(integrationRuntime,
                                                                                  parameters.ResourceGroupName,
                                                                                  parameters.DataFactoryName);
                    }
                }
            };

            parameters.ConfirmAction(
                parameters.Force,      // prompt only if the integration runtime exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IntegrationRuntimeExists,
                    parameters.Name,
                    parameters.DataFactoryName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IntegrationRuntimeUpdating,
                    parameters.Name,
                    parameters.DataFactoryName),
                parameters.Name,
                createOrUpdateIntegrationRuntime,
                () => parameters.IsUpdate);

            return(psIntegrationRuntime);
        }