#![doc = "generated by AutoRust"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(clippy::redundant_clone)]
use super::models;
#[derive(Clone)]
pub struct Client {
endpoint: String,
credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>,
scopes: Vec<String>,
pipeline: azure_core::Pipeline,
}
#[derive(Clone)]
pub struct ClientBuilder {
credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>,
endpoint: Option<String>,
scopes: Option<Vec<String>>,
}
pub const DEFAULT_ENDPOINT: &str = azure_core::resource_manager_endpoint::AZURE_PUBLIC_CLOUD;
impl ClientBuilder {
pub fn new(credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>) -> Self {
Self {
credential,
endpoint: None,
scopes: None,
}
}
pub fn endpoint(mut self, endpoint: impl Into<String>) -> Self {
self.endpoint = Some(endpoint.into());
self
}
pub fn scopes(mut self, scopes: &[&str]) -> Self {
self.scopes = Some(scopes.iter().map(|scope| (*scope).to_owned()).collect());
self
}
pub fn build(self) -> Client {
let endpoint = self.endpoint.unwrap_or_else(|| DEFAULT_ENDPOINT.to_owned());
let scopes = self.scopes.unwrap_or_else(|| vec![format!("{}/", endpoint)]);
Client::new(endpoint, self.credential, scopes)
}
}
impl Client {
pub(crate) fn endpoint(&self) -> &str {
self.endpoint.as_str()
}
pub(crate) fn token_credential(&self) -> &dyn azure_core::auth::TokenCredential {
self.credential.as_ref()
}
pub(crate) fn scopes(&self) -> Vec<&str> {
self.scopes.iter().map(String::as_str).collect()
}
pub(crate) async fn send(&self, request: impl Into<azure_core::Request>) -> azure_core::error::Result<azure_core::Response> {
let mut context = azure_core::Context::default();
let mut request = request.into();
self.pipeline.send(&mut context, &mut request).await
}
pub fn new(
endpoint: impl Into<String>,
credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>,
scopes: Vec<String>,
) -> Self {
let endpoint = endpoint.into();
let pipeline = azure_core::Pipeline::new(
option_env!("CARGO_PKG_NAME"),
option_env!("CARGO_PKG_VERSION"),
azure_core::ClientOptions::default(),
Vec::new(),
Vec::new(),
);
Self {
endpoint,
credential,
scopes,
pipeline,
}
}
pub fn entities(&self) -> entities::Client {
entities::Client(self.clone())
}
pub fn hierarchy_settings(&self) -> hierarchy_settings::Client {
hierarchy_settings::Client(self.clone())
}
pub fn management_group_subscriptions(&self) -> management_group_subscriptions::Client {
management_group_subscriptions::Client(self.clone())
}
pub fn management_groups(&self) -> management_groups::Client {
management_groups::Client(self.clone())
}
pub fn operations(&self) -> operations::Client {
operations::Client(self.clone())
}
}
pub mod management_groups {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
pub fn list(&self) -> list::Builder {
list::Builder {
client: self.0.clone(),
cache_control: None,
skiptoken: None,
}
}
pub fn get(&self, group_id: impl Into<String>) -> get::Builder {
get::Builder {
client: self.0.clone(),
group_id: group_id.into(),
expand: None,
recurse: None,
filter: None,
cache_control: None,
}
}
pub fn create_or_update(
&self,
group_id: impl Into<String>,
create_management_group_request: impl Into<models::CreateManagementGroupRequest>,
) -> create_or_update::Builder {
create_or_update::Builder {
client: self.0.clone(),
group_id: group_id.into(),
create_management_group_request: create_management_group_request.into(),
cache_control: None,
}
}
pub fn update(
&self,
group_id: impl Into<String>,
patch_group_request: impl Into<models::PatchManagementGroupRequest>,
) -> update::Builder {
update::Builder {
client: self.0.clone(),
group_id: group_id.into(),
patch_group_request: patch_group_request.into(),
cache_control: None,
}
}
pub fn delete(&self, group_id: impl Into<String>) -> delete::Builder {
delete::Builder {
client: self.0.clone(),
group_id: group_id.into(),
cache_control: None,
}
}
pub fn get_descendants(&self, group_id: impl Into<String>) -> get_descendants::Builder {
get_descendants::Builder {
client: self.0.clone(),
group_id: group_id.into(),
skiptoken: None,
top: None,
}
}
}
pub mod list {
use super::models;
use azure_core::error::ResultExt;
type Response = models::ManagementGroupListResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) cache_control: Option<String>,
pub(crate) skiptoken: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn skiptoken(mut self, skiptoken: impl Into<String>) -> Self {
self.skiptoken = Some(skiptoken.into());
self
}
pub fn into_stream(self) -> azure_core::Pageable<Response, azure_core::error::Error> {
let make_request = move |continuation: Option<azure_core::prelude::Continuation>| {
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/managementGroups", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::Other, "build request")?;
let mut req_builder = http::request::Builder::new();
let rsp = match continuation {
Some(token) => {
url.set_path("");
url = url
.join(&token.into_raw())
.context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let has_api_version_already = url.query_pairs().any(|(k, _)| k == "api-version");
if !has_api_version_already {
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
}
req_builder = req_builder.uri(url.as_str());
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
let req_body = azure_core::EMPTY_BODY;
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
None => {
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
if let Some(skiptoken) = &this.skiptoken {
url.query_pairs_mut().append_pair("$skiptoken", skiptoken);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
};
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::ManagementGroupListResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get {
use super::models;
use azure_core::error::ResultExt;
type Response = models::ManagementGroup;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) expand: Option<String>,
pub(crate) recurse: Option<bool>,
pub(crate) filter: Option<String>,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn expand(mut self, expand: impl Into<String>) -> Self {
self.expand = Some(expand.into());
self
}
pub fn recurse(mut self, recurse: bool) -> Self {
self.recurse = Some(recurse);
self
}
pub fn filter(mut self, filter: impl Into<String>) -> Self {
self.filter = Some(filter.into());
self
}
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(expand) = &this.expand {
url.query_pairs_mut().append_pair("$expand", expand);
}
if let Some(recurse) = &this.recurse {
url.query_pairs_mut().append_pair("$recurse", &recurse.to_string());
}
if let Some(filter) = &this.filter {
url.query_pairs_mut().append_pair("$filter", filter);
}
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::ManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod create_or_update {
use super::models;
use azure_core::error::ResultExt;
#[derive(Debug)]
pub enum Response {
Ok200(models::ManagementGroup),
Accepted202(models::AzureAsyncOperationResults),
}
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) create_management_group_request: models::CreateManagementGroupRequest,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::PUT);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
req_builder = req_builder.header("content-type", "application/json");
let req_body = azure_core::to_json(&this.create_management_group_request)?;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::ManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(Response::Ok200(rsp_value))
}
http::StatusCode::ACCEPTED => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::AzureAsyncOperationResults = serde_json::from_slice(&rsp_body)?;
Ok(Response::Accepted202(rsp_value))
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod update {
use super::models;
use azure_core::error::ResultExt;
type Response = models::ManagementGroup;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) patch_group_request: models::PatchManagementGroupRequest,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::PATCH);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
req_builder = req_builder.header("content-type", "application/json");
let req_body = azure_core::to_json(&this.patch_group_request)?;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::ManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod delete {
use super::models;
use azure_core::error::ResultExt;
#[derive(Debug)]
pub enum Response {
Accepted202(models::AzureAsyncOperationResults),
NoContent204,
}
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::DELETE);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::ACCEPTED => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::AzureAsyncOperationResults = serde_json::from_slice(&rsp_body)?;
Ok(Response::Accepted202(rsp_value))
}
http::StatusCode::NO_CONTENT => Ok(Response::NoContent204),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod get_descendants {
use super::models;
use azure_core::error::ResultExt;
type Response = models::DescendantListResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) skiptoken: Option<String>,
pub(crate) top: Option<i64>,
}
impl Builder {
pub fn skiptoken(mut self, skiptoken: impl Into<String>) -> Self {
self.skiptoken = Some(skiptoken.into());
self
}
pub fn top(mut self, top: i64) -> Self {
self.top = Some(top);
self
}
pub fn into_stream(self) -> azure_core::Pageable<Response, azure_core::error::Error> {
let make_request = move |continuation: Option<azure_core::prelude::Continuation>| {
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/descendants",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::Other, "build request")?;
let mut req_builder = http::request::Builder::new();
let rsp = match continuation {
Some(token) => {
url.set_path("");
url = url
.join(&token.into_raw())
.context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let has_api_version_already = url.query_pairs().any(|(k, _)| k == "api-version");
if !has_api_version_already {
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
}
req_builder = req_builder.uri(url.as_str());
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
let req_body = azure_core::EMPTY_BODY;
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
None => {
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(skiptoken) = &this.skiptoken {
url.query_pairs_mut().append_pair("$skiptoken", skiptoken);
}
if let Some(top) = &this.top {
url.query_pairs_mut().append_pair("$top", &top.to_string());
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
};
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::DescendantListResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
};
azure_core::Pageable::new(make_request)
}
}
}
}
pub mod management_group_subscriptions {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
pub fn get_subscription(&self, group_id: impl Into<String>, subscription_id: impl Into<String>) -> get_subscription::Builder {
get_subscription::Builder {
client: self.0.clone(),
group_id: group_id.into(),
subscription_id: subscription_id.into(),
cache_control: None,
}
}
pub fn create(&self, group_id: impl Into<String>, subscription_id: impl Into<String>) -> create::Builder {
create::Builder {
client: self.0.clone(),
group_id: group_id.into(),
subscription_id: subscription_id.into(),
cache_control: None,
}
}
pub fn delete(&self, group_id: impl Into<String>, subscription_id: impl Into<String>) -> delete::Builder {
delete::Builder {
client: self.0.clone(),
group_id: group_id.into(),
subscription_id: subscription_id.into(),
cache_control: None,
}
}
pub fn get_subscriptions_under_management_group(
&self,
group_id: impl Into<String>,
) -> get_subscriptions_under_management_group::Builder {
get_subscriptions_under_management_group::Builder {
client: self.0.clone(),
group_id: group_id.into(),
skiptoken: None,
}
}
}
pub mod get_subscription {
use super::models;
use azure_core::error::ResultExt;
type Response = models::SubscriptionUnderManagementGroup;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) subscription_id: String,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/subscriptions/{}",
this.client.endpoint(),
&this.group_id,
&this.subscription_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::SubscriptionUnderManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod create {
use super::models;
use azure_core::error::ResultExt;
type Response = models::SubscriptionUnderManagementGroup;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) subscription_id: String,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/subscriptions/{}",
this.client.endpoint(),
&this.group_id,
&this.subscription_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::PUT);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::SubscriptionUnderManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod delete {
use super::models;
use azure_core::error::ResultExt;
#[derive(Debug)]
pub enum Response {
Ok200,
NoContent204,
}
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) subscription_id: String,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/subscriptions/{}",
this.client.endpoint(),
&this.group_id,
&this.subscription_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::DELETE);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => Ok(Response::Ok200),
http::StatusCode::NO_CONTENT => Ok(Response::NoContent204),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod get_subscriptions_under_management_group {
use super::models;
use azure_core::error::ResultExt;
type Response = models::ListSubscriptionUnderManagementGroup;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) skiptoken: Option<String>,
}
impl Builder {
pub fn skiptoken(mut self, skiptoken: impl Into<String>) -> Self {
self.skiptoken = Some(skiptoken.into());
self
}
pub fn into_stream(self) -> azure_core::Pageable<Response, azure_core::error::Error> {
let make_request = move |continuation: Option<azure_core::prelude::Continuation>| {
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/subscriptions",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::Other, "build request")?;
let mut req_builder = http::request::Builder::new();
let rsp = match continuation {
Some(token) => {
url.set_path("");
url = url
.join(&token.into_raw())
.context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let has_api_version_already = url.query_pairs().any(|(k, _)| k == "api-version");
if !has_api_version_already {
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
}
req_builder = req_builder.uri(url.as_str());
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
let req_body = azure_core::EMPTY_BODY;
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
None => {
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(skiptoken) = &this.skiptoken {
url.query_pairs_mut().append_pair("$skiptoken", skiptoken);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
};
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::ListSubscriptionUnderManagementGroup = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
};
azure_core::Pageable::new(make_request)
}
}
}
}
pub mod hierarchy_settings {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
pub fn list(&self, group_id: impl Into<String>) -> list::Builder {
list::Builder {
client: self.0.clone(),
group_id: group_id.into(),
}
}
pub fn get(&self, group_id: impl Into<String>) -> get::Builder {
get::Builder {
client: self.0.clone(),
group_id: group_id.into(),
}
}
pub fn create_or_update(
&self,
group_id: impl Into<String>,
create_tenant_settings_request: impl Into<models::CreateOrUpdateSettingsRequest>,
) -> create_or_update::Builder {
create_or_update::Builder {
client: self.0.clone(),
group_id: group_id.into(),
create_tenant_settings_request: create_tenant_settings_request.into(),
}
}
pub fn update(
&self,
group_id: impl Into<String>,
create_tenant_settings_request: impl Into<models::CreateOrUpdateSettingsRequest>,
) -> update::Builder {
update::Builder {
client: self.0.clone(),
group_id: group_id.into(),
create_tenant_settings_request: create_tenant_settings_request.into(),
}
}
pub fn delete(&self, group_id: impl Into<String>) -> delete::Builder {
delete::Builder {
client: self.0.clone(),
group_id: group_id.into(),
}
}
}
pub mod list {
use super::models;
use azure_core::error::ResultExt;
type Response = models::HierarchySettingsList;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/settings",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::HierarchySettingsList = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod get {
use super::models;
use azure_core::error::ResultExt;
type Response = models::HierarchySettings;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/settings/default",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::HierarchySettings = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod create_or_update {
use super::models;
use azure_core::error::ResultExt;
type Response = models::HierarchySettings;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) create_tenant_settings_request: models::CreateOrUpdateSettingsRequest,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/settings/default",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::PUT);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
req_builder = req_builder.header("content-type", "application/json");
let req_body = azure_core::to_json(&this.create_tenant_settings_request)?;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::HierarchySettings = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod update {
use super::models;
use azure_core::error::ResultExt;
type Response = models::HierarchySettings;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
pub(crate) create_tenant_settings_request: models::CreateOrUpdateSettingsRequest,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/settings/default",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::PATCH);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
req_builder = req_builder.header("content-type", "application/json");
let req_body = azure_core::to_json(&this.create_tenant_settings_request)?;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::HierarchySettings = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod delete {
use super::models;
use azure_core::error::ResultExt;
type Response = ();
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) group_id: String,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!(
"{}/providers/Microsoft.Management/managementGroups/{}/settings/default",
this.client.endpoint(),
&this.group_id
);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::DELETE);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => Ok(()),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
}
pub mod operations {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
pub fn list(&self) -> list::Builder {
list::Builder { client: self.0.clone() }
}
}
pub mod list {
use super::models;
use azure_core::error::ResultExt;
type Response = models::OperationListResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
}
impl Builder {
pub fn into_stream(self) -> azure_core::Pageable<Response, azure_core::error::Error> {
let make_request = move |continuation: Option<azure_core::prelude::Continuation>| {
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/operations", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::Other, "build request")?;
let mut req_builder = http::request::Builder::new();
let rsp = match continuation {
Some(token) => {
url.set_path("");
url = url
.join(&token.into_raw())
.context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let has_api_version_already = url.query_pairs().any(|(k, _)| k == "api-version");
if !has_api_version_already {
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
}
req_builder = req_builder.uri(url.as_str());
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
let req_body = azure_core::EMPTY_BODY;
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
None => {
req_builder = req_builder.method(http::Method::GET);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
};
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::OperationListResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
};
azure_core::Pageable::new(make_request)
}
}
}
}
impl Client {
pub fn check_name_availability(
&self,
check_name_availability_request: impl Into<models::CheckNameAvailabilityRequest>,
) -> check_name_availability::Builder {
check_name_availability::Builder {
client: self.clone(),
check_name_availability_request: check_name_availability_request.into(),
}
}
pub fn start_tenant_backfill(&self) -> start_tenant_backfill::Builder {
start_tenant_backfill::Builder { client: self.clone() }
}
pub fn tenant_backfill_status(&self) -> tenant_backfill_status::Builder {
tenant_backfill_status::Builder { client: self.clone() }
}
}
pub mod check_name_availability {
use super::models;
use azure_core::error::ResultExt;
type Response = models::CheckNameAvailabilityResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::Client,
pub(crate) check_name_availability_request: models::CheckNameAvailabilityRequest,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/checkNameAvailability", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::POST);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
req_builder = req_builder.header("content-type", "application/json");
let req_body = azure_core::to_json(&this.check_name_availability_request)?;
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::CheckNameAvailabilityResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod start_tenant_backfill {
use super::models;
use azure_core::error::ResultExt;
type Response = models::TenantBackfillStatusResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::Client,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/startTenantBackfill", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::POST);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.header(http::header::CONTENT_LENGTH, 0);
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::TenantBackfillStatusResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod tenant_backfill_status {
use super::models;
use azure_core::error::ResultExt;
type Response = models::TenantBackfillStatusResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::Client,
}
impl Builder {
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::error::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/tenantBackfillStatus", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let mut req_builder = http::request::Builder::new();
req_builder = req_builder.method(http::Method::POST);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder = req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.header(http::header::CONTENT_LENGTH, 0);
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
let rsp = this
.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?;
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::TenantBackfillStatusResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
})
}
}
}
pub mod entities {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
pub fn list(&self) -> list::Builder {
list::Builder {
client: self.0.clone(),
skiptoken: None,
skip: None,
top: None,
select: None,
search: None,
filter: None,
view: None,
group_name: None,
cache_control: None,
}
}
}
pub mod list {
use super::models;
use azure_core::error::ResultExt;
type Response = models::EntityListResult;
#[derive(Clone)]
pub struct Builder {
pub(crate) client: super::super::Client,
pub(crate) skiptoken: Option<String>,
pub(crate) skip: Option<i64>,
pub(crate) top: Option<i64>,
pub(crate) select: Option<String>,
pub(crate) search: Option<String>,
pub(crate) filter: Option<String>,
pub(crate) view: Option<String>,
pub(crate) group_name: Option<String>,
pub(crate) cache_control: Option<String>,
}
impl Builder {
pub fn skiptoken(mut self, skiptoken: impl Into<String>) -> Self {
self.skiptoken = Some(skiptoken.into());
self
}
pub fn skip(mut self, skip: i64) -> Self {
self.skip = Some(skip);
self
}
pub fn top(mut self, top: i64) -> Self {
self.top = Some(top);
self
}
pub fn select(mut self, select: impl Into<String>) -> Self {
self.select = Some(select.into());
self
}
pub fn search(mut self, search: impl Into<String>) -> Self {
self.search = Some(search.into());
self
}
pub fn filter(mut self, filter: impl Into<String>) -> Self {
self.filter = Some(filter.into());
self
}
pub fn view(mut self, view: impl Into<String>) -> Self {
self.view = Some(view.into());
self
}
pub fn group_name(mut self, group_name: impl Into<String>) -> Self {
self.group_name = Some(group_name.into());
self
}
pub fn cache_control(mut self, cache_control: impl Into<String>) -> Self {
self.cache_control = Some(cache_control.into());
self
}
pub fn into_stream(self) -> azure_core::Pageable<Response, azure_core::error::Error> {
let make_request = move |continuation: Option<azure_core::prelude::Continuation>| {
let this = self.clone();
async move {
let url_str = &format!("{}/providers/Microsoft.Management/getEntities", this.client.endpoint(),);
let mut url = url::Url::parse(url_str).context(azure_core::error::ErrorKind::Other, "build request")?;
let mut req_builder = http::request::Builder::new();
let rsp = match continuation {
Some(token) => {
url.set_path("");
url = url
.join(&token.into_raw())
.context(azure_core::error::ErrorKind::DataConversion, "parse url")?;
let has_api_version_already = url.query_pairs().any(|(k, _)| k == "api-version");
if !has_api_version_already {
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
}
req_builder = req_builder.uri(url.as_str());
req_builder = req_builder.method(http::Method::POST);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
let req_body = azure_core::EMPTY_BODY;
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
None => {
req_builder = req_builder.method(http::Method::POST);
let credential = this.client.token_credential();
let token_response = credential
.get_token(&this.client.scopes().join(" "))
.await
.context(azure_core::error::ErrorKind::Other, "get bearer token")?;
req_builder =
req_builder.header(http::header::AUTHORIZATION, format!("Bearer {}", token_response.token.secret()));
url.query_pairs_mut().append_pair("api-version", "2021-04-01");
if let Some(skiptoken) = &this.skiptoken {
url.query_pairs_mut().append_pair("$skiptoken", skiptoken);
}
if let Some(skip) = &this.skip {
url.query_pairs_mut().append_pair("$skip", &skip.to_string());
}
if let Some(top) = &this.top {
url.query_pairs_mut().append_pair("$top", &top.to_string());
}
if let Some(select) = &this.select {
url.query_pairs_mut().append_pair("$select", select);
}
if let Some(search) = &this.search {
url.query_pairs_mut().append_pair("$search", search);
}
if let Some(filter) = &this.filter {
url.query_pairs_mut().append_pair("$filter", filter);
}
if let Some(view) = &this.view {
url.query_pairs_mut().append_pair("$view", view);
}
if let Some(group_name) = &this.group_name {
url.query_pairs_mut().append_pair("groupName", group_name);
}
if let Some(cache_control) = &this.cache_control {
req_builder = req_builder.header("Cache-Control", cache_control);
}
let req_body = azure_core::EMPTY_BODY;
req_builder = req_builder.header(http::header::CONTENT_LENGTH, 0);
req_builder = req_builder.uri(url.as_str());
let req = req_builder
.body(req_body)
.context(azure_core::error::ErrorKind::Other, "build request")?;
this.client
.send(req)
.await
.context(azure_core::error::ErrorKind::Io, "execute request")?
}
};
let (rsp_status, rsp_headers, rsp_stream) = rsp.deconstruct();
match rsp_status {
http::StatusCode::OK => {
let rsp_body = azure_core::collect_pinned_stream(rsp_stream).await?;
let rsp_value: models::EntityListResult = serde_json::from_slice(&rsp_body)?;
Ok(rsp_value)
}
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code.as_u16(),
error_code: None,
})),
}
}
};
azure_core::Pageable::new(make_request)
}
}
}
}