Skip to content

Commit

Permalink
Merge pull request #537 from cmrberry/zd395153
Browse files Browse the repository at this point in the history
Remove 429 check on remaining data sources
  • Loading branch information
imjaroiswebdev authored Jul 1, 2022
2 parents 5ccb076 + f56e7bb commit e052263
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 54 deletions.
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ func dataSourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interfa
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.BusinessServices.List()
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.BusinessService
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_extension_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ func dataSourcePagerDutyExtensionSchemaRead(d *schema.ResourceData, meta interfa
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.ExtensionSchemas.List(&pagerduty.ListExtensionSchemasOptions{Query: searchName})
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.ExtensionSchema
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ func dataSourcePagerDutyPriorityRead(d *schema.ResourceData, meta interface{}) e
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.Priorities.List()
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.Priority
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ func dataSourcePagerDutyServiceRead(d *schema.ResourceData, meta interface{}) er
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.Services.List(o)
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.Service
Expand Down
8 changes: 2 additions & 6 deletions pagerduty/data_source_pagerduty_service_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ func dataSourcePagerDutyServiceIntegrationRead(d *schema.ResourceData, meta inte
}

func handleError(err error) *resource.RetryError {
if isErrCode(err, 429) {
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ func dataSourcePagerDutyTagRead(d *schema.ResourceData, meta interface{}) error
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.Tags.List(o)
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.Tag
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ func dataSourcePagerDutyTeamRead(d *schema.ResourceData, meta interface{}) error
return resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, _, err := client.Teams.List(o)
if err != nil {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

var found *pagerduty.Team
Expand Down

0 comments on commit e052263

Please sign in to comment.