// Code generated by generators/resource/main.go; DO NOT EDIT.

package ssm

import (
	"context"
	"regexp"

	"github.com/hashicorp/terraform-plugin-framework/tfsdk"
	"github.com/hashicorp/terraform-plugin-framework/types"
	. "github.com/hashicorp/terraform-provider-awscc/internal/generic"
	"github.com/hashicorp/terraform-provider-awscc/internal/registry"
	"github.com/hashicorp/terraform-provider-awscc/internal/validate"
)

func init() {
	registry.AddResourceTypeFactory("awscc_ssm_document", documentResourceType)
}

// documentResourceType returns the Terraform awscc_ssm_document resource type.
// This Terraform resource type corresponds to the CloudFormation AWS::SSM::Document resource type.
func documentResourceType(ctx context.Context) (tfsdk.ResourceType, error) {
	attributes := map[string]tfsdk.Attribute{
		"attachments": {
			// Property: Attachments
			// CloudFormation resource type schema:
			// {
			//   "description": "A list of key and value pairs that describe attachments to a version of a document.",
			//   "insertionOrder": false,
			//   "items": {
			//     "additionalProperties": false,
			//     "properties": {
			//       "Key": {
			//         "description": "The key of a key-value pair that identifies the location of an attachment to a document.",
			//         "enum": [
			//           "SourceUrl",
			//           "S3FileUrl",
			//           "AttachmentReference"
			//         ],
			//         "type": "string"
			//       },
			//       "Name": {
			//         "description": "The name of the document attachment file.",
			//         "maxLength": 128,
			//         "minLength": 1,
			//         "pattern": "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$",
			//         "type": "string"
			//       },
			//       "Values": {
			//         "description": "The value of a key-value pair that identifies the location of an attachment to a document. The format for Value depends on the type of key you specify.",
			//         "insertionOrder": false,
			//         "items": {
			//           "maxLength": 100000,
			//           "minLength": 1,
			//           "type": "string"
			//         },
			//         "maxItems": 1,
			//         "minItems": 1,
			//         "type": "array"
			//       }
			//     },
			//     "type": "object"
			//   },
			//   "maxItems": 20,
			//   "minItems": 0,
			//   "type": "array"
			// }
			Description: "A list of key and value pairs that describe attachments to a version of a document.",
			Attributes: tfsdk.ListNestedAttributes(
				map[string]tfsdk.Attribute{
					"key": {
						// Property: Key
						Description: "The key of a key-value pair that identifies the location of an attachment to a document.",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringInSlice([]string{
								"SourceUrl",
								"S3FileUrl",
								"AttachmentReference",
							}),
						},
					},
					"name": {
						// Property: Name
						Description: "The name of the document attachment file.",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringLenBetween(1, 128),
							validate.StringMatch(regexp.MustCompile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$"), ""),
						},
					},
					"values": {
						// Property: Values
						Description: "The value of a key-value pair that identifies the location of an attachment to a document. The format for Value depends on the type of key you specify.",
						Type:        types.ListType{ElemType: types.StringType},
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.ArrayLenBetween(1, 1),
							validate.ArrayForEach(validate.StringLenBetween(1, 100000)),
						},
						PlanModifiers: []tfsdk.AttributePlanModifier{
							Multiset(),
						},
					},
				},
				tfsdk.ListNestedAttributesOptions{},
			),
			Optional: true,
			Validators: []tfsdk.AttributeValidator{
				validate.ArrayLenBetween(0, 20),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				Multiset(),
			},
		},
		"content": {
			// Property: Content
			// CloudFormation resource type schema:
			// {
			//   "description": "The content for the Systems Manager document in JSON, YAML or String format.",
			//   "type": "string"
			// }
			Description: "The content for the Systems Manager document in JSON, YAML or String format.",
			Type:        types.StringType,
			Required:    true,
		},
		"document_format": {
			// Property: DocumentFormat
			// CloudFormation resource type schema:
			// {
			//   "default": "JSON",
			//   "description": "Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default format.",
			//   "enum": [
			//     "YAML",
			//     "JSON",
			//     "TEXT"
			//   ],
			//   "type": "string"
			// }
			Description: "Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default format.",
			Type:        types.StringType,
			Optional:    true,
			Computed:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringInSlice([]string{
					"YAML",
					"JSON",
					"TEXT",
				}),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				DefaultValue(types.String{Value: "JSON"}),
				tfsdk.UseStateForUnknown(),
			},
		},
		"document_type": {
			// Property: DocumentType
			// CloudFormation resource type schema:
			// {
			//   "description": "The type of document to create.",
			//   "enum": [
			//     "ApplicationConfiguration",
			//     "ApplicationConfigurationSchema",
			//     "Automation",
			//     "Automation.ChangeTemplate",
			//     "ChangeCalendar",
			//     "CloudFormation",
			//     "Command",
			//     "DeploymentStrategy",
			//     "Package",
			//     "Policy",
			//     "ProblemAnalysis",
			//     "ProblemAnalysisTemplate",
			//     "Session"
			//   ],
			//   "type": "string"
			// }
			Description: "The type of document to create.",
			Type:        types.StringType,
			Optional:    true,
			Computed:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringInSlice([]string{
					"ApplicationConfiguration",
					"ApplicationConfigurationSchema",
					"Automation",
					"Automation.ChangeTemplate",
					"ChangeCalendar",
					"CloudFormation",
					"Command",
					"DeploymentStrategy",
					"Package",
					"Policy",
					"ProblemAnalysis",
					"ProblemAnalysisTemplate",
					"Session",
				}),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				tfsdk.UseStateForUnknown(),
				tfsdk.RequiresReplace(),
			},
		},
		"name": {
			// Property: Name
			// CloudFormation resource type schema:
			// {
			//   "description": "A name for the Systems Manager document.",
			//   "pattern": "^[a-zA-Z0-9_\\-.]{3,128}$",
			//   "type": "string"
			// }
			Description: "A name for the Systems Manager document.",
			Type:        types.StringType,
			Optional:    true,
			Computed:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringMatch(regexp.MustCompile("^[a-zA-Z0-9_\\-.]{3,128}$"), ""),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				tfsdk.UseStateForUnknown(),
				tfsdk.RequiresReplace(),
			},
		},
		"requires": {
			// Property: Requires
			// CloudFormation resource type schema:
			// {
			//   "description": "A list of SSM documents required by a document. For example, an ApplicationConfiguration document requires an ApplicationConfigurationSchema document.",
			//   "insertionOrder": false,
			//   "items": {
			//     "additionalProperties": false,
			//     "properties": {
			//       "Name": {
			//         "description": "The name of the required SSM document. The name can be an Amazon Resource Name (ARN).",
			//         "maxLength": 200,
			//         "pattern": "^[a-zA-Z0-9_\\-.:/]{3,200}$",
			//         "type": "string"
			//       },
			//       "Version": {
			//         "description": "The document version required by the current document.",
			//         "maxLength": 8,
			//         "pattern": "([$]LATEST|[$]DEFAULT|^[1-9][0-9]*$)",
			//         "type": "string"
			//       }
			//     },
			//     "type": "object"
			//   },
			//   "minItems": 1,
			//   "type": "array"
			// }
			Description: "A list of SSM documents required by a document. For example, an ApplicationConfiguration document requires an ApplicationConfigurationSchema document.",
			Attributes: tfsdk.ListNestedAttributes(
				map[string]tfsdk.Attribute{
					"name": {
						// Property: Name
						Description: "The name of the required SSM document. The name can be an Amazon Resource Name (ARN).",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringLenAtMost(200),
							validate.StringMatch(regexp.MustCompile("^[a-zA-Z0-9_\\-.:/]{3,200}$"), ""),
						},
					},
					"version": {
						// Property: Version
						Description: "The document version required by the current document.",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringLenAtMost(8),
							validate.StringMatch(regexp.MustCompile("([$]LATEST|[$]DEFAULT|^[1-9][0-9]*$)"), ""),
						},
					},
				},
				tfsdk.ListNestedAttributesOptions{},
			),
			Optional: true,
			Validators: []tfsdk.AttributeValidator{
				validate.ArrayLenAtLeast(1),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				Multiset(),
			},
		},
		"tags": {
			// Property: Tags
			// CloudFormation resource type schema:
			// {
			//   "description": "Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment.",
			//   "insertionOrder": false,
			//   "items": {
			//     "additionalProperties": false,
			//     "properties": {
			//       "Key": {
			//         "description": "The name of the tag.",
			//         "maxLength": 128,
			//         "minLength": 1,
			//         "pattern": "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$",
			//         "type": "string"
			//       },
			//       "Value": {
			//         "description": "The value of the tag.",
			//         "maxLength": 256,
			//         "minLength": 1,
			//         "pattern": "^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$",
			//         "type": "string"
			//       }
			//     },
			//     "type": "object"
			//   },
			//   "maxItems": 1000,
			//   "type": "array"
			// }
			Description: "Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment.",
			Attributes: tfsdk.ListNestedAttributes(
				map[string]tfsdk.Attribute{
					"key": {
						// Property: Key
						Description: "The name of the tag.",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringLenBetween(1, 128),
							validate.StringMatch(regexp.MustCompile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$"), ""),
						},
					},
					"value": {
						// Property: Value
						Description: "The value of the tag.",
						Type:        types.StringType,
						Optional:    true,
						Validators: []tfsdk.AttributeValidator{
							validate.StringLenBetween(1, 256),
							validate.StringMatch(regexp.MustCompile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$"), ""),
						},
					},
				},
				tfsdk.ListNestedAttributesOptions{},
			),
			Optional: true,
			Validators: []tfsdk.AttributeValidator{
				validate.ArrayLenAtMost(1000),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				Multiset(),
			},
		},
		"target_type": {
			// Property: TargetType
			// CloudFormation resource type schema:
			// {
			//   "description": "Specify a target type to define the kinds of resources the document can run on.",
			//   "pattern": "^\\/[\\w\\.\\-\\:\\/]*$",
			//   "type": "string"
			// }
			Description: "Specify a target type to define the kinds of resources the document can run on.",
			Type:        types.StringType,
			Optional:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringMatch(regexp.MustCompile("^\\/[\\w\\.\\-\\:\\/]*$"), ""),
			},
		},
		"update_method": {
			// Property: UpdateMethod
			// CloudFormation resource type schema:
			// {
			//   "default": "Replace",
			//   "description": "Update method - when set to 'Replace', the update will replace the existing document; when set to 'NewVersion', the update will create a new version.",
			//   "enum": [
			//     "Replace",
			//     "NewVersion"
			//   ],
			//   "type": "string"
			// }
			Description: "Update method - when set to 'Replace', the update will replace the existing document; when set to 'NewVersion', the update will create a new version.",
			Type:        types.StringType,
			Optional:    true,
			Computed:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringInSlice([]string{
					"Replace",
					"NewVersion",
				}),
			},
			PlanModifiers: []tfsdk.AttributePlanModifier{
				DefaultValue(types.String{Value: "Replace"}),
				tfsdk.UseStateForUnknown(),
			},
		},
		"version_name": {
			// Property: VersionName
			// CloudFormation resource type schema:
			// {
			//   "description": "An optional field specifying the version of the artifact you are creating with the document. This value is unique across all versions of a document, and cannot be changed.",
			//   "pattern": "^[a-zA-Z0-9_\\-.]{1,128}$",
			//   "type": "string"
			// }
			Description: "An optional field specifying the version of the artifact you are creating with the document. This value is unique across all versions of a document, and cannot be changed.",
			Type:        types.StringType,
			Optional:    true,
			Validators: []tfsdk.AttributeValidator{
				validate.StringMatch(regexp.MustCompile("^[a-zA-Z0-9_\\-.]{1,128}$"), ""),
			},
		},
	}

	attributes["id"] = tfsdk.Attribute{
		Description: "Uniquely identifies the resource.",
		Type:        types.StringType,
		Computed:    true,
		PlanModifiers: []tfsdk.AttributePlanModifier{
			tfsdk.UseStateForUnknown(),
		},
	}

	schema := tfsdk.Schema{
		Description: "The AWS::SSM::Document resource is an SSM document in AWS Systems Manager that defines the actions that Systems Manager performs, which can be used to set up and run commands on your instances.",
		Version:     1,
		Attributes:  attributes,
	}

	var opts ResourceTypeOptions

	opts = opts.WithCloudFormationTypeName("AWS::SSM::Document").WithTerraformTypeName("awscc_ssm_document")
	opts = opts.WithTerraformSchema(schema)
	opts = opts.WithSyntheticIDAttribute(true)
	opts = opts.WithAttributeNameMap(map[string]string{
		"attachments":     "Attachments",
		"content":         "Content",
		"document_format": "DocumentFormat",
		"document_type":   "DocumentType",
		"key":             "Key",
		"name":            "Name",
		"requires":        "Requires",
		"tags":            "Tags",
		"target_type":     "TargetType",
		"update_method":   "UpdateMethod",
		"value":           "Value",
		"values":          "Values",
		"version":         "Version",
		"version_name":    "VersionName",
	})

	opts = opts.WithCreateTimeoutInMinutes(0).WithDeleteTimeoutInMinutes(0)

	opts = opts.WithUpdateTimeoutInMinutes(0)

	resourceType, err := NewResourceType(ctx, opts...)

	if err != nil {
		return nil, err
	}

	return resourceType, nil
}