package schemas

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

func MakeSchemaDataSourceLBList() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		// optional attributes
		"by_id": schema.Int64Attribute{
			Optional:    true,
			Description: "find by id",
		},
		"name": schema.StringAttribute{
			Optional:    true,
			Description: "find by name",
		},
		"account_id": schema.Int64Attribute{
			Optional:    true,
			Description: "find by account ID",
		},
		"rg_id": schema.Int64Attribute{
			Optional:    true,
			Description: "find by RG ID",
		},
		"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",
		},
		"include_deleted": schema.BoolAttribute{
			Optional:    true,
			Description: "included deleted LBs. If using field 'status', then include_deleted will be ignored",
		},
		"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,
					},
					"backend_haip": 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,
										},
										"downinter": schema.Int64Attribute{
											Computed: true,
										},
										"rise": schema.Int64Attribute{
											Computed: true,
										},
										"fall": schema.Int64Attribute{
											Computed: true,
										},
										"slowstart": schema.Int64Attribute{
											Computed: true,
										},
										"maxconn": schema.Int64Attribute{
											Computed: true,
										},
										"maxqueue": 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,
													},
													"downinter": schema.Int64Attribute{
														Computed: true,
													},
													"rise": schema.Int64Attribute{
														Computed: true,
													},
													"fall": schema.Int64Attribute{
														Computed: true,
													},
													"slowstart": schema.Int64Attribute{
														Computed: true,
													},
													"maxconn": schema.Int64Attribute{
														Computed: true,
													},
													"maxqueue": 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,
					},
					"frontend_haip": schema.StringAttribute{
						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,
					},
					"lb_id": schema.Int64Attribute{
						Computed: true,
					},
					"manager_id": schema.Int64Attribute{
						Computed: true,
					},
					"manager_type": schema.StringAttribute{
						Computed: true,
					},
					"image_id": schema.Int64Attribute{
						Computed: true,
					},
					"milestones": schema.Int64Attribute{
						Computed: true,
					},
					"name": schema.StringAttribute{
						Computed: true,
					},
					"part_k8s": schema.BoolAttribute{
						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_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,
					},
					"user_managed": schema.BoolAttribute{
						Computed: true,
					},
					"vins_id": schema.Int64Attribute{
						Computed: true,
					},
				},
			},
		},
		"entry_count": schema.Int64Attribute{
			Computed: true,
		},
	}
}
