# Copyright (c) 2025, Jingrow and contributors
# For license information, please see license.txt

import jingrow
from jingrow.model.page import Page


class JsiteServer(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 jcloud.jcloud.pagetype.firewall_rules.firewall_rules import FirewallRules
		from jingrow.types import DF

		auto_renew: DF.Check
		bandwidth: DF.Data | None
		cpu: DF.Data | None
		disk_size: DF.Data | None
		end_date: DF.Datetime | None
		firewall_rules: DF.Table[FirewallRules]
		image_id: DF.Data | None
		instance_id: DF.Data | None
		key_pair_name: DF.Data | None
		memory: DF.Data | None
		order_id: DF.Data | None
		os_type: DF.Data | None
		password: DF.Password | None
		period: DF.Int
		plan_price: DF.Int
		plan_type: DF.Data | None
		planid: DF.Data | None
		private_ip: DF.Data | None
		private_key: DF.Text | None
		public_ip: DF.Data | None
		region: DF.Data | None
		ssh_port: DF.Int
		ssh_user: DF.Data | None
		status: DF.Literal["Pending", "Starting", "Running", "Stopping", "Stopped", "Resetting", "Upgrading", "Disabled"]
		system: DF.Data | None
		team: DF.Link | None
		title: DF.Data | None
	# end: auto-generated types

	dashboard_fields = (
		"title",
		"status",
		"region",
		"cpu",
		"memory",
		"disk_size",
		"public_ip",
		"private_ip",
		"end_date",
		"bandwidth",
		"team",
		"instance_id",
		"order_id",
		"planid",
		"image_id",
		"system",
		"plan_price",
		"key_pair_name",
		"private_key",
		"password"
	)

	@staticmethod
	def get_list_query(query):
		JsiteServer = jingrow.qb.PageType("Jsite Server")
		query = query.where(JsiteServer.team == jingrow.local.team().name)
		return query.run(as_dict=True)

	def get_pg(self, pg):
		return pg
