// PureLife Device Provisioning Protocol, version 1.0 (Draft).
//
// Endpoint `pld-info`: identity of the Device. Read-only.
// See the Device Provisioning Protocol (pld-provisioning.html), section 9.1.

syntax = "proto3";

package pld;

import "pld_constants.proto";

// Type of the message carried in `InfoPayload`.
enum InfoMsgType {
  // Not set. A payload with this type is invalid.
  INFO_MSG_TYPE_UNSPECIFIED = 0;

  // Provisioner to Device: `GetInfoCommand`.
  INFO_MSG_TYPE_GET_INFO_COMMAND = 1;

  // Device to Provisioner: `GetInfoResponse`.
  INFO_MSG_TYPE_GET_INFO_RESPONSE = 2;
}

// Requests the identity of the Device. Has no fields.
message GetInfoCommand {}

// Identity of the Device.
//
// The Provisioner compares `device_id` with the Device ID from the label and
// aborts if they differ.
message GetInfoResponse {
  // Required. Result of the command.
  Status status = 1;

  // Optional. Human readable detail for logs and support, English, at most
  // 64 bytes. MUST be empty when `status` is `STATUS_OK`.
  string detail = 2;

  // Required. Device ID: 8 to 24 characters from `A-Z`, `0-9` and `-`.
  // Unique per Manufacturer and stable for the lifetime of the Device.
  //
  // Recommended: the 12 hex digits of the primary MAC address in upper
  // case without separators.
  string device_id = 3;

  // Required. Manufacturer identifier agreed with PureSec: 1 to 32
  // characters from `a-z`, `0-9` and `-`. Equals the `O` of the Device
  // certificate subject (Device Messaging Protocol, section 4).
  string manufacturer = 4;

  // Required. Model name, 1 to 32 bytes.
  string model = 5;

  // Required. Hardware revision, free text, 1 to 32 bytes.
  string hardware_revision = 6;

  // Required. Firmware version, free text, 1 to 32 bytes. Recommended: a
  // semantic version such as `1.2.0`.
  string firmware_version = 7;
}

// Payload of the `pld-info` endpoint.
message InfoPayload {
  // Required. Identifies which member of `payload` is set.
  InfoMsgType msg = 1;

  // The command or response. Exactly one member is set.
  oneof payload {
    // Set when `msg` is `INFO_MSG_TYPE_GET_INFO_COMMAND`.
    GetInfoCommand get_info_command = 10;

    // Set when `msg` is `INFO_MSG_TYPE_GET_INFO_RESPONSE`.
    GetInfoResponse get_info_response = 11;
  }
}
