Gunakan cargo untuk menambahkan crate google-cloud-compute-v1 ke file Cargo.toml
Anda:
cargoaddgoogle-cloud-compute-v1
Membuat daftar virtual machine
Klien untuk membuat dan mengelola virtual machine disebut Instances. Anda dapat mencantumkan VM dalam project dan zona menggunakan metode list() dari jenis ini:
pubasyncfnsample(project_id:&str)->anyhow::Result<()>{usegoogle_cloud_compute_v1::client::Instances;usegoogle_cloud_gax::paginator::ItemPaginator;constZONE:&str="us-central1-a";letclient=Instances::builder().build().await?;println!("Listing instances for project {project_id}");letmutinstances=client.list().set_project(project_id).set_zone(ZONE).by_item();whileletSome(item)=instances.next().await.transpose()?{println!(" {:?}",item.name);}println!("DONE");Ok(())}
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2026-11-04 UTC."],[],[]]