// Copyright (c) 2025 Aiven, Helsinki, Finland. https://aiven.io/
// Code generated by user config generator. DO NOT EDIT.

package project

import (
	"context"

	"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
	"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
	"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
	"github.com/hashicorp/terraform-plugin-framework/types"

	"github.com/aiven/terraform-provider-aiven/internal/plugin/adapter"
)

func newDatasourceModel() adapter.Model[tfModel] {
	return new(datasourceModel)
}

// datasourceModel with specific datasource timeouts
type datasourceModel struct {
	tfModel
	Timeouts timeouts.Value `tfsdk:"timeouts"`
}

func (tf *datasourceModel) SharedModel() *tfModel {
	return &tf.tfModel
}

func (tf *datasourceModel) TimeoutsObject() types.Object {
	return tf.Timeouts.Object
}

/*
newDatasourceSchema:

	data "aiven_organization_project" "example" {
	  organization_id = "org1a23f456789"
	  project_id      = "foo"

	  // COMPUTED FIELDS
	  base_port        = 42
	  billing_group_id = "foo"
	  ca_cert          = "foo"
	  parent_id        = "foo"
	  tag {
	    key   = "foo"
	    value = "foo"
	  }
	  technical_emails = ["test@example.com"]
	}
*/
func newDatasourceSchema(ctx context.Context) schema.Schema {
	return schema.Schema{
		Attributes: map[string]schema.Attribute{
			"base_port": schema.Int64Attribute{
				Computed:            true,
				MarkdownDescription: "Valid port number (1-65535) to use as a base for service port allocation.",
			},
			"billing_group_id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "Billing group ID to assign to the project. It's required when moving projects between organizations.",
			},
			"ca_cert": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "PEM encoded certificate.",
				Sensitive:           true,
			},
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "Resource ID, a composite of `organization_id` and `project_id` IDs.",
			},
			"organization_id": schema.StringAttribute{
				MarkdownDescription: "ID of an organization.",
				Required:            true,
				Validators:          []validator.String{stringvalidator.LengthAtMost(36)},
			},
			"parent_id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "Link a project to an [organization or organizational unit](https://aiven.io/docs/platform/concepts/orgs-units-projects) by using its ID. To set up proper dependencies please refer to this variable as a reference.",
			},
			"project_id": schema.StringAttribute{
				MarkdownDescription: "The name of the project. Names must be globally unique among all Aiven customers. Names must begin with a letter (a-z), and consist of letters, numbers, and dashes. It's recommended to use a random string or your organization name as a prefix or suffix. Changing this property forces recreation of the resource.",
				Required:            true,
			},
			"technical_emails": schema.SetAttribute{
				Computed:            true,
				ElementType:         types.StringType,
				MarkdownDescription: "The email addresses for [project contacts](https://aiven.io/docs/platform/howto/technical-emails), who will receive important alerts and updates about this project and its services. You can also set email contacts at the service level. It's good practice to keep these up-to-date to be aware of any potential issues with your project.",
			},
		},
		Blocks: map[string]schema.Block{
			"tag": schema.SetNestedBlock{
				MarkdownDescription: "Tags are key-value pairs that allow you to categorize projects.",
				NestedObject: schema.NestedBlockObject{Attributes: map[string]schema.Attribute{
					"key": schema.StringAttribute{
						Computed:            true,
						MarkdownDescription: "Project tag key.",
					},
					"value": schema.StringAttribute{
						Computed:            true,
						MarkdownDescription: "Project tag value.",
					},
				}},
			},
			"timeouts": timeouts.Block(ctx),
		},
		MarkdownDescription: "Gets information about an Aiven project.",
	}
}
