{
  "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" ]
    },
    "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"
        }
      },
      "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
    }
  },
  "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"
    }
  },
  "additionalProperties" : false,
  "required" : [ "Type", "DestinationName" ],
  "readOnlyProperties" : [ "/properties/ThingName", "/properties/Id", "/properties/Arn" ],
  "primaryIdentifier" : [ "/properties/Id" ],
  "taggable" : true,
  "handlers" : {
    "create" : {
      "permissions" : [ "iotwireless:CreateWirelessDevice", "iotwireless:TagResource", "iotwireless:ListTagsForResource" ]
    },
    "read" : {
      "permissions" : [ "iotwireless:GetWirelessDevice", "iotwireless:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "iotwireless:UpdateWirelessDevice", "iotwireless:UntagResource", "iotwireless:ListTagsForResource" ]
    },
    "delete" : {
      "permissions" : [ "iotwireless:DeleteWirelessDevice" ]
    },
    "list" : {
      "permissions" : [ "iotwireless:ListWirelessDevices", "iotwireless:ListTagsForResource" ]
    }
  }
}