{
  "typeName" : "AWS::IoTSiteWise::Portal",
  "description" : "Resource schema for AWS::IoTSiteWise::Portal",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-iotsitewise.git",
  "definitions" : {
    "PortalTypeEntry" : {
      "description" : "Container associated a certain PortalType.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "PortalTools" : {
          "$ref" : "#/definitions/PortalTools"
        }
      },
      "required" : [ "PortalTools" ]
    },
    "PortalTools" : {
      "description" : "List of enabled Tools for a certain portal.",
      "type" : "array",
      "items" : {
        "type" : "string"
      }
    },
    "PortalTypeConfiguration" : {
      "description" : "Map to associate detail of configuration related with a PortalType.",
      "type" : "object",
      "additionalProperties" : false,
      "patternProperties" : {
        "^[a-z][a-zA-Z0-9_]*$" : {
          "$ref" : "#/definitions/PortalTypeEntry"
        }
      }
    },
    "Tag" : {
      "description" : "To add or update tag, provide both key and value. To delete tag, provide only tag key to be deleted.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Key" : {
          "type" : "string"
        },
        "Value" : {
          "type" : "string"
        }
      },
      "required" : [ "Key", "Value" ]
    }
  },
  "properties" : {
    "PortalAuthMode" : {
      "description" : "The service to use to authenticate users to the portal. Choose from SSO or IAM. You can't change this value after you create a portal.",
      "type" : "string"
    },
    "PortalArn" : {
      "description" : "The ARN of the portal, which has the following format.",
      "type" : "string"
    },
    "PortalClientId" : {
      "description" : "The AWS SSO application generated client ID (used with AWS SSO APIs).",
      "type" : "string"
    },
    "PortalContactEmail" : {
      "description" : "The AWS administrator's contact email address.",
      "type" : "string"
    },
    "PortalDescription" : {
      "description" : "A description for the portal.",
      "type" : "string"
    },
    "PortalId" : {
      "description" : "The ID of the portal.",
      "type" : "string"
    },
    "PortalName" : {
      "description" : "A friendly name for the portal.",
      "type" : "string"
    },
    "PortalStartUrl" : {
      "description" : "The public root URL for the AWS IoT AWS IoT SiteWise Monitor application portal.",
      "type" : "string"
    },
    "PortalType" : {
      "description" : "The type of portal",
      "type" : "string",
      "enum" : [ "SITEWISE_PORTAL_V1", "SITEWISE_PORTAL_V2" ]
    },
    "PortalTypeConfiguration" : {
      "$ref" : "#/definitions/PortalTypeConfiguration"
    },
    "RoleArn" : {
      "description" : "The ARN of a service role that allows the portal's users to access your AWS IoT SiteWise resources on your behalf.",
      "type" : "string"
    },
    "NotificationSenderEmail" : {
      "description" : "The email address that sends alarm notifications.",
      "type" : "string"
    },
    "Alarms" : {
      "type" : "object",
      "description" : "Contains the configuration information of an alarm created in an AWS IoT SiteWise Monitor portal. You can use the alarm to monitor an asset property and get notified when the asset property value is outside a specified range.",
      "additionalProperties" : false,
      "properties" : {
        "AlarmRoleArn" : {
          "type" : "string",
          "description" : "The ARN of the IAM role that allows the alarm to perform actions and access AWS resources and services, such as AWS IoT Events."
        },
        "NotificationLambdaArn" : {
          "type" : "string",
          "description" : "The ARN of the AWS Lambda function that manages alarm notifications. For more information, see Managing alarm notifications in the AWS IoT Events Developer Guide."
        }
      }
    },
    "Tags" : {
      "description" : "A list of key-value pairs that contain metadata for the portal.",
      "type" : "array",
      "uniqueItems" : false,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    }
  },
  "additionalProperties" : false,
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "iotsitewise:TagResource", "iotsitewise:UntagResource", "iotsitewise:ListTagsForResource" ]
  },
  "required" : [ "PortalContactEmail", "PortalName", "RoleArn" ],
  "createOnlyProperties" : [ "/properties/PortalAuthMode", "/properties/PortalType" ],
  "readOnlyProperties" : [ "/properties/PortalArn", "/properties/PortalClientId", "/properties/PortalId", "/properties/PortalStartUrl" ],
  "primaryIdentifier" : [ "/properties/PortalId" ],
  "additionalIdentifiers" : [ [ "/properties/PortalArn" ] ],
  "handlers" : {
    "create" : {
      "permissions" : [ "iotsitewise:CreatePortal", "iotsitewise:DescribePortal", "iotsitewise:ListTagsForResource", "iotsitewise:TagResource", "iam:PassRole", "sso:CreateManagedApplicationInstance", "sso:DescribeRegisteredRegions" ]
    },
    "read" : {
      "permissions" : [ "iotsitewise:DescribePortal", "iotsitewise:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "iotsitewise:DescribePortal", "iotsitewise:ListTagsForResource", "iotsitewise:TagResource", "iotsitewise:UpdatePortal", "iotsitewise:UntagResource", "iam:PassRole", "sso:GetManagedApplicationInstance", "sso:UpdateApplicationInstanceDisplayData" ]
    },
    "delete" : {
      "permissions" : [ "iotsitewise:DescribePortal", "iotsitewise:DeletePortal", "sso:DeleteManagedApplicationInstance" ]
    },
    "list" : {
      "permissions" : [ "iotsitewise:ListPortals", "iotsitewise:ListTagsForResource" ]
    }
  }
}