// Generated by openapi-moonbit — DO NOT EDIT
// Spec SHA-256: 7e574664c0f434e52021e12f313a3266fd3175fe2ecddde4c0e0930549c72ba2
///|
#derive(Debug, Eq, Compare)
pub(all) struct AgentSecretCreation {
path : Array[String]
/// wire: `secretType`.
secret_type : SchemaGraph
/// wire: `secretValue`.
secret_value : ExternalSchemaValue?
}
///|
/// Construct a `AgentSecretCreation` with optional fields defaulting to absent/`None`.
pub fn AgentSecretCreation::new(
path~ : Array[String],
secret_type~ : SchemaGraph,
secret_value? : ExternalSchemaValue,
) -> AgentSecretCreation {
{ path, secret_type, secret_value, }
}
///|
pub impl @cjson.FromJson for AgentSecretCreation with fn from_json(
json : @cjson.Json,
path : @cjson.DecodeContext,
) -> AgentSecretCreation raise @cjson.JsonDecodeError {
let __r = @rjson.JsonReader::new(json, path)
let path = __r.req_field("path", __fr => {
__fr.read_array().map(__el_0 => __el_0.read_string())
})
let secret_type = __r.req_field("secretType", __fr => {
(@cjson.FromJson::from_json(__fr.raw(), __fr.context()) : SchemaGraph)
})
let secret_value = __r.opt_field_as("secretValue", __fr => {
(
@cjson.FromJson::from_json(__fr.raw(), __fr.context()) :
ExternalSchemaValue)
})
{ path, secret_type, secret_value, }
}
///|
pub impl @cjson.ToJson for AgentSecretCreation with fn to_json(
self : AgentSecretCreation,
) -> @cjson.Json {
let __obj = @rjson.ObjectBuilder::new()
let _ = __obj.field(
"path",
@cjson.Json::array(self.path.map(__ev_0 => @rjson.write_string(__ev_0))),
)
let _ = __obj.field("secretType", self.secret_type.to_json())
let _ = __obj.opt_field(
"secretValue",
match self.secret_value {
Option::Some(__fv) => Option::Some(__fv.to_json())
Option::None => Option::None
},
)
__obj.build()
}
///|
pub extend AgentSecretCreation with @cjson.ToJson::{to_json}
///|
#derive(Debug, Eq, Compare)
pub(all) struct AgentSecretDto {
/// format: `uuid`.
id : @uuid.UUID
/// format: `uuid`; wire: `environmentId`.
environment_id : @uuid.UUID
path : Array[String]
/// format: `uint64`.
revision : UInt64
/// wire: `secretType`.
secret_type : SchemaGraph
/// wire: `secretValue`.
secret_value : ExternalSchemaValue?
}
///|
/// Construct a `AgentSecretDto` with optional fields defaulting to absent/`None`.
pub fn AgentSecretDto::new(
id~ : @uuid.UUID,
environment_id~ : @uuid.UUID,
path~ : Array[String],
revision~ : UInt64,
secret_type~ : SchemaGraph,
secret_value? : ExternalSchemaValue,
) -> AgentSecretDto {
{ id, environment_id, path, revision, secret_type, secret_value, }
}
///|
pub impl @cjson.FromJson for AgentSecretDto with fn from_json(
json : @cjson.Json,
path : @cjson.DecodeContext,
) -> AgentSecretDto raise @cjson.JsonDecodeError {
let __r = @rjson.JsonReader::new(json, path)
let id = __r.req_field("id", __fr => {
@uuid.from_hex(__fr.read_string()) catch {
_ => {
let __err = __fr.error("invalid uuid")
raise __err
}
}
})
let environment_id = __r.req_field("environmentId", __fr => {
@uuid.from_hex(__fr.read_string()) catch {
_ => {
let __err = __fr.error("invalid uuid")
raise __err
}
}
})
let path = __r.req_field("path", __fr => {
__fr.read_array().map(__el_0 => __el_0.read_string())
})
let revision = __r.req_field("revision", __fr => __fr.read_uint64())
let secret_type = __r.req_field("secretType", __fr => {
(@cjson.FromJson::from_json(__fr.raw(), __fr.context()) : SchemaGraph)
})
let secret_value = __r.opt_field_as("secretValue", __fr => {
(
@cjson.FromJson::from_json(__fr.raw(), __fr.context()) :
ExternalSchemaValue)
})
{ id, environment_id, path, revision, secret_type, secret_value, }
}
///|
pub impl @cjson.ToJson for AgentSecretDto with fn to_json(self : AgentSecretDto) -> @cjson.Json {
let __obj = @rjson.ObjectBuilder::new()
let _ = __obj.field("id", @rjson.write_string(self.id.to_string()))
let _ = __obj.field(
"environmentId",
@rjson.write_string(self.environment_id.to_string()),
)
let _ = __obj.field(
"path",
@cjson.Json::array(self.path.map(__ev_0 => @rjson.write_string(__ev_0))),
)
let _ = __obj.field("revision", @rjson.write_uint64(self.revision))
let _ = __obj.field("secretType", self.secret_type.to_json())
let _ = __obj.opt_field(
"secretValue",
match self.secret_value {
Option::Some(__fv) => Option::Some(__fv.to_json())
Option::None => Option::None
},
)
__obj.build()
}
///|
pub extend AgentSecretDto with @cjson.ToJson::{to_json}
///|
#derive(Debug, Eq, Compare)
pub(all) enum OptionalFieldUpdateExternalSchemaValue {
Set(value~ : ExternalSchemaValue)
Unset
}
///|
pub impl @cjson.FromJson for OptionalFieldUpdateExternalSchemaValue with fn from_json(
json : @cjson.Json,
path : @cjson.DecodeContext,
) -> OptionalFieldUpdateExternalSchemaValue raise @cjson.JsonDecodeError {
let __r = @rjson.JsonReader::new(json, path)
match __r.field("op").read_string() {
"set" => {
let value = __r.req_field("value", __fr => {
(
@cjson.FromJson::from_json(__fr.raw(), __fr.context()) :
ExternalSchemaValue)
})
OptionalFieldUpdateExternalSchemaValue::Set(value~)
}
"unset" => OptionalFieldUpdateExternalSchemaValue::Unset
other => {
let __err = __r.error(
"unknown OptionalFieldUpdateExternalSchemaValue tag: " + other,
)
raise __err
}
}
}
///|
pub impl @cjson.ToJson for OptionalFieldUpdateExternalSchemaValue with fn to_json(
self : OptionalFieldUpdateExternalSchemaValue,
) -> @cjson.Json {
match self {
OptionalFieldUpdateExternalSchemaValue::Set(value~) => {
let __obj = @rjson.ObjectBuilder::new().field(
"op",
@rjson.write_string("set"),
)
let _ = __obj.field("value", value.to_json())
__obj.build()
}
OptionalFieldUpdateExternalSchemaValue::Unset =>
@rjson.ObjectBuilder::new()
.field("op", @rjson.write_string("unset"))
.build()
}
}
///|
pub extend OptionalFieldUpdateExternalSchemaValue with @cjson.ToJson::{to_json}
///|
#derive(Debug, Eq, Compare)
pub(all) struct AgentSecretUpdate {
/// format: `uint64`; wire: `currentRevision`.
current_revision : UInt64
/// wire: `secretValue`.
secret_value : OptionalFieldUpdateExternalSchemaValue?
}
///|
/// Construct a `AgentSecretUpdate` with optional fields defaulting to absent/`None`.
pub fn AgentSecretUpdate::new(
current_revision~ : UInt64,
secret_value? : OptionalFieldUpdateExternalSchemaValue,
) -> AgentSecretUpdate {
{ current_revision, secret_value, }
}
///|
pub impl @cjson.FromJson for AgentSecretUpdate with fn from_json(
json : @cjson.Json,
path : @cjson.DecodeContext,
) -> AgentSecretUpdate raise @cjson.JsonDecodeError {
let __r = @rjson.JsonReader::new(json, path)
let current_revision = __r.req_field("currentRevision", __fr => {
__fr.read_uint64()
})
let secret_value = __r.opt_field_as("secretValue", __fr => {
(
@cjson.FromJson::from_json(__fr.raw(), __fr.context()) :
OptionalFieldUpdateExternalSchemaValue)
})
{ current_revision, secret_value, }
}
///|
pub impl @cjson.ToJson for AgentSecretUpdate with fn to_json(
self : AgentSecretUpdate,
) -> @cjson.Json {
let __obj = @rjson.ObjectBuilder::new()
let _ = __obj.field(
"currentRevision",
@rjson.write_uint64(self.current_revision),
)
let _ = __obj.opt_field(
"secretValue",
match self.secret_value {
Option::Some(__fv) => Option::Some(__fv.to_json())
Option::None => Option::None
},
)
__obj.build()
}
///|
pub extend AgentSecretUpdate with @cjson.ToJson::{to_json}
///|
#derive(Debug, Eq, Compare)
pub(all) struct PageAgentSecretDto {
values : Array[AgentSecretDto]
}
///|
pub impl @cjson.FromJson for PageAgentSecretDto with fn from_json(
json : @cjson.Json,
path : @cjson.DecodeContext,
) -> PageAgentSecretDto raise @cjson.JsonDecodeError {
let __r = @rjson.JsonReader::new(json, path)
let values = __r.req_field("values", __fr => {
__fr
.read_array()
.map(__el_0 => {
(
@cjson.FromJson::from_json(__el_0.raw(), __el_0.context()) :
AgentSecretDto)
})
})
{ values, }
}
///|
pub impl @cjson.ToJson for PageAgentSecretDto with fn to_json(
self : PageAgentSecretDto,
) -> @cjson.Json {
let __obj = @rjson.ObjectBuilder::new()
let _ = __obj.field(
"values",
@cjson.Json::array(self.values.map(__ev_0 => __ev_0.to_json())),
)
__obj.build()
}
///|
pub extend PageAgentSecretDto with @cjson.ToJson::{to_json}