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

package access

import (
	"context"

	"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
	"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
	"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
	"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"

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

func newResourceModel() adapter.Model[tfModel] {
	return new(resourceModel)
}

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

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

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

/*
newResourceSchema:

	resource "aiven_governance_access" "example" {
	  access_data {
	    acls {
	      host            = "foo" // Force new
	      operation       = "Read" // Force new
	      permission_type = "ALLOW" // Force new
	      resource_name   = "test" // Force new
	      resource_type   = "Topic" // Force new
	      id              = "foo"
	      pattern_type    = "LITERAL"
	      principal       = "foo"
	    }
	    project      = "foo" // Force new
	    service_name = "test" // Force new
	    username     = "test" // Force new
	  }
	  access_name         = "test" // Force new
	  access_type         = "KAFKA" // Force new
	  organization_id     = "org1a23f456789" // Force new
	  owner_user_group_id = "foo" // Force new

	  // COMPUTED FIELDS
	  susbcription_id = "foo"
	}
*/
func newResourceSchema(ctx context.Context) schema.Schema {
	return schema.Schema{
		Attributes: map[string]schema.Attribute{
			"access_name": schema.StringAttribute{
				MarkdownDescription: "Label to describe the access. Changing this property forces recreation of the resource.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
				Required:            true,
			},
			"access_type": schema.StringAttribute{
				MarkdownDescription: "An enumeration. The possible value is `KAFKA`. Changing this property forces recreation of the resource.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
				Required:            true,
				Validators:          []validator.String{stringvalidator.OneOf("KAFKA")},
			},
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "Resource ID, a composite of `organization_id` and `susbcription_id` IDs.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
			},
			"organization_id": schema.StringAttribute{
				MarkdownDescription: "ID of an organization. Changing this property forces recreation of the resource.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
				Required:            true,
			},
			"owner_user_group_id": schema.StringAttribute{
				MarkdownDescription: "The ID of the group that will own the access. Maximum length: `36`. Changing this property forces recreation of the resource.",
				Optional:            true,
				PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
				Validators:          []validator.String{stringvalidator.LengthAtMost(36)},
			},
			"susbcription_id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "The ID of the access.",
			},
		},
		Blocks: map[string]schema.Block{
			"access_data": schema.ListNestedBlock{
				MarkdownDescription: "Required property. access type specific data. Changing this property forces recreation of the resource.",
				NestedObject: schema.NestedBlockObject{
					Attributes: map[string]schema.Attribute{
						"project": schema.StringAttribute{
							MarkdownDescription: "Project name. Changing this property forces recreation of the resource.",
							PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
							Required:            true,
						},
						"service_name": schema.StringAttribute{
							MarkdownDescription: "Service name. Changing this property forces recreation of the resource.",
							PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
							Required:            true,
						},
						"username": schema.StringAttribute{
							Computed:            true,
							MarkdownDescription: "The service username assigned to the access. Changing this property forces recreation of the resource.",
							Optional:            true,
							PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
						},
					},
					Blocks: map[string]schema.Block{"acls": schema.SetNestedBlock{
						MarkdownDescription: "Required property. Acls. Changing this property forces recreation of the resource.",
						NestedObject: schema.NestedBlockObject{Attributes: map[string]schema.Attribute{
							"host": schema.StringAttribute{
								Computed:            true,
								MarkdownDescription: "The IP address from which a principal is allowed or denied access to the resource. Use `*` for all hosts. Maximum length: `256`. Changing this property forces recreation of the resource.",
								Optional:            true,
								PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
								Validators:          []validator.String{stringvalidator.LengthAtMost(256)},
							},
							"id": schema.StringAttribute{
								Computed:            true,
								MarkdownDescription: "Acl ID.",
							},
							"operation": schema.StringAttribute{
								MarkdownDescription: "An enumeration. The possible values are `Read` and `Write`. Changing this property forces recreation of the resource.",
								PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
								Required:            true,
								Validators:          []validator.String{stringvalidator.OneOf("Read", "Write")},
							},
							"pattern_type": schema.StringAttribute{
								Computed:            true,
								MarkdownDescription: "An enumeration. The possible value is `LITERAL`.",
							},
							"permission_type": schema.StringAttribute{
								MarkdownDescription: "An enumeration. The possible value is `ALLOW`. Changing this property forces recreation of the resource.",
								PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
								Required:            true,
								Validators:          []validator.String{stringvalidator.OneOf("ALLOW")},
							},
							"principal": schema.StringAttribute{
								Computed:            true,
								MarkdownDescription: "Acl principal.",
							},
							"resource_name": schema.StringAttribute{
								MarkdownDescription: "Acl resource name. Maximum length: `256`. Changing this property forces recreation of the resource.",
								PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
								Required:            true,
								Validators:          []validator.String{stringvalidator.LengthAtMost(256)},
							},
							"resource_type": schema.StringAttribute{
								MarkdownDescription: "An enumeration. The possible value is `Topic`. Changing this property forces recreation of the resource.",
								PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
								Required:            true,
								Validators:          []validator.String{stringvalidator.OneOf("Topic")},
							},
						}},
						Validators: []validator.Set{setvalidator.IsRequired()},
					}},
				},
				Validators: []validator.List{listvalidator.IsRequired(), listvalidator.SizeAtMost(1)},
			},
			"timeouts": timeouts.BlockAll(ctx),
		},
		MarkdownDescription: "Request access to an Apache Kafka topic in Aiven for Apache Kafka® Governance. [Governance](https://aiven.io/docs/products/kafka/howto/governance) helps you manage your Kafka clusters securely and efficiently through structured policies, roles, and processes. You can [manage approval workflows using Terraform and GitHub Actions](https://aiven.io/docs/products/kafka/howto/terraform-governance-approvals). \n\n**This resource is in the beta stage and may change without notice.** Set\nthe `PROVIDER_AIVEN_ENABLE_BETA` environment variable to use the resource.",
	}
}
