Skip to content

Commit

Permalink
Open API generator update and Compute Engine API support
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Nov 16, 2023
1 parent 41d3e84 commit e58cbb5
Show file tree
Hide file tree
Showing 1,224 changed files with 238,936 additions and 578 deletions.
2 changes: 1 addition & 1 deletion examples/gcs-rest-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["me@abdolence.dev"]
edition = "2021"

[dependencies]
gcloud-sdk = { path = "./../../gcloud-sdk", default-features = false, features = ["rest", "google-rest-storage-v1"] }
gcloud-sdk = { path = "./../../gcloud-sdk", default-features = false, features = ["rest", "tls-roots", "google-rest-storage-v1", "google-rest-compute-v1"] }
tokio = { version = "1.20", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version ="0.3", features = ["env-filter"] }
Expand Down
69 changes: 67 additions & 2 deletions examples/gcs-rest-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
&google_rest_client.create_google_storage_v1_config().await?,
gcloud_sdk::google_rest_apis::storage_v1::buckets_api::StoragePeriodBucketsPeriodListParams {
project: google_project_id,
..Default::default()
alt: None,
fields: None,
key: None,
oauth_token: None,
pretty_print: None,
quota_user: None,
upload_type: None,
user_ip: None,
max_results: None,
page_token: None,
prefix: None,
projection: None,
user_project: None,
}
).await?;

println!("{:?}", response);

test_compute().await;

Ok(())
}

Expand All @@ -40,8 +54,25 @@ async fn test_upload(
&google_rest_client.create_google_storage_v1_config().await?,
gcloud_sdk::google_rest_apis::storage_v1::objects_api::StoragePeriodObjectsPeriodInsertParams {
bucket: bucket.to_string(),
alt: None,
fields: None,
key: None,
oauth_token: None,
pretty_print: None,
quota_user: None,
upload_type: None,
user_ip: None,
content_encoding: None,
if_generation_match: None,
if_generation_not_match: None,
if_metageneration_match: None,
if_metageneration_not_match: None,
kms_key_name: None,
name: Some(filename.to_string()),
..Default::default()
predefined_acl: None,
projection: None,
user_project: None,
object: None,
},
None,
"Hello".as_bytes().to_vec()
Expand All @@ -51,3 +82,37 @@ async fn test_upload(

Ok(())
}

async fn test_compute() {
let google_project_id = gcloud_sdk::GoogleEnvironment::detect_google_project_id().await
.expect("No Google Project ID detected. Please specify it explicitly using env variable: PROJECT_ID");

let google_rest_client = gcloud_sdk::GoogleRestApi::new().await.unwrap();

let response = gcloud_sdk::google_rest_apis::compute_v1::instances_api::compute_instances_list(
&google_rest_client.create_google_compute_v1_config().await.unwrap(),
gcloud_sdk::google_rest_apis::compute_v1::instances_api::ComputePeriodInstancesPeriodListParams {
project: google_project_id.to_string(),
zone: "us-central1-a".to_string(),
dollar_xgafv: None,
access_token: None,
alt: None,
callback: None,
fields: None,
key: None,
oauth_token: None,
pretty_print: None,
quota_user: None,
upload_protocol: None,
upload_type: None,
user_ip: None,
filter: None,
max_results: None,
order_by: None,
page_token: None,
return_partial_success: None,
}
).await.unwrap();

println!("{:?}", response);
}
4 changes: 2 additions & 2 deletions gcloud-protos-generator/openapi/generate-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SCRIPT_LOCATION=$( dirname -- "$0"; );
SPEC_LOCATIONS="$SCRIPT_LOCATION/google"
GENERATOR_LOCATION="$SCRIPT_LOCATION/generator/openapi-generator-cli-6.6.0.jar"
GENERATOR_LOCATION="$SCRIPT_LOCATION/generator/openapi-generator-cli-7.1.0.jar"
GCLOUD_SDK_DIR="$SCRIPT_LOCATION/../../gcloud-sdk"
TEMPLATES_DIR="$SCRIPT_LOCATION/templates"

Expand Down Expand Up @@ -32,7 +32,7 @@ do
do
echo "Found spec: $API_DIR_FILE"

java -jar "$GENERATOR_LOCATION" generate -i "$API_DIR_FILE" -g rust -o "$TEMP_OUTPUT/$API_NAME" --additional-properties=useSingleRequestParameter=true --additional-properties=packageName="$API_DIR_NAME"
java -DmaxYamlCodePoints=99999999 -jar "$GENERATOR_LOCATION" generate -i "$API_DIR_FILE" -g rust -o "$TEMP_OUTPUT/$API_NAME" --additional-properties=useSingleRequestParameter=true --additional-properties=packageName="$API_DIR_NAME"

sed -i "s/crate::apis/crate::google_rest_apis::$API_NAME::apis/g" "$TEMP_OUTPUT"/"$API_NAME"/src/apis/*.rs
sed -i "s/_period_/_/g" "$TEMP_OUTPUT"/"$API_NAME"/src/apis/*.rs
Expand Down
Loading

0 comments on commit e58cbb5

Please sign in to comment.