{
  "typeName" : "AWS::IoTWireless::WirelessDevice",
  "description" : "Create and manage wireless gateways, including LoRa gateways.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "OtaaV10x" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "AppKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "AppEui" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{16}"
        }
      },
      "required" : [ "AppKey", "AppEui" ]
    },
    "OtaaV11" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "AppKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "NwkKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "JoinEui" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{16}"
        }
      },
      "required" : [ "AppKey", "NwkKey", "JoinEui" ]
    },
    "SessionKeysAbpV11" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "FNwkSIntKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "SNwkSIntKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "NwkSEncKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "AppSKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        }
      },
      "required" : [ "FNwkSIntKey", "SNwkSIntKey", "NwkSEncKey", "AppSKey" ]
    },
    "AbpV11" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DevAddr" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{8}"
        },
        "SessionKeys" : {
          "$ref" : "#/definitions/SessionKeysAbpV11"
        }
      },
      "required" : [ "DevAddr", "SessionKeys" ]
    },
    "SessionKeysAbpV10x" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "NwkSKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        },
        "AppSKey" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{32}"
        }
      },
      "required" : [ "NwkSKey", "AppSKey" ]
    },
    "AbpV10x" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DevAddr" : {
          "type" : "string",
          "pattern" : "[a-fA-F0-9]{8}"
        },
        "SessionKeys" : {
          "$ref" : "#/definitions/SessionKeysAbpV10x"
        }
      },
      "required" : [ "DevAddr", "SessionKeys" ]
    },
    "FPorts" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Applications" : {
          "description" : "A list of optional LoRaWAN application information, which can be used for geolocation.",
          "type" : "array",
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/Application"
          }
        }
      }
    },
    "LoRaWANDevice" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "DevEui" : {
          "type" : "string",
          "pattern" : "[a-f0-9]{16}"
        },
        "DeviceProfileId" : {
          "type" : "string",
          "maxLength" : 256
        },
        "ServiceProfileId" : {
          "type" : "string",
          "maxLength" : 256
        },
        "OtaaV11" : {
          "$ref" : "#/definitions/OtaaV11"
        },
        "OtaaV10x" : {
          "$ref" : "#/definitions/OtaaV10x"
        },
        "AbpV11" : {
          "$ref" : "#/definitions/AbpV11"
        },
        "AbpV10x" : {
          "$ref" : "#/definitions/AbpV10x"
        },
        "FPorts" : {
          "$ref" : "#/definitions/FPorts"
        }
      },
      "oneOf" : [ {
        "required" : [ "OtaaV11" ]
      }, {
        "required" : [ "OtaaV10x" ]
      }, {
        "required" : [ "AbpV11" ]
      }, {
        "required" : [ "AbpV10x" ]
      } ]
    },
    "Tag" : {
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "additionalProperties" : false
    },
    "Application" : {
      "description" : "LoRaWAN application configuration, which can be used to perform geolocation.",
      "type" : "object",
      "properties" : {
        "DestinationName" : {
          "description" : "The name of the position data destination that describes the AWS IoT rule that processes the device's position data for use by AWS IoT Core for LoRaWAN.",
          "type" : "string",
          "pattern" : "[a-zA-Z0-9-_]+",
          "maxLength" : 128
        },
        "FPort" : {
          "description" : "The Fport value.",
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 223
        },
        "Type" : {
          "description" : "Application type, which can be specified to obtain real-time position information of your LoRaWAN device.",
          "type" : "string",
          "enum" : [ "SemtechGeolocation", "SemtechGNSS", "SemtechGNSSNG", "SemtechWiFi" ]
        }
      },
      "additionalProperties" : false
    }
  },
  "properties" : {
    "Type" : {
      "description" : "Wireless device type, currently only Sidewalk and LoRa",
      "type" : "string",
      "enum" : [ "Sidewalk", "LoRaWAN" ]
    },
    "Name" : {
      "description" : "Wireless device name",
      "type" : "string",
      "maxLength" : 256
    },
    "Description" : {
      "description" : "Wireless device description",
      "type" : "string",
      "maxLength" : 2048
    },
    "DestinationName" : {
      "description" : "Wireless device destination name",
      "type" : "string",
      "maxLength" : 128
    },
    "LoRaWAN" : {
      "description" : "The combination of Package, Station and Model which represents the version of the LoRaWAN Wireless Device.",
      "$ref" : "#/definitions/LoRaWANDevice"
    },
    "Tags" : {
      "description" : "A list of key-value pairs that contain metadata for the device. Currently not supported, will not create if tags are passed.",
      "type" : "array",
      "uniqueItems" : true,
      "maxItems" : 200,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "Arn" : {
      "description" : "Wireless device arn. Returned after successful create.",
      "type" : "string"
    },
    "Id" : {
      "description" : "Wireless device Id. Returned after successful create.",
      "type" : "string",
      "maxLength" : 256
    },
    "ThingArn" : {
      "description" : "Thing arn. Passed into update to associate Thing with Wireless device.",
      "type" : "string"
    },
    "ThingName" : {
      "description" : "Thing Arn. If there is a Thing created, this can be returned with a Get call.",
      "type" : "string"
    },
    "LastUplinkReceivedAt" : {
      "description" : "The date and time when the most recent uplink was received.",
      "type" : "string"
    },
    "Positioning" : {
      "description" : "FPort values for the GNSS, stream, and ClockSync functions of the positioning information.",
      "type" : "string",
      "enum" : [ "Enabled", "Disabled" ]
    }
  },
  "additionalProperties" : false,
  "required" : [ "Type", "DestinationName" ],
  "readOnlyProperties" : [ "/properties/ThingName", "/properties/Id", "/properties/Arn" ],
  "primaryIdentifier" : [ "/properties/Id" ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "iotwireless:TagResource", "iotwireless:UntagResource", "iotwireless:ListTagsForResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "iotwireless:CreateWirelessDevice", "iotwireless:TagResource" ]
    },
    "read" : {
      "permissions" : [ "iotwireless:GetWirelessDevice", "iotwireless:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "iotwireless:UpdateWirelessDevice", "iotwireless:GetWirelessDevice", "iotwireless:AssociateWirelessDeviceWithThing", "iotwireless:TagResource", "iotwireless:UntagResource" ]
    },
    "delete" : {
      "permissions" : [ "iotwireless:DeleteWirelessDevice", "iotwireless:DisassociateWirelessDeviceFromThing" ]
    },
    "list" : {
      "permissions" : [ "iotwireless:ListWirelessDevices", "iotwireless:ListTagsForResource" ]
    }
  }
}