#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::network_slices::slice::get_job_logs;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LogEntry<'a> {
pub created_at: Datetime,
pub id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub job_id: Option<CowStr<'a>>,
#[serde(borrow)]
pub level: CowStr<'a>,
#[serde(borrow)]
pub log_type: CowStr<'a>,
#[serde(borrow)]
pub message: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub metadata: Option<Data<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub slice_uri: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user_did: Option<Did<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetJobLogs<'a> {
#[serde(borrow)]
pub job_id: CowStr<'a>,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetJobLogsOutput<'a> {
#[serde(borrow)]
pub logs: Vec<get_job_logs::LogEntry<'a>>,
}
impl<'a> LexiconSchema for LogEntry<'a> {
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<'de> = GetJobLogsOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetJobLogs<'a> {
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<'de> = GetJobLogs<'de>;
type Response = GetJobLogsResponse;
}
pub mod log_entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Id;
type CreatedAt;
type Level;
type LogType;
type Message;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type CreatedAt = Unset;
type Level = Unset;
type LogType = Unset;
type Message = Unset;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type Id = Set<members::id>;
type CreatedAt = S::CreatedAt;
type Level = S::Level;
type LogType = S::LogType;
type Message = S::Message;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Id = S::Id;
type CreatedAt = Set<members::created_at>;
type Level = S::Level;
type LogType = S::LogType;
type Message = S::Message;
}
pub struct SetLevel<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLevel<S> {}
impl<S: State> State for SetLevel<S> {
type Id = S::Id;
type CreatedAt = S::CreatedAt;
type Level = Set<members::level>;
type LogType = S::LogType;
type Message = S::Message;
}
pub struct SetLogType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLogType<S> {}
impl<S: State> State for SetLogType<S> {
type Id = S::Id;
type CreatedAt = S::CreatedAt;
type Level = S::Level;
type LogType = Set<members::log_type>;
type Message = S::Message;
}
pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMessage<S> {}
impl<S: State> State for SetMessage<S> {
type Id = S::Id;
type CreatedAt = S::CreatedAt;
type Level = S::Level;
type LogType = S::LogType;
type Message = Set<members::message>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct created_at(());
pub struct level(());
pub struct log_type(());
pub struct message(());
}
}
pub struct LogEntryBuilder<'a, S: log_entry_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Data<'a>>,
Option<CowStr<'a>>,
Option<Did<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LogEntry<'a> {
pub fn new() -> LogEntryBuilder<'a, log_entry_state::Empty> {
LogEntryBuilder::new()
}
}
impl<'a> LogEntryBuilder<'a, log_entry_state::Empty> {
pub fn new() -> Self {
LogEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::CreatedAt: log_entry_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> LogEntryBuilder<'a, log_entry_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::Id: log_entry_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<i64>,
) -> LogEntryBuilder<'a, log_entry_state::SetId<S>> {
self._fields.1 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: log_entry_state::State> LogEntryBuilder<'a, S> {
pub fn job_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_job_id(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::Level: log_entry_state::IsUnset,
{
pub fn level(
mut self,
value: impl Into<CowStr<'a>>,
) -> LogEntryBuilder<'a, log_entry_state::SetLevel<S>> {
self._fields.3 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::LogType: log_entry_state::IsUnset,
{
pub fn log_type(
mut self,
value: impl Into<CowStr<'a>>,
) -> LogEntryBuilder<'a, log_entry_state::SetLogType<S>> {
self._fields.4 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::Message: log_entry_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<CowStr<'a>>,
) -> LogEntryBuilder<'a, log_entry_state::SetMessage<S>> {
self._fields.5 = Option::Some(value.into());
LogEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: log_entry_state::State> LogEntryBuilder<'a, S> {
pub fn metadata(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<Data<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: log_entry_state::State> LogEntryBuilder<'a, S> {
pub fn slice_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_slice_uri(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: log_entry_state::State> LogEntryBuilder<'a, S> {
pub fn user_did(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_user_did(mut self, value: Option<Did<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> LogEntryBuilder<'a, S>
where
S: log_entry_state::State,
S::Id: log_entry_state::IsSet,
S::CreatedAt: log_entry_state::IsSet,
S::Level: log_entry_state::IsSet,
S::LogType: log_entry_state::IsSet,
S::Message: log_entry_state::IsSet,
{
pub fn build(self) -> LogEntry<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> LogEntry<'a> {
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> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetJobId<S> {}
impl<S: State> State for SetJobId<S> {
type JobId = Set<members::job_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct job_id(());
}
}
pub struct GetJobLogsBuilder<'a, S: get_job_logs_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetJobLogs<'a> {
pub fn new() -> GetJobLogsBuilder<'a, get_job_logs_state::Empty> {
GetJobLogsBuilder::new()
}
}
impl<'a> GetJobLogsBuilder<'a, get_job_logs_state::Empty> {
pub fn new() -> Self {
GetJobLogsBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetJobLogsBuilder<'a, S>
where
S: get_job_logs_state::State,
S::JobId: get_job_logs_state::IsUnset,
{
pub fn job_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> GetJobLogsBuilder<'a, get_job_logs_state::SetJobId<S>> {
self._fields.0 = Option::Some(value.into());
GetJobLogsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_job_logs_state::State> GetJobLogsBuilder<'a, S> {
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<'a, S> GetJobLogsBuilder<'a, S>
where
S: get_job_logs_state::State,
S::JobId: get_job_logs_state::IsSet,
{
pub fn build(self) -> GetJobLogs<'a> {
GetJobLogs {
job_id: self._fields.0.unwrap(),
limit: self._fields.1,
}
}
}