package schemas

import (
	"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

func MakeSchemaDataSourceRGListLB() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		// required attributes
		"rg_id": schema.Int64Attribute{
			Required:    true,
			Description: "ID of the RG",
		},

		// optional attributes
		"by_id": schema.Int64Attribute{
			Optional:    true,
			Description: "find by id",
		},
		"name": schema.StringAttribute{
			Optional:    true,
			Description: "find by name",
		},
		"tech_status": schema.StringAttribute{
			Optional:    true,
			Description: "find by tech status",
		},
		"status": schema.StringAttribute{
			Optional:    true,
			Description: "find by status",
		},
		"front_ip": schema.StringAttribute{
			Optional:    true,
			Description: "find by frontend Ip",
		},
		"back_ip": schema.StringAttribute{
			Optional:    true,
			Description: "find by backend Ip",
		},
		"sort_by": schema.StringAttribute{
			Optional:    true,
			Description: "sort by one of supported fields, format +|-(field)",
		},
		"page": schema.Int64Attribute{
			Optional:    true,
			Description: "page number",
		},
		"size": schema.Int64Attribute{
			Optional:    true,
			Description: "size number",
		},

		// computed attributes
		"id": schema.StringAttribute{
			Optional: true,
		},
		"items": schema.ListNestedAttribute{
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"ha_mode": schema.BoolAttribute{
						Computed: true,
					},
					"acl": schema.StringAttribute{
						Computed: true,
					},
					"backends": schema.ListNestedAttribute{
						Computed: true,
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"algorithm": schema.StringAttribute{
									Computed: true,
								},
								"guid": schema.StringAttribute{
									Computed: true,
								},
								"name": schema.StringAttribute{
									Computed: true,
								},
								"server_default_settings": schema.SingleNestedAttribute{
									Computed: true,
									Attributes: map[string]schema.Attribute{
										"inter": schema.Int64Attribute{
											Computed: true,
										},
										"guid": schema.StringAttribute{
											Computed: true,
										},
										"down_inter": schema.Int64Attribute{
											Computed: true,
										},
										"rise": schema.Int64Attribute{
											Computed: true,
										},
										"fall": schema.Int64Attribute{
											Computed: true,
										},
										"slow_start": schema.Int64Attribute{
											Computed: true,
										},
										"max_conn": schema.Int64Attribute{
											Computed: true,
										},
										"max_queue": schema.Int64Attribute{
											Computed: true,
										},
										"weight": schema.Int64Attribute{
											Computed: true,
										},
									},
								},
								"servers": schema.ListNestedAttribute{
									Computed: true,
									NestedObject: schema.NestedAttributeObject{
										Attributes: map[string]schema.Attribute{
											"address": schema.StringAttribute{
												Computed: true,
											},
											"check": schema.StringAttribute{
												Computed: true,
											},
											"guid": schema.StringAttribute{
												Computed: true,
											},
											"name": schema.StringAttribute{
												Computed: true,
											},
											"port": schema.Int64Attribute{
												Computed: true,
											},
											"server_settings": schema.SingleNestedAttribute{
												Computed: true,
												Attributes: map[string]schema.Attribute{
													"inter": schema.Int64Attribute{
														Computed: true,
													},
													"guid": schema.StringAttribute{
														Computed: true,
													},
													"down_inter": schema.Int64Attribute{
														Computed: true,
													},
													"rise": schema.Int64Attribute{
														Computed: true,
													},
													"fall": schema.Int64Attribute{
														Computed: true,
													},
													"slow_start": schema.Int64Attribute{
														Computed: true,
													},
													"max_conn": schema.Int64Attribute{
														Computed: true,
													},
													"max_queue": schema.Int64Attribute{
														Computed: true,
													},
													"weight": schema.Int64Attribute{
														Computed: true,
													},
												},
											},
										},
									},
								},
							},
						},
					},
					"created_by": schema.StringAttribute{
						Computed: true,
					},
					"created_time": schema.Int64Attribute{
						Computed: true,
					},
					"deleted_by": schema.StringAttribute{
						Computed: true,
					},
					"deleted_time": schema.Int64Attribute{
						Computed: true,
					},
					"desc": schema.StringAttribute{
						Computed: true,
					},
					"dp_api_user": schema.StringAttribute{
						Computed: true,
					},
					"extnet_id": schema.Int64Attribute{
						Computed: true,
					},
					"frontends": schema.ListNestedAttribute{
						Computed: true,
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"backend": schema.StringAttribute{
									Computed: true,
								},
								"bindings": schema.ListNestedAttribute{
									Computed: true,
									NestedObject: schema.NestedAttributeObject{
										Attributes: map[string]schema.Attribute{
											"address": schema.StringAttribute{
												Computed: true,
											},
											"guid": schema.StringAttribute{
												Computed: true,
											},
											"name": schema.StringAttribute{
												Computed: true,
											},
											"port": schema.Int64Attribute{
												Computed: true,
											},
										},
									},
								},
								"guid": schema.StringAttribute{
									Computed: true,
								},
								"name": schema.StringAttribute{
									Computed: true,
								},
							},
						},
					},
					"gid": schema.Int64Attribute{
						Computed: true,
					},
					"guid": schema.Int64Attribute{
						Computed: true,
					},
					"id": schema.Int64Attribute{
						Computed: true,
					},
					"image_id": schema.Int64Attribute{
						Computed: true,
					},
					"milestones": schema.Int64Attribute{
						Computed: true,
					},
					"name": schema.StringAttribute{
						Computed: true,
					},
					"primary_node": schema.SingleNestedAttribute{
						Computed: true,
						Attributes: map[string]schema.Attribute{
							"backend_ip": schema.StringAttribute{
								Computed: true,
							},
							"compute_id": schema.Int64Attribute{
								Computed: true,
							},
							"frontend_ip": schema.StringAttribute{
								Computed: true,
							},
							"guid": schema.StringAttribute{
								Computed: true,
							},
							"mgmt_ip": schema.StringAttribute{
								Computed: true,
							},
							"network_id": schema.Int64Attribute{
								Computed: true,
							},
						},
					},
					"rg_name": schema.StringAttribute{
						Computed: true,
					},
					"secondary_node": schema.SingleNestedAttribute{
						Computed: true,
						Attributes: map[string]schema.Attribute{
							"backend_ip": schema.StringAttribute{
								Computed: true,
							},
							"compute_id": schema.Int64Attribute{
								Computed: true,
							},
							"frontend_ip": schema.StringAttribute{
								Computed: true,
							},
							"guid": schema.StringAttribute{
								Computed: true,
							},
							"mgmt_ip": schema.StringAttribute{
								Computed: true,
							},
							"network_id": schema.Int64Attribute{
								Computed: true,
							},
						},
					},
					"status": schema.StringAttribute{
						Computed: true,
					},
					"tech_status": schema.StringAttribute{
						Computed: true,
					},
					"updated_by": schema.StringAttribute{
						Computed: true,
					},
					"updated_time": schema.Int64Attribute{
						Computed: true,
					},
					"vins_id": schema.Int64Attribute{
						Computed: true,
					},
				},
			},
		},
		"entry_count": schema.Int64Attribute{
			Computed: true,
		},
	}
}
