package schemas import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" ) func MakeSchemaResourceDisk() map[string]schema.Attribute { return map[string]schema.Attribute{ // required attributes "account_id": schema.Int64Attribute{ Required: true, Description: "ID of the account", }, "disk_name": schema.StringAttribute{ Required: true, Description: "Iname of disk", }, "size_max": schema.Int64Attribute{ Required: true, Description: "size in GB, default is 10", }, "gid": schema.Int64Attribute{ Required: true, Description: "ID of the grid (platform)", }, // optional attributes "desc": schema.StringAttribute{ Optional: true, Computed: true, Description: "description of disk", }, "pool": schema.StringAttribute{ Optional: true, Computed: true, Description: "Pool for disk location", }, "sep_id": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Storage endpoint provider ID to create disk", }, "type": schema.StringAttribute{ Optional: true, Computed: true, Validators: []validator.String{ stringvalidator.OneOf("B", "D", "T"), // case is not ignored }, Description: "(B;D;T) B=Boot;D=Data;T=Temp", // default is D }, "detach": schema.BoolAttribute{ Optional: true, Description: "Detaching the disk from compute", // default is false }, "permanently": schema.BoolAttribute{ Optional: true, Description: "Whether to completely delete the disk, works only with non attached disks", // default is false }, "shareable": schema.BoolAttribute{ Optional: true, Computed: true, Description: "share disk", }, "iotune": schema.SingleNestedAttribute{ Optional: true, Computed: true, Attributes: map[string]schema.Attribute{ "read_bytes_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Number of bytes to read per second", }, "read_bytes_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum number of bytes to read", }, "read_iops_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Number of io read operations per second", }, "read_iops_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum number of io read operations", }, "size_iops_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Size of io operations", }, "total_bytes_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Total size bytes per second", }, "total_bytes_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum total size of bytes per second", }, "total_iops_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Total number of io operations per second", }, "total_iops_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum total number of io operations per second", }, "write_bytes_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Number of bytes to write per second", }, "write_bytes_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum number of bytes to write per second", }, "write_iops_sec": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Number of write operations per second", }, "write_iops_sec_max": schema.Int64Attribute{ Optional: true, Computed: true, Description: "Maximum number of write operations per second", }, }, }, // computed attributes "id": schema.StringAttribute{ Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "disk_id": schema.Int64Attribute{ Computed: true, }, "account_name": schema.StringAttribute{ Computed: true, }, "acl": schema.StringAttribute{ Computed: true, }, "computes": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "compute_id": schema.StringAttribute{ Computed: true, }, "compute_name": schema.StringAttribute{ Computed: true, }, }, }, }, "created_time": schema.Int64Attribute{ Computed: true, }, "deleted_time": schema.Int64Attribute{ Computed: true, }, "destruction_time": schema.Int64Attribute{ Computed: true, }, "devicename": schema.StringAttribute{ Computed: true, }, "image_id": schema.Int64Attribute{ Computed: true, }, "images": schema.ListAttribute{ Computed: true, ElementType: types.StringType, }, "last_updated": schema.StringAttribute{ Computed: true, Description: "Timestamp of the last Terraform update of the disk resource.", }, "order": schema.Int64Attribute{ Computed: true, }, "params": schema.StringAttribute{ Computed: true, }, "parent_id": schema.Int64Attribute{ Computed: true, }, "pci_slot": schema.Int64Attribute{ Computed: true, }, "present_to": schema.ListAttribute{ Computed: true, ElementType: types.Int64Type, }, "purge_time": schema.Int64Attribute{ Computed: true, }, "res_id": schema.StringAttribute{ Computed: true, }, "res_name": schema.StringAttribute{ Computed: true, }, "role": schema.StringAttribute{ Computed: true, }, "sep_type": schema.StringAttribute{ Computed: true, }, "size_used": schema.Float64Attribute{ Computed: true, }, "snapshots": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "guid": schema.StringAttribute{ Computed: true, }, "label": schema.StringAttribute{ Computed: true, }, "res_id": schema.StringAttribute{ Computed: true, }, "snap_set_guid": schema.StringAttribute{ Computed: true, }, "snap_set_time": schema.Int64Attribute{ Computed: true, }, "timestamp": schema.Int64Attribute{ Computed: true, }, }, }, }, "status": schema.StringAttribute{ Computed: true, }, "tech_status": schema.StringAttribute{ Computed: true, }, "vmid": schema.Int64Attribute{ Computed: true, }, } }