//
// This file is generated by grafana-app-sdk
// DO NOT EDIT
//

package manifestdata

import (
	"encoding/json"
	"fmt"
	"strings"

	"github.com/grafana/grafana-app-sdk/app"
	"github.com/grafana/grafana-app-sdk/resource"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/kube-openapi/pkg/spec3"
	"k8s.io/kube-openapi/pkg/validation/spec"

	v1alpha1 "github.com/grafana/grafana-app-sdk/app/appmanifest/v1alpha1"
	v1alpha2 "github.com/grafana/grafana-app-sdk/app/appmanifest/v1alpha2"
)

var (
	rawSchemaAppManifestv1alpha1     = []byte(`{"AdditionalPrinterColumns":{"additionalProperties":false,"properties":{"description":{"description":"description is a human readable description of this column.","type":"string"},"format":{"description":"format is an optional OpenAPI type definition for this column. The 'name' format is applied\nto the primary identifier column to assist in clients identifying column is the resource name.\nSee https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.","type":"string"},"jsonPath":{"description":"jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against\neach custom resource to produce the value for this column.","type":"string"},"name":{"description":"name is a human readable name for the column.","type":"string"},"priority":{"description":"priority is an integer defining the relative importance of this column compared to others. Lower\nnumbers are considered higher priority. Columns that may be omitted in limited space scenarios\nshould be given a priority greater than 0.","type":"integer"},"type":{"description":"type is an OpenAPI type definition for this column.\nSee https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.","type":"string"}},"required":["name","type","jsonPath"],"type":"object"},"AdmissionCapabilities":{"additionalProperties":false,"properties":{"mutation":{"$ref":"#/components/schemas/MutationCapability"},"validation":{"$ref":"#/components/schemas/ValidationCapability"}},"type":"object"},"AdmissionOperation":{"enum":["CREATE","UPDATE","DELETE","CONNECT","*"],"type":"string"},"AppManifest":{"properties":{"spec":{"$ref":"#/components/schemas/spec"},"status":{"$ref":"#/components/schemas/status"}},"required":["spec"]},"ApplyStatus":{"additionalProperties":false,"properties":{"details":{"description":"details may contain specific information (such as error message(s)) on the reason for the status","type":"string"},"managedResources":{"description":"objects contains a list of managed resources (such as roles, CRDs, webhooks, etc.)","items":{"$ref":"#/components/schemas/ApplyStatusManagedResource"},"type":"array"},"status":{"enum":["success","failure"],"type":"string"}},"required":["status"],"type":"object"},"ApplyStatusManagedResource":{"additionalProperties":false,"properties":{"apiVersion":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"}},"required":["kind","apiVersion","namespace","name"],"type":"object"},"KindPermission":{"additionalProperties":false,"properties":{"actions":{"items":{"type":"string"},"type":"array"},"group":{"type":"string"},"resource":{"type":"string"}},"required":["group","resource","actions"],"type":"object"},"ManifestVersion":{"additionalProperties":false,"properties":{"kinds":{"description":"Kinds is a list of all the kinds served in this version.\nGenerally, kinds should exist in each version unless they have been deprecated (and no longer exist in a newer version)\nor newly added (and didn't exist for older versions).","items":{"$ref":"#/components/schemas/ManifestVersionKind"},"type":"array"},"name":{"description":"Name is the version name string, such as \"v1\" or \"v1alpha1\"","type":"string"},"served":{"default":true,"description":"Served dictates whether this version is served by the API server.\nA version cannot be removed from a manifest until it is no longer served.","type":"boolean"}},"required":["name","kinds"],"type":"object"},"ManifestVersionKind":{"additionalProperties":false,"properties":{"additionalPrinterColumns":{"items":{"$ref":"#/components/schemas/AdditionalPrinterColumns"},"type":"array"},"admission":{"$ref":"#/components/schemas/AdmissionCapabilities"},"conversion":{"default":false,"description":"Conversion indicates whether this kind supports custom conversion behavior exposed by the Convert method in the App.\nIt may not prevent automatic conversion behavior between versions of the kind when set to false\n(for example, CRDs will always support simple conversion, and this flag enables webhook conversion).\nThis field should be the same for all versions of the kind. Different values will result in an error or undefined behavior.","type":"boolean"},"kind":{"description":"Kind is the name of the kind. This should begin with a capital letter and be CamelCased","type":"string"},"plural":{"description":"Plural is the plural version of ` + "`" + `kind` + "`" + `. This is optional and defaults to the kind + \"s\" if not present.","type":"string"},"routes":{"additionalProperties":true,"description":"Routes is a map of subresource route path to spec3.PathProps description of the route.\nCurrently the spec3.PathProps is not explicitly typed, but typing will be enfoced in the future.\nInvalid payloads will not be parsed correctly and may cause undefined behavior.","type":"object"},"schema":{"$ref":"#/components/schemas/ManifestVersionKindSchema"},"scope":{"default":"Namespaced","description":"Scope dictates the scope of the kind. This field must be the same for all versions of the kind.\nDifferent values will result in an error or undefined behavior.","enum":["Namespaced","Cluster"],"type":"string"},"selectableFields":{"items":{"type":"string"},"type":"array"}},"required":["kind","scope","schema"],"type":"object"},"ManifestVersionKindSchema":{"additionalProperties":true,"type":"object"},"MutationCapability":{"additionalProperties":false,"properties":{"operations":{"items":{"$ref":"#/components/schemas/AdmissionOperation"},"type":"array"}},"required":["operations"],"type":"object"},"OperatorInfo":{"additionalProperties":false,"properties":{"url":{"description":"URL is the URL of the operator's HTTPS endpoint, including port if non-standard (443).\nIt should be a URL which the API server can access.","type":"string"},"webhooks":{"$ref":"#/components/schemas/OperatorWebhookProperties","description":"Webhooks contains information about the various webhook paths."}},"type":"object"},"OperatorState":{"additionalProperties":false,"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"additionalProperties":true,"description":"details contains any extra information that is operator-specific","type":"object"},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"OperatorWebhookProperties":{"additionalProperties":false,"properties":{"conversionPath":{"default":"/convert","type":"string"},"mutationPath":{"default":"/mutate","type":"string"},"validationPath":{"default":"/validate","type":"string"}},"type":"object"},"Role":{"additionalProperties":false,"properties":{"description":{"description":"Description is used as the role description in grafana, displayed in the UI and API responses","type":"string"},"kinds":{"items":{"$ref":"#/components/schemas/RoleKind"},"type":"array"},"routes":{"description":"Routes is a list of route names to match.\nTo match the same route in multiple versions, it should share the same name.","items":{"type":"string"},"type":"array"},"title":{"description":"Title will be used as the role title in grafana","type":"string"}},"required":["title","description"],"type":"object"},"RoleKind":{"oneOf":[{"$ref":"#/components/schemas/RoleKindWithPermissionSet"},{"$ref":"#/components/schemas/RoleKindWithVerbs"}]},"RoleKindWithPermissionSet":{"additionalProperties":false,"properties":{"kind":{"type":"string"},"permissionSet":{"default":"viewer","enum":["viewer","editor","admin"],"type":"string"}},"required":["kind","permissionSet"],"type":"object"},"RoleKindWithVerbs":{"additionalProperties":false,"properties":{"kind":{"type":"string"},"verbs":{"items":{"type":"string"},"type":"array"}},"required":["kind","verbs"],"type":"object"},"ValidationCapability":{"additionalProperties":false,"properties":{"operations":{"items":{"$ref":"#/components/schemas/AdmissionOperation"},"type":"array"}},"required":["operations"],"type":"object"},"spec":{"additionalProperties":false,"properties":{"appDisplayName":{"description":"AppDisplayName is the display name of the app, which can contain any printable characters","type":"string"},"appName":{"pattern":"^([a-z][a-z0-9-]*[a-z0-9])$","type":"string"},"dryRunKinds":{"default":false,"description":"DryRunKinds dictates whether this revision should create/update CRD's from the provided kinds,\nOr simply validate and report errors in status.resources.crds.\nIf dryRunKinds is true, CRD change validation will be skipped on ingress and reported in status instead.\nEven if no validation errors exist, CRDs will not be created or updated for a revision with dryRunKinds=true.","type":"boolean"},"extraPermissions":{"additionalProperties":false,"description":"ExtraPermissions contains additional permissions needed for an app's backend component to operate.\nApps implicitly have all permissions for kinds they managed (defined in ` + "`" + `kinds` + "`" + `).","properties":{"accessKinds":{"description":"accessKinds is a list of KindPermission objects for accessing additional kinds provided by other apps","items":{"$ref":"#/components/schemas/KindPermission"},"type":"array"}},"required":["accessKinds"],"type":"object"},"group":{"type":"string"},"operator":{"$ref":"#/components/schemas/OperatorInfo","description":"Operator has information about the operator being run for the app, if there is one.\nWhen present, it can indicate to the API server the URL and paths for webhooks, if applicable.\nThis is only required if you run your app as an operator and any of your kinds support webhooks for validation,\nmutation, or conversion."},"preferredVersion":{"description":"PreferredVersion is the preferred version for API use. If empty, it will use the latest from versions.\nFor CRDs, this also dictates which version is used for storage.","type":"string"},"roleBindings":{"additionalProperties":false,"description":"RoleBindings binds the roles specified in Roles to groups.\nBasic groups are \"anonymous\", \"viewer\", \"editor\", and \"admin\".\nAdditional groups are specified under \"additional\"","properties":{"additional":{"additionalProperties":{"items":{"type":"string"},"type":"array"},"type":"object"},"admin":{"items":{"type":"string"},"type":"array"},"editor":{"items":{"type":"string"},"type":"array"},"viewer":{"items":{"type":"string"},"type":"array"}},"type":"object"},"roles":{"additionalProperties":{"$ref":"#/components/schemas/Role"},"description":"Roles contains information for new user roles associated with this app.\nIt is a map of the role name (e.g. \"dashboard:reader\") to the set of permissions on resources managed by this app.","type":"object"},"versions":{"description":"Versions is the list of versions for this manifest, in order.","items":{"$ref":"#/components/schemas/ManifestVersion"},"type":"array"}},"required":["appName","appDisplayName","group","versions"],"type":"object"},"status":{"additionalProperties":false,"properties":{"additionalFields":{"additionalProperties":true,"description":"additionalFields is reserved for future use","type":"object"},"observedGeneration":{"description":"ObservedGeneration is the last generation which has been applied by the controller.","type":"integer"},"operatorStates":{"additionalProperties":{"$ref":"#/components/schemas/OperatorState"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"resources":{"additionalProperties":{"$ref":"#/components/schemas/ApplyStatus"},"description":"Resources contains the status of each resource type created or updated in the API server\nas a result of the AppManifest.","type":"object"}},"required":["resources"],"type":"object"}}`)
	versionSchemaAppManifestv1alpha1 app.VersionSchema
	_                                = json.Unmarshal(rawSchemaAppManifestv1alpha1, &versionSchemaAppManifestv1alpha1)
	rawSchemaAppManifestv1alpha2     = []byte(`{"AdditionalPrinterColumns":{"additionalProperties":false,"properties":{"description":{"description":"description is a human readable description of this column.","type":"string"},"format":{"description":"format is an optional OpenAPI type definition for this column. The 'name' format is applied\nto the primary identifier column to assist in clients identifying column is the resource name.\nSee https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.","type":"string"},"jsonPath":{"description":"jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against\neach custom resource to produce the value for this column.","type":"string"},"name":{"description":"name is a human readable name for the column.","type":"string"},"priority":{"description":"priority is an integer defining the relative importance of this column compared to others. Lower\nnumbers are considered higher priority. Columns that may be omitted in limited space scenarios\nshould be given a priority greater than 0.","type":"integer"},"type":{"description":"type is an OpenAPI type definition for this column.\nSee https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details.","type":"string"}},"required":["name","type","jsonPath"],"type":"object"},"AdmissionCapabilities":{"additionalProperties":false,"properties":{"mutation":{"$ref":"#/components/schemas/MutationCapability"},"validation":{"$ref":"#/components/schemas/ValidationCapability"}},"type":"object"},"AdmissionOperation":{"enum":["CREATE","UPDATE","DELETE","CONNECT","*"],"type":"string"},"AppManifest":{"properties":{"spec":{"$ref":"#/components/schemas/spec"},"status":{"$ref":"#/components/schemas/status"}},"required":["spec"]},"ApplyStatus":{"additionalProperties":false,"properties":{"details":{"description":"details may contain specific information (such as error message(s)) on the reason for the status","type":"string"},"managedResources":{"description":"objects contains a list of managed resources (such as roles, CRDs, webhooks, etc.)","items":{"$ref":"#/components/schemas/ApplyStatusManagedResource"},"type":"array"},"status":{"enum":["success","failure"],"type":"string"}},"required":["status"],"type":"object"},"ApplyStatusManagedResource":{"additionalProperties":false,"properties":{"apiVersion":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"}},"required":["kind","apiVersion","namespace","name"],"type":"object"},"KindPermission":{"additionalProperties":false,"properties":{"actions":{"items":{"type":"string"},"type":"array"},"group":{"type":"string"},"resource":{"type":"string"}},"required":["group","resource","actions"],"type":"object"},"ManifestVersion":{"additionalProperties":false,"properties":{"kinds":{"description":"Kinds is a list of all the kinds served in this version.\nGenerally, kinds should exist in each version unless they have been deprecated (and no longer exist in a newer version)\nor newly added (and didn't exist for older versions).","items":{"$ref":"#/components/schemas/ManifestVersionKind"},"type":"array"},"name":{"description":"Name is the version name string, such as \"v1\" or \"v1alpha1\"","type":"string"},"routes":{"$ref":"#/components/schemas/ManifestVersionRoutes","description":"Routes is a section defining version-level custom resource routes.\nThese routes are registered at the same level as kinds, and thus should not conflict with existing kinds."},"served":{"default":true,"description":"Served dictates whether this version is served by the API server.\nA version cannot be removed from a manifest until it is no longer served.","type":"boolean"}},"required":["name","kinds"],"type":"object"},"ManifestVersionKind":{"additionalProperties":false,"properties":{"additionalPrinterColumns":{"items":{"$ref":"#/components/schemas/AdditionalPrinterColumns"},"type":"array"},"admission":{"$ref":"#/components/schemas/AdmissionCapabilities"},"conversion":{"default":false,"description":"Conversion indicates whether this kind supports custom conversion behavior exposed by the Convert method in the App.\nIt may not prevent automatic conversion behavior between versions of the kind when set to false\n(for example, CRDs will always support simple conversion, and this flag enables webhook conversion).\nThis field should be the same for all versions of the kind. Different values will result in an error or undefined behavior.","type":"boolean"},"folderScoped":{"default":true,"description":"folderScoped controls whether resources of this kind are scoped to folders.\nOnly meaningful when scope is \"Namespaced\"; for cluster-scoped kinds the field is ignored.\nDefaults to true (folder-scoped).","type":"boolean"},"kind":{"description":"Kind is the name of the kind. This should begin with a capital letter and be CamelCased","type":"string"},"plural":{"description":"Plural is the plural version of ` + "`" + `kind` + "`" + `. This is optional and defaults to the kind + \"s\" if not present.","type":"string"},"routes":{"additionalProperties":true,"description":"Routes is a map of subresource route path to spec3.PathProps description of the route.\nCurrently the spec3.PathProps is not explicitly typed, but typing will be enfoced in the future.\nInvalid payloads will not be parsed correctly and may cause undefined behavior.","type":"object"},"schemas":{"additionalProperties":true,"description":"Schemas is the components.schemas section of an OpenAPI document describing this Kind.\nIt must contain a key named the same as the ` + "`" + `kind` + "`" + ` field of the Kind.\nOther fields may be present to be referenced by $ref tags in a schema,\nand references should lead with '#/components/schemas/' just as they would in a standard OpenAPI document.\nIf route responses in the ` + "`" + `routes` + "`" + ` section reference a definition in '#/components/schemas',\nthat schema definition must exist in this section.","type":"object"},"scope":{"default":"Namespaced","description":"Scope dictates the scope of the kind. This field must be the same for all versions of the kind.\nDifferent values will result in an error or undefined behavior.","enum":["Namespaced","Cluster"],"type":"string"},"searchFields":{"items":{"$ref":"#/components/schemas/SearchField"},"type":"array"},"selectableFields":{"items":{"type":"string"},"type":"array"},"userReadable":{"default":false,"description":"userReadable controls whether end users may get/list cluster-scoped resources of this kind.\nOnly meaningful when scope is \"Cluster\"; for namespaced kinds the field is ignored.","type":"boolean"}},"required":["kind","scope","schemas"],"type":"object"},"ManifestVersionRoutes":{"additionalProperties":false,"properties":{"cluster":{"additionalProperties":true,"description":"Cluster is a map of cluster-scoped route paths to spec3.PathProps description of the route.\nCurrently the spec3.PathProps is not explicitly typed, but typing will be enfoced in the future.\nInvalid payloads will not be parsed correctly and may cause undefined behavior.","type":"object"},"namespaced":{"additionalProperties":true,"description":"Namespaced is a map of namespace-scoped route paths to spec3.PathProps description of the route.\nCurrently the spec3.PathProps is not explicitly typed, but typing will be enfoced in the future.\nInvalid payloads will not be parsed correctly and may cause undefined behavior.","type":"object"},"schemas":{"additionalProperties":true,"description":"Schemas contains additional schemas referenced by requests/responses for namespaced and cluster routes.\nIf route responses in the ` + "`" + `namespaced` + "`" + ` or ` + "`" + `cluster` + "`" + ` section reference a definition in '#/components/schemas',\nthat schema definition must exist in this section.","type":"object"}},"type":"object"},"MutationCapability":{"additionalProperties":false,"properties":{"operations":{"items":{"$ref":"#/components/schemas/AdmissionOperation"},"type":"array"}},"required":["operations"],"type":"object"},"OperatorInfo":{"additionalProperties":false,"properties":{"url":{"description":"URL is the URL of the operator's HTTPS endpoint, including port if non-standard (443).\nIt should be a URL which the API server can access.","type":"string"},"webhooks":{"$ref":"#/components/schemas/OperatorWebhookProperties","description":"Webhooks contains information about the various webhook paths."}},"type":"object"},"OperatorState":{"additionalProperties":false,"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"additionalProperties":true,"description":"details contains any extra information that is operator-specific","type":"object"},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"OperatorWebhookProperties":{"additionalProperties":false,"properties":{"conversionPath":{"default":"/convert","type":"string"},"mutationPath":{"default":"/mutate","type":"string"},"validationPath":{"default":"/validate","type":"string"}},"type":"object"},"Role":{"additionalProperties":false,"properties":{"description":{"description":"Description is used as the role description in grafana, displayed in the UI and API responses","type":"string"},"kinds":{"items":{"$ref":"#/components/schemas/RoleKind"},"type":"array"},"routes":{"description":"Routes is a list of route names to match.\nTo match the same route in multiple versions, it should share the same name.","items":{"type":"string"},"type":"array"},"title":{"description":"Title will be used as the role title in grafana","type":"string"}},"required":["title","description"],"type":"object"},"RoleKind":{"oneOf":[{"$ref":"#/components/schemas/RoleKindWithPermissionSet"},{"$ref":"#/components/schemas/RoleKindWithVerbs"}]},"RoleKindWithPermissionSet":{"additionalProperties":false,"properties":{"kind":{"type":"string"},"permissionSet":{"default":"viewer","enum":["viewer","editor","admin"],"type":"string"}},"required":["kind","permissionSet"],"type":"object"},"RoleKindWithVerbs":{"additionalProperties":false,"properties":{"kind":{"type":"string"},"verbs":{"items":{"type":"string"},"type":"array"}},"required":["kind","verbs"],"type":"object"},"SearchField":{"additionalProperties":false,"description":"#SearchField describes a field exposed for search indexing and querying.\nThe type and capabilities values, and which capabilities are valid on which\ntype, are defined by the searchfields package\n(github.com/grafana/grafana-app-sdk/searchfields), the shared source of\ntruth for both the SDK codegen validator and the runtime search backend.","properties":{"array":{"default":false,"description":"array indicates that the field holds a list of values of the given type.","type":"boolean"},"capabilities":{"description":"capabilities lists what the field can be used for at query time, such as\nfiltering, full-text search, sorting, or faceting.","items":{"enum":["filter","text","partial","sort","facet","retrieve","unranked"],"type":"string"},"type":"array"},"description":{"description":"description is a human readable description of the field.","type":"string"},"emitZeroIfAbsent":{"default":false,"description":"emitZeroIfAbsent indexes the type's zero value when path resolves to nothing,\nso sort and range queries see every document. Without it, a document missing\nthe path omits the field entirely.","type":"boolean"},"name":{"description":"name is the field name as it appears in search documents and queries.","type":"string"},"path":{"description":"path is the JSON path within the resource that supplies this field's value\n(for example \"spec.email\"). When omitted, the field is populated by a custom\ndocument builder rather than read directly from the resource.","type":"string"},"type":{"description":"type is the value type of the field.","enum":["string","int64","double","boolean","date"],"type":"string"}},"required":["name","type","capabilities"],"type":"object"},"ValidationCapability":{"additionalProperties":false,"properties":{"operations":{"items":{"$ref":"#/components/schemas/AdmissionOperation"},"type":"array"}},"required":["operations"],"type":"object"},"spec":{"additionalProperties":false,"properties":{"appDisplayName":{"description":"AppDisplayName is the display name of the app, which can contain any printable characters","type":"string"},"appName":{"description":"AppName is the unique ID of the app","pattern":"^([a-z][a-z0-9-]*[a-z0-9])$","type":"string"},"dryRunKinds":{"default":false,"description":"DryRunKinds dictates whether this revision should create/update CRD's from the provided kinds,\nOr simply validate and report errors in status.resources.crds.\nIf dryRunKinds is true, CRD change validation will be skipped on ingress and reported in status instead.\nEven if no validation errors exist, CRDs will not be created or updated for a revision with dryRunKinds=true.","type":"boolean"},"extraPermissions":{"additionalProperties":false,"description":"ExtraPermissions contains additional permissions needed for an app's backend component to operate.\nApps implicitly have all permissions for kinds they managed (defined in ` + "`" + `kinds` + "`" + `).","properties":{"accessKinds":{"description":"accessKinds is a list of KindPermission objects for accessing additional kinds provided by other apps","items":{"$ref":"#/components/schemas/KindPermission"},"type":"array"}},"required":["accessKinds"],"type":"object"},"group":{"type":"string"},"operator":{"$ref":"#/components/schemas/OperatorInfo","description":"Operator has information about the operator being run for the app, if there is one.\nWhen present, it can indicate to the API server the URL and paths for webhooks, if applicable.\nThis is only required if you run your app as an operator and any of your kinds support webhooks for validation,\nmutation, or conversion."},"preferredVersion":{"description":"PreferredVersion is the preferred version for API use. If empty, it will use the latest from versions.\nFor CRDs, this also dictates which version is used for storage.","type":"string"},"roleBindings":{"additionalProperties":false,"description":"RoleBindings binds the roles specified in Roles to groups.\nBasic groups are \"anonymous\", \"viewer\", \"editor\", and \"admin\".\nAdditional groups are specified under \"additional\"","properties":{"additional":{"additionalProperties":{"items":{"type":"string"},"type":"array"},"type":"object"},"admin":{"items":{"type":"string"},"type":"array"},"editor":{"items":{"type":"string"},"type":"array"},"viewer":{"items":{"type":"string"},"type":"array"}},"type":"object"},"roles":{"additionalProperties":{"$ref":"#/components/schemas/Role"},"description":"Roles contains information for new user roles associated with this app.\nIt is a map of the role name (e.g. \"dashboard:reader\") to the set of permissions on resources managed by this app.","type":"object"},"versions":{"description":"Versions is the list of versions for this manifest, in order.","items":{"$ref":"#/components/schemas/ManifestVersion"},"type":"array"}},"required":["appName","appDisplayName","group","versions"],"type":"object"},"status":{"additionalProperties":false,"properties":{"additionalFields":{"additionalProperties":true,"description":"additionalFields is reserved for future use","type":"object"},"observedGeneration":{"description":"ObservedGeneration is the last generation which has been applied by the controller.","type":"integer"},"operatorStates":{"additionalProperties":{"$ref":"#/components/schemas/OperatorState"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"resources":{"additionalProperties":{"$ref":"#/components/schemas/ApplyStatus"},"description":"Resources contains the status of each resource type created or updated in the API server\nas a result of the AppManifest.","type":"object"}},"required":["resources"],"type":"object"}}`)
	versionSchemaAppManifestv1alpha2 app.VersionSchema
	_                                = json.Unmarshal(rawSchemaAppManifestv1alpha2, &versionSchemaAppManifestv1alpha2)
)

