Skip to content

Commit 46cc082

Browse files
authored
initial 100 service mgmt APIs generated by AutoRust (#31)
* add azure_mgmt_storage_v2019_06_01 * headers now generated * all local types in same mod * include referenced types * CamelCase for vec types * fix referenced schemas * add referenced schemas recursively * multiple input files ctaggart/autorust#38 * create local structs * move to rest/mgmt_storage/2019-06-01 * unlock build on other branches * add rest/rustfmt.toml * allOf & pub * optional params * default Configuration * added mgmt_storage 2020-08-01-preview * API_VERSION const * api-version from config * query params * map with Vec::is_empty * skip_serializing if readOnly * remove anyhow dependency ctaggart/autorust#26 * remove if statement around api-version param * switch services layout to be like go sdk * add compute_mgmt example * add body and header params * add avs_mgmt * group operations into modules * add resources mgmt * service api versions as features * add two examples * version modules * add avs_private_cloud_list example * vm_list example * switch name back to azure_mgmt_${service} #42 * many compute API versions * add 70 mgmt services * map all respones with error handling * +30 mgmt services, 100 total * use spec folder names * add readme for Azure Service Crates * fix vmware example & add examples to readme * add storage account list to readme * docs are hard
1 parent a6c38b5 commit 46cc082

File tree

1,425 files changed

+1122023
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,425 files changed

+1122023
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
22
members = [
33
"sdk/*",
4+
"services/mgmt/*",
45
]

services/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Azure Service Crates
2+
3+
Rust crates for accessing [Azure services](https://azure.microsoft.com/services/). These crates are client libraries generated by [AutoRust](https://github.com/ctaggart/autorust) using the web service [specifications](https://github.com/Azure/azure-rest-api-specs/tree/master/specification) found in Azure/azure-rest-api-specs. The specifications are divided into two categories - [control plane and data plane](https://docs.microsoft.com/azure/azure-resource-manager/management/control-plane-and-data-plane). "You use the control plane to manage resources in your subscription. You use the data plane to use capabilities exposed by your instance of a resource type."
4+
5+
There are 168 specifications. So far, we have generated 100 control plane crates. We expect that number to go up as AutoRust matures and bugs are fixed.
6+
7+
## Control Plane Crates
8+
The control plane crates are named `azure_mgmt_${specification_directory}`, such as `azure_mgmt_storage`. Each service may have multiple API versions. Each API version has a set of OpenAPI 2.0 documents, listed under a `Tag` in a [readme.md](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/readme.md) file in a `Conifguration` section. Sometimes there are multiple `Tag`s for the same API version. For example, [Tag: package-2018-07](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/readme.md#tag-package-2018-07) and [Tag: package-2018-07-only](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/readme.md#tag-package-2018-07-only). Rust code is generated for each tag and organized as a crate feature. The first tag without `-preview` is selected as the default feature:
9+
10+
``` toml
11+
[features]
12+
default = ["package-2019-06"]
13+
"package-2020-08-preview" = []
14+
"package-2019-06" = []
15+
"package-2019-04" = []
16+
"package-2018-11" = []
17+
"package-2018-07" = []
18+
"package-2018-07-only" = []
19+
"package-2018-03" = []
20+
"package-2018-02" = []
21+
"package-2017-10" = []
22+
"package-2017-06" = []
23+
"package-2016-12" = []
24+
"package-2016-05" = []
25+
"package-2016-01" = []
26+
"package-2015-06" = []
27+
"package-2015-05-preview" = []
28+
```
29+
30+
The default feature will be used when this dependency is specified:
31+
``` toml
32+
[dependencies]
33+
azure_mgmt_storage = { git = "https://github.com/Azure/azure-sdk-for-rust" }
34+
```
35+
36+
To use another tag, for example to try out the newer preview API, you must disable the default:
37+
``` toml
38+
[dependencies]
39+
azure_mgmt_storage = { git = "https://github.com/Azure/azure-sdk-for-rust", default-features = false, features = ["package-2020-08-preview"] }
40+
```
41+
42+
A few use cases require using more than tag. This can be done by [renaming the dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml):
43+
``` toml
44+
[dependencies]
45+
azure_mgmt_storage_2019_06 = { package = "azure_mgmt_storage", git = "https://github.com/Azure/azure-sdk-for-rust", default-features = false, features = ["package-2019-06"] }
46+
azure_mgmt_storage_2018_02 = { package = "azure_mgmt_storage", git = "https://github.com/Azure/azure-sdk-for-rust", default-features = false, features = ["package-2018-02"] }
47+
```
48+
49+
## Data Plane Crates
50+
The control plane crates will be named `azure_svc_${specification_directory}`, such as `azure_svc_storage`.
51+
52+
## Examples
53+
There are a few examples:
54+
- [mgmt/storage/examples/storage_account_list.rs](mgmt/storage/examples/storage_account_list.rs)
55+
- [mgmt/resources/examples/group_create.rs](mgmt/resources/examples/group_create.rs)
56+
- [mgmt/compute/examples/vm_list.rs](mgmt/compute/examples/vm_list.rs)
57+
- [mgmt/vmware/examples/vmware_private_cloud_list.rs](mgmt/vmware/examples/vmware_private_cloud_list.rs)

services/mgmt/addons/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# generated by AutoRust 0.1.0
2+
[package]
3+
name = "azure_mgmt_addons"
4+
version = "0.1.0"
5+
edition = "2018"
6+
7+
[dependencies]
8+
serde = { version = "1.0", features = ["derive"] }
9+
serde_json = "1.0"
10+
reqwest = { version = "0.10", features = ["json"] }
11+
bytes = "0.5"
12+
snafu = "0.6"
13+
14+
[dev-dependencies]
15+
tokio = { version = "0.2", features = ["macros"] }
16+
17+
[features]
18+
default = ["package-2018-03"]
19+
"package-2018-03" = []
20+
"package-2017-05" = []

services/mgmt/addons/src/lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![doc = "generated by AutoRust 0.1.0"]
2+
#[cfg(feature = "package-2018-03")]
3+
mod package_2018_03;
4+
#[cfg(feature = "package-2018-03")]
5+
pub use package_2018_03::{models, operations, API_VERSION};
6+
#[cfg(feature = "package-2017-05")]
7+
mod package_2017_05;
8+
#[cfg(feature = "package-2017-05")]
9+
pub use package_2017_05::{models, operations, API_VERSION};
10+
pub struct Configuration {
11+
pub api_version: String,
12+
pub client: reqwest::Client,
13+
pub base_path: String,
14+
pub bearer_access_token: Option<String>,
15+
}
16+
impl Configuration {
17+
pub fn new(bearer_access_token: &str) -> Self {
18+
Self {
19+
bearer_access_token: Some(bearer_access_token.to_owned()),
20+
..Default::default()
21+
}
22+
}
23+
}
24+
impl Default for Configuration {
25+
fn default() -> Self {
26+
Self {
27+
api_version: API_VERSION.to_owned(),
28+
client: reqwest::Client::new(),
29+
base_path: "https://management.azure.com".to_owned(),
30+
bearer_access_token: None,
31+
}
32+
}
33+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod models;
2+
pub mod operations;
3+
pub const API_VERSION: &str = "2017-05-15";
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#![doc = "generated by AutoRust 0.1.0"]
2+
#![allow(non_camel_case_types)]
3+
#![allow(unused_imports)]
4+
use crate::*;
5+
use serde::{Deserialize, Serialize};
6+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
7+
pub struct CanonicalSupportPlanProperties {
8+
#[serde(rename = "provisioningState", skip_serializing_if = "Option::is_none")]
9+
pub provisioning_state: Option<canonical_support_plan_properties::ProvisioningState>,
10+
}
11+
mod canonical_support_plan_properties {
12+
use super::*;
13+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
14+
pub enum ProvisioningState {
15+
Succeeded,
16+
Failed,
17+
Cancelled,
18+
Purchasing,
19+
Downgrading,
20+
Cancelling,
21+
Upgrading,
22+
}
23+
}
24+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
25+
pub struct CanonicalSupportPlanResponseEnvelope {
26+
#[serde(skip_serializing)]
27+
pub id: Option<String>,
28+
#[serde(skip_serializing)]
29+
pub name: Option<String>,
30+
#[serde(rename = "type", skip_serializing)]
31+
pub type_: Option<String>,
32+
pub properties: CanonicalSupportPlanProperties,
33+
}
34+
pub type CanonicalSupportPlanStatus = Vec<serde_json::Value>;
35+
pub type OperationList = Vec<OperationsDefinition>;
36+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
37+
pub struct OperationsDefinition {
38+
#[serde(skip_serializing_if = "Option::is_none")]
39+
pub name: Option<String>,
40+
#[serde(skip_serializing_if = "Option::is_none")]
41+
pub display: Option<OperationsDisplayDefinition>,
42+
}
43+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
44+
pub struct OperationsDisplayDefinition {
45+
#[serde(skip_serializing_if = "Option::is_none")]
46+
pub provider: Option<String>,
47+
#[serde(skip_serializing_if = "Option::is_none")]
48+
pub resource: Option<String>,
49+
#[serde(skip_serializing_if = "Option::is_none")]
50+
pub operation: Option<String>,
51+
#[serde(skip_serializing_if = "Option::is_none")]
52+
pub description: Option<String>,
53+
}
54+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
55+
pub struct ErrorDefinition {
56+
pub message: String,
57+
pub code: i64,
58+
}

0 commit comments

Comments
 (0)