diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_authorization.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_authorization_25080.go similarity index 100% rename from tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_authorization.go rename to tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_authorization_25080.go diff --git a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_devcenter_26189.go b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_devcenter_26189.go new file mode 100644 index 00000000000..f49ffa44fa8 --- /dev/null +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_devcenter_26189.go @@ -0,0 +1,49 @@ +package dataworkarounds + +import ( + "fmt" + + "github.com/hashicorp/pandora/tools/importer-rest-api-specs/models" +) + +// This workaround fixes an issue in DevCenter where the field `DevCenterUri` is not +// marked as ReadOnly, meaning that it's surfaced as an Optional field rather than +// being Computed. +// +// PR: https://github.com/Azure/azure-rest-api-specs/pull/26189 +// Additional: https://github.com/hashicorp/pandora/pull/2675#issuecomment-1759115231 + +var _ workaround = workaroundDevCenter26189{} + +type workaroundDevCenter26189 struct { +} + +func (workaroundDevCenter26189) IsApplicable(apiDefinition *models.AzureApiDefinition) bool { + return apiDefinition.ServiceName == "DevCenter" && apiDefinition.ApiVersion == "2022-04-01" +} + +func (workaroundDevCenter26189) Name() string { + return "DevCenter / 26189" +} + +func (workaroundDevCenter26189) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) { + resource, ok := apiDefinition.Resources["DevCenters"] + if !ok { + return nil, fmt.Errorf("expected a Resource named `DevCenters` but didn't get one") + } + + model, ok := resource.Models["DevCenterProperties"] + if !ok { + return nil, fmt.Errorf("expected a Model named `DevCenterProperties` but didn't get one") + } + field, ok := model.Fields["DevCenterUri"] + if !ok { + return nil, fmt.Errorf("expected a Field named `DevCenterUri` but didn't get one") + } + field.ReadOnly = true + + model.Fields["DevCenterUri"] = field + resource.Models["DevCenterProperties"] = model + apiDefinition.Resources["DevCenters"] = 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 44b9475663b..2f39ba61f96 100644 --- a/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go +++ b/tools/importer-rest-api-specs/components/parser/dataworkarounds/workarounds.go @@ -15,6 +15,7 @@ var workarounds = []workaround{ workaroundBatch21291{}, workaroundContainerService21394{}, workaroundDataFactory23013{}, + workaroundDevCenter26189{}, workaroundLoadTest20961{}, workaroundRedis22407{}, workaroundMachineLearning25142{},