2023-06-26 21:15:54 -05:00
|
|
|
// Simple Schema
|
2023-08-28 14:09:31 -05:00
|
|
|
namespace tests::idl::simple
|
2023-06-23 22:16:35 -05:00
|
|
|
|
2023-08-28 14:09:31 -05:00
|
|
|
import std::validators::string_bounds::StringBounds
|
2023-06-26 21:15:54 -05:00
|
|
|
|
|
|
|
const POWER: u8 = 1
|
|
|
|
const DEFAULT_NAME: str = f"flower power: {POWER}"
|
2023-06-23 22:16:35 -05:00
|
|
|
|
|
|
|
settings Test {
|
2023-06-26 21:15:54 -05:00
|
|
|
forbid_indexing=True
|
2023-06-23 22:16:35 -05:00
|
|
|
forbid_optional_indexing=True
|
|
|
|
}
|
|
|
|
|
2023-08-28 14:09:31 -05:00
|
|
|
enum EncryptionAlgorithm {
|
|
|
|
Bad
|
|
|
|
Medium
|
|
|
|
}
|
|
|
|
|
2023-06-26 21:15:54 -05:00
|
|
|
enum EncryptionMode {
|
2023-08-28 14:09:31 -05:00
|
|
|
None
|
|
|
|
Encrypt
|
2023-06-26 21:15:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/// A message that can be sent through the mail protocol
|
2023-06-23 22:16:35 -05:00
|
|
|
struct Message {
|
2023-08-28 14:09:31 -05:00
|
|
|
name: str = DEFAULT_NAME
|
|
|
|
encryption_mode: EncryptionMode = default
|
2023-06-23 22:16:35 -05:00
|
|
|
|
|
|
|
@validators=[StringBounds(min_chars=3 max_chars=12)]
|
2023-08-28 14:09:31 -05:00
|
|
|
optional recipient: str = "bee"
|
2023-06-23 22:16:35 -05:00
|
|
|
}
|
|
|
|
|
2023-06-26 21:15:54 -05:00
|
|
|
/// Throw when sending a message to a missing recipient
|
2023-06-23 22:16:35 -05:00
|
|
|
error RecipientNotFoundError {
|
2023-06-26 21:15:54 -05:00
|
|
|
message = "Recipient with name {self.recipient} not found"
|
2023-06-23 22:16:35 -05:00
|
|
|
|
|
|
|
@validators=[StringBounds(min_chars=8 max_chars=16)]
|
2023-08-28 14:09:31 -05:00
|
|
|
recipient: str
|
2023-06-23 22:16:35 -05:00
|
|
|
}
|
|
|
|
|
2023-06-26 21:15:54 -05:00
|
|
|
/// Mail API for receiving and sending emails
|
2023-06-23 22:16:35 -05:00
|
|
|
@provider=Any
|
|
|
|
protocol Mail {
|
|
|
|
|
|
|
|
@timeout_ms=1000
|
2023-08-28 14:09:31 -05:00
|
|
|
function send_message(message: Message) -> str
|
2023-06-23 22:16:35 -05:00
|
|
|
! RecipientNotFoundError(function.message.recipient)
|
|
|
|
}
|