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;
        }
Exemplo 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);
        }
Exemplo n.º 3
0
 private bool CheckInputExists(string resourceGroupName, string jobName, string inputName)
 {
     try
     {
         PSInput input = GetInput(resourceGroupName, jobName, inputName);
         return(true);
     }
     catch (CloudException e)
     {
         //Get throws Exception message with NotFound Status
         if (e.Response.StatusCode == HttpStatusCode.NotFound)
         {
             return(false);
         }
         else
         {
             throw;
         }
     }
 }
Exemplo n.º 4
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;
        }