martindstone / pagerduty-cli

A command line interface for PagerDuty
MIT License
91 stars 12 forks source link

schedule:render with schedule ID and name #28

Closed sdenef-adeo closed 2 years ago

sdenef-adeo commented 2 years ago

Hello,

I need to use schedule:render then use the result to join escalation policies, teams, or whatever. I faced an issue because I'm not able to have the schedule ID and/or name. As far as I understand, the schedule:render command restrict data to the schedule.final_schedule.rendered_schedule_entries part. I didn't find any way to add schedule ID and name to the ouput.

Any idea? Or is it a feature request to implement?

Example: pd schedule render -i P999999 --since=$PD_SINCE --until=$PD_UNTIL --sort=start --output=csv --delimiter=, Output:

Start,End,Duration,User id,User name
"27/05/2022, 00:00:00","27/05/2022, 23:59:59","23 hours","PU00000","John Doe"

Expected:

Schedule id,Schedule name,Start,End,Duration,User id,User name
"PSSSSSS",""my schedule","27/05/2022, 00:00:00","27/05/2022, 23:59:59","23 hours","PU00000","John Doe"

Regards, Sébastien

martindstone commented 2 years ago

Hi @sdenef-adeo , I guess I thought that since this command can only render one schedule at a time, nobody would need the id and the name because they would already have known it. But I sort of get what you are trying to do. How about if i add those values as extended columns that will be shown if you give the -x flag?

sdenef-adeo commented 2 years ago

Make them available through the -x flag would be enough for my use case. Thanks Martin.

Note about my use case. As a PagerDuty admin I want to inform all people in my company about:

who will be on call for the next public holiday

NB: will be Thursday 26th of May for France

With this info, they're able to update their schedule if needed. eg: Alice should be oncall from 9:00 AM to 18:00 AM, but as it's a public holiday her team know it's Bob turn to be oncall all the day long.

I output the results as CSV to store them in a database table. Having the ID, I can join it with the schedule, the EP, the services and the teams data to provide to my users full data. They may filter on services to exclude those for DEV environments or whatever they need.

Regards

martindstone commented 2 years ago

Hi @sdenef-adeo it makes good sense what you are trying to do. I have added those columns to the extended output in schedule:render in 0.1.3, just pushed. If you have a self-updatable installation of pd, you can do pd update rc to get it; if you installed using npm, something like npm i -g pagerduty-cli@0.1.3 should do the trick. I will keep this issue open until i know this solves the issue for you and i promote 0.1.3+ to a stable update channel. Let me know... Thank you!

sdenef-adeo commented 2 years ago

Hi Martin, I tested and it works well. Thank you.

martindstone commented 2 years ago

Awesome. I will close this issue now. Thanks for reporting it!