FilterPSLinkedServices() public method

public FilterPSLinkedServices ( Microsoft.Azure.Commands.DataFactories.LinkedServiceFilterOptions filterOptions ) : List
filterOptions Microsoft.Azure.Commands.DataFactories.LinkedServiceFilterOptions
return List
Exemplo n.º 1
0
        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;
            }

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

            if (Name != null)
            {
                List <PSLinkedService> linkedServices = DataFactoryClient.FilterPSLinkedServices(filterOptions);

                if (linkedServices != null && linkedServices.Any())
                {
                    WriteObject(linkedServices[0]);
                }
                return;
            }

            // List all linked services until all pages are fetched.
            do
            {
                WriteObject(DataFactoryClient.FilterPSLinkedServices(filterOptions), true);
            } while (filterOptions.NextLink.IsNextPageLink());
        }
Exemplo n.º 2
0
        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;
            }

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

            List <PSLinkedService> linkedServices = DataFactoryClient.FilterPSLinkedServices(filterOptions);

            if (linkedServices != null)
            {
                if (linkedServices.Count == 1 && Name != null)
                {
                    WriteObject(linkedServices[0]);
                }
                else
                {
                    WriteObject(linkedServices, true);
                }
            }
        }