package rg

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

func dataSourceRgSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"rg_id": {
			Type:     schema.TypeInt,
			Required: true,
		},

		"account_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"account_name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"acl": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"email": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"explicit": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"right": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"type": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"user_group_id": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
		"compute_features": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"cpu_allocation_parameter": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"cpu_allocation_ratio": {
			Type:     schema.TypeFloat,
			Computed: true,
		},
		"created_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"created_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"def_net_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"def_net_type": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"deleted_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"deleted_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"desc": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"dirty": {
			Type:     schema.TypeBool,
			Computed: true,
		},
		"gid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"lock_status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"milestones": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"resource_limits": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"cu_c": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_d": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_dm": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_i": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_m": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"gpu_units": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"storage_policy": {
						Type:     schema.TypeSet,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"limit": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
		"resource_types": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"secret": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"uniq_pools": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"updated_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"updated_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vins": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"computes": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"sdn_access_group_id": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"storage_policy_ids": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
	}
}

func dataSourceRgAuditsSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"rg_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"call": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"responsetime": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"statuscode": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"timestamp": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"user": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
	}
}

func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"page": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Page number",
		},
		"size": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Page size",
		},

		"affinity_groups": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"label": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"node_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
}

func dataSourceRgAffinityGroupsGetSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"affinity_group": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Affinity group label",
		},

		"ids": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
	}

	return res
}

func dataSourceRgAffinityGroupComputesSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"affinity_group": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Affinity group label",
		},

		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"compute_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"other_node": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"other_node_indirect": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"other_node_indirect_soft": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"other_node_soft": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"same_node": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"same_node_soft": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
				},
			},
		},
	}

	return res
}

func dataSourceRGResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_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.TypeFloat,
						Computed: true,
					},
					"extips": {
						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.TypeFloat,
						Computed: true,
					},
					"extips": {
						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,
								},
							},
						},
					},
				},
			},
		},
		"resource_limits": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"cu_c": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_d": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_dm": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_i": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_m": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"gpu_units": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
				},
			},
		},
	}

	return res
}

func dataSourceRGResourceConsumptionListSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: 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.TypeFloat,
									Computed: true,
								},
								"extips": {
									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.TypeFloat,
									Computed: true,
								},
								"extips": {
									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,
											},
										},
									},
								},
							},
						},
					},
					"resource_limits": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"cu_c": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_d": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_dm": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_i": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_m": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"gpu_units": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
	return res
}

func dataSourceRgUsageSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:     schema.TypeInt,
			Required: true,
		},

		"cpu": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"disk_size": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"disk_size_max": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"extips": {
			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,
					},
				},
			},
		},
	}

	return res
}

func dataSourceRgListComputesSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"compute_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by compute ID",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by name",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by account ID",
		},
		"tech_status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by tech. status",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by status",
		},
		"ip_address": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "FIlter by IP address",
		},
		"extnet_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by extnet name",
		},
		"extnet_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by extnet ID",
		},
		"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,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"account_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"account_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"affinity_label": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"affinity_rules": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"key": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"mode": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"policy": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"topology": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"value": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"affinity_weight": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"antiaffinity_rules": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"key": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"mode": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"policy": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"topology": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"value": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"cpus": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"created_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"deleted_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"ram": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"registered": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"rg_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"tech_status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"total_disks_size": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"updated_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"user_managed": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"vins_connected": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}

	return res
}

func dataSourceRgListLbSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by ID",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by name",
		},
		"tech_status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by tech. status",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by status",
		},
		"front_ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by frontend IP",
		},
		"back_ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by backend IP",
		},
		"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,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"ha_mode": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"acl": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"explicit": {
									Type:     schema.TypeBool,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"right": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"status": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"type": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"user_group_id": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"backends": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"algorithm": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"server_default_settings": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"inter": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"guid": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"down_inter": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"rise": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"fall": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"slow_start": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"max_conn": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"max_queue": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"weight": {
												Type:     schema.TypeInt,
												Computed: true,
											},
										},
									},
								},
								"servers": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"address": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"check": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"guid": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"name": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"port": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"server_settings": {
												Type:     schema.TypeList,
												Computed: true,
												Elem: &schema.Resource{
													Schema: map[string]*schema.Schema{
														"inter": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"guid": {
															Type:     schema.TypeString,
															Computed: true,
														},
														"down_inter": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"rise": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"fall": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"slow_start": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"max_conn": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"max_queue": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"weight": {
															Type:     schema.TypeInt,
															Computed: true,
														},
													},
												},
											},
										},
									},
								},
							},
						},
					},
					"created_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"deleted_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"desc": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"dp_api_user": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"extnet_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"frontends": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"backend": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"bindings": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"address": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"guid": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"name": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"port": {
												Type:     schema.TypeInt,
												Computed: true,
											},
										},
									},
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"name": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"gid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"image_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"milestones": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"primary_node": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"backend_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"compute_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"frontend_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"mgmt_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"network_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
					"rg_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"secondary_node": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"backend_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"compute_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"frontend_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"mgmt_ip": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"network_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"tech_status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vins_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}

	return res
}

