public virtual List<PSDataset> ListDatasets(DatasetFilterOptions filterOptions)
        {
            List<PSDataset> datasets = new List<PSDataset>();

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

            if (response != null && response.Datasets != null)
            {
                foreach (var dataset in response.Datasets)
                {
                    datasets.Add(
                        new PSDataset(dataset)
                        {
                            ResourceGroupName = filterOptions.ResourceGroupName,
                            DataFactoryName = filterOptions.DataFactoryName
                        });
                }
            }

            return datasets;
        }
Ejemplo n.º 2
0
        public virtual List<PSDataset> FilterPSDatasets(DatasetFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

            if (string.IsNullOrWhiteSpace(filterOptions.ResourceGroupName))
            {
                throw new ArgumentException(Resources.ResourceGroupNameCannotBeEmpty);
            }

            List<PSDataset> datasets = new List<PSDataset>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                datasets.Add(this.GetDataset(filterOptions.ResourceGroupName, filterOptions.DataFactoryName, filterOptions.Name));
            }
            else
            {
                datasets.AddRange(this.ListDatasets(filterOptions));
            }

            return datasets;
        }
Ejemplo n.º 3
0
        public virtual List<PSDataset> ListDatasets(DatasetFilterOptions filterOptions)
        {
            List<PSDataset> datasets = new List<PSDataset>();

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

            if (response != null && response.Datasets != null)
            {
                foreach (var dataset in response.Datasets)
                {
                    datasets.Add(
                        new PSDataset(dataset)
                        {
                            ResourceGroupName = filterOptions.ResourceGroupName,
                            DataFactoryName = filterOptions.DataFactoryName
                        });
                }
            }

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

            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName   = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            DatasetFilterOptions filterOptions = new DatasetFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName,
                DataFactoryName   = DataFactoryName
            };

            if (Name != null)
            {
                List <PSDataset> datasets = DataFactoryClient.FilterPSDatasets(filterOptions);
                if (datasets != null && datasets.Any())
                {
                    WriteObject(datasets[0]);
                }
                return;
            }

            // List datasets until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSDatasets(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
        public override void ExecuteCmdlet()
        {
            // ValidationNotNullOrEmpty doesn't handle whitespaces well
            if (Name != null && string.IsNullOrWhiteSpace(Name))            
            {
                throw new PSArgumentNullException("Name");
            }

            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            DatasetFilterOptions filterOptions = new DatasetFilterOptions()
            {
                Name = Name,
                ResourceGroupName = ResourceGroupName,
                DataFactoryName = DataFactoryName
            };

            if (Name != null)
            {
                List<PSDataset> datasets = DataFactoryClient.FilterPSDatasets(filterOptions);
                if (datasets != null && datasets.Any())
                {
                    WriteObject(datasets[0]);
                }
                return;
            }
            
            // List datasets until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSDatasets(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
        public virtual List<PSDataset> FilterPSDatasets(DatasetFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

            if (string.IsNullOrWhiteSpace(filterOptions.ResourceGroupName))
            {
                throw new ArgumentException(Resources.ResourceGroupNameCannotBeEmpty);
            }

            List<PSDataset> datasets = new List<PSDataset>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                datasets.Add(this.GetDataset(filterOptions.ResourceGroupName, filterOptions.DataFactoryName, filterOptions.Name));
            }
            else
            {
                datasets.AddRange(this.ListDatasets(filterOptions));
            }

            return datasets;
        }