From 220ed2c067c18a712c7adf811fb040c8434f4398 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 22 Aug 2023 17:27:45 +0800 Subject: [PATCH 1/2] add new workaround for automation python3package lro --- .../workaround_automation_25435.go | 37 +++++++++++++++++++ .../parser/dataworkarounds/workarounds.go | 1 + 2 files changed, 38 insertions(+) create mode 100644 tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go new file mode 100644 index 00000000000..fb95873c875 --- /dev/null +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go @@ -0,0 +1,37 @@ +package dataworkarounds + +import ( + "fmt" + + "github.com/hashicorp/pandora/tools/importer-rest-api-specs/models" +) + +var _ workaround = workaroundAutomation25434{} + +type workaroundAutomation25434 struct { +} + +func (workaroundAutomation25434) IsApplicable(apiDefinition *models.AzureApiDefinition) bool { + return apiDefinition.ServiceName == "Automation" && apiDefinition.ApiVersion == "2022-08-08" +} + +func (workaroundAutomation25434) Name() string { + return "Automation / 25434" +} + +func (workaroundAutomation25434) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) { + resource, ok := apiDefinition.Resources["Python3Package"] + if !ok { + return nil, fmt.Errorf("expected a Resource named `Python3Package`") + } + operation, ok := resource.Operations["CreateOrUpdate"] + if !ok { + return nil, fmt.Errorf("expected an Operation named `CreateOrUpdate` for `Python3Package`") + } + + operation.LongRunning = true + resource.Operations["CreateOrUpdate"] = operation + apiDefinition.Resources["Python3Package"] = resource + + return &apiDefinition, nil +} diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go index 7bd7f792719..795e45d7e63 100644 --- a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go @@ -11,6 +11,7 @@ var workarounds = []workaround{ workaroundAuthorization25080{}, workaroundDigitalTwins25120{}, workaroundAutomation25108{}, + workaroundAutomation25434{}, workaroundBatch21291{}, workaroundContainerService21394{}, workaroundDataFactory23013{}, From 4320c282d2c25c477da200a986ea09ed2b0023fa Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Wed, 23 Aug 2023 09:29:52 +0800 Subject: [PATCH 2/2] fix typo. add pr link --- .../dataworkarounds/workaround_automation_25435.go | 12 +++++++----- .../components/parser/dataworkarounds/workarounds.go | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go index fb95873c875..0a3cc1e13d5 100644 --- a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25435.go @@ -6,20 +6,22 @@ import ( "github.com/hashicorp/pandora/tools/importer-rest-api-specs/models" ) -var _ workaround = workaroundAutomation25434{} +var _ workaround = workaroundAutomation25435{} -type workaroundAutomation25434 struct { +// workaround for https://github.com/Azure/azure-rest-api-specs/pull/25435 +// this is a workaround for the fact that the `CreateOrUpdate` operation for `Python3Package` is not marked as `LongRunning` +type workaroundAutomation25435 struct { } -func (workaroundAutomation25434) IsApplicable(apiDefinition *models.AzureApiDefinition) bool { +func (workaroundAutomation25435) IsApplicable(apiDefinition *models.AzureApiDefinition) bool { return apiDefinition.ServiceName == "Automation" && apiDefinition.ApiVersion == "2022-08-08" } -func (workaroundAutomation25434) Name() string { +func (workaroundAutomation25435) Name() string { return "Automation / 25434" } -func (workaroundAutomation25434) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) { +func (workaroundAutomation25435) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) { resource, ok := apiDefinition.Resources["Python3Package"] if !ok { return nil, fmt.Errorf("expected a Resource named `Python3Package`") diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go index 795e45d7e63..44b9475663b 100644 --- a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go @@ -11,7 +11,7 @@ var workarounds = []workaround{ workaroundAuthorization25080{}, workaroundDigitalTwins25120{}, workaroundAutomation25108{}, - workaroundAutomation25434{}, + workaroundAutomation25435{}, workaroundBatch21291{}, workaroundContainerService21394{}, workaroundDataFactory23013{},