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

ListIncidentsOptions Example #139

Closed
jkondapalli03 opened this issue Mar 10, 2019 · 2 comments
Closed

ListIncidentsOptions Example #139

jkondapalli03 opened this issue Mar 10, 2019 · 2 comments

Comments

@jkondapalli03
Copy link

jkondapalli03 commented Mar 10, 2019

Can anyone please explain how to use this struct
https://godoc.org/github.com/PagerDuty/go-pagerduty#ListIncidentsOptions

i'm planning on using since or DateRage attributes to fetch incidents since a point in time.

@jkondapalli03
Copy link
Author

Little more context for the above question:

I tried using api-reference.pagerduty.com to query list of incidents since 2019-03-10T03:00:00. I see the reponse back with list of all the incidents that occured. here is the GET api https://api.pagerduty.com/incidents?since=2019-03-10T03%3A00%3A00&time_zone=UTC

However, when I try doing the same in code, there are 0 responses

	var incOptions pagerduty.ListIncidentsOptions
	incOptions.Since = "2019-03-10T03:00:00"
	current := time.Now()
	Info.Println("Current time is:" + current.Format(time.RFC3339))
	// incOptions.Until = current.Format(time.RFC3339)
	// incOptions.Statuses= "acknowledged"
	client := pagerduty.NewClient(authtoken)

	if incs, incsError := client.ListIncidents(incOptions); incsError != nil {
		Error.Println(incsError)
		panic(incsError)
	} else {
		// fmt.Println(*incidents)
		Info.Println(incs.Total)
		for _, inc := range incs.Incidents {
			Info.Println("Gathered list of incidents. Iterating over the list to produce to kafka...")
			incJson, err := json.Marshal(inc)
			if err != nil {
				Error.Println(err)
				panic(err)
			}
			Info.Println("About to produce follwoing incident to kafka" + string(incJson))
		}
	}

@jkondapalli03
Copy link
Author

This was my bad. I did not pass in timezone.

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

No branches or pull requests

1 participant