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

Get-RubrikReportData does not work for reports with more than 9999 rows #440

Closed
railroadmanuk opened this issue Sep 9, 2019 · 1 comment

Comments

@railroadmanuk
Copy link
Contributor

Current Behavior:

Provide information about the failure by issuing the command using the -Verbose command.

PS /Users/tim/Google Drive/Coding Projects/Rubrik/PowerShell/SR-000628> $report_data = Get-RubrikReportData -id 'CustomReport:::e3bff371-3b65-4958-a04d-ddeff101276f' -Verbose
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikReportData
VERBOSE: Selected 4.1 API Data for Get-RubrikReportData
VERBOSE: Load API data for
VERBOSE: Description: Retrieve table data for a specific report
VERBOSE: Build the URI
VERBOSE: URI = https://rubrik.demo.com/api/internal/report/CustomReport:::e3bff371-3b65-4958-a04d-ddeff101276f/table
VERBOSE: Build the query parameters for
VERBOSE: URI = https://rubrik.demo.com/api/internal/report/CustomReport:::e3bff371-3b65-4958-a04d-ddeff101276f/table
VERBOSE: List of set parameters: [id, CustomReport:::e3bff371-3b65-4958-a04d-ddeff101276f] [Verbose, True] [limit, 9999]
VERBOSE: Build the body parameters
VERBOSE: Adding requestFilters...
VERBOSE: Adding limit...
VERBOSE: Adding search_value...
VERBOSE: Adding sortOrder...
VERBOSE: Adding sortBy...
VERBOSE: Adding cursor...
VERBOSE: Body = {
  "limit": 9999
}
VERBOSE: Submitting the request
VERBOSE: POST https://rubrik.demo.com/api/internal/report/CustomReport:::e3bff371-3b65-4958-a04d-ddeff101276f/table with 19-byte payload
VERBOSE: received 2770291-byte response of content type application/json
VERBOSE: Received HTTP Status 200                                                                                                         VERBOSE: Formatting return value                                                                                                          VERBOSE: Filter the results                                                                                                               
PS /Users/tim/Google Drive/Coding Projects/Rubrik/PowerShell/SR-000628>
PS /Users/tim/Google Drive/Coding Projects/Rubrik/PowerShell/SR-000628> $report_data


hasMore        : True
cursor         : eyJyb3dJZCI6OTk5OSwiY29sdW1uU29ydFZhbHVlIjoie1widHlwXCI6XCJOb1ZhbHVlXCJ9In0=
reportTemplate : ProtectionTasksDetails
dataGrid       : {Failed Backup VirtualMachine:::e6a7e6f1-6049-4d44-9ba6-8e284e2801de-vm-102 devops-nsx VmwareVirtualMachine Active
                 devops-vcsa.rangers.lab 8e6f6618-6af0-4833-a94d-6b32f00ca9b0 Gold Active 2019-06-27 03:32:13 2019-06-27 03:33:31 78019
                 0 0, Failed Backup VirtualMachine:::e6a7e6f1-6049-4d44-9ba6-8e284e2801de-vm-102 devops-nsx VmwareVirtualMachine Active
                 devops-vcsa.rangers.lab 8e6f6618-6af0-4833-a94d-6b32f00ca9b0 Gold Active 2019-06-27 07:36:47 2019-06-27 07:38:05 78393
                 0 0, Failed Backup VirtualMachine:::e6a7e6f1-6049-4d44-9ba6-8e284e2801de-vm-102 devops-nsx VmwareVirtualMachine Active
                 devops-vcsa.rangers.lab 8e6f6618-6af0-4833-a94d-6b32f00ca9b0 Gold Active 2019-06-27 11:40:39 2019-06-27 11:41:11 31454
                 0 0, Failed Backup VirtualMachine:::e6a7e6f1-6049-4d44-9ba6-8e284e2801de-vm-102 devops-nsx VmwareVirtualMachine Active
                 devops-vcsa.rangers.lab 8e6f6618-6af0-4833-a94d-6b32f00ca9b0 Gold Active 2019-06-27 15:46:09 2019-06-27 15:47:18 68986
                 0 0...}
columns        : {TaskStatus, TaskType, ObjectId, ObjectName...}



PS /Users/tim/Google Drive/Coding Projects/Rubrik/PowerShell/SR-000628> $report_data.dataGrid.Count
9999

Expected Behavior:

This report has 14858 rows, not getting all the data back here.

Steps to Reproduce:

Please provide detailed steps for reproducing the issue.

  1. Find a report with more than 9999 rows
  2. Run above steps

Context:

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Rubrik PowerShell Module Version: 4.0.0.468
  • PowerShell Version: 6.1.0
  • Operating System: macOS

The below is the logic you should use here, then we end up with an object which is properly formed, and includes all rows:

$report_query = @{
    limit = 100
}

$report_output = @()
$has_more = $true
while ($has_more -eq $true) {
    if ($cursor -ne $null) {
        $report_query['cursor'] = $cursor
    }
    $report_response = Invoke-WebRequest -Uri $("https://"+$rubrik_cluster+"/api/internal/report/"+$report_id+"/table") -Headers $headers -Method POST -Body $(ConvertTo-Json $report_query)
    $report_data = $report_response.Content | ConvertFrom-Json
    $has_more = $report_data.hasMore
    $cursor = $report_data.cursor
    foreach ($report_entry in $report_data.dataGrid) {
        $row = '' | select $report_data.columns
        for ($i = 0; $i -lt $report_entry.count; $i++) {
            $row.$($report_data.columns[$i]) = $($report_entry[$i])
        }
        $report_output += $row
    }
}
return $report_output
@rfitzhugh
Copy link
Contributor

Duplicated by issue #485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants