schemaRoot: "../../v2/specs/azure-rest-api-specs/specification"
destinationGoModuleFile: go.mod
# These two paths are relative to the module path above.
typesOutputPath: apis

supportedResourcesReport:
  # Path is relative to the module path, above
  outputFolder: apis
  # Path to documentation fragments to inject into the report
  fragmentPath: ../../docs/v2/crossplane/supported-resources
  currentRelease: v2.13.0

pipeline: crossplane
typeFilters:
  - action: prune
    group: definitions
    name: Expression
    because: expression is an ARM template construct which doesn't belong in CRDs

  - action: include
    group: common
    matchRequired: false # only triggers for Status types

  - action: include
    version: v*20201101
    group: network
    because: Including network for Crossplane

  - action: include
    version: v*20200601
    group: cache
    because: Including cache for Crossplane

  - action: include
    version: v*20201101preview
    group: sql
    because: Including sql

  - action: include
    group: sql
    version: "*v1"
    because: Including sql v1 common types
    matchRequired: false # only triggers for Status types

  - action: include
    group: sql
    version: "*v2"
    because: Including sql v2 common types
    matchRequired: false # only triggers for Status types

  - action: prune
    version: "*preview"
    because: preview SDK versions are excluded by default

  - action: prune
    group: network
    version: "*"
    because: Pruning all networking api versions since we don't use them anyway

  - action: prune
    group: compute
    version: "*"
    because: Pruning all compute api versions since we don't use them anyway

  - action: prune
    group: solutions
    because: There seems to be some issue with embedded JSON objects, specifically "CreateUiDefinition"

  - action: prune
    group: kusto
    because: Some types use OneOf in a way we don't currently handle correctly.

  - action: prune
    group: timeseriesinsights
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: databoxedge
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: resources
    name: ScopedDeployment
    because: Terrifying. Also has scoped-resource clashes.

  - action: prune
    name: Deployment
    group: resources
    because: Terrifying.

  - action: prune
    group: compute.admin
    name: Disk
    because: "don't know how to intersect types: []github.com/Azure/azure-service-operator/hack/crossplane/apis/compute.admin/v1beta20210901/Disk and (object)"

  - action: prune
    group: compute.admin
    name: DiskListInput
    because: Disk was pruned

  - action: prune
    name: ManagementGroup
    group: management
    because: Contains directly recursive type.

  - action: prune
    group: datashare
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: apimanagement
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: automation
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: machinelearningservices
    name: Workspaces_Service*
    because: Some types use OneOf to model inheritance, which we don't currently support.
  - action: prune
    group: resources
    name: DeploymentScript*
    because: Some types use OneOf to model inheritance, which we don't currently support.

  - action: prune
    group: web
    because: Some types (SitesSlotsConfig) use OneOf in a way we don't currently handle. Exclude the whole set for now.

  - action: prune
    group: hdinsight
    name: Clusters;Clusters_Extensions
    because: Uses one-of in a way we don't support

  - action: prune
    group: resources
    name: Tags
    because: This type is defined recursively.

  - action: prune
    group: web
    because: Some types (SitesSlotsConfig) use OneOf in a way we don't currently handle. Exclude the whole set for now.

  - action: prune
    group: compute.extensions
    because: All other extensions should be removed

  - action: prune
    group: costmanagement
    because: QueryFilter is a self-referential, infinitely recursive type. We can't easily unroll it and controller-gen doesn't support recursive types

  - action: prune
    group: azurestackhci
    because: There are some types in here (Step) that are defined recursively.

  - action: prune
    group: securityinsights
    name: Workspaces_Providers*
    because: Resource ownership is malformed

# Exclusions for packages that currently produce types including AnyType.
# TODO: get rid of these, either by chasing the teams generating
# weird json or by handling them differently in the generator.
anyTypePackages:

typeTransformers:
  # Deal with stuff that exists on ARM resources but doesn't make sense on CRDs
  - group: definitions
    name: NumberOrExpression
    because: NumberOrExpression is an ARM template artifact that doesn't make sense in CRDs
    target:
      name: float
    matchRequired: false # TODO: Remove this if/when we actually require it
    
  - name: "*"
    property: Tags
    ifType:
      map:
        key:
          name: string
        value:
          name: any
    target:
      map:
        key:
          name: string
        value:
          name: string
    because: Tags is defined as map[string]interface{} when it should be map[string]string

  # Deal with readonly properties that were not properly pruned in the JSON schema
  - name: ResourceIdentity
    group: sql
    property: UserAssignedIdentities
    remove: true
    because: The UserAssignedIdentities property is enitrely readOnly but is modelled poorly in the JSON schemas. See discussion on https://github.com/Azure/azure-resource-manager-schemas/issues/835

status:
  overrides: [
      {
        # give the common types their own namespace
        basePath: "common-types/resource-management",
        namespace: "Microsoft.Common",
      },
      {
        # force the namespace here or it can fall foul of the sibling-name-collision test
        basePath: "sql/resource-manager/common",
        namespace: "Microsoft.Sql",
      },
      {
        # force the namespace here or it can fall foul of the sibling-name-collision test
        basePath: "security/resource-manager/common",
        namespace: "Microsoft.Security",
      },
      {
        # force the namespace here or it can fall foul of the sibling-name-collision test
        basePath: "eventhub/resource-manager/common",
        namespace: "Microsoft.EventHub",
      },
      {
        # force the namespace here or it can fall foul of the sibling-name-collision test
        basePath: "securityinsights/resource-manager/common",
        namespace: "Microsoft.SecurityInsights",
      },
      # the rest of the configuration below is copied from the ARM schema repo:
      # https://github.com/Azure/azure-resource-manager-schemas/blob/master/generator/autogenlist.ts
      {
        basePath: "blueprint/resource-manager",
        namespace: "Microsoft.Blueprint",
        resourceConfig:
          [
            {
              type: "blueprintAssignments",
              scopes: ScopeType.Subcription | ScopeType.ManagementGroup,
            },
            {
              type: "blueprints",
              scopes: ScopeType.Subcription | ScopeType.ManagementGroup,
            },
            {
              type: "blueprints/artifacts",
              scopes: ScopeType.Subcription | ScopeType.ManagementGroup,
            },
            {
              type: "blueprints/versions",
              scopes: ScopeType.Subcription | ScopeType.ManagementGroup,
            },
          ],
      },
      {
        basePath: "customproviders/resource-manager",
        namespace: "Microsoft.CustomProviders",
        resourceConfig: [{ type: "associations", scopes: ScopeType.Extension }],
      },
      {
        basePath: "consumption/resource-manager",
        namespace: "Microsoft.Consumption",
        resourceConfig:
          [
            {
              type: "budgets",
              scopes: ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.Extension,
            },
          ],
      },
      {
        basePath: "digitaltwins/resource-manager",
        resourceConfig:
          [{ type: "integrationResources", scopes: ScopeType.Extension }],
      },
      {
        basePath: "deviceprovisioningservices/resource-manager",
        suffix: "Provisioning",
      },
      { basePath: "frontdoor/resource-manager", suffix: "FrontDoor" },
      {
        basePath: "eventgrid/resource-manager",
        resourceConfig:
          [
            {
              type: "eventSubscriptions",
              scopes: ScopeType.Extension | ScopeType.Subcription | ScopeType.ResourceGroup,
            },
          ],
      },
      {
        basePath: "machinelearning/resource-manager",
        postProcessor: machineLearningPostProcessor,
      },
      {
        basePath: "managednetwork/resource-manager",
        resourceConfig:
          [{ type: "scopeAssignments", scopes: ScopeType.Subcription }],
      },
      {
        basePath: "policyinsights/resource-manager",
        resourceConfig:
          [
            {
              type: "remediations",
              scopes: ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.ManagementGroup,
            },
          ],
      },
      {
        basePath: "resources/resource-manager",
        resourceConfig:
          [
            {
              type: "deployments",
              scopes: ScopeType.Tenant | ScopeType.ManagementGroup | ScopeType.Subcription | ScopeType.ResourceGroup,
            },
            {
              type: "tags",
              scopes: ScopeType.ManagementGroup | ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.Extension,
            },
          ],
        postProcessor: resourcesPostProcessor,
      },
      { basePath: "storSimple1200Series/resource-manager", suffix: "1200" },
      { basePath: "storsimple8000series/resource-manager", suffix: "8000" },
      {
        basePath: "softwareplan/resource-manager",
        resourceConfig:
          [{ type: "hybridUseBenefits", scopes: ScopeType.Extension }],
      },
    ]
objectModelConfiguration:
  sql:
    2020-11-01-preview:
      Server:
        $export: true
        $supportedFrom: "-"
      Servers_Database:
        $export: true
        $supportedFrom: "-"
    2021-11-01:
      Server:
        $export: true
        $supportedFrom: "-"
  cache:
    2020-06-01:
      Redis:
        $export: true
        $supportedFrom: "-"
