{
  "typeName" : "AWS::M2::Application",
  "description" : "Represents an application that runs on an AWS Mainframe Modernization Environment",
  "definitions" : {
    "Definition" : {
      "oneOf" : [ {
        "type" : "object",
        "title" : "S3Location",
        "properties" : {
          "S3Location" : {
            "type" : "string",
            "pattern" : "^\\S{1,2000}$"
          }
        },
        "required" : [ "S3Location" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Content",
        "properties" : {
          "Content" : {
            "type" : "string",
            "maxLength" : 65000,
            "minLength" : 1
          }
        },
        "required" : [ "Content" ],
        "additionalProperties" : false
      } ]
    },
    "EngineType" : {
      "type" : "string",
      "enum" : [ "microfocus", "bluage" ]
    },
    "TagMap" : {
      "type" : "object",
      "maxProperties" : 200,
      "minProperties" : 0,
      "patternProperties" : {
        "^(?!aws:).+$" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 0
        }
      },
      "additionalProperties" : false
    }
  },
  "properties" : {
    "ApplicationArn" : {
      "type" : "string",
      "pattern" : "^arn:(aws|aws-cn|aws-iso|aws-iso-[a-z]{1}|aws-us-gov):[A-Za-z0-9][A-Za-z0-9_/.-]{0,62}:([a-z]{2}-((iso[a-z]{0,1}-)|(gov-)){0,1}[a-z]+-[0-9]):[0-9]{12}:[A-Za-z0-9/][A-Za-z0-9:_/+=,@.-]{0,1023}$"
    },
    "ApplicationId" : {
      "type" : "string",
      "pattern" : "^\\S{1,80}$"
    },
    "Definition" : {
      "$ref" : "#/definitions/Definition"
    },
    "Description" : {
      "type" : "string",
      "maxLength" : 500,
      "minLength" : 0
    },
    "EngineType" : {
      "$ref" : "#/definitions/EngineType"
    },
    "KmsKeyId" : {
      "type" : "string",
      "maxLength" : 2048,
      "description" : "The ID or the Amazon Resource Name (ARN) of the customer managed KMS Key used for encrypting application-related resources."
    },
    "Name" : {
      "type" : "string",
      "pattern" : "^[A-Za-z0-9][A-Za-z0-9_\\-]{1,59}$"
    },
    "RoleArn" : {
      "type" : "string",
      "pattern" : "^arn:(aws|aws-cn|aws-iso|aws-iso-[a-z]{1}|aws-us-gov):[A-Za-z0-9][A-Za-z0-9_/.-]{0,62}:([a-z]{2}-((iso[a-z]{0,1}-)|(gov-)){0,1}[a-z]+-[0-9]|):[0-9]{12}:[A-Za-z0-9/][A-Za-z0-9:_/+=,@.-]{0,1023}$"
    },
    "Tags" : {
      "$ref" : "#/definitions/TagMap"
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : false,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "m2:TagResource", "m2:UntagResource", "m2:ListTagsForResource" ]
  },
  "required" : [ "EngineType", "Name" ],
  "readOnlyProperties" : [ "/properties/ApplicationArn", "/properties/ApplicationId" ],
  "writeOnlyProperties" : [ "/properties/Definition" ],
  "createOnlyProperties" : [ "/properties/EngineType", "/properties/Name", "/properties/KmsKeyId", "/properties/RoleArn" ],
  "primaryIdentifier" : [ "/properties/ApplicationArn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "m2:CreateApplication", "m2:GetApplication", "m2:ListTagsForResource", "m2:TagResource", "s3:GetObject", "s3:ListBucket", "kms:DescribeKey", "kms:CreateGrant", "iam:PassRole" ]
    },
    "read" : {
      "permissions" : [ "m2:GetApplication", "m2:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "m2:UpdateApplication", "m2:GetApplication", "m2:ListTagsForResource", "m2:TagResource", "m2:UntagResource", "s3:GetObject", "s3:ListBucket" ]
    },
    "delete" : {
      "permissions" : [ "elasticloadbalancing:DeleteListener", "elasticloadbalancing:DeleteTargetGroup", "logs:DeleteLogDelivery", "m2:GetApplication", "m2:DeleteApplication" ]
    },
    "list" : {
      "permissions" : [ "m2:ListApplications" ]
    }
  },
  "additionalProperties" : false
}