/*
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Sergey Kisil, <svkisil@dbasistech.ru>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.

Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort

Please see README.md to learn where to place source code so that it
builds seamlessly.

Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package k8ci

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

func dataSourceK8CISchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"k8ci_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "K8CI ID",
		},
		"desc": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"gid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "gid",
		},
		"guid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "guid",
		},
		"lb_image_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "LB Image ID",
		},
		"master_image_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"max_master_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"max_worker_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"milestones": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"name": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "K8CI name",
		},
		"network_plugins": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"shared_with": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"status": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "K8CI Status",
		},
		"version": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"worker_driver": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"worker_image_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
}

func dataSourceK8CIListSchemaMake() map[string]*schema.Schema {
	return 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",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by status",
		},
		"network_plugin": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by network plugin",
		},
		"include_disabled": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "Include deleted k8cis in result",
		},
		"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{
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"desc": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"gid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "gid",
					},
					"guid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "guid",
					},
					"k8ci_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "K8CI ID",
					},
					"lb_image_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "LB Image ID",
					},
					"master_image_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"max_master_count": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"max_worker_count": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "K8CI name",
					},
					"shared_with": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"status": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "K8CI Status",
					},
					"version": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"worker_image_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
}

func dataSourceK8CIListDeletedSchemaMake() map[string]*schema.Schema {
	return 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",
		},
		"network_plugin": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Filter by network plugin",
		},
		"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{
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"desc": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"gid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "gid",
					},
					"guid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "guid",
					},
					"k8ci_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "K8CI ID",
					},
					"lb_image_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "LB Image ID",
					},
					"master_image_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"max_master_count": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"max_worker_count": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "K8CI name",
					},
					"shared_with": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"status": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "K8CI Status",
					},
					"version": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"worker_image_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
}

func resourceK8CISchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "K8CI name",
		},
		"version": {
			Type:     schema.TypeString,
			Required: true,
		},
		"master_image_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"max_master_count": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"max_worker_count": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"worker_image_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"network_plugins": {
			Type:     schema.TypeList,
			Required: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"enabled": {
			Type:     schema.TypeBool,
			Optional: true,
		},
		"permanently": {
			Type:     schema.TypeBool,
			Default:  false,
			Optional: true,
		},
		"desc": {
			Type:     schema.TypeString,
			Computed: true,
			Optional: true,
		},
		"gid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "gid",
		},
		"guid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "guid",
		},
		"k8ci_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "K8CI ID",
		},
		"lb_image_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "LB Image ID",
		},
		"milestones": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"shared_with": {
			Type:     schema.TypeSet,
			Computed: true,
			Optional: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"status": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "K8CI Status",
		},
	}
}
