Inheritance: Microsoft.Azure.Commands.StreamAnalytics.Models.JobParametersBase
        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);
        }
        public override void ExecuteCmdlet()
        {
            if (ResourceGroupName != null && string.IsNullOrWhiteSpace(ResourceGroupName))
            {
                throw new PSArgumentNullException("ResourceGroupName");
            }

            if (JobName != null && string.IsNullOrWhiteSpace(JobName))
            {
                throw new PSArgumentNullException("JobName");
            }

            if (File != null && string.IsNullOrWhiteSpace(File))
            {
                throw new PSArgumentNullException("File");
            }

            string rawJsonContent = StreamAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(File));

            Name = ResolveResourceName(rawJsonContent, Name, "Input");

            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new ArgumentException(Resources.InputNameCannotBeEmpty);
            }

            CreatePSInputParameter parameter = new CreatePSInputParameter
            {
                ResourceGroupName = ResourceGroupName,
                JobName = JobName,
                InputName = Name,
                RawJsonContent = rawJsonContent,
                Force = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            var result = StreamAnalyticsClient.CreatePSInput(parameter);
            if (result != null)
            {
                WriteObject(result);
            }
        }
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;
        }