예제 #1
0
        public virtual List <PSHub> FilterPSHubs(HubFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

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

            List <PSHub> hubs = new List <PSHub>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                hubs.Add(GetHub(filterOptions.ResourceGroupName, filterOptions.DataFactoryName, filterOptions.Name));
            }
            else
            {
                hubs.AddRange(ListHubs(filterOptions.ResourceGroupName, filterOptions.DataFactoryName));
            }

            return(hubs);
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

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

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

            List<PSHub> hubs = DataFactoryClient.FilterPSHubs(filterOptions);

            if (hubs != null)
            {
                if (hubs.Count == 1 && Name != null)
                {
                    WriteObject(hubs[0]);
                }
                else
                {
                    WriteObject(hubs, true);
                }
            }
        }
예제 #3
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

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

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

            List <PSHub> hubs = DataFactoryClient.FilterPSHubs(filterOptions);

            if (hubs != null)
            {
                if (hubs.Count == 1 && Name != null)
                {
                    WriteObject(hubs[0]);
                }
                else
                {
                    WriteObject(hubs, true);
                }
            }
        }
        public virtual List <PSHub> ListHubs(HubFilterOptions filterOptions)
        {
            List <PSHub> hubs = new List <PSHub>();

            HubListResponse response;

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

            if (response != null && response.Hubs != null)
            {
                foreach (var hub in response.Hubs)
                {
                    hubs.Add(new PSHub(hub)
                    {
                        ResourceGroupName = filterOptions.ResourceGroupName,
                        DataFactoryName   = filterOptions.DataFactoryName
                    });
                }
            }

            return(hubs);
        }
        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;
            }

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

            if (Name != null)
            {
                List<PSHub> hubs = DataFactoryClient.FilterPSHubs(filterOptions);

                if (hubs != null && hubs.Any())
                {
                    WriteObject(hubs.First());
                }
                return;
            }
            
            // List hubs until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSHubs(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;
            }

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

            if (Name != null)
            {
                List <PSHub> hubs = DataFactoryClient.FilterPSHubs(filterOptions);

                if (hubs != null && hubs.Any())
                {
                    WriteObject(hubs.First());
                }
                return;
            }

            // List hubs until all pages are fetched
            do
            {
                WriteObject(DataFactoryClient.FilterPSHubs(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
        public virtual List<PSHub> FilterPSHubs(HubFilterOptions filterOptions)
        {
            if (filterOptions == null)
            {
                throw new ArgumentNullException("filterOptions");
            }

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

            List<PSHub> hubs = new List<PSHub>();

            if (!string.IsNullOrWhiteSpace(filterOptions.Name))
            {
                hubs.Add(GetHub(filterOptions.ResourceGroupName, filterOptions.DataFactoryName, filterOptions.Name));
            }
            else
            {
                hubs.AddRange(ListHubs(filterOptions.ResourceGroupName, filterOptions.DataFactoryName));
            }

            return hubs;
        }
        public virtual List<PSHub> ListHubs(HubFilterOptions filterOptions)
        {
            List<PSHub> hubs = new List<PSHub>();

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

            if (response != null && response.Hubs != null)
            {
                foreach (var hub in response.Hubs)
                {
                    hubs.Add(new PSHub(hub)
                                 {
                                     ResourceGroupName = filterOptions.ResourceGroupName,
                                     DataFactoryName = filterOptions.DataFactoryName
                                 });
                }
            }

            return hubs;
        }