use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkerDeployment {
pub account_id: String,
pub script_name: String,
pub deployment_id: String,
pub url: String,
pub deployed_at: DateTime<Utc>,
}
impl WorkerDeployment {
#[must_use]
pub fn new(
account_id: impl Into<String>,
script_name: impl Into<String>,
deployment_id: impl Into<String>,
url: impl Into<String>,
) -> Self {
Self {
account_id: account_id.into(),
script_name: script_name.into(),
deployment_id: deployment_id.into(),
url: url.into(),
deployed_at: Utc::now(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CloudRunDeployment {
pub resource_name: String,
pub service_name: String,
pub region: String,
pub project_id: String,
pub url: String,
pub image: String,
pub deployed_at: DateTime<Utc>,
}
impl CloudRunDeployment {
#[must_use]
pub fn new(
resource_name: impl Into<String>,
service_name: impl Into<String>,
region: impl Into<String>,
project_id: impl Into<String>,
url: impl Into<String>,
image: impl Into<String>,
) -> Self {
Self {
resource_name: resource_name.into(),
service_name: service_name.into(),
region: region.into(),
project_id: project_id.into(),
url: url.into(),
image: image.into(),
deployed_at: Utc::now(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CloudRunJobDeployment {
pub resource_name: String,
pub job_name: String,
pub region: String,
pub project_id: String,
pub deployed_at: DateTime<Utc>,
}
impl CloudRunJobDeployment {
#[must_use]
pub fn new(
resource_name: impl Into<String>,
job_name: impl Into<String>,
region: impl Into<String>,
project_id: impl Into<String>,
) -> Self {
Self {
resource_name: resource_name.into(),
job_name: job_name.into(),
region: region.into(),
project_id: project_id.into(),
deployed_at: Utc::now(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeploymentOutput {
pub id: String,
pub name: String,
pub url: Option<String>,
pub metadata: serde_json::Value,
pub deployed_at: DateTime<Utc>,
}
impl DeploymentOutput {
#[must_use]
pub fn new(id: impl Into<String>, name: impl Into<String>) -> Self {
Self {
id: id.into(),
name: name.into(),
url: None,
metadata: serde_json::Value::Null,
deployed_at: Utc::now(),
}
}
#[must_use]
pub fn with_url(mut self, url: impl Into<String>) -> Self {
self.url = Some(url.into());
self
}
#[must_use]
pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
self.metadata = metadata;
self
}
}