// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: tools.ozone.queue.createQueue // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[allow(unused_imports)] use alloc::collections::BTreeMap; use crate::tools_ozone::queue::QueueView; #[allow(unused_imports)] use core::marker::PhantomData; use jacquard_common::deps::smol_str::SmolStr; use jacquard_common::types::string::Nsid; use jacquard_common::types::value::Data; use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr}; use jacquard_derive::{IntoStatic, open_union}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct CreateQueue { /// Collection name for record subjects. Required if subjectTypes includes 'record'. #[serde(skip_serializing_if = "Option::is_none")] pub collection: Option>, /// Optional description of the queue #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// Display name for the queue (must be unique) pub name: S, /// Policy keys to recommend when actioning reports in this queue #[serde(skip_serializing_if = "Option::is_none")] pub recommended_policies: Option>, /// Report reason types (fully qualified NSIDs) #[serde(skip_serializing_if = "Option::is_none")] pub report_types: Option>, /// Subject types this queue accepts #[serde(skip_serializing_if = "Option::is_none")] pub subject_types: Option>>, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum CreateQueueSubjectTypes { Account, Record, Message, Conversation, Other(S), } impl CreateQueueSubjectTypes { pub fn as_str(&self) -> &str { match self { Self::Account => "account", Self::Record => "record", Self::Message => "message", Self::Conversation => "conversation", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "account" => Self::Account, "record" => Self::Record, "message" => Self::Message, "conversation" => Self::Conversation, _ => Self::Other(s), } } } impl core::fmt::Display for CreateQueueSubjectTypes { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for CreateQueueSubjectTypes { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for CreateQueueSubjectTypes { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for CreateQueueSubjectTypes { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for CreateQueueSubjectTypes { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for CreateQueueSubjectTypes where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = CreateQueueSubjectTypes; fn into_static(self) -> Self::Output { match self { CreateQueueSubjectTypes::Account => CreateQueueSubjectTypes::Account, CreateQueueSubjectTypes::Record => CreateQueueSubjectTypes::Record, CreateQueueSubjectTypes::Message => CreateQueueSubjectTypes::Message, CreateQueueSubjectTypes::Conversation => CreateQueueSubjectTypes::Conversation, CreateQueueSubjectTypes::Other(v) => CreateQueueSubjectTypes::Other(v.into_static()), } } } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct CreateQueueOutput { pub queue: QueueView, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive( Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, )] #[serde(tag = "error", content = "message")] pub enum CreateQueueError { /// One or more recommended policy keys do not exist in the configured policy list #[serde(rename = "InvalidRecommendedPolicies")] InvalidRecommendedPolicies(#[serde(skip_serializing_if = "Option::is_none")] Option), /// The queue configuration conflicts with an existing queue #[serde(rename = "ConflictingQueue")] ConflictingQueue(#[serde(skip_serializing_if = "Option::is_none")] Option), /// Catch-all for unknown error codes. #[serde(untagged)] Other { error: SmolStr, #[serde(skip_serializing_if = "Option::is_none")] message: Option, }, } impl core::fmt::Display for CreateQueueError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::InvalidRecommendedPolicies(msg) => { write!(f, "InvalidRecommendedPolicies")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::ConflictingQueue(msg) => { write!(f, "ConflictingQueue")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Other { error, message } => { write!(f, "{}", error)?; if let Some(msg) = message { write!(f, ": {}", msg)?; } Ok(()) } } } } /** Response marker for the `tools.ozone.queue.createQueue` procedure. Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output`, which is `CreateQueueOutput` for this endpoint.*/ pub struct CreateQueueResponse; impl jacquard_common::xrpc::XrpcResp for CreateQueueResponse { const NSID: &'static str = "tools.ozone.queue.createQueue"; const ENCODING: &'static str = "application/json"; type Output = CreateQueueOutput; type Err = CreateQueueError; } impl jacquard_common::xrpc::XrpcRequest for CreateQueue { const NSID: &'static str = "tools.ozone.queue.createQueue"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure("application/json"); type Response = CreateQueueResponse; } /** Endpoint marker for the `tools.ozone.queue.createQueue` procedure. Path: `/xrpc/tools.ozone.queue.createQueue`. The request payload type is `CreateQueue`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/ pub struct CreateQueueRequest; impl jacquard_common::xrpc::XrpcEndpoint for CreateQueueRequest { const PATH: &'static str = "/xrpc/tools.ozone.queue.createQueue"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure("application/json"); type Request = CreateQueue; type Response = CreateQueueResponse; }