Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

brokkr-models::models::rendered_deployment_objects Rust

Structs

brokkr-models::models::rendered_deployment_objects::RenderedDeploymentObject

pub

Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents a rendered deployment object provenance record in the database.

Fields

NameTypeDescription
idUuidUnique identifier for this provenance record.
deployment_object_idUuidID of the deployment object that was created.
template_idUuidID of the template used to create the deployment object.
template_versioni32Version of the template at the time of rendering (snapshot).
template_parametersStringJSON string of parameters used for rendering.
created_atDateTime < Utc >Timestamp when the rendering occurred.

brokkr-models::models::rendered_deployment_objects::NewRenderedDeploymentObject

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema

Represents a new rendered deployment object provenance record to be inserted.

Fields

NameTypeDescription
deployment_object_idUuidID of the deployment object that was created.
template_idUuidID of the template used to create the deployment object.
template_versioni32Version of the template at the time of rendering (snapshot).
template_parametersStringJSON string of parameters used for rendering.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (deployment_object_id : Uuid , template_id : Uuid , template_version : i32 , template_parameters : String ,) -> Result < Self , String >
}

Creates a new NewRenderedDeploymentObject instance.

Parameters:

NameTypeDescription
deployment_object_id-UUID of the deployment object created from this rendering.
template_id-UUID of the template used for rendering.
template_version-Version number of the template used.
template_parameters-JSON string of the parameters used for rendering.

Returns:

Returns Ok(NewRenderedDeploymentObject) if all parameters are valid, otherwise returns an Err with a description of the validation failure.

Source
#![allow(unused)]
fn main() {
    pub fn new(
        deployment_object_id: Uuid,
        template_id: Uuid,
        template_version: i32,
        template_parameters: String,
    ) -> Result<Self, String> {
        // Validate deployment_object_id
        if deployment_object_id.is_nil() {
            return Err("Invalid deployment object ID".to_string());
        }

        // Validate template_id
        if template_id.is_nil() {
            return Err("Invalid template ID".to_string());
        }

        // Validate template_version
        if template_version < 1 {
            return Err("Template version must be at least 1".to_string());
        }

        // Validate template_parameters is valid JSON
        if serde_json::from_str::<serde_json::Value>(&template_parameters).is_err() {
            return Err("Template parameters must be valid JSON".to_string());
        }

        Ok(NewRenderedDeploymentObject {
            deployment_object_id,
            template_id,
            template_version,
            template_parameters,
        })
    }
}