diff --git a/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workaround_manageddevopspools_40905.go b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workaround_manageddevopspools_40905.go new file mode 100644 index 0000000000..35df577bee --- /dev/null +++ b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workaround_manageddevopspools_40905.go @@ -0,0 +1,56 @@ +package dataworkarounds + +import ( + "errors" + "fmt" + + sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models" +) + +var _ workaround = workaroundManagedDevopsPools40905{} + +// workaroundManagedDevopsPools40905 works around the wrong identity type. +// Swagger PR: https://github.com/Azure/azure-rest-api-specs/pull/40905 +type workaroundManagedDevopsPools40905 struct{} + +func (workaroundManagedDevopsPools40905) IsApplicable(serviceName string, apiVersion sdkModels.APIVersion) bool { + return serviceName == "DevOpsInfrastructure" && (apiVersion.APIVersion == "2025-01-21" || apiVersion.APIVersion == "2025-09-20") +} + +func (workaroundManagedDevopsPools40905) Name() string { + return "ManagedDevopsPools / 40905" +} + +func (workaroundManagedDevopsPools40905) Process(input sdkModels.APIVersion) (*sdkModels.APIVersion, error) { + resource, ok := input.Resources["Pools"] + if !ok { + return nil, errors.New("expected a resource named `Pools` but didn't get one") + } + + models := []string{ + "Pool", + "PoolUpdate", + } + + for _, modelName := range models { + model, ok := resource.Models[modelName] + if !ok { + return nil, fmt.Errorf("couldn't find model `%s`", modelName) + } + + identityField, ok := model.Fields["Identity"] + if !ok { + return nil, fmt.Errorf("couldn't find the field `Identity` within model `%s`", modelName) + } + + identityField.ObjectDefinition.Type = sdkModels.UserAssignedIdentityMapSDKObjectDefinitionType + identityField.ObjectDefinition.ReferenceName = nil + + model.Fields["Identity"] = identityField + resource.Models[modelName] = model + } + + input.Resources["Pools"] = resource + + return &input, nil +} diff --git a/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go index 7834733020..d91a04fd8e 100644 --- a/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go +++ b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go @@ -32,6 +32,7 @@ var workarounds = []workaround{ workaroundLoadTest20961{}, workaroundMachineLearning25142{}, workaroundMachineLearning40149{}, + workaroundManagedDevopsPools40905{}, workaroundMongoCluster38810{}, workaroundNetwork29303{}, workaroundNetwork38407{},