in src/Modules/Data/Commands.Data/GetPowerBIDataflow.cs [93:153]
public override void ExecuteCmdlet()
{
if (this.Workspace != null)
{
this.WorkspaceId = this.Workspace.Id;
this.Logger.WriteDebug($"Using {nameof(this.Workspace)} object to get {nameof(this.WorkspaceId)} parameter. Value: {this.WorkspaceId}");
}
if (this.Id != default)
{
this.Filter = $"id eq '{this.Id}'";
}
if (this.Name != default)
{
this.Filter = $"tolower(name) eq '{this.Name.ToLower()}'";
}
IEnumerable<Dataflow> dataflows = null;
using (var client = this.CreateClient())
{
if (this.WorkspaceId != default)
{
dataflows = this.Scope == PowerBIUserScope.Organization ?
client.Dataflows.GetDataflowsAsAdminForWorkspace(this.WorkspaceId, filter: this.Filter, top: this.First, skip: this.Skip) :
client.Dataflows.GetDataflows(this.WorkspaceId);
}
else if (this.Scope == PowerBIUserScope.Organization)
{
// No workspace id - Works only for organization scope
dataflows = client.Dataflows.GetDataflowsAsAdmin(filter: this.Filter, top: this.First, skip: this.Skip);
}
}
// In individual scope - filter the results locally
if (this.Scope == PowerBIUserScope.Individual)
{
if (this.Id != default)
{
dataflows = dataflows?.Where(d => this.Id == d.Id);
}
if (!string.IsNullOrEmpty(this.Name))
{
dataflows = dataflows?.Where(d => d.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
}
if (this.Skip.HasValue)
{
dataflows = dataflows?.Skip(this.Skip.Value);
}
if (this.First.HasValue)
{
dataflows = dataflows?.Take(this.First.Value);
}
}
this.Logger.WriteObject(dataflows, true);
}