Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proper filter for webapp and function app #993

Merged
merged 3 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/ResourceManagement/AppService/FunctionAppsImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ internal partial class FunctionAppsImpl :
///GENMHASH:95834C6C7DA388E666B705A62A7D02BF:437A8ECA353AAE23242BFC82A5066CC3
public override IEnumerable<IFunctionApp> ListByResourceGroup(string resourceGroupName)
{
Func<SiteInner, IFunctionApp> converter = inner =>
{
return Extensions.Synchronize(() => PopulateModelAsync(inner));
};

return Extensions.Synchronize(() => Inner.ListByResourceGroupAsync(resourceGroupName))
.AsContinuousCollection(link => Extensions.Synchronize(() => Inner.ListByResourceGroupNextAsync(link)))
.Select(inner => converter(inner));
return base.ListByResourceGroup(resourceGroupName).Where(this.FilterFunctionApp);
}

public override async Task<IPagedCollection<IFunctionApp>> ListByResourceGroupAsync(string resourceGroupName, bool loadAllPages = true, CancellationToken cancellationToken = default(CancellationToken))
Expand All @@ -48,7 +41,12 @@ public override IEnumerable<IFunctionApp> ListByResourceGroup(string resourceGro
Inner.ListByResourceGroupNextAsync,
async (inner, cancellation) => await PopulateModelAsync(inner, cancellation),
loadAllPages, cancellationToken);
return PagedCollection<IFunctionApp, SiteInner>.CreateFromEnumerable(collection.Where(w => "functionapp".Equals(w.Inner.Kind, StringComparison.OrdinalIgnoreCase)));
return PagedCollection<IFunctionApp, SiteInner>.CreateFromEnumerable(collection.Where(this.FilterFunctionApp));
}

public override IEnumerable<IFunctionApp> List()
{
return base.List().Where(this.FilterFunctionApp);
}

public override async Task<IPagedCollection<IFunctionApp>> ListAsync(bool loadAllPages = true, CancellationToken cancellationToken = default(CancellationToken))
Expand All @@ -58,7 +56,12 @@ public override IEnumerable<IFunctionApp> ListByResourceGroup(string resourceGro
Inner.ListNextAsync,
async (inner, cancellation) => await PopulateModelAsync(inner, cancellation),
loadAllPages, cancellationToken);
return PagedCollection<IFunctionApp, SiteInner>.CreateFromEnumerable(collection.Where(w => "functionapp".Equals(w.Inner.Kind, StringComparison.OrdinalIgnoreCase)));
return PagedCollection<IFunctionApp, SiteInner>.CreateFromEnumerable(collection.Where(this.FilterFunctionApp));
}

private bool FilterFunctionApp(IFunctionApp w)
{
return w.Inner.Kind != null && w.Inner.Kind.ToLower().Split(new char[] { ',' }).Contains("functionapp");
}

///GENMHASH:0679DF8CA692D1AC80FC21655835E678:586E2B084878E8767487234B852D8D20
Expand Down
23 changes: 13 additions & 10 deletions src/ResourceManagement/AppService/WebAppsImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,7 @@ internal partial class WebAppsImpl :

public override IEnumerable<IWebApp> ListByResourceGroup(string resourceGroupName)
{
Func<SiteInner, IWebApp> converter = inner =>
{
return Extensions.Synchronize(() => PopulateModelAsync(inner));
};

return Extensions.Synchronize(() => Inner.ListByResourceGroupAsync(resourceGroupName))
.AsContinuousCollection(link => Extensions.Synchronize(() => Inner.ListByResourceGroupNextAsync(link)))
.Select(inner => converter(inner));
return base.ListByResourceGroup(resourceGroupName).Where(this.FilterWebApp);
}

public override async Task<IPagedCollection<IWebApp>> ListByResourceGroupAsync(string resourceGroupName, bool loadAllPages = true, CancellationToken cancellationToken = default(CancellationToken))
Expand All @@ -49,7 +42,12 @@ public override IEnumerable<IWebApp> ListByResourceGroup(string resourceGroupNam
Inner.ListByResourceGroupNextAsync,
async (inner, cancellation) => await PopulateModelAsync(inner, cancellation),
loadAllPages, cancellationToken);
return PagedCollection<IWebApp, SiteInner>.CreateFromEnumerable(collection.Where(w => w.Inner.Kind != null && w.Inner.Kind.Split(new char[] { ',' }).Contains("app")));
return PagedCollection<IWebApp, SiteInner>.CreateFromEnumerable(collection.Where(this.FilterWebApp));
}

public override IEnumerable<IWebApp> List()
{
return base.List().Where(this.FilterWebApp);
}

public override async Task<IPagedCollection<IWebApp>> ListAsync(bool loadAllPages = true, CancellationToken cancellationToken = default(CancellationToken))
Expand All @@ -59,7 +57,12 @@ public override IEnumerable<IWebApp> ListByResourceGroup(string resourceGroupNam
Inner.ListNextAsync,
async (inner, cancellation) => await PopulateModelAsync(inner, cancellation),
loadAllPages, cancellationToken);
return PagedCollection<IWebApp, SiteInner>.CreateFromEnumerable(collection.Where(w => w.Inner.Kind != null && w.Inner.Kind.Split(new char[] { ',' }).Contains("app")));
return PagedCollection<IWebApp, SiteInner>.CreateFromEnumerable(collection.Where(this.FilterWebApp));
}

private bool FilterWebApp(IWebApp w)
{
return w.Inner.Kind != null && w.Inner.Kind.Split(new char[] { ',' }).Contains("app");
}

///GENMHASH:0679DF8CA692D1AC80FC21655835E678:586E2B084878E8767487234B852D8D20
Expand Down