Skip to content

Commit 4a8391a

Browse files
authored
Workaround for Microsoft.Web - CreateOrUpdate_Certificate operation (#5273)
1 parent 05053c9 commit 4a8391a

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/common_workaround_is_lro.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import (
1414
var _ workaround = commonWorkaroundIsLRO{}
1515

1616
type commonWorkaroundIsLRO struct {
17-
serviceName string
18-
apiVersions []string
19-
resources []string
20-
operations []string
17+
serviceName string
18+
apiVersions []string
19+
resources []string
20+
operations []string
21+
additionalStatusCodes []int
2122
}
2223

2324
func (w commonWorkaroundIsLRO) IsApplicable(serviceName string, apiVersion sdkModels.APIVersion) bool {
@@ -45,6 +46,15 @@ func (w commonWorkaroundIsLRO) Process(input sdkModels.APIVersion) (*sdkModels.A
4546
return nil, fmt.Errorf("expected operation `%s` to not be marked as `LongRunning`. The workaround for this operation should be removed", operation)
4647
}
4748

49+
if len(w.additionalStatusCodes) > 0 {
50+
for _, statusCode := range w.additionalStatusCodes {
51+
if slices.Contains(o.ExpectedStatusCodes, statusCode) {
52+
return nil, fmt.Errorf("expected operation `%s` to not contain status code `%d`. This should be removed", operation, statusCode)
53+
}
54+
o.ExpectedStatusCodes = append(o.ExpectedStatusCodes, statusCode)
55+
}
56+
}
57+
4858
o.LongRunning = true
4959
r.Operations[operation] = o
5060
}

tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ var workarounds = []workaround{
88

99
// Common workarounds
1010
// https://github.com/Azure/azure-rest-api-specs/issues/22758
11-
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2023-02-01"}, []string{"ProtectedItems"}, []string{"CreateOrUpdate", "Delete"}},
12-
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2025-02-01"}, []string{"ProtectedItems"}, []string{"Delete"}},
11+
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2023-02-01"}, []string{"ProtectedItems"}, []string{"CreateOrUpdate", "Delete"}, nil},
12+
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2025-02-01"}, []string{"ProtectedItems"}, []string{"Delete"}, nil},
1313
// https://github.com/Azure/azure-rest-api-specs/issues/37325
14-
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2025-02-01"}, []string{"ProtectionContainers"}, []string{"Unregister"}},
14+
commonWorkaroundIsLRO{"RecoveryServicesBackup", []string{"2025-02-01"}, []string{"ProtectionContainers"}, []string{"Unregister"}, nil},
15+
// https://github.com/Azure/azure-rest-api-specs/issues/41432
16+
commonWorkaroundIsLRO{"Web", []string{"2023-01-01", "2023-12-01", "2024-11-01", "2025-05-01"}, []string{"Certificates"}, []string{"CreateOrUpdate"}, []int{202}},
1517

1618
// Workarounds
1719
workaroundAlertsManagement{},

0 commit comments

Comments
 (0)