protected override void ProcessRecord()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new PSArgumentNullException("Name");
            }

            DataFactoryFilterOptions filterOptions = new DataFactoryFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName
            };

            if (Name != null)
            {
                List<PSDataFactory> dataFactories = DataFactoryClient.FilterPSDataFactories(filterOptions);
                if (dataFactories != null && dataFactories.Any())
                {
                    WriteObject(dataFactories.First());
                }
                return;
            }
            
            //List data factories until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSDataFactories(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
        public virtual List<PSDataFactory> FilterPSDataFactories(DataFactoryFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }
            
            // ToDo: make ResourceGroupName optional
            if (string.IsNullOrWhiteSpace(filterOptions.ResourceGroupName))
            {
                throw new ArgumentException(Resources.ResourceGroupNameCannotBeEmpty);
            }

            List<PSDataFactory> dataFactories = new List<PSDataFactory>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                dataFactories.Add(GetDataFactory(filterOptions.ResourceGroupName, filterOptions.Name));
            }
            else
            {
                // ToDo: Filter list results by Tag
                dataFactories.AddRange(ListDataFactories(filterOptions.ResourceGroupName));
            }

            return dataFactories;
        }
        public override void ExecuteCmdlet()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new PSArgumentNullException("Name");
            }

            DataFactoryFilterOptions filterOptions = new DataFactoryFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName
            };

            if (Name != null)
            {
                List <PSDataFactory> dataFactories = DataFactoryClient.FilterPSDataFactories(filterOptions);
                if (dataFactories != null && dataFactories.Any())
                {
                    WriteObject(dataFactories.First());
                }
                return;
            }

            //List data factories until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSDataFactories(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
        public virtual List <PSDataFactory> FilterPSDataFactories(DataFactoryFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

            // ToDo: make ResourceGroupName optional
            if (string.IsNullOrWhiteSpace(filterOptions.ResourceGroupName))
            {
                throw new ArgumentException(Resources.ResourceGroupNameCannotBeEmpty);
            }

            List <PSDataFactory> dataFactories = new List <PSDataFactory>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                dataFactories.Add(GetDataFactory(filterOptions.ResourceGroupName, filterOptions.Name));
            }
            else
            {
                dataFactories.AddRange(ListDataFactories(filterOptions));
            }

            return(dataFactories);
        }
        public virtual List <PSDataFactory> ListDataFactories(DataFactoryFilterOptions filterOptions)
        {
            List <PSDataFactory> dataFactories = new List <PSDataFactory>();

            DataFactoryListResponse response;

            if (filterOptions.NextLink.IsNextPageLink())
            {
                response = DataPipelineManagementClient.DataFactories.ListNext(filterOptions.NextLink);
            }
            else
            {
                response = DataPipelineManagementClient.DataFactories.List(filterOptions.ResourceGroupName);
            }
            filterOptions.NextLink = response != null ? response.NextLink : null;

            if (response != null && response.DataFactories != null)
            {
                response.DataFactories.ForEach(
                    df => dataFactories.Add(new PSDataFactory(df)
                {
                    ResourceGroupName = filterOptions.ResourceGroupName
                }));
            }

            return(dataFactories);
        }
Exemplo n.º 6
0
        public override void ExecuteCmdlet()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new PSArgumentNullException("Name");
            }

            DataFactoryFilterOptions filterOptions = new DataFactoryFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName
            };

            List <PSDataFactory> dataFactories = DataFactoryClient.FilterPSDataFactories(filterOptions);

            if (dataFactories != null)
            {
                if (dataFactories.Count == 1 && Name != null)
                {
                    WriteObject(dataFactories[0]);
                }
                else
                {
                    WriteObject(dataFactories, true);
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new PSArgumentNullException("Name");
            }

            DataFactoryFilterOptions filterOptions = new DataFactoryFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName
            };
            
            List<PSDataFactory> dataFactories = DataFactoryClient.FilterPSDataFactories(filterOptions);

            if (dataFactories != null)
            {
                if (dataFactories.Count == 1 && Name != null)
                {
                    WriteObject(dataFactories[0]);
                }
                else
                {
                    WriteObject(dataFactories, true);
                }
            }
        }
        public virtual List<PSDataFactory> ListDataFactories(DataFactoryFilterOptions filterOptions)
        {
            List<PSDataFactory> dataFactories = new List<PSDataFactory>();

            DataFactoryListResponse response;
            if (filterOptions.NextLink.IsNextPageLink())
            {
                response = DataPipelineManagementClient.DataFactories.ListNext(filterOptions.NextLink);
            }
            else
            {
                response = DataPipelineManagementClient.DataFactories.List(filterOptions.ResourceGroupName);
            }
            filterOptions.NextLink = response != null ? response.NextLink : null;

            if (response != null && response.DataFactories != null)
            {
                response.DataFactories.ForEach(
                    df => dataFactories.Add(new PSDataFactory(df) { ResourceGroupName = filterOptions.ResourceGroupName }));
            }

            return dataFactories;
        }