func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by ID",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by name",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by account ID",
		},
		"account_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by account name",
		},
		"created_after": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter RGs created after certain point in time (unix timestamp)",
		},
		"created_before": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter RGs created before certain point in time (unix timestamp)",
		},
		"lock_status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by lock status",
		},
		"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,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"account_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"account_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"acl": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"explicit": {
									Type:     schema.TypeBool,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"right": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"status": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"type": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"user_group_id": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"compute_features": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"cpu_allocation_parameter": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"cpu_allocation_ratio": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"created_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"def_net_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"def_net_type": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"desc": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"dirty": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"gid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"lock_status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"milestones": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"resource_limits": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"cu_c": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_d": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_dm": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_i": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_m": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"gpu_units": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"storage_policy": {
									Type:     schema.TypeSet,
									Optional: true,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"id": {
												Type:     schema.TypeInt,
												Required: true,
											},
											"limit": {
												Type:     schema.TypeInt,
												Optional: true,
											},
										},
									},
								},
							},
						},
					},
					"secret": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vins": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"vms": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"resource_types": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"uniq_pools": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"sdn_access_group_id": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"storage_policy_ids": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
	return res
}

func dataSourceRgListSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by ID",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by name",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by account ID",
		},
		"account_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by account name",
		},
		"created_after": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter RGs created after certain point in time (unix timestamp)",
		},
		"created_before": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter RGs created before certain point in time (unix timestamp)",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by status",
		},
		"lock_status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by lock status",
		},
		"includedeleted": {
			Type:        schema.TypeBool,
			Optional:    true,
			Description: "Include deleted",
		},
		"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,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"account_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"account_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"acl": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"explicit": {
									Type:     schema.TypeBool,
									Computed: true,
								},
								"guid": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"right": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"status": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"type": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"user_group_id": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"compute_features": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"cpu_allocation_parameter": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"cpu_allocation_ratio": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"created_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"def_net_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"def_net_type": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"desc": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"dirty": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"gid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"lock_status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"milestones": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"resource_limits": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"cu_c": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_d": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_dm": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_i": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"cu_m": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"gpu_units": {
									Type:     schema.TypeFloat,
									Computed: true,
								},
								"storage_policy": {
									Type:     schema.TypeSet,
									Optional: true,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"id": {
												Type:     schema.TypeInt,
												Required: true,
											},
											"limit": {
												Type:     schema.TypeInt,
												Optional: true,
											},
										},
									},
								},
							},
						},
					},
					"secret": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vins": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"vms": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"resource_types": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"uniq_pools": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"sdn_access_group_id": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"storage_policy_ids": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
	return res
}

func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by name",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by account ID",
		},
		"ext_ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by external IP",
		},
		"vins_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Filter by ViNS ID",
		},
		"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,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"account_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"account_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"computes": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"created_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"deleted_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"deleted_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"external_ip": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"extnet_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"free_ips": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"network": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"pri_vnf_dev_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"rg_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_by": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}

	return res
}

func dataSourceRgListPfwSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"rg_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "ID of the RG",
		},
		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"public_port_end": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"public_port_start": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vm_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vm_ip": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"vm_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"vm_port": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vins_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vins_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}

	return res
}

func resourceRgSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"account_id": {
			Type:         schema.TypeInt,
			Required:     true,
			ValidateFunc: validation.IntAtLeast(1),
			Description:  "Unique ID of the account, which this resource group belongs to.",
		},

		"gid": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "Unique ID of the grid, where this resource group is deployed.",
		},

		"rg_name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Name of this resource group. Names are case sensitive and unique within the context of a account.",
		},

		"resource_limits": {
			Type:     schema.TypeList,
			Optional: true,
			Computed: true,
			MaxItems: 1,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"cu_c": {
						Type:        schema.TypeFloat,
						Optional:    true,
						Computed:    true,
						Description: "MaxCPUCapacity",
					},
					"cu_d": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"cu_dm": {
						Type:        schema.TypeFloat,
						Optional:    true,
						Computed:    true,
						Description: "MaxVDiskCapacity",
					},
					"cu_i": {
						Type:        schema.TypeFloat,
						Optional:    true,
						Computed:    true,
						Description: "MaxNumPublicIP",
					},
					"cu_m": {
						Type:        schema.TypeFloat,
						Optional:    true,
						Computed:    true,
						Description: "MaxMemoryCapacity",
					},
					"gpu_units": {
						Type:     schema.TypeFloat,
						Computed: true,
					},
					"storage_policy": {
						Type:     schema.TypeSet,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"limit": {
									Type:     schema.TypeInt,
									Computed: true,
								},
							},
						},
					},
				},
			},
		},

		"owner": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "username - owner of this RG. Leave blank to set current user as owner",
		},

		"def_net_type": {
			Type:     schema.TypeString,
			Optional: true,
			// Default:      "PRIVATE",
			ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC", "NONE"}, false),
			Description:  "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
		},

		"ipcidr": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Address of the netowrk inside the private network segment (aka ViNS) if def_net_type=PRIVATE",
		},

		"description": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "User-defined text description of this resource group.",
		},

		"ext_net_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Default:     0,
			Description: "ID of the external network for default ViNS. Pass 0 if def_net_type=PUBLIC or no external connection required for the defult ViNS when def_net_type=PRIVATE",
		},

		"ext_ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "IP address on the external netowrk to request when def_net_type=PRIVATE and ext_net_id is not 0",
		},

		"uniq_pools": {
			Type:     schema.TypeList,
			Computed: true,
			Optional: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},

		"access": {
			Type:     schema.TypeSet,
			Optional: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"user": {
						Type:        schema.TypeString,
						Required:    true,
						Description: "User or group name to grant access",
					},
					"right": {
						Type:        schema.TypeString,
						Required:    true,
						Description: "Access rights to set, one of 'R', 'RCX' or 'ARCXDU'",
					},
				},
			},
		},

		"def_net": {
			Type:     schema.TypeSet,
			Optional: true,
			MaxItems: 1,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"net_type": {
						Type:         schema.TypeString,
						Required:     true,
						ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC"}, false),
						Description:  "Network type to set. Must be on of 'PRIVATE' or 'PUBLIC'.",
					},
					"net_id": {
						Type:        schema.TypeInt,
						Optional:    true,
						Default:     0,
						Description: "Network segment ID. If netType is PUBLIC and netId is 0 then default external network segment will be selected. If netType is PRIVATE and netId=0, the first ViNS defined for this RG will be selected. Otherwise, netId identifies either existing external network segment or ViNS.",
					},
				},
			},
		},

		"cpu_allocation_parameter": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "set cpu allocation parameter",
		},

		"cpu_allocation_ratio": {
			Type:        schema.TypeFloat,
			Optional:    true,
			Computed:    true,
			Description: "set cpu allocation ratio",
		},

		"enable": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     true,
			Description: "enable/disable rg",
		},
		"restore": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "restore deleted rg",
		},

		"force": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "flag to force deleting resource group",
		},
		"permanently": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "flag to permanently delete resource group",
		},

		"compute_features": {
			Type:     schema.TypeSet,
			Optional: true,
			Elem: &schema.Schema{
				Type:         schema.TypeString,
				ValidateFunc: validation.StringInSlice([]string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"}, true),
			},
		},
		"sdn_access_group_id": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "ID of the SDN access group",
		},
		"storage_policy": {
			Type:     schema.TypeSet,
			Optional: true,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"id": {
						Type:     schema.TypeInt,
						Required: true,
					},
					"limit": {
						Type:     schema.TypeInt,
						Optional: true,
						Default:  -1,
					},
				},
			},
		},

		"acl": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"email": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"explicit": {
						Type:     schema.TypeBool,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"right": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"type": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"user_group_id": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},

		"account_name": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "Name of the account, which this resource group belongs to.",
		},
		"created_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"created_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},

		"def_net_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "ID of the default network for this resource group (if any).",
		},

		"deleted_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"deleted_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"rg_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"lock_status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"milestones": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"resource_types": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"secret": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"status": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "Current status of this resource group.",
		},
		"updated_by": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"updated_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vins": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "List of VINs deployed in this resource group.",
		},
		"vms": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "List of VM ids in this resource group.",
		},

		"storage_policy_ids": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
	}

	return res
}
