Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
czinu
Contributor

show-changes - how to iterate over total number of changes (sessions)

Jump to solution

Hello CheckMates,

Normally when I interact with API calls I can specify "limit", "offset" etc. to iterate over results and get all objects I need. show-task seems to be different in this matter. I cannot see any option to control it. Is there something I am missing?

I need to perform delta of changes since date X. Below sample output which returns changes from only 10 sessions out of all (203).

{
    "tasks": [
        {
            "task-id""abcdef01-2345-6789-b935-3c9e5cd83d90",
            "task-name""Show Changes",
            "status""succeeded",
            "progress-percentage"100,
            "progress-description""Operation Complete",
            "suppressed"false,
            "task-details": [
                {
                    "limit"10,
                    "offset"0,
                    "from"1,
                    "to"10,
                    "total"203,
...
0 Kudos
1 Solution

Accepted Solutions
Tomer_Noy
Employee
Employee

The show-changes API has a built-in "limit" parameter. The default is 10 sessions, maximum is 500.

This is there to protect against very long processing that might happen when comparing two revisions that are very far apart.

https://sc1.checkpoint.com/documents/latest/APIs/#cli/show-changes~v1.8%20 

View solution in original post

(1)
8 Replies
PhoneBoy
Admin
Admin

You have to query each individual task to get that level of detail.

0 Kudos
Stuart_Green1
Employee
Employee

Hey Czinu, just to clarify - what is it you're trying to get from the API? Is is the status of tasks or the number of changes? If it's a change report you're trying to build you might be better looking at show-changes and specifying the date ranges. If that returns a task-id you need to monitor that task until it succeeds and is complete and then you should get the changes in a report. Make sure that you have details-level set to full as well.

czinu
Contributor

I might not be clear enough initially.

First I am doing "show-changes". Taking task-id from response and do "show-task" with full details against it. After retrieval is complete I get default limit of 10 changes as shown above. I am attaching screenshots for clarity.

0 Kudos
Stuart_Green1
Employee
Employee

ah, think I follow. You can set the limit higher than 10 in your request (docs suggest 500 is the limit but if you have a huge amount of changes in each session you might want to scale it back to maybe 50). If the changes ever exceeded the 'limit' then you would have to page your requests using a loop and an offset.

So in request one - you would need to store the total (lets say there were 35 changes). I would build a loop along these lines

-> make initial request. Limit set to 10, offset set to 0.

<- 35 changes reported by API, first 10 returned as per limit setting.

-> Store these and loop while offset < total. Add limit to offset.

 

If you're using Postman, just manually increase the offset by the value of the limit you specify for each request.

Tomer_Noy
Employee
Employee

The show-changes API has a built-in "limit" parameter. The default is 10 sessions, maximum is 500.

This is there to protect against very long processing that might happen when comparing two revisions that are very far apart.

https://sc1.checkpoint.com/documents/latest/APIs/#cli/show-changes~v1.8%20 

View solution in original post

(1)
czinu
Contributor

This is what I have been missing.

 

This is quite inconvenient as this is async task, so to the get all changes I need to repeat "show-changes" - > "show-task" sequence several times. It would be nice to see all (or at least most) async tasks as sync tasks similarly to show-objects etc.

 

Anyways, thanks a lot for your quick and on spot response.

0 Kudos
PhoneBoy
Admin
Admin

When you ask the API server for a lot of data, it's going to take time to gather and output said data.
Which means that results are limited and certain tasks must be done asynchronously.
This is done to keep the API server performant. 

0 Kudos
czinu
Contributor

I do not argue about the performance side of operation, rather about consistency across calls. "show-objects" also holds a lot of data but is synchronous and you can easily (easier) iterate over results to get them all.

0 Kudos