Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to latest specs #1090

Merged
merged 9 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check-all-services.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions services/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.6 (2022-09)
- generated from azure-rest-api-specs [commit from 2022-09-08](https://github.com/Azure/azure-rest-api-specs/208c91dc71eec634400fb0c0a7e073e35afd2978)

# 0.5 (2022-08)
- generated from azure-rest-api-specs [commit from 2022-08-01](https://github.com/Azure/azure-rest-api-specs/commit/d1b0569d8adbd342a1111d6a69764d099f5f717c)

Expand Down
2 changes: 2 additions & 0 deletions services/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ members = [
"mgmt/hdinsight",
"mgmt/healthbot",
"mgmt/healthcareapis",
"mgmt/hybridaks",
"mgmt/hybridcompute",
"mgmt/hybridconnectivity",
"mgmt/hybriddatamanager",
Expand Down Expand Up @@ -221,6 +222,7 @@ members = [
"svc/containerregistry",
"svc/cosmosdb",
"svc/datalakeanalytics",
"svc/devcenter",
"svc/deviceprovisioningservices",
"svc/deviceupdate",
"svc/digitaltwins",
Expand Down
80 changes: 72 additions & 8 deletions services/autorust/codegen/src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ pub fn create(package_name: &str, tags: &[&Tag], default_tag: &Tag, has_xml: boo
}

pub fn get_default_tag<'a>(tags: &[&'a Tag], default_tag: Option<&str>) -> &'a Tag {
if let Some(default_tag) = default_tag {
if let Some(tag) = tags.iter().find(|tag| tag.name() == default_tag) {
return tag;
let default_tag = tags.iter().find(|tag| Some(tag.name()) == default_tag);
let is_preview = default_tag.map(|tag| tag.name().contains("preview")).unwrap_or_default();
let stable_tag = tags.iter().find(|tag| !tag.name().contains("preview"));
match (default_tag, is_preview, stable_tag) {
(Some(default_tag), false, _) => default_tag,
(Some(default_tag), true, None) => default_tag,
(Some(default_tag), true, Some(stable_tag)) => {
println!(
" WARN preview tag `{}` used instead of stable tag `{}`",
default_tag.name(),
stable_tag.name()
);
default_tag
}
}
let tag = tags.iter().find(|tag| !tag.name().contains("preview"));
match tag {
Some(tag) => tag,
None => tags[0],
(_, _, Some(tag)) => tag,
_ => tags[0],
}
}

Expand All @@ -53,3 +60,60 @@ pub fn get_default_tag<'a>(tags: &[&'a Tag], default_tag: Option<&str>) -> &'a T
// features.insert(0, NO_DEFAULT_TAG.to_owned());
// features
// }

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn default_tag_is_stable() -> Result<()> {
let tags = vec![
"package-preview-2022-05",
"package-2021-06",
"package-2020-09",
"package-2020-04",
"package-2019-12",
"package-2019-06-preview",
"package-2019-06",
"package-2019-04",
"package-2017-10",
"package-2017-04",
];
let tags: Vec<_> = tags.into_iter().map(Tag::new).collect();
let tags: Vec<_> = tags.iter().collect();
assert_eq!("package-2021-06", get_default_tag(&tags, None).name());
Ok(())
}

#[test]
fn specified_tag() -> Result<()> {
let tags = vec![
"package-preview-2022-05",
"package-2021-06",
"package-2020-09",
"package-2020-04",
"package-2019-12",
"package-2019-06-preview",
"package-2019-06",
"package-2019-04",
"package-2017-10",
"package-2017-04",
];
let tags: Vec<_> = tags.into_iter().map(Tag::new).collect();
let tags: Vec<_> = tags.iter().collect();
assert_eq!("package-2020-04", get_default_tag(&tags, Some("package-2020-04")).name());
Ok(())
}

#[test]
fn specified_preview() -> Result<()> {
let tags = vec!["package-preview-2022-05", "package-2019-06-preview", "package-2019-04-preview"];
let tags: Vec<_> = tags.into_iter().map(Tag::new).collect();
let tags: Vec<_> = tags.iter().collect();
assert_eq!(
"package-2019-06-preview",
get_default_tag(&tags, Some("package-2019-06-preview")).name()
);
Ok(())
}
}
6 changes: 3 additions & 3 deletions services/mgmt/advisor/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions services/mgmt/advisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ https://github.com/Azure/azure-rest-api-specs/blob/main/specification/advisor/re

To get started with these generated service crates, see the [examples](https://github.com/Azure/azure-sdk-for-rust/blob/main/services/README.md#examples).

The default tag is `package-2020-01`.
The default tag is `package-2022-09`.

The following [tags](https://github.com/Azure/azure-sdk-for-rust/blob/main/services/tags.md) are available:

- `package-2022-09` has 16 operations from 1 API versions: `2022-09-01`. Use crate feature `package-2022-09` to enable. The operations will be in the `package_2022_09` module.
- `package-2022-02-preview` has 2 operations from 1 API versions: `2022-02-01-preview`. Use crate feature `package-2022-02-preview` to enable. The operations will be in the `package_2022_02_preview` module.
- `package-2020-07-preview` has 3 operations from 1 API versions: `2020-07-01-preview`. Use crate feature `package-2020-07-preview` to enable. The operations will be in the `package_2020_07_preview` module.
- `package-2020-01` has 15 operations from 1 API versions: `2020-01-01`. Use crate feature `package-2020-01` to enable. The operations will be in the `package_2020_01` module.
- `package-2017-04` has 15 operations from 1 API versions: `2017-04-19`. Use crate feature `package-2017-04` to enable. The operations will be in the `package_2017_04` module.
- `package-2017-03` has 9 operations from 1 API versions: `2017-03-31`. Use crate feature `package-2017-03` to enable. The operations will be in the `package_2017_03` module.
- `package-2017-04` has 15 operations from 1 API versions: `2017-04-19`. Use crate feature `package-2017-04` to enable. The operations will be in the `package_2017_04` module.
8 changes: 4 additions & 4 deletions services/mgmt/advisor/src/lib.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading