PagerDuty / go-pagerduty

go client library for PagerDuty v2 API
https://v2.developer.pagerduty.com/docs/rest-api
Apache License 2.0
285 stars 241 forks source link

Cannot grok how to construct a ResponderRequestOptions! #485

Closed andrewwatson closed 11 months ago

andrewwatson commented 1 year ago

Does anyone have an example of how to add an escalation policy to an incident as a responder? The example on the api docs site doesn't use the SDK, it uses http to POST a JSON blob to the API!

I've tried a lot of different things but I keep running into type issues.

Thanks

andrewwatson commented 1 year ago

Also, as my use of the SDK grows I'd love to submit PRs with new examples!

andrewwatson commented 1 year ago

Also, also... I kinda found my answer in a unit test!

    request_target := ResponderRequestTarget{}
    request_target.ID = "PJ25ZYX"
    request_target.Type = "user_reference"

    request_target_wrapper := ResponderRequestTargetWrapper{Target: request_target}
    request_targets := []ResponderRequestTargetWrapper{request_target_wrapper}

    input := ResponderRequestOptions{
        From:        from,
        Message:     "Help",
        RequesterID: "PL1JMK5",
        Targets:     request_targets,
    }

So I think will write this up as an example and submit a PR...

ChuckCrawford commented 11 months ago

Glad you got this figured out @andrewwatson . Can we close this issue?

andrewwatson commented 11 months ago

Yeah that's fine. Thanks!

On Wed, Sep 20, 2023, 5:56 PM Charlie @.***> wrote:

Glad you got this figured out @andrewwatson https://github.com/andrewwatson . Can we close this issue?

— Reply to this email directly, view it on GitHub https://github.com/PagerDuty/go-pagerduty/issues/485#issuecomment-1728479606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABMY6SIGAUB6FI7GK6HXXTX3NRBPANCNFSM6AAAAAAZA4PLZ4 . You are receiving this because you were mentioned.Message ID: @.***>