package grid

import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

func dataSourceGetGridSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"grid_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"ckey": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"meta": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
			Description: "meta",
		},
		"auth_broker": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"flag": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"gid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"location_code": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"network_modes": {
			Type: schema.TypeList,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
			Computed: true,
		},
		"sdn_support": {
			Type:     schema.TypeBool,
			Computed: true,
		},
	}
}

func dataSourceGridListSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "by id",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "name",
		},
		"sort_by": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "sort by one of supported fields, format +|-(field)",
		},
		"page": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page number",
		},
		"size": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page size",
		},
		"items": {
			Type:        schema.TypeList,
			Computed:    true,
			Description: "grid list",
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"resources": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"current": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"cpu": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"disk_size": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
											"disk_size_max": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"ext_ips": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"gpu": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"ram": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"seps": {
												Type:     schema.TypeList,
												Computed: true,
												Elem: &schema.Resource{
													Schema: map[string]*schema.Schema{
														"sep_id": {
															Type:     schema.TypeString,
															Computed: true,
														},
														"data_name": {
															Type:     schema.TypeString,
															Computed: true,
														},
														"disk_size": {
															Type:     schema.TypeFloat,
															Computed: true,
														},
														"disk_size_max": {
															Type:     schema.TypeFloat,
															Computed: true,
														},
													},
												},
											},
										},
									},
								},
								"reserved": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"cpu": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"disk_size": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
											"disk_size_max": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"ext_ips": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"gpu": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"ram": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"seps": {
												Type:     schema.TypeList,
												Computed: true,
												Elem: &schema.Resource{
													Schema: map[string]*schema.Schema{
														"sep_id": {
															Type:     schema.TypeString,
															Computed: true,
														},
														"data_name": {
															Type:     schema.TypeString,
															Computed: true,
														},
														"disk_size": {
															Type:     schema.TypeFloat,
															Computed: true,
														},
														"disk_size_max": {
															Type:     schema.TypeFloat,
															Computed: true,
														},
													},
												},
											},
										},
									},
								},
							},
						},
					},
					"auth_broker": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"flag": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"gid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"location_code": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"network_modes": {
						Type: schema.TypeList,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
						Computed: true,
					},
					"sdn_support": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"zero_access_enabled": {
						Type:     schema.TypeBool,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "entry count",
		},
	}

	return rets
}

func dataSourceGridListEmailsSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"page": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page number",
		},
		"size": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page size",
		},
		"items": {
			Type:        schema.TypeList,
			Computed:    true,
			Description: "grid list emails",
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"entry_count": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "entry count",
		},
	}

	return rets
}

func dataSourceGridGetConsumptionSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"grid_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"consumed": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"cpu": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"disk_size": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"disk_size_max": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"ext_ips": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"gpu": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"ram": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"seps": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"sep_id": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"data_name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"disk_size": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"disk_size_max": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
		"reserved": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"cpu": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"disk_size": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"disk_size_max": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"ext_ips": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"gpu": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"ram": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"seps": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"sep_id": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"data_name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"disk_size": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"disk_size_max": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
	}
}

func dataSourceGridListConsumptionSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"items": {
			Type:        schema.TypeList,
			Computed:    true,
			Description: "grid list consumption",
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"consumed": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"cpu": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"disk_size": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"disk_size_max": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"ext_ips": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"gpu": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"ram": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"seps": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"sep_id": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"data_name": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"disk_size": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
											"disk_size_max": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
										},
									},
								},
							},
						},
					},
					"reserved": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"cpu": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"disk_size": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"disk_size_max": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"ext_ips": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"gpu": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"ram": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"seps": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"sep_id": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"data_name": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"disk_size": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
											"disk_size_max": {
												Type:     schema.TypeFloat,
												Computed: true,
											},
										},
									},
								},
							},
						},
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "entry count",
		},
	}
	return rets
}

func dataSourceGridGetStatusSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"status": {
			Type:     schema.TypeBool,
			Computed: true,
		},
	}
}

func dataSourceGridPostStatusSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"status": {
			Type:     schema.TypeBool,
			Computed: true,
		},
	}
}

func dataSourceGridGetDiagnosisSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"gid": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"file_path": {
			Type:     schema.TypeString,
			Required: true,
		},
	}
}

func dataSourceGridGetSettingsSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"grid_id": {
			Type:        schema.TypeInt,
			Description: "grid (platform) ID",
			Required:    true,
		},
		"allowed_ports": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"cleanup_retention_period": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"docker_registry": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"password": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"server": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"username": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
		"enable_uptime_monitor": {
			Type:     schema.TypeBool,
			Computed: true,
		},
		"extnet_max_pre_reservations_num": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"healthcheck_notifications": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"emails": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"address": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"enabled": {
									Type:     schema.TypeBool,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
		"k8s_cleanup_enabled": {
			Type:     schema.TypeBool,
			Computed: true,
		},
		"limits": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"location_url": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"net_qos": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"extnet": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"e_rate": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"in_burst": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"in_rate": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
					"vins": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"e_rate": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"in_burst": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"in_rate": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
		"networks": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"prometheus": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"scrape_interval": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"vins_max_pre_reservations_num": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vnfdev_mgmt_net_range": {
			Type:     schema.TypeString,
			Computed: true,
		},
	}
}
