#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Datetime, Did};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::network_slices::slice::get_job_logs;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct LogEntry<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<S>,
pub level: S,
pub log_type: S,
pub message: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub slice_uri: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_did: Option<Did<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetJobLogs<S: BosStr = DefaultStr> {
pub job_id: S,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetJobLogsOutput<S: BosStr = DefaultStr> {
pub logs: Vec<get_job_logs::LogEntry<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for LogEntry<S> {
fn nsid() -> &'static str {
"network.slices.slice.getJobLogs"
}
fn def_name() -> &'static str {
"logEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_network_slices_slice_getJobLogs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct GetJobLogsResponse;
impl jacquard_common::xrpc::XrpcResp for GetJobLogsResponse {
const NSID: &'static str = "network.slices.slice.getJobLogs";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetJobLogsOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetJobLogs<S> {
const NSID: &'static str = "network.slices.slice.getJobLogs";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetJobLogsResponse;
}
pub struct GetJobLogsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetJobLogsRequest {
const PATH: &'static str = "/xrpc/network.slices.slice.getJobLogs";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = GetJobLogs<S>;
type Response = GetJobLogsResponse;
}
pub mod log_entry_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Id;
type LogType;
type CreatedAt;
type Level;
type Message;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type LogType = Unset;
type CreatedAt = Unset;
type Level = Unset;
type Message = Unset;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Id = Set<members::id>;
type LogType = St::LogType;
type CreatedAt = St::CreatedAt;
type Level = St::Level;
type Message = St::Message;
}
pub struct SetLogType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLogType<St> {}
impl<St: State> State for SetLogType<St> {
type Id = St::Id;
type LogType = Set<members::log_type>;
type CreatedAt = St::CreatedAt;
type Level = St::Level;
type Message = St::Message;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Id = St::Id;
type LogType = St::LogType;
type CreatedAt = Set<members::created_at>;
type Level = St::Level;
type Message = St::Message;
}
pub struct SetLevel<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLevel<St> {}
impl<St: State> State for SetLevel<St> {
type Id = St::Id;
type LogType = St::LogType;
type CreatedAt = St::CreatedAt;
type Level = Set<members::level>;
type Message = St::Message;
}
pub struct SetMessage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMessage<St> {}
impl<St: State> State for SetMessage<St> {
type Id = St::Id;
type LogType = St::LogType;
type CreatedAt = St::CreatedAt;
type Level = St::Level;
type Message = Set<members::message>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct log_type(());
pub struct created_at(());
pub struct level(());
pub struct message(());
}
}
pub struct LogEntryBuilder<S: BosStr, St: log_entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Data<S>>,
Option<S>,
Option<Did<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> LogEntry<S> {
pub fn new() -> LogEntryBuilder<S, log_entry_state::Empty> {
LogEntryBuilder::new()
}
}
impl<S: BosStr> LogEntryBuilder<S, log_entry_state::Empty> {
pub fn new() -> Self {
LogEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::CreatedAt: log_entry_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> LogEntryBuilder<S, log_entry_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::Id: log_entry_state::IsUnset,
{
pub fn id(mut self, value: impl Into<i64>) -> LogEntryBuilder<S, log_entry_state::SetId<St>> {
self._fields.1 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: log_entry_state::State> LogEntryBuilder<S, St> {
pub fn job_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_job_id(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::Level: log_entry_state::IsUnset,
{
pub fn level(
mut self,
value: impl Into<S>,
) -> LogEntryBuilder<S, log_entry_state::SetLevel<St>> {
self._fields.3 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::LogType: log_entry_state::IsUnset,
{
pub fn log_type(
mut self,
value: impl Into<S>,
) -> LogEntryBuilder<S, log_entry_state::SetLogType<St>> {
self._fields.4 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::Message: log_entry_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<S>,
) -> LogEntryBuilder<S, log_entry_state::SetMessage<St>> {
self._fields.5 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: log_entry_state::State> LogEntryBuilder<S, St> {
pub fn metadata(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<Data<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: log_entry_state::State> LogEntryBuilder<S, St> {
pub fn slice_uri(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_slice_uri(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: log_entry_state::State> LogEntryBuilder<S, St> {
pub fn user_did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_user_did(mut self, value: Option<Did<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> LogEntryBuilder<S, St>
where
St: log_entry_state::State,
St::Id: log_entry_state::IsSet,
St::LogType: log_entry_state::IsSet,
St::CreatedAt: log_entry_state::IsSet,
St::Level: log_entry_state::IsSet,
St::Message: log_entry_state::IsSet,
{
pub fn build(self) -> LogEntry<S> {
LogEntry {
created_at: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
job_id: self._fields.2,
level: self._fields.3.unwrap(),
log_type: self._fields.4.unwrap(),
message: self._fields.5.unwrap(),
metadata: self._fields.6,
slice_uri: self._fields.7,
user_did: self._fields.8,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> LogEntry<S> {
LogEntry {
created_at: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
job_id: self._fields.2,
level: self._fields.3.unwrap(),
log_type: self._fields.4.unwrap(),
message: self._fields.5.unwrap(),
metadata: self._fields.6,
slice_uri: self._fields.7,
user_did: self._fields.8,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_network_slices_slice_getJobLogs() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("network.slices.slice.getJobLogs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("logEntry"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("id"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("logType"),
SmolStr::new_static("level"),
SmolStr::new_static("message"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"When the log entry was created",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("jobId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"UUID of related job if applicable",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("level"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Log level")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("logType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Type of log entry")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Log message")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sliceUri"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"AT-URI of related slice if applicable",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userDid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"DID of related user if applicable",
)),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("jobId")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("jobId"),
LexXrpcParametersProperty::String(LexString {
description: Some(CowStr::new_static("UUID of the sync job")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_limit() -> Option<i64> {
Some(100i64)
}
pub mod get_job_logs_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type JobId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type JobId = Unset;
}
pub struct SetJobId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetJobId<St> {}
impl<St: State> State for SetJobId<St> {
type JobId = Set<members::job_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct job_id(());
}
}
pub struct GetJobLogsBuilder<S: BosStr, St: get_job_logs_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetJobLogs<S> {
pub fn new() -> GetJobLogsBuilder<S, get_job_logs_state::Empty> {
GetJobLogsBuilder::new()
}
}
impl<S: BosStr> GetJobLogsBuilder<S, get_job_logs_state::Empty> {
pub fn new() -> Self {
GetJobLogsBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetJobLogsBuilder<S, St>
where
St: get_job_logs_state::State,
St::JobId: get_job_logs_state::IsUnset,
{
pub fn job_id(
mut self,
value: impl Into<S>,
) -> GetJobLogsBuilder<S, get_job_logs_state::SetJobId<St>> {
self._fields.0 = Option::Some(value.into());
GetJobLogsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: get_job_logs_state::State> GetJobLogsBuilder<S, St> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> GetJobLogsBuilder<S, St>
where
St: get_job_logs_state::State,
St::JobId: get_job_logs_state::IsSet,
{
pub fn build(self) -> GetJobLogs<S> {
GetJobLogs {
job_id: self._fields.0.unwrap(),
limit: self._fields.1,
}
}
}