in src/Modules/Reports/Commands.Reports/GetPowerBIDashboard.cs [88:146]
public override void ExecuteCmdlet()
{
if(this.Workspace != null)
{
this.WorkspaceId = this.Workspace.Id;
}
if (this.Id != default)
{
this.Filter = $"id eq '{this.Id}'";
}
if (this.Name != default)
{
this.Filter = $"tolower(name) eq '{this.Name.ToLower()}'";
}
IEnumerable<Dashboard> dashboards = null;
using (var client = this.CreateClient())
{
if(this.WorkspaceId != default)
{
dashboards = this.Scope == PowerBIUserScope.Individual ?
client.Reports.GetDashboardsForWorkspace(workspaceId: this.WorkspaceId) :
client.Reports.GetDashboardsAsAdminForWorkspace(workspaceId: this.WorkspaceId, filter: this.Filter, top: this.First, skip: this.Skip);
}
else
{
dashboards = this.Scope == PowerBIUserScope.Individual ?
client.Reports.GetDashboards() :
client.Reports.GetDashboardsAsAdmin(filter: this.Filter, top: this.First, skip: this.Skip);
}
}
if(this.Scope == PowerBIUserScope.Individual)
{
if (this.Id != default)
{
dashboards = dashboards?.Where(d => this.Id == d.Id);
}
if (!string.IsNullOrEmpty(this.Name))
{
dashboards = dashboards?.Where(d => d.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
}
if (this.Skip.HasValue)
{
dashboards = dashboards?.Skip(this.Skip.Value);
}
if (this.First.HasValue)
{
dashboards = dashboards?.Take(this.First.Value);
}
}
this.Logger.WriteObject(dashboards, true);
}