in src/Modules/Reports/Commands.Reports/GetPowerBIImport.cs [98:154]
public override void ExecuteCmdlet()
{
if(this.Workspace != null)
{
this.WorkspaceId = this.Workspace.Id;
}
if (this.ParameterSet.Equals(IdParameterSetName))
{
this.Filter = $"id eq '{this.Id}'";
}
if (this.ParameterSet.Equals(NameParameterSetName))
{
this.Filter = $"tolower(name) eq '{this.Name.ToLower()}'";
}
IEnumerable<Import> imports = null;
using (var client = this.CreateClient())
{
if (this.WorkspaceId != default)
{
imports = client.Reports.GetImportsForWorkspace(this.WorkspaceId);
}
else
{
imports = this.Scope == PowerBIUserScope.Individual ?
client.Reports.GetImports() :
client.Reports.GetImportsAsAdmin(expand: null, filter: this.Filter, top: this.First, skip: this.Skip);
}
}
if (this.Scope == PowerBIUserScope.Individual)
{
if (this.Id != default)
{
imports = imports?.Where(d => this.Id == d.Id);
}
if (!string.IsNullOrEmpty(this.Name))
{
imports = imports?.Where(d => d.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
}
if (this.Skip.HasValue)
{
imports = imports?.Skip(this.Skip.Value);
}
if (this.First.HasValue)
{
imports = imports?.Take(this.First.Value);
}
}
this.Logger.WriteObject(imports, true);
}