#[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::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::network_slices::slice::SparklinePoint;
use crate::network_slices::slice::get_sparklines;
#[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 GetSparklines<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_get_sparklines_duration")]
pub duration: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_get_sparklines_interval")]
pub interval: Option<S>,
pub slices: Vec<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 GetSparklinesOutput<S: BosStr = DefaultStr> {
pub sparklines: Vec<get_sparklines::SparklineEntry<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 SparklineEntry<S: BosStr = DefaultStr> {
pub points: Vec<SparklinePoint<S>>,
pub slice_uri: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct GetSparklinesResponse;
impl jacquard_common::xrpc::XrpcResp for GetSparklinesResponse {
const NSID: &'static str = "network.slices.slice.getSparklines";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GetSparklinesOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetSparklines<S> {
const NSID: &'static str = "network.slices.slice.getSparklines";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = GetSparklinesResponse;
}
pub struct GetSparklinesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetSparklinesRequest {
const PATH: &'static str = "/xrpc/network.slices.slice.getSparklines";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = GetSparklines<S>;
type Response = GetSparklinesResponse;
}
impl<S: BosStr> LexiconSchema for SparklineEntry<S> {
fn nsid() -> &'static str {
"network.slices.slice.getSparklines"
}
fn def_name() -> &'static str {
"sparklineEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_network_slices_slice_getSparklines()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn _default_get_sparklines_duration<S: FromStaticStr>() -> ::core::option::Option<S> {
Some(S::from_static("24h"))
}
fn _default_get_sparklines_interval<S: FromStaticStr>() -> ::core::option::Option<S> {
Some(S::from_static("hour"))
}
pub mod get_sparklines_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 Slices;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Slices = Unset;
}
pub struct SetSlices<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSlices<St> {}
impl<St: State> State for SetSlices<St> {
type Slices = Set<members::slices>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct slices(());
}
}
pub struct GetSparklinesBuilder<S: BosStr, St: get_sparklines_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<Vec<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetSparklines<S> {
pub fn new() -> GetSparklinesBuilder<S, get_sparklines_state::Empty> {
GetSparklinesBuilder::new()
}
}
impl<S: BosStr> GetSparklinesBuilder<S, get_sparklines_state::Empty> {
pub fn new() -> Self {
GetSparklinesBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: get_sparklines_state::State> GetSparklinesBuilder<S, St> {
pub fn duration(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_duration(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: get_sparklines_state::State> GetSparklinesBuilder<S, St> {
pub fn interval(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_interval(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> GetSparklinesBuilder<S, St>
where
St: get_sparklines_state::State,
St::Slices: get_sparklines_state::IsUnset,
{
pub fn slices(
mut self,
value: impl Into<Vec<S>>,
) -> GetSparklinesBuilder<S, get_sparklines_state::SetSlices<St>> {
self._fields.2 = Option::Some(value.into());
GetSparklinesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetSparklinesBuilder<S, St>
where
St: get_sparklines_state::State,
St::Slices: get_sparklines_state::IsSet,
{
pub fn build(self) -> GetSparklines<S> {
GetSparklines {
duration: self._fields.0.or_else(|| Some(S::from_static("24h"))),
interval: self._fields.1.or_else(|| Some(S::from_static("hour"))),
slices: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> GetSparklines<S> {
GetSparklines {
duration: self._fields.0.or_else(|| Some(S::from_static("24h"))),
interval: self._fields.1.or_else(|| Some(S::from_static("hour"))),
slices: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod sparkline_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 SliceUri;
type Points;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type SliceUri = Unset;
type Points = Unset;
}
pub struct SetSliceUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSliceUri<St> {}
impl<St: State> State for SetSliceUri<St> {
type SliceUri = Set<members::slice_uri>;
type Points = St::Points;
}
pub struct SetPoints<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPoints<St> {}
impl<St: State> State for SetPoints<St> {
type SliceUri = St::SliceUri;
type Points = Set<members::points>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct slice_uri(());
pub struct points(());
}
}
pub struct SparklineEntryBuilder<S: BosStr, St: sparkline_entry_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<SparklinePoint<S>>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SparklineEntry<S> {
pub fn new() -> SparklineEntryBuilder<S, sparkline_entry_state::Empty> {
SparklineEntryBuilder::new()
}
}
impl<S: BosStr> SparklineEntryBuilder<S, sparkline_entry_state::Empty> {
pub fn new() -> Self {
SparklineEntryBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SparklineEntryBuilder<S, St>
where
St: sparkline_entry_state::State,
St::Points: sparkline_entry_state::IsUnset,
{
pub fn points(
mut self,
value: impl Into<Vec<SparklinePoint<S>>>,
) -> SparklineEntryBuilder<S, sparkline_entry_state::SetPoints<St>> {
self._fields.0 = Option::Some(value.into());
SparklineEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SparklineEntryBuilder<S, St>
where
St: sparkline_entry_state::State,
St::SliceUri: sparkline_entry_state::IsUnset,
{
pub fn slice_uri(
mut self,
value: impl Into<S>,
) -> SparklineEntryBuilder<S, sparkline_entry_state::SetSliceUri<St>> {
self._fields.1 = Option::Some(value.into());
SparklineEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SparklineEntryBuilder<S, St>
where
St: sparkline_entry_state::State,
St::SliceUri: sparkline_entry_state::IsSet,
St::Points: sparkline_entry_state::IsSet,
{
pub fn build(self) -> SparklineEntry<S> {
SparklineEntry {
points: self._fields.0.unwrap(),
slice_uri: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SparklineEntry<S> {
SparklineEntry {
points: self._fields.0.unwrap(),
slice_uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_network_slices_slice_getSparklines() -> 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.getSparklines"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(LexXrpcBodySchema::Object(LexObject {
required: Some(vec![SmolStr::new_static("slices")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("duration"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Time range to fetch data for",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("interval"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Time interval for data points",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("slices"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Array of slice AT-URIs to get sparkline data for",
)),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sparklineEntry"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("sliceUri"),
SmolStr::new_static("points"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("points"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Array of sparkline data points",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"network.slices.slice.defs#sparklinePoint",
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sliceUri"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("AT-URI of the slice")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}