MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_gcp_region

Function validate_gcp_region

crates/openshell-server/src/inference.rs:342–360  ·  view source on GitHub ↗

Validate a GCP region/location value. Accepts the special keywords `global`, `us`, and `eu`, plus standard regional patterns like `us-central1`, `europe-west4`, `us-east4-a`.

(value: &str)

Source from the content-addressed store, hash-verified

340/// Accepts the special keywords `global`, `us`, and `eu`, plus standard
341/// regional patterns like `us-central1`, `europe-west4`, `us-east4-a`.
342fn validate_gcp_region(value: &str) -> Result<(), Status> {
343 let lower = value.trim().to_ascii_lowercase();
344 let valid = matches!(lower.as_str(), "global" | "us" | "eu")
345 || (lower
346 .chars()
347 .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-')
348 && lower.contains('-')
349 && !lower.starts_with('-')
350 && !lower.ends_with('-'));
351 if valid {
352 Ok(())
353 } else {
354 Err(Status::invalid_argument(format!(
355 "VERTEX_AI_REGION has invalid format: {value:?}. \
356 Expected a GCP region (e.g. us-central1, europe-west4) \
357 or one of: global, us, eu."
358 )))
359 }
360}
361
362/// Resolve the Vertex AI API host and normalized location from a configured region.
363fn vertex_location_and_host(region: &str) -> (String, String) {

Callers 1

resolve_vertex_ai_routeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected