func NewAzureResourceType(specType Type, statusType Type, typeName TypeName) *ResourceType {
	if objectType, ok := specType.(*ObjectType); ok {
		var nameProperty *PropertyDefinition
		var typeProperty *PropertyDefinition
		var apiVersionProperty *PropertyDefinition
		isNameOptional := false
		isTypeOptional := false
		for _, property := range objectType.Properties() {
			if property.HasName(NameProperty) {
				nameProperty = property
				if _, ok := property.PropertyType().(*OptionalType); ok {
					isNameOptional = true
				}
			}
			if property.HasName(TypeProperty) {
				typeProperty = property
				if _, ok := property.PropertyType().(*OptionalType); ok {
					isTypeOptional = true
				}
			}
			if property.HasName(ApiVersionProperty) {
				apiVersionProperty = property
			}
		}
		if typeProperty == nil {
			panic(fmt.Sprintf("Resource %s is missing type property", typeName))
		}
		if nameProperty == nil {
			klog.V(1).Infof("resource %s is missing field 'Name', fabricating one...", typeName)
			nameProperty = NewPropertyDefinition("Name", "name", StringType)
			nameProperty.WithDescription("The name of the resource")
			isNameOptional = true
		}
		if apiVersionProperty == nil {
			panic(fmt.Sprintf("Resource %s is missing apiVersion property", typeName))
		}
		if isNameOptional {
			nameProperty = nameProperty.MakeRequired()
			objectType = objectType.WithProperty(nameProperty)
		}
		apiVersionProperty = apiVersionProperty.MakeRequired()
		objectType = objectType.WithProperty(apiVersionProperty)
		if isTypeOptional {
			typeProperty = typeProperty.MakeRequired()
			objectType = objectType.WithProperty(typeProperty)
		}
		specType = objectType
	}
	return NewResourceType(specType, statusType)
}
NewAzureResourceType defines a new resource type for Azure. It ensures that
the resource has certain expected properties such as type and name.
The typeName parameter is just used for logging.
package astmodel
import (
	"fmt"
	"go/token"
	"sort"
	"strings"
	"github.com/dave/dst"
	"k8s.io/klog/v2"
	"github.com/Azure/k8s-infra/hack/generator/pkg/astbuilder"
)
type ResourceType struct {
	spec             Type
	status           Type
	isStorageVersion bool
	owner            *TypeName
	functions        map[string]Function
	testcases        map[string]TestCase
	InterfaceImplementer
}
func NewResourceType(specType Type, statusType Type) *ResourceType {
	result := &ResourceType{
		isStorageVersion:     false,
		owner:                nil,
		functions:            make(map[string]Function),
		testcases:            make(map[string]TestCase),
		InterfaceImplementer: MakeInterfaceImplementer(),
	}
	return result.WithSpec(specType).WithStatus(statusType)
}
func IsResourceType(t Type) bool {
	_, ok := t.(*ResourceType)
	return ok
}
func IsResourceDefinition(def TypeDefinition) bool {
	return IsResourceType(def.Type())
}