var appManifestData = app.ManifestData{
	AppName:          "app-manifest",
	AppDisplayName:   "app-manifest",
	Group:            "apps.grafana.app",
	PreferredVersion: "v1alpha2",
	Versions: []app.ManifestVersion{
		{
			Name:   "v1alpha1",
			Served: true,
			Kinds: []app.ManifestVersionKind{
				{
					Kind:       "AppManifest",
					Plural:     "AppManifests",
					Scope:      "Cluster",
					Conversion: false,
					Schema:     &versionSchemaAppManifestv1alpha1,
				},
			},
			Routes: app.ManifestVersionRoutes{
				Namespaced: map[string]spec3.PathProps{},
				Cluster:    map[string]spec3.PathProps{},
				Schemas:    map[string]spec.Schema{},
			},
		},

		{
			Name:   "v1alpha2",
			Served: true,
			Kinds: []app.ManifestVersionKind{
				{
					Kind:       "AppManifest",
					Plural:     "AppManifests",
					Scope:      "Cluster",
					Conversion: false,
					Schema:     &versionSchemaAppManifestv1alpha2,
				},
			},
			Routes: app.ManifestVersionRoutes{
				Namespaced: map[string]spec3.PathProps{},
				Cluster:    map[string]spec3.PathProps{},
				Schemas:    map[string]spec.Schema{},
			},
		},
	},
	ExtraPermissions: &app.Permissions{
		AccessKinds: []app.KindPermission{
			{
				Group:    "apiextensions.k8s.io",
				Resource: "customresourcedefinitions",
				Actions: []app.KindPermissionAction{
					"get",
					"list",
					"create",
					"update",
					"delete",
					"watch",
				},
			},
		},
	},
	Roles: map[string]app.ManifestRole{
		"appmanifest:viewer": {
			Title:       "AppManifest Viewer",
			Description: "Get, List, and Watch AppManifests",
			Kinds: []app.ManifestRoleKind{
				{
					Kind:          "AppManifest",
					PermissionSet: strPtr("viewer"),
				},
			},
			Routes: []string{},
		},
	},
	RoleBindings: &app.ManifestRoleBindings{
		Viewer: []string{
			"appmanifest:viewer",
		},
		Editor: []string{
			"appmanifest:viewer",
		},
		Admin: []string{
			"appmanifest:viewer",
		},
	},
}

func LocalManifest() app.Manifest {
	return app.NewEmbeddedManifest(appManifestData)
}

func RemoteManifest() app.Manifest {
	return app.NewAPIServerManifest("app-manifest")
}

var kindVersionToGoType = map[string]resource.Kind{
	"AppManifest/v1alpha1": v1alpha1.AppManifestKind(),
	"AppManifest/v1alpha2": v1alpha2.AppManifestKind(),
}

// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
// If there is no association for the provided Kind and Version, exists will return false.
func ManifestGoTypeAssociator(kind, version string) (goType resource.Kind, exists bool) {
	goType, exists = kindVersionToGoType[fmt.Sprintf("%s/%s", kind, version)]
	return goType, exists
}

var customRouteToGoResponseType = map[string]any{}

// ManifestCustomRouteResponsesAssociator returns the associated response go type for a given kind, version, custom route path, and method, if one exists.
// kind may be empty for custom routes which are not kind subroutes. Leading slashes are removed from subroute paths.
// If there is no association for the provided kind, version, custom route path, and method, exists will return false.
// Resource routes (those without a kind) should prefix their route with "<namespace>/" if the route is namespaced (otherwise the route is assumed to be cluster-scope)
func ManifestCustomRouteResponsesAssociator(kind, version, path, verb string) (goType any, exists bool) {
	if len(path) > 0 && path[0] == '/' {
		path = path[1:]
	}
	goType, exists = customRouteToGoResponseType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
	return goType, exists
}

var customRouteToGoParamsType = map[string]runtime.Object{}

func ManifestCustomRouteQueryAssociator(kind, version, path, verb string) (goType runtime.Object, exists bool) {
	if len(path) > 0 && path[0] == '/' {
		path = path[1:]
	}
	goType, exists = customRouteToGoParamsType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
	return goType, exists
}

var customRouteToGoRequestBodyType = map[string]any{}

func ManifestCustomRouteRequestBodyAssociator(kind, version, path, verb string) (goType any, exists bool) {
	if len(path) > 0 && path[0] == '/' {
		path = path[1:]
	}
	goType, exists = customRouteToGoRequestBodyType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
	return goType, exists
}

type GoTypeAssociator struct{}

func NewGoTypeAssociator() *GoTypeAssociator {
	return &GoTypeAssociator{}
}

func (g *GoTypeAssociator) KindToGoType(kind, version string) (goType resource.Kind, exists bool) {
	return ManifestGoTypeAssociator(kind, version)
}
func (g *GoTypeAssociator) CustomRouteReturnGoType(kind, version, path, verb string) (goType any, exists bool) {
	return ManifestCustomRouteResponsesAssociator(kind, version, path, verb)
}
func (g *GoTypeAssociator) CustomRouteQueryGoType(kind, version, path, verb string) (goType runtime.Object, exists bool) {
	return ManifestCustomRouteQueryAssociator(kind, version, path, verb)
}
func (g *GoTypeAssociator) CustomRouteRequestBodyGoType(kind, version, path, verb string) (goType any, exists bool) {
	return ManifestCustomRouteRequestBodyAssociator(kind, version, path, verb)
}
func strPtr(s string) *string {
	return &s
}
