-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azurerm_log_analytics_data_export_rule
- wait for state after creat…
…ion (#27876) * `azurerm_log_analytics_data_export` - add a workaround for Azure/azure-rest-api-specs#31399 * update comment * turn to poller
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
internal/services/loganalytics/custompollers/log_analytics_data_export_poller.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package custompollers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/hashicorp/go-azure-helpers/lang/response" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/dataexport" | ||
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers" | ||
) | ||
|
||
var _ pollers.PollerType = &LogAnalyticsDataExportPoller{} | ||
|
||
type LogAnalyticsDataExportPoller struct { | ||
client *dataexport.DataExportClient | ||
id dataexport.DataExportId | ||
} | ||
|
||
var ( | ||
pollingSuccess = pollers.PollResult{ | ||
Status: pollers.PollingStatusSucceeded, | ||
PollInterval: 10 * time.Second, | ||
} | ||
pollingInProgress = pollers.PollResult{ | ||
Status: pollers.PollingStatusInProgress, | ||
PollInterval: 10 * time.Second, | ||
} | ||
) | ||
|
||
func NewLogAnalyticsDataExportPoller(client *dataexport.DataExportClient, id dataexport.DataExportId) *LogAnalyticsDataExportPoller { | ||
return &LogAnalyticsDataExportPoller{ | ||
client: client, | ||
id: id, | ||
} | ||
} | ||
|
||
func (p LogAnalyticsDataExportPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { | ||
resp, err := p.client.Get(ctx, p.id) | ||
if err != nil { | ||
if response.WasNotFound(resp.HttpResponse) { | ||
return &pollingInProgress, nil | ||
} | ||
return nil, fmt.Errorf("retrieving %s: %+v", p.id, err) | ||
} | ||
return &pollingSuccess, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters