Skip to main content

alien_core/import/data/gcp/
ai.rs

1use serde::{Deserialize, Serialize};
2
3/// GCP AI (Vertex AI) ImportData.
4///
5/// The `project_id` and `location` fields identify the Vertex AI endpoint and
6/// are carried directly into the controller's ready state so that heartbeat
7/// ticks and binding-param serialization work without a cloud round-trip.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
10#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
11#[serde(rename_all = "camelCase")]
12pub struct GcpAiImportData {
13    /// GCP project ID that owns the Vertex AI endpoint.
14    pub project_id: String,
15    /// GCP region (location) of the Vertex AI endpoint.
16    pub location: String,
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    /// The GCP AI Terraform emitter writes the import ref with key `projectId`
24    /// (`crates/alien-terraform/src/emitters/gcp/ai.rs`), matching every other GCP
25    /// resource. This pins the serde key so a frozen/Terraform import round-trip does not
26    /// fail with `missing field project`.
27    #[test]
28    fn deserializes_the_emitter_import_ref_key() {
29        let json = serde_json::json!({ "projectId": "my-project", "location": "us-central1" });
30        let data: GcpAiImportData =
31            serde_json::from_value(json).expect("emitter's projectId key must deserialize");
32        assert_eq!(data.project_id, "my-project");
33        assert_eq!(data.location, "us-central1");
34    }
35}