Skip to content

Commit b513748

Browse files
bmc-msftdemoray
andauthored
generate keyvault svc bindings (#418)
Co-authored-by: Brian Caswell <[email protected]>
1 parent 1ffa50b commit b513748

File tree

31 files changed

+59244
-15
lines changed

31 files changed

+59244
-15
lines changed

services/autorust/codegen/examples/gen_svc.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const SKIP_SERVICES: &[&str] = &[
1414
"machinelearningservices", // untagged enum
1515
"servicefabric", // currently generates `async` member names
1616
"hdinsight", // job_id appears multiple times?
17-
"keyvault", // `{field_name}` used in formatting url
1817
"videoanalyzer", // no operations
1918
"mediaservices", // no operations
2019
"marketplacecatalog", // BadRequest400 uses models::String?
@@ -28,9 +27,6 @@ const SKIP_SERVICE_TAGS: &[(&str, &str)] = &[
2827
("datalake-store", "package-2016-11"), // TODO #81 DataType::File
2928
("datalake-store", "package-2015-10-preview"), // TODO #81 DataType::File
3029
("purview", "package-2021-05-01-preview"), // untagged enum
31-
("keyvault", "package-preview-7.3-preview"), // parse error
32-
("keyvault", "package-7.2"), // parse error
33-
("keyvault", "package-7.2-preview"), // parse error
3430
("batch", "package-2018-03.6.1"), // TODO #81 DataType::File
3531
("batch", "package-2017-09.6.0"), // TODO #81 DataType::File
3632
("batch", "package-2017-06.5.1"), // TODO #81 DataType::File
@@ -69,16 +65,14 @@ const FIX_CASE_PROPERTIES: &[(&str, &str, &str)] = &[
6965
// https://github.com/ctaggart/autorust/issues/73
7066
const BOX_PROPERTIES: &[(&str, &str, &str)] = &[
7167
// keyvault
72-
(
73-
"../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.1/common.json",
74-
"Error",
75-
"innererror",
76-
),
77-
(
78-
"../../../azure-rest-api-specs/specification/applicationinsights/data-plane/Microsoft.Insights/preview/v1/AppInsights.json",
79-
"errorInfo",
80-
"innererror",
81-
),
68+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.0/keyvault.json" , "Error" , "innererror"),
69+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.1/common.json" , "Error" , "innererror"),
70+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.2-preview/common.json" , "Error" , "innererror"),
71+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.3-preview/common.json" , "Error" , "innererror"),
72+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/stable/2016-10-01/keyvault.json" , "Error" , "innererror"),
73+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.0/keyvault.json" , "Error" , "innererror"),
74+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.1/common.json" , "Error" , "innererror"),
75+
("../../../azure-rest-api-specs/specification/keyvault/data-plane/Microsoft.KeyVault/stable/7.2/common.json" , "Error" , "innererror"),
8276
// webpubsub
8377
(
8478
"../../../azure-rest-api-specs/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json",

services/autorust/codegen/src/codegen_models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn create_struct(cg: &CodeGen, doc_file: &Path, struct_name: &str, schema: &Reso
211211

212212
let (mut field_tp_name, field_tp) = create_struct_field_type(cg, doc_file, &ns, property_name, property, lowercase_workaround)?;
213213
// uncomment the next two lines to help identify entries that need boxed
214-
// let prop_nm_str = format!("{:?}", prop_nm);
214+
// let prop_nm_str = format!("{} , {} , {}", prop_nm.file_path.display(), prop_nm.schema_name, property_name);
215215
// props.extend(quote! { #[doc = #prop_nm_str ]});
216216

217217
if cg.should_force_obj(prop_nm) {

services/svc/keyvault/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# generated by AutoRust 0.1.0
2+
[package]
3+
name = "azure_svc_keyvault"
4+
version = "0.1.0"
5+
edition = "2018"
6+
7+
[dependencies]
8+
azure_core = { path = "../../../sdk/core", version = "0.1.0" }
9+
serde = { version = "1.0", features = ["derive"] }
10+
serde_json = "1.0"
11+
reqwest = { version = "0.11", features = ["json"] }
12+
bytes = "1.0"
13+
thiserror = "1.0"
14+
http = "0.2"
15+
url = "2.2"
16+
17+
[dev-dependencies]
18+
azure_identity = { path = "../../../sdk/identity", version = "0.1.0" }
19+
tokio = { version = "1.0", features = ["macros"] }
20+
21+
[features]
22+
default = ["package-7.2"]
23+
no-default-version = []
24+
"package-preview-7.3-preview" = []
25+
"package-7.2" = []
26+
"package-7.2-preview" = []
27+
"package-7.1" = []
28+
"package-7.1-preview" = []
29+
"package-7.0" = []
30+
"package-7.0-preview" = []
31+
"package-2016-10" = []
32+
"package-2015-06" = []

services/svc/keyvault/src/lib.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#![doc = "generated by AutoRust 0.1.0"]
2+
#[cfg(feature = "package-preview-7.3-preview")]
3+
pub mod package_preview_7_3_preview;
4+
#[cfg(all(feature = "package-preview-7.3-preview", not(feature = "no-default-version")))]
5+
pub use package_preview_7_3_preview::{models, operations};
6+
#[cfg(feature = "package-7.2")]
7+
pub mod package_7_2;
8+
#[cfg(all(feature = "package-7.2", not(feature = "no-default-version")))]
9+
pub use package_7_2::{models, operations};
10+
#[cfg(feature = "package-7.2-preview")]
11+
pub mod package_7_2_preview;
12+
#[cfg(all(feature = "package-7.2-preview", not(feature = "no-default-version")))]
13+
pub use package_7_2_preview::{models, operations};
14+
#[cfg(feature = "package-7.1")]
15+
pub mod package_7_1;
16+
#[cfg(all(feature = "package-7.1", not(feature = "no-default-version")))]
17+
pub use package_7_1::{models, operations};
18+
#[cfg(feature = "package-7.1-preview")]
19+
pub mod package_7_1_preview;
20+
#[cfg(all(feature = "package-7.1-preview", not(feature = "no-default-version")))]
21+
pub use package_7_1_preview::{models, operations};
22+
#[cfg(feature = "package-7.0")]
23+
pub mod package_7_0;
24+
#[cfg(all(feature = "package-7.0", not(feature = "no-default-version")))]
25+
pub use package_7_0::{models, operations};
26+
#[cfg(feature = "package-7.0-preview")]
27+
pub mod package_7_0_preview;
28+
#[cfg(all(feature = "package-7.0-preview", not(feature = "no-default-version")))]
29+
pub use package_7_0_preview::{models, operations};
30+
#[cfg(feature = "package-2016-10")]
31+
pub mod package_2016_10;
32+
#[cfg(all(feature = "package-2016-10", not(feature = "no-default-version")))]
33+
pub use package_2016_10::{models, operations};
34+
#[cfg(feature = "package-2015-06")]
35+
pub mod package_2015_06;
36+
use azure_core::setters;
37+
#[cfg(all(feature = "package-2015-06", not(feature = "no-default-version")))]
38+
pub use package_2015_06::{models, operations};
39+
pub fn config(
40+
http_client: std::sync::Arc<dyn azure_core::HttpClient>,
41+
token_credential: Box<dyn azure_core::TokenCredential>,
42+
) -> OperationConfigBuilder {
43+
OperationConfigBuilder {
44+
http_client,
45+
base_path: None,
46+
token_credential,
47+
token_credential_resource: None,
48+
}
49+
}
50+
pub struct OperationConfigBuilder {
51+
http_client: std::sync::Arc<dyn azure_core::HttpClient>,
52+
base_path: Option<String>,
53+
token_credential: Box<dyn azure_core::TokenCredential>,
54+
token_credential_resource: Option<String>,
55+
}
56+
impl OperationConfigBuilder {
57+
setters! { base_path : String => Some (base_path) , token_credential_resource : String => Some (token_credential_resource) , }
58+
pub fn build(self) -> OperationConfig {
59+
OperationConfig {
60+
http_client: self.http_client,
61+
base_path: self.base_path.unwrap_or("https://management.azure.com".to_owned()),
62+
token_credential: Some(self.token_credential),
63+
token_credential_resource: self.token_credential_resource.unwrap_or("https://management.azure.com/".to_owned()),
64+
}
65+
}
66+
}
67+
pub struct OperationConfig {
68+
http_client: std::sync::Arc<dyn azure_core::HttpClient>,
69+
base_path: String,
70+
token_credential: Option<Box<dyn azure_core::TokenCredential>>,
71+
token_credential_resource: String,
72+
}
73+
impl OperationConfig {
74+
pub fn http_client(&self) -> &dyn azure_core::HttpClient {
75+
self.http_client.as_ref()
76+
}
77+
pub fn base_path(&self) -> &str {
78+
self.base_path.as_str()
79+
}
80+
pub fn token_credential(&self) -> Option<&dyn azure_core::TokenCredential> {
81+
self.token_credential.as_deref()
82+
}
83+
pub fn token_credential_resource(&self) -> &str {
84+
self.token_credential_resource.as_str()
85+
}
86+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod models;
2+
pub mod operations;
3+
#[allow(dead_code)]
4+
pub const API_VERSION: &str = "2015-06-01";

0 commit comments

Comments
 (0)