martindstone / pagerduty-cli

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

feat: pd incident:rename #25

Closed georgettica closed 2 years ago

georgettica commented 2 years ago

if you have a better way of getting the same goal. I would be glad to use that

I would love to have a way of changing the title of an incident this is the way of team we easily label an incident, for and example:

current incident name:
ISSUE HAPPENED 
new incident name:
[Pending Customer] ISSUE HAPPENED

as seen in https://developer.pagerduty.com/api-reference/b3A6Mjc0ODE0Mg-update-an-incident

jcalcada commented 2 years ago

Hi there - although Martin doesn't have a "pd incident:set" option you can use the rest parameter to easily do it. Try this... pd rest:put -e https://api.pagerduty.com/incidents/YOURINCIDENT -d '{"incident": {"type": "incident","title": "NEW TITLE"}}'

georgettica commented 2 years ago

yeah, I know the rest works, I guess I wanted to make this easier than the API call

thanks though!

georgettica commented 2 years ago

I'll create a bash function that does this and note this issue.. if enough people will want it I guess we can push that change?

martindstone commented 2 years ago

Thanks @jcalcada! that will definitely work (also, the https://api.pagerduty.com/ part isn't needed 😉) - I could do a dedicated incident:set command if that's helpful, there are a few things that can be set on incident besides the title, like the urgency etc...

sarman-tftsr commented 2 years ago

This sounds like a great idea! We do the same things, especially when it’s a “known issue” we can’t fix right now. We use that to quickly merge cases based on our internal ticket numbers!

georgettica commented 2 years ago

@sarman-tftsr I would suggest adding a 👍 to the issue, so we can track how many people want this feature

martindstone commented 2 years ago

hi everyone, I just published v0.0.84 which adds:

both commands take the usual incident selection arguments (-i, -m, -p) and can work on multiple incidents in one go. Let me know if this works for you and if so I will close this issue

georgettica commented 2 years ago

it does work, my use case and @jcalcada was to add a prefix, my work now is to do a rest:get to get the incidents name

pd incident:rename -i <ID> -t "<PREFIX> $(pd rest:get -e /incidents/<ID> | jq .incident.title)"
martindstone commented 2 years ago

I thought about implementing it that way @georgettica but it would have to get every incident first so it would be more https requests... I was on the fence about it, now I think I want to do it 😂. I'll probably make that change tomorrow and push it as 0.0.85

georgettica commented 2 years ago

I don't see an issue with having more requests if it minimizes users overhead

martindstone commented 2 years ago

I am thinking to have a separate flag to prefix a given string to the existing title... later on maybe I will mess around with regexps too

georgettica commented 2 years ago

I think an additional flag would be perfect

martindstone commented 2 years ago

Hi so I just published 0.0.85 which adds the --prefix flag and just prepends the given string to the incident title... let me know how you make out with it...

georgettica commented 2 years ago

I tried it now at last and it works great, thanks!