public override void ExecuteCmdlet()

in src/Modules/Reports/Commands.Reports/GetPowerBIReport.cs [88:147]


        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<Report> reports = null;
            using (var client = this.CreateClient())
            {
                if(this.WorkspaceId != default)
                {
                    reports = this.Scope == PowerBIUserScope.Individual ?
                        client.Reports.GetReportsForWorkspace(this.WorkspaceId) :
                        client.Reports.GetReportsAsAdminForWorkspace(this.WorkspaceId, filter: this.Filter, top: this.First, skip: this.Skip);
                }
                else
                {
                    reports = this.Scope == PowerBIUserScope.Individual ?
                        client.Reports.GetReports() :
                        client.Reports.GetReportsAsAdmin(filter: this.Filter, top: this.First, skip: this.Skip);
                } 
            }

            // Bug in OData filter for ID, workaround is to use LINQ
            if (this.Id != default)
            {
                reports = reports?.Where(r => this.Id == r.Id);
            }

            if (this.Scope == PowerBIUserScope.Individual)
            {
                if(!string.IsNullOrEmpty(this.Name))
                {
                    reports = reports?.Where(r => r.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
                }

                if(this.Skip.HasValue)
                {
                    reports = reports?.Skip(this.Skip.Value);
                }

                if(this.First.HasValue)
                {
                    reports = reports?.Take(this.First.Value);
                }
            }

            this.Logger.WriteObject(reports, true);
        }