Skip to content

Commit

Permalink
add API call to delete pagerduty_event_orchestration_global
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Apr 14, 2023
1 parent dd85970 commit 3d33c17
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions pagerduty/resource_pagerduty_event_orchestration_path_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,31 @@ func resourcePagerDutyEventOrchestrationPathGlobalUpdate(ctx context.Context, d
}

func resourcePagerDutyEventOrchestrationPathGlobalDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
client, err := meta.(*Config).Client()
if err != nil {
return diag.FromErr(err)
}

// In order to delete a Global Orchestration an empty orchestration path
// config should be sent as an update.
emptyPath := emptyOrchestrationPathStructBuilder("global_orchestration")
orchestrationID := d.Get("event_orchestration").(string)

log.Printf("[INFO] Deleting PagerDuty Global Event Orchestration Path: %s", orchestrationID)

retryErr := resource.RetryContext(ctx, 30*time.Second, func() *resource.RetryError {
if _, _, err := client.EventOrchestrationPaths.UpdateContext(ctx, orchestrationID, "global", emptyPath); err != nil {
return resource.RetryableError(err)
}
return nil
})

if retryErr != nil {
return diag.FromErr(retryErr)
}

d.SetId("")
return diags
return nil
}

func resourcePagerDutyEventOrchestrationPathGlobalImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Expand Down

0 comments on commit 3d33c17

Please sign in to comment.