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

package applicationuser

import (
	"context"

	"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
	"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_organization_application_user" "example" {
	  organization_id = "org1a23f456789" // Force new
	  is_super_admin  = false
	  name            = "test"

	  // COMPUTED FIELDS
	  email   = "test@example.com"
	  user_id = "foo"
	}
*/
func newResourceSchema(ctx context.Context) schema.Schema {
	return schema.Schema{
		Attributes: map[string]schema.Attribute{
			"email": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "User Email.",
			},
			"id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "Resource ID, a composite of `organization_id` and `user_id` IDs.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
			},
			"is_super_admin": schema.BoolAttribute{
				Computed:            true,
				Default:             booldefault.StaticBool(false),
				DeprecationMessage:  "This field is no longer accepted by the API. For administrative tasks, assign application users the organization admin role instead using the aiven_organization_permission resource.",
				MarkdownDescription: "Alters super admin state of the organization application user. The default value is `false`.",
				Optional:            true,
			},
			"name": schema.StringAttribute{
				MarkdownDescription: "Name.",
				Required:            true,
			},
			"organization_id": schema.StringAttribute{
				MarkdownDescription: "ID of an organization. Changing this property forces recreation of the resource.",
				PlanModifiers:       []planmodifier.String{stringplanmodifier.RequiresReplace()},
				Required:            true,
			},
			"user_id": schema.StringAttribute{
				Computed:            true,
				MarkdownDescription: "User ID.",
			},
		},
		Blocks:              map[string]schema.Block{"timeouts": timeouts.BlockAll(ctx)},
		MarkdownDescription: "Creates and manages an organization application user. [Application users](https://aiven.io/docs/platform/concepts/application-users) can be used for programmatic access to the platform using a token created with the `aiven_organization_application_user_token` resource. You give application users access to your organization, projects, and services using the `aiven_organization_permission` resource. You can also add application users to groups using the `aiven_organization_user_group_member` resource.`.",
	}
}
