#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(clippy::redundant_clone)]
pub mod 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>>,
options: azure_core::ClientOptions,
}
pub const DEFAULT_ENDPOINT: &str = azure_core::resource_manager_endpoint::AZURE_PUBLIC_CLOUD;
impl ClientBuilder {
#[doc = "Create a new instance of `ClientBuilder`."]
#[must_use]
pub fn new(credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>) -> Self {
Self {
credential,
endpoint: None,
scopes: None,
options: azure_core::ClientOptions::default(),
}
}
#[doc = "Set the endpoint."]
#[must_use]
pub fn endpoint(mut self, endpoint: impl Into<String>) -> Self {
self.endpoint = Some(endpoint.into());
self
}
#[doc = "Set the scopes."]
#[must_use]
pub fn scopes(mut self, scopes: &[&str]) -> Self {
self.scopes = Some(scopes.iter().map(|scope| (*scope).to_owned()).collect());
self
}
#[doc = "Set the retry options."]
#[must_use]
pub fn retry(mut self, retry: impl Into<azure_core::RetryOptions>) -> Self {
self.options = self.options.retry(retry);
self
}
#[doc = "Set the transport options."]
#[must_use]
pub fn transport(mut self, transport: impl Into<azure_core::TransportOptions>) -> Self {
self.options = self.options.transport(transport);
self
}
#[doc = "Convert the builder into a `Client` instance."]
#[must_use]
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, self.options)
}
}
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: &mut azure_core::Request) -> azure_core::Result<azure_core::Response> {
let mut context = azure_core::Context::default();
self.pipeline.send(&mut context, request).await
}
#[doc = "Create a new `ClientBuilder`."]
#[must_use]
pub fn builder(credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>) -> ClientBuilder {
ClientBuilder::new(credential)
}
#[doc = "Create a new `Client`."]
#[must_use]
pub fn new(
endpoint: impl Into<String>,
credential: std::sync::Arc<dyn azure_core::auth::TokenCredential>,
scopes: Vec<String>,
options: azure_core::ClientOptions,
) -> Self {
let endpoint = endpoint.into();
let pipeline = azure_core::Pipeline::new(
option_env!("CARGO_PKG_NAME"),
option_env!("CARGO_PKG_VERSION"),
options,
Vec::new(),
Vec::new(),
);
Self {
endpoint,
credential,
scopes,
pipeline,
}
}
pub fn billing_subscriptions_client(&self) -> billing_subscriptions::Client {
billing_subscriptions::Client(self.clone())
}
pub fn billing_subscriptions_aliases_client(&self) -> billing_subscriptions_aliases::Client {
billing_subscriptions_aliases::Client(self.clone())
}
pub fn operations_client(&self) -> operations::Client {
operations::Client(self.clone())
}
pub fn payment_methods_client(&self) -> payment_methods::Client {
payment_methods::Client(self.clone())
}
}
pub mod billing_subscriptions {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
#[doc = "Lists the subscriptions for a billing account. The operation is currently supported for billing accounts with agreement type Microsoft Customer Agreement, Microsoft Partner Agreement and Microsoft Online Services Program."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
pub fn list_by_billing_account(&self, billing_account_name: impl Into<String>) -> list_by_billing_account::RequestBuilder {
list_by_billing_account::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
}
}
#[doc = "Gets a subscription by its ID. The operation is currently supported for billing accounts with agreement type Microsoft Customer Agreement, Microsoft Partner Agreement and Microsoft Online Services Program."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
pub fn get(&self, billing_account_name: impl Into<String>, billing_subscription_name: impl Into<String>) -> get::RequestBuilder {
get::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
}
}
#[doc = "Updates the properties of a billing subscription."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
#[doc = "* `parameters`: Request parameters that are provided to the update billing subscription operation."]
pub fn update(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
parameters: impl Into<models::BillingSubscription>,
) -> update::RequestBuilder {
update::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
parameters: parameters.into(),
}
}
#[doc = "Cancels a billing subscription."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
pub fn delete(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
) -> delete::RequestBuilder {
delete::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
}
}
#[doc = "Moves a subscription's charges to a new invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
#[doc = "* `parameters`: Request parameters that are provided to the move subscription operation."]
pub fn move_(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
parameters: impl Into<models::MoveBillingSubscriptionRequest>,
) -> move_::RequestBuilder {
move_::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
parameters: parameters.into(),
}
}
#[doc = "Validates if a subscription's charges can be moved to a new invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
#[doc = "* `parameters`: Request parameters that are provided to the validate move eligibility operation."]
pub fn validate_move_eligibility(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
parameters: impl Into<models::MoveBillingSubscriptionRequest>,
) -> validate_move_eligibility::RequestBuilder {
validate_move_eligibility::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
parameters: parameters.into(),
}
}
#[doc = "Merges the billing subscription provided in the request with a target billing subscription."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
#[doc = "* `parameters`: Request parameters that are provided to merge the two billing subscriptions."]
pub fn merge(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
parameters: impl Into<models::BillingSubscriptionMergeRequest>,
) -> merge::RequestBuilder {
merge::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
parameters: parameters.into(),
}
}
#[doc = "Splits a subscription into a new subscription with quantity less than current subscription quantity and not equal to 0."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_subscription_name`: The ID that uniquely identifies a subscription."]
#[doc = "* `parameters`: Request parameters that are provided to split the billing subscription."]
pub fn split(
&self,
billing_account_name: impl Into<String>,
billing_subscription_name: impl Into<String>,
parameters: impl Into<models::BillingSubscriptionSplitRequest>,
) -> split::RequestBuilder {
split::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_subscription_name: billing_subscription_name.into(),
parameters: parameters.into(),
}
}
}
pub mod list_by_billing_account {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscriptionsListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscriptionsListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::BillingSubscriptionsListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions",
this.client.endpoint(),
&this.billing_account_name
))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscription> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscription = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscription>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod update {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscription> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscription = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
pub fn headers(&self) -> Headers {
Headers(self.0.headers())
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
pub struct Headers<'a>(&'a azure_core::headers::Headers);
impl<'a> Headers<'a> {
#[doc = "Location URI to poll for result"]
pub fn location(&self) -> azure_core::Result<&str> {
self.0.get_str(&azure_core::headers::HeaderName::from_static("location"))
}
#[doc = "Recommended time to wait before making another request to check the status of the operation. The time is specified in seconds."]
pub fn retry_after(&self) -> azure_core::Result<i64> {
self.0.get_as(&azure_core::headers::HeaderName::from_static("retry-after"))
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
pub(crate) parameters: models::BillingSubscription,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Patch);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscription>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod delete {
use super::models;
pub struct Response(azure_core::Response);
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Delete);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
}
}
pub mod move_ {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscription> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscription = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
pub fn headers(&self) -> Headers {
Headers(self.0.headers())
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
pub struct Headers<'a>(&'a azure_core::headers::Headers);
impl<'a> Headers<'a> {
#[doc = "Location URI to poll for result."]
pub fn location(&self) -> azure_core::Result<&str> {
self.0.get_str(&azure_core::headers::HeaderName::from_static("location"))
}
#[doc = "Recommended time to wait before making another request to check the status of the operation. The time is specified in seconds."]
pub fn retry_after(&self) -> azure_core::Result<i32> {
self.0.get_as(&azure_core::headers::HeaderName::from_static("retry-after"))
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
pub(crate) parameters: models::MoveBillingSubscriptionRequest,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}/move",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Post);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscription>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod validate_move_eligibility {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::ValidateMoveBillingSubscriptionEligibilityResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::ValidateMoveBillingSubscriptionEligibilityResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
pub(crate) parameters: models::MoveBillingSubscriptionRequest,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}/validateMoveEligibility",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Post);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(
self,
) -> futures::future::BoxFuture<'static, azure_core::Result<models::ValidateMoveBillingSubscriptionEligibilityResult>>
{
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod merge {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscription> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscription = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
pub fn headers(&self) -> Headers {
Headers(self.0.headers())
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
pub struct Headers<'a>(&'a azure_core::headers::Headers);
impl<'a> Headers<'a> {
#[doc = "Location URI to poll for result."]
pub fn location(&self) -> azure_core::Result<&str> {
self.0.get_str(&azure_core::headers::HeaderName::from_static("location"))
}
#[doc = "Recommended time to wait before making another request to check the status of the operation. The time is specified in seconds."]
pub fn retry_after(&self) -> azure_core::Result<i64> {
self.0.get_as(&azure_core::headers::HeaderName::from_static("retry-after"))
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
pub(crate) parameters: models::BillingSubscriptionMergeRequest,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}/merge",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Post);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscription>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod split {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscription> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscription = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
pub fn headers(&self) -> Headers {
Headers(self.0.headers())
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
pub struct Headers<'a>(&'a azure_core::headers::Headers);
impl<'a> Headers<'a> {
#[doc = "Location URI to poll for result."]
pub fn location(&self) -> azure_core::Result<&str> {
self.0.get_str(&azure_core::headers::HeaderName::from_static("location"))
}
#[doc = "Recommended time to wait before making another request to check the status of the operation. The time is specified in seconds."]
pub fn retry_after(&self) -> azure_core::Result<i64> {
self.0.get_as(&azure_core::headers::HeaderName::from_static("retry-after"))
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_subscription_name: String,
pub(crate) parameters: models::BillingSubscriptionSplitRequest,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptions/{}/split",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_subscription_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Post);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscription>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
}
pub mod billing_subscriptions_aliases {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
#[doc = "Lists the subscription aliases for a billing account. The operation is supported for seat based billing subscriptions."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
pub fn list_by_billing_account(&self, billing_account_name: impl Into<String>) -> list_by_billing_account::RequestBuilder {
list_by_billing_account::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
}
}
#[doc = "Gets a subscription by its alias ID. The operation is supported for seat based billing subscriptions."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `alias_name`: The ID that uniquely identifies a subscription alias."]
pub fn get(&self, billing_account_name: impl Into<String>, alias_name: impl Into<String>) -> get::RequestBuilder {
get::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
alias_name: alias_name.into(),
}
}
#[doc = "Creates or updates a billing subscription by its alias ID. The operation is supported for seat based billing subscriptions."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `alias_name`: The ID that uniquely identifies a subscription alias."]
#[doc = "* `parameters`: New or updated billing subscription alias."]
pub fn create_or_update(
&self,
billing_account_name: impl Into<String>,
alias_name: impl Into<String>,
parameters: impl Into<models::BillingSubscriptionAlias>,
) -> create_or_update::RequestBuilder {
create_or_update::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
alias_name: alias_name.into(),
parameters: parameters.into(),
}
}
}
pub mod list_by_billing_account {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscriptionAliasListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscriptionAliasListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::BillingSubscriptionAliasListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptionAliases",
this.client.endpoint(),
&this.billing_account_name
))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscriptionAlias> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscriptionAlias = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) alias_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptionAliases/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.alias_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscriptionAlias>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod create_or_update {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::BillingSubscriptionAlias> {
let bytes = self.0.into_body().collect().await?;
let body: models::BillingSubscriptionAlias = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
pub fn headers(&self) -> Headers {
Headers(self.0.headers())
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
pub struct Headers<'a>(&'a azure_core::headers::Headers);
impl<'a> Headers<'a> {
#[doc = "Location URI to poll for result"]
pub fn location(&self) -> azure_core::Result<&str> {
self.0.get_str(&azure_core::headers::HeaderName::from_static("location"))
}
#[doc = "Recommended time to wait before making another request to check the status of the operation. The time is specified in seconds."]
pub fn retry_after(&self) -> azure_core::Result<i64> {
self.0.get_as(&azure_core::headers::HeaderName::from_static("retry-after"))
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) alias_name: String,
pub(crate) parameters: models::BillingSubscriptionAlias,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingSubscriptionAliases/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.alias_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Put);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
req.insert_header("content-type", "application/json");
let req_body = azure_core::to_json(&this.parameters)?;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::BillingSubscriptionAlias>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
}
pub mod payment_methods {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
#[doc = "Lists the payment methods owned by the caller."]
pub fn list_by_user(&self) -> list_by_user::RequestBuilder {
list_by_user::RequestBuilder { client: self.0.clone() }
}
#[doc = "Gets a payment method owned by the caller."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `payment_method_name`: The ID that uniquely identifies a payment method."]
pub fn get_by_user(&self, payment_method_name: impl Into<String>) -> get_by_user::RequestBuilder {
get_by_user::RequestBuilder {
client: self.0.clone(),
payment_method_name: payment_method_name.into(),
}
}
#[doc = "Deletes a payment method owned by the caller."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `payment_method_name`: The ID that uniquely identifies a payment method."]
pub fn delete_by_user(&self, payment_method_name: impl Into<String>) -> delete_by_user::RequestBuilder {
delete_by_user::RequestBuilder {
client: self.0.clone(),
payment_method_name: payment_method_name.into(),
}
}
#[doc = "Lists the payment methods available for a billing account. Along with the payment methods owned by the caller, these payment methods can be attached to a billing profile to make payments. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
pub fn list_by_billing_account(&self, billing_account_name: impl Into<String>) -> list_by_billing_account::RequestBuilder {
list_by_billing_account::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
}
}
#[doc = "Gets a payment method available for a billing account. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `payment_method_name`: The ID that uniquely identifies a payment method."]
pub fn get_by_billing_account(
&self,
billing_account_name: impl Into<String>,
payment_method_name: impl Into<String>,
) -> get_by_billing_account::RequestBuilder {
get_by_billing_account::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
payment_method_name: payment_method_name.into(),
}
}
#[doc = "Lists payment methods attached to a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_profile_name`: The ID that uniquely identifies a billing profile."]
pub fn list_by_billing_profile(
&self,
billing_account_name: impl Into<String>,
billing_profile_name: impl Into<String>,
) -> list_by_billing_profile::RequestBuilder {
list_by_billing_profile::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_profile_name: billing_profile_name.into(),
}
}
#[doc = "Gets a payment method linked with a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_profile_name`: The ID that uniquely identifies a billing profile."]
#[doc = "* `payment_method_name`: The ID that uniquely identifies a payment method."]
pub fn get_by_billing_profile(
&self,
billing_account_name: impl Into<String>,
billing_profile_name: impl Into<String>,
payment_method_name: impl Into<String>,
) -> get_by_billing_profile::RequestBuilder {
get_by_billing_profile::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_profile_name: billing_profile_name.into(),
payment_method_name: payment_method_name.into(),
}
}
#[doc = "Deletes a payment method link and removes the payment method from a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement."]
#[doc = ""]
#[doc = "Arguments:"]
#[doc = "* `billing_account_name`: The ID that uniquely identifies a billing account."]
#[doc = "* `billing_profile_name`: The ID that uniquely identifies a billing profile."]
#[doc = "* `payment_method_name`: The ID that uniquely identifies a payment method."]
pub fn delete_at_billing_profile(
&self,
billing_account_name: impl Into<String>,
billing_profile_name: impl Into<String>,
payment_method_name: impl Into<String>,
) -> delete_at_billing_profile::RequestBuilder {
delete_at_billing_profile::RequestBuilder {
client: self.0.clone(),
billing_account_name: billing_account_name.into(),
billing_profile_name: billing_profile_name.into(),
payment_method_name: payment_method_name.into(),
}
}
}
pub mod list_by_user {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethodsListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethodsListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::PaymentMethodsListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url =
azure_core::Url::parse(&format!("{}/providers/Microsoft.Billing/paymentMethods", this.client.endpoint(),))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get_by_user {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethod> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethod = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) payment_method_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/paymentMethods/{}",
this.client.endpoint(),
&this.payment_method_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::PaymentMethod>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod delete_by_user {
use super::models;
pub struct Response(azure_core::Response);
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) payment_method_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/paymentMethods/{}",
this.client.endpoint(),
&this.payment_method_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Delete);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
}
}
pub mod list_by_billing_account {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethodsListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethodsListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::PaymentMethodsListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/paymentMethods",
this.client.endpoint(),
&this.billing_account_name
))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get_by_billing_account {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethod> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethod = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) payment_method_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/paymentMethods/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.payment_method_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::PaymentMethod>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod list_by_billing_profile {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethodLinksListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethodLinksListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_profile_name: String,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::PaymentMethodLinksListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingProfiles/{}/paymentMethodLinks",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_profile_name
))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
pub mod get_by_billing_profile {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::PaymentMethodLink> {
let bytes = self.0.into_body().collect().await?;
let body: models::PaymentMethodLink = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_profile_name: String,
pub(crate) payment_method_name: String,
}
impl RequestBuilder {
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingProfiles/{}/paymentMethodLinks/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_profile_name,
&this.payment_method_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
#[doc = "Send the request and return the response body."]
pub fn into_future(self) -> futures::future::BoxFuture<'static, azure_core::Result<models::PaymentMethodLink>> {
Box::pin(async move { self.send().await?.into_body().await })
}
}
}
pub mod delete_at_billing_profile {
use super::models;
pub struct Response(azure_core::Response);
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
pub(crate) billing_account_name: String,
pub(crate) billing_profile_name: String,
pub(crate) payment_method_name: String,
}
impl RequestBuilder {
#[doc = "only the first response will be fetched as long running operations are not supported yet"]
#[doc = "Send the request and returns the response."]
pub fn send(self) -> futures::future::BoxFuture<'static, azure_core::Result<Response>> {
Box::pin({
let this = self.clone();
async move {
let url = azure_core::Url::parse(&format!(
"{}/providers/Microsoft.Billing/billingAccounts/{}/billingProfiles/{}/paymentMethodLinks/{}",
this.client.endpoint(),
&this.billing_account_name,
&this.billing_profile_name,
&this.payment_method_name
))?;
let mut req = azure_core::Request::new(url, azure_core::Method::Delete);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
Ok(Response(this.client.send(&mut req).await?))
}
})
}
}
}
}
pub mod operations {
use super::models;
pub struct Client(pub(crate) super::Client);
impl Client {
#[doc = "Lists the available billing REST API operations."]
pub fn list(&self) -> list::RequestBuilder {
list::RequestBuilder { client: self.0.clone() }
}
}
pub mod list {
use super::models;
pub struct Response(azure_core::Response);
impl Response {
pub async fn into_body(self) -> azure_core::Result<models::OperationListResult> {
let bytes = self.0.into_body().collect().await?;
let body: models::OperationListResult = serde_json::from_slice(&bytes)?;
Ok(body)
}
pub fn into_raw_response(self) -> azure_core::Response {
self.0
}
pub fn as_raw_response(&self) -> &azure_core::Response {
&self.0
}
}
impl From<Response> for azure_core::Response {
fn from(rsp: Response) -> Self {
rsp.into_raw_response()
}
}
impl AsRef<azure_core::Response> for Response {
fn as_ref(&self) -> &azure_core::Response {
self.as_raw_response()
}
}
#[derive(Clone)]
pub struct RequestBuilder {
pub(crate) client: super::super::Client,
}
impl RequestBuilder {
pub fn into_stream(self) -> azure_core::Pageable<models::OperationListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
async move {
let mut url =
azure_core::Url::parse(&format!("{}/providers/Microsoft.Billing/operations", this.client.endpoint(),))?;
let rsp = match continuation {
Some(value) => {
url.set_path("");
url = url.join(&value)?;
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
let has_api_version_already =
req.url_mut().query_pairs().any(|(k, _)| k == azure_core::query_param::API_VERSION);
if !has_api_version_already {
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
}
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
None => {
let mut req = azure_core::Request::new(url, azure_core::Method::Get);
let credential = this.client.token_credential();
let token_response = credential.get_token(&this.client.scopes().join(" ")).await?;
req.insert_header(
azure_core::headers::AUTHORIZATION,
format!("Bearer {}", token_response.token.secret()),
);
req.url_mut()
.query_pairs_mut()
.append_pair(azure_core::query_param::API_VERSION, "2021-10-01");
let req_body = azure_core::EMPTY_BODY;
req.set_body(req_body);
this.client.send(&mut req).await?
}
};
let rsp = match rsp.status() {
azure_core::StatusCode::Ok => Ok(Response(rsp)),
status_code => Err(azure_core::error::Error::from(azure_core::error::ErrorKind::HttpResponse {
status: status_code,
error_code: None,
})),
};
rsp?.into_body().await
}
};
azure_core::Pageable::new(make_request)
}
}
}
}