Inheritance: Microsoft.Azure.Commands.StreamAnalytics.Models.JobParametersBase
        public virtual PSTransformation CreatePSTransformation(CreatePSTransformationParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSTransformation transformation = null;
            Action createTransformation = () =>
            {
                transformation =
                    new PSTransformation(CreateOrUpdatePSTransformation(parameter.ResourceGroupName,
                        parameter.JobName,
                        parameter.TransformationName,
                        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.
                createTransformation();
            }
            else
            {
                bool transformationExists = CheckTransformationExists(parameter.ResourceGroupName, parameter.JobName, parameter.TransformationName);

                parameter.ConfirmAction(
                        !transformationExists,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.TransformationExists,
                            parameter.TransformationName,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.TransformationCreating,
                            parameter.TransformationName,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        parameter.TransformationName,
                        createTransformation);
            }

            return transformation;
        }
Esempio n. 2
0
        public virtual PSTransformation CreatePSTransformation(CreatePSTransformationParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSTransformation transformation       = null;
            Action           createTransformation = () =>
            {
                transformation =
                    new PSTransformation(CreateOrUpdatePSTransformation(parameter.ResourceGroupName,
                                                                        parameter.JobName,
                                                                        parameter.TransformationName,
                                                                        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.
                createTransformation();
            }
            else
            {
                bool transformationExists = CheckTransformationExists(parameter.ResourceGroupName, parameter.JobName, parameter.TransformationName);

                parameter.ConfirmAction(
                    !transformationExists,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.TransformationExists,
                        parameter.TransformationName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.TransformationCreating,
                        parameter.TransformationName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.TransformationName,
                    createTransformation);
            }

            return(transformation);
        }
        public virtual PSTransformation CreatePSTransformation(CreatePSTransformationParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSTransformation transformation = null;

            parameter.ConfirmAction(
                parameter.Force,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.TransformationExists,
                    parameter.TransformationName,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.TransformationCreating,
                    parameter.TransformationName,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                parameter.TransformationName,
                () =>
            {
                transformation =
                    new PSTransformation(CreateOrUpdatePSTransformation(parameter.ResourceGroupName,
                                                                        parameter.JobName,
                                                                        parameter.TransformationName,
                                                                        parameter.RawJsonContent))
                {
                    ResourceGroupName = parameter.ResourceGroupName,
                    JobName           = parameter.JobName
                };
            },
                () => CheckTransformationExists(parameter.ResourceGroupName, parameter.JobName, parameter.TransformationName));

            return(transformation);
        }
        public virtual PSTransformation CreatePSTransformation(CreatePSTransformationParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSTransformation transformation = null;
            parameter.ConfirmAction(
                    parameter.Force,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.TransformationExists,
                        parameter.TransformationName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.TransformationCreating,
                        parameter.TransformationName,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.TransformationName,
                    () =>
                    {
                        transformation =
                            new PSTransformation(CreateOrUpdatePSTransformation(parameter.ResourceGroupName,
                                parameter.JobName,
                                parameter.TransformationName,
                                parameter.RawJsonContent))
                            {
                                ResourceGroupName = parameter.ResourceGroupName,
                                JobName = parameter.JobName
                            };
                    },
                    () => CheckTransformationExists(parameter.ResourceGroupName, parameter.JobName, parameter.TransformationName));

            return transformation;
        }
        public override void ExecuteCmdlet()
        {
            string rawJsonContent = StreamAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(File));

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

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

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

            WriteObject(StreamAnalyticsClient.CreatePSTransformation(parameter));
        }