# Copyright (c) 2023, JINGROW
# For license information, please see license.txt

import jingrow
from jingrow.model.page import Page


class JcloudMethodPermission(Page):
	# begin: auto-generated types
	# This code is auto-generated. Do not modify anything in this block.

	from typing import TYPE_CHECKING

	if TYPE_CHECKING:
		from jingrow.types import DF

		checkbox_label: DF.Data
		document_type: DF.Link
		method: DF.Data
	# end: auto-generated types

	pass


def available_actions():
	result = {}
	pagetypes = jingrow.get_all(
		"Jcloud Method Permission", pluck="document_type", distinct=True
	)

	for pagetype in pagetypes:
		result[pagetype] = {
			perm["checkbox_label"]: perm["method"]
			for perm in jingrow.get_all(
				"Jcloud Method Permission", {"document_type": pagetype}, ["checkbox_label", "method"]
			)
		}

	return result
