public virtual PSInput CreatePSInput(CreatePSInputParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSInput input = null;
            Action createInput = () =>
            {
                input = new PSInput(
                    CreateOrUpdatePSInput(parameter.ResourceGroupName,
                        parameter.JobName,
                        parameter.InputName,
                        parameter.RawJsonContent))
                    {
                        ResourceGroupName = parameter.ResourceGroupName,
                        JobName = parameter.JobName
                    };
            };

            if (parameter.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createInput();
            }
            else
            {
                bool inputExists = CheckInputExists(parameter.ResourceGroupName, parameter.JobName, parameter.InputName);

                parameter.ConfirmAction(
                        !inputExists,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.InputExists,
                            parameter.InputName,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.InputCreating,
                            parameter.InputName,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        parameter.InputName,
                        createInput);
            }

            return input;
        }
Ejemplo n.º 2
0
        public virtual PSInput CreatePSInput(CreatePSInputParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSInput input       = null;
            Action  createInput = () =>
            {
                input = new PSInput(
                    CreateOrUpdatePSInput(parameter.ResourceGroupName,
                                          parameter.JobName,
                                          parameter.InputName,
                                          parameter.RawJsonContent))
                {
                    ResourceGroupName = parameter.ResourceGroupName,
                    JobName           = parameter.JobName
                };
            };

            if (parameter.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createInput();
            }
            else
            {
                bool inputExists = CheckInputExists(parameter.ResourceGroupName, parameter.JobName, parameter.InputName);

                parameter.ConfirmAction(
                    !inputExists,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.InputExists,
                        parameter.InputName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.InputCreating,
                        parameter.InputName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.InputName,
                    createInput);
            }

            return(input);
        }
Ejemplo n.º 3
0
        public virtual PSInput CreatePSInput(CreatePSInputParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSInput input = null;

            parameter.ConfirmAction(
                parameter.Force,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.InputExists,
                    parameter.InputName,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.InputCreating,
                    parameter.InputName,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                parameter.InputName,
                () =>
            {
                input = new PSInput(
                    CreateOrUpdatePSInput(parameter.ResourceGroupName,
                                          parameter.JobName,
                                          parameter.InputName,
                                          parameter.RawJsonContent))
                {
                    ResourceGroupName = parameter.ResourceGroupName,
                    JobName           = parameter.JobName
                };
            },
                () => CheckInputExists(parameter.ResourceGroupName, parameter.JobName, parameter.InputName));

            return(input);
        }
        public virtual PSInput CreatePSInput(CreatePSInputParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSInput input = null;
            parameter.ConfirmAction(
                    parameter.Force,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.InputExists,
                        parameter.InputName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.InputCreating,
                        parameter.InputName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.InputName,
                    () =>
                    {
                        input = new PSInput(
                            CreateOrUpdatePSInput(parameter.ResourceGroupName,
                                parameter.JobName,
                                parameter.InputName,
                                parameter.RawJsonContent))
                        {
                            ResourceGroupName = parameter.ResourceGroupName,
                            JobName = parameter.JobName
                        };
                    },
                    () => CheckInputExists(parameter.ResourceGroupName, parameter.JobName, parameter.InputName));

            return input;
        }