11#![ allow( dead_code) ]
2+ use gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: Instance ;
23
3- use gcloud_sdk:: GoogleRestApi ;
4+ async fn instances_create ( project : & str , location : & str , instance_name : & str ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
5+ let google_rest_client = gcloud_sdk:: GoogleRestApi :: new ( ) . await ?;
46
5- #[ tokio:: main]
6- async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
7- // Debug logging
8- //let subscriber = tracing_subscriber::fmt()
9- // .with_max_level(tracing::Level::TRACE)
10- // .with_env_filter("gcloud_sdk=debug")
11- // .finish();
12- //tracing::subscriber::set_global_default(subscriber)?;
7+ let instance = Instance {
8+ capacity_gib : Some ( "16384" . to_string ( ) ) ,
9+ create_time : None ,
10+ description : Some ( "Jon's test lustre instance" . to_string ( ) ) ,
11+ filesystem : Some ( instance_name. to_string ( ) ) ,
12+ labels : None ,
13+ mount_point : None ,
14+ name : Some ( instance_name. to_string ( ) ) ,
15+ network : Some ( "projects/8589356148/global/networks/default" . to_string ( ) ) ,
16+ state : None ,
17+ update_time : None ,
18+ } ;
1319
14- // Detect Google project ID using environment variables PROJECT_ID/GCP_PROJECT_ID
15- // or GKE metadata server when the app runs inside GKE
16- let google_project_id = gcloud_sdk:: GoogleEnvironment :: detect_google_project_id ( ) . await
17- . expect ( "No Google Project ID detected. Please specify it explicitly using env variable: PROJECT_ID" ) ;
20+ let response = gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: autopush_lustre_sandbox_projects_locations_instances_create (
21+ & google_rest_client. create_google_lustre_v1alpha_config ( ) . await ?,
22+ gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: AutopushLustreSandboxPeriodProjectsPeriodLocationsPeriodInstancesPeriodCreateParams {
23+ parent : format ! ( "projects/{project}/locations/{location}" ) ,
24+ access_token : None ,
25+ alt : None ,
26+ callback : None ,
27+ fields : None ,
28+ key : None ,
29+ oauth_token : None ,
30+ pretty_print : None ,
31+ quota_user : None ,
32+ upload_protocol : None ,
33+ upload_type : None ,
34+ dollar_xgafv : None ,
35+ instance_id : Some ( instance_name. to_string ( ) ) ,
36+ instance : Some ( instance) ,
37+ request_id : None ,
38+ }
39+ ) . await ?;
40+ println ! ( "{:#?}" , response) ;
41+ Ok ( ( ) )
42+ }
1843
44+ async fn instances_delete ( project : & str , location : & str , instance_name : & str ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
45+ let google_rest_client = gcloud_sdk:: GoogleRestApi :: new ( ) . await ?;
46+
47+ let response = gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: autopush_lustre_sandbox_projects_locations_instances_delete (
48+ & google_rest_client. create_google_lustre_v1alpha_config ( ) . await ?,
49+ gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: AutopushLustreSandboxPeriodProjectsPeriodLocationsPeriodInstancesPeriodDeleteParams {
50+ name : format ! ( "projects/{project}/locations/{location}/instances/{instance_name}" ) ,
51+ access_token : None ,
52+ alt : None ,
53+ callback : None ,
54+ fields : None ,
55+ key : None ,
56+ oauth_token : None ,
57+ pretty_print : None ,
58+ quota_user : None ,
59+ upload_protocol : None ,
60+ upload_type : None ,
61+ dollar_xgafv : None ,
62+ request_id : None ,
63+ }
64+ ) . await ?;
65+ println ! ( "{:#?}" , response) ;
66+ Ok ( ( ) )
67+ }
68+
69+ async fn instances_get ( project : & str , location : & str , instance_name : & str ) -> Result < gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: Instance , Box < dyn std:: error:: Error > > {
70+ let google_rest_client = gcloud_sdk:: GoogleRestApi :: new ( ) . await ?;
71+
72+ let response = gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: autopush_lustre_sandbox_projects_locations_instances_get (
73+ & google_rest_client. create_google_lustre_v1alpha_config ( ) . await ?,
74+ gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: AutopushLustreSandboxPeriodProjectsPeriodLocationsPeriodInstancesPeriodGetParams {
75+ name : format ! ( "projects/{project}/locations/{location}/instances/{instance_name}" ) ,
76+ access_token : None ,
77+ alt : None ,
78+ callback : None ,
79+ fields : None ,
80+ key : None ,
81+ oauth_token : None ,
82+ pretty_print : None ,
83+ quota_user : None ,
84+ upload_protocol : None ,
85+ upload_type : None ,
86+ dollar_xgafv : None ,
87+ }
88+ ) . await ?;
89+ Ok ( response)
90+ }
91+
92+ async fn instances_list ( project : & str , location : & str ) -> Result < Vec < gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: Instance > , Box < dyn std:: error:: Error > > {
1993 let google_rest_client = gcloud_sdk:: GoogleRestApi :: new ( ) . await ?;
2094
2195 let response = gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: autopush_lustre_sandbox_projects_locations_instances_list (
2296 & google_rest_client. create_google_lustre_v1alpha_config ( ) . await ?,
2397 gcloud_sdk:: google_rest_apis:: lustre_v1alpha:: projects_api:: AutopushLustreSandboxPeriodProjectsPeriodLocationsPeriodInstancesPeriodListParams {
24- parent : format ! ( "projects/{google_project_id }/locations/us-central1-a " ) ,
98+ parent : format ! ( "projects/{project }/locations/{location} " ) ,
2599 access_token : None ,
26100 alt : None ,
27101 callback : None ,
@@ -42,5 +116,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
42116
43117 println ! ( "{:#?}" , response) ;
44118
119+ Ok ( vec ! [ ] )
120+ }
121+ //"projects/ddn-e2e-testing/locations/us-central1-a/operations/operation-1736279872873-62b23290da4da-6d3fcf0c-8eef803c",
122+
123+ #[ tokio:: main]
124+ async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
125+ // Debug logging
126+ //let subscriber = tracing_subscriber::fmt()
127+ // .with_max_level(tracing::Level::TRACE)
128+ // .with_env_filter("gcloud_sdk=debug")
129+ // .finish();
130+ //tracing::subscriber::set_global_default(subscriber)?;
131+
132+ // Detect Google project ID using environment variables PROJECT_ID/GCP_PROJECT_ID
133+ // or GKE metadata server when the app runs inside GKE
134+ let google_project_id = gcloud_sdk:: GoogleEnvironment :: detect_google_project_id ( ) . await
135+ . expect ( "No Google Project ID detected. Please specify it explicitly using env variable: PROJECT_ID" ) ;
136+
137+ let location = "us-central1-a" ;
138+ //dbg!(instances_get(&google_project_id, &location, "emf-sandbox").await);
139+ //dbg!(instances_create(&google_project_id, &location, "emfjdp").await);
140+ //dbg!(instances_delete(&google_project_id, &location, "emfjdp").await);
141+ instances_list ( & google_project_id, & location) . await ?;
142+
45143 Ok ( ( ) )
46144}
0 commit comments