1#![allow(unused_mut)]
4#![allow(unused_variables)]
5#![allow(unused_imports)]
6#![allow(clippy::redundant_clone)]
7#![allow(clippy::too_many_arguments)]
8#![allow(clippy::module_inception)]
9pub mod models;
10#[derive(Clone)]
11pub struct Client {
12 endpoint: azure_core::http::Url,
13 credential: crate::Credential,
14 scopes: Vec<String>,
15 pipeline: azure_core::http::Pipeline,
16}
17#[derive(Clone)]
18pub struct ClientBuilder {
19 credential: crate::Credential,
20 endpoint: Option<azure_core::http::Url>,
21 scopes: Option<Vec<String>>,
22 options: azure_core::http::ClientOptions,
23}
24azure_core::static_url!(DEFAULT_ENDPOINT, "https://dev.azure.com");
25impl ClientBuilder {
26 #[doc = "Create a new instance of `ClientBuilder`."]
27 #[must_use]
28 pub fn new(credential: crate::Credential) -> Self {
29 Self {
30 credential,
31 endpoint: None,
32 scopes: None,
33 options: azure_core::http::ClientOptions::default(),
34 }
35 }
36 #[doc = "Set the endpoint."]
37 #[must_use]
38 pub fn endpoint(mut self, endpoint: impl Into<azure_core::http::Url>) -> Self {
39 self.endpoint = Some(endpoint.into());
40 self
41 }
42 #[doc = "Set the scopes."]
43 #[must_use]
44 pub fn scopes(mut self, scopes: &[&str]) -> Self {
45 self.scopes = Some(scopes.iter().map(|scope| (*scope).to_owned()).collect());
46 self
47 }
48 #[doc = "Set the retry options."]
49 #[must_use]
50 pub fn retry(mut self, retry: impl Into<azure_core::http::RetryOptions>) -> Self {
51 self.options.retry = Some(retry.into());
52 self
53 }
54 #[doc = "Set the transport options."]
55 #[must_use]
56 pub fn transport(mut self, transport: impl Into<azure_core::http::TransportOptions>) -> Self {
57 self.options.transport = Some(transport.into());
58 self
59 }
60 #[doc = "Set per-call policies."]
61 #[must_use]
62 pub fn per_call_policies(
63 mut self,
64 policies: impl Into<Vec<std::sync::Arc<dyn azure_core::http::policies::Policy>>>,
65 ) -> Self {
66 self.options.per_call_policies = policies.into();
67 self
68 }
69 #[doc = "Set per-try policies."]
70 #[must_use]
71 pub fn per_try_policies(
72 mut self,
73 policies: impl Into<Vec<std::sync::Arc<dyn azure_core::http::policies::Policy>>>,
74 ) -> Self {
75 self.options.per_try_policies = policies.into();
76 self
77 }
78 #[doc = "Convert the builder into a `Client` instance."]
79 pub fn build(self) -> Client {
80 let endpoint = self.endpoint.unwrap_or_else(|| DEFAULT_ENDPOINT.to_owned());
81 let scopes = self
82 .scopes
83 .unwrap_or_else(|| vec![crate::ADO_SCOPE.to_string()]);
84 Client::new(endpoint, self.credential, scopes, self.options)
85 }
86}
87impl Client {
88 pub(crate) fn endpoint(&self) -> &azure_core::http::Url {
89 &self.endpoint
90 }
91 pub(crate) fn token_credential(&self) -> &crate::Credential {
92 &self.credential
93 }
94 pub(crate) fn scopes(&self) -> Vec<&str> {
95 self.scopes.iter().map(String::as_str).collect()
96 }
97 pub(crate) async fn send(
98 &self,
99 request: &mut azure_core::http::Request,
100 ) -> azure_core::Result<azure_core::http::BufResponse> {
101 let context = azure_core::http::Context::default();
102 self.pipeline.send(&context, request).await
103 }
104 #[doc = "Create a new `ClientBuilder`."]
105 #[must_use]
106 pub fn builder(credential: crate::Credential) -> ClientBuilder {
107 ClientBuilder::new(credential)
108 }
109 #[doc = "Create a new `Client`."]
110 #[must_use]
111 pub fn new(
112 endpoint: impl Into<azure_core::http::Url>,
113 credential: crate::Credential,
114 scopes: Vec<String>,
115 options: azure_core::http::ClientOptions,
116 ) -> Self {
117 let endpoint = endpoint.into();
118 let pipeline = azure_core::http::Pipeline::new(
119 option_env!("CARGO_PKG_NAME"),
120 option_env!("CARGO_PKG_VERSION"),
121 options,
122 Vec::new(),
123 Vec::new(),
124 None,
125 );
126 Self {
127 endpoint,
128 credential,
129 scopes,
130 pipeline,
131 }
132 }
133 pub fn configurations_client(&self) -> configurations::Client {
134 configurations::Client(self.clone())
135 }
136 pub fn evaluations_client(&self) -> evaluations::Client {
137 evaluations::Client(self.clone())
138 }
139 pub fn revisions_client(&self) -> revisions::Client {
140 revisions::Client(self.clone())
141 }
142 pub fn types_client(&self) -> types::Client {
143 types::Client(self.clone())
144 }
145}
146pub mod configurations {
147 use super::models;
148 #[cfg(not(target_arch = "wasm32"))]
149 use futures::future::BoxFuture;
150 #[cfg(target_arch = "wasm32")]
151 use futures::future::LocalBoxFuture as BoxFuture;
152 pub struct Client(pub(crate) super::Client);
153 impl Client {
154 #[doc = "Get a list of policy configurations in a project.\n\nThe 'scope' parameter for this API should not be used, except for legacy compatability reasons. It returns specifically\nscoped policies and does not support heirarchical nesting. Instead, use the /_apis/git/policy/configurations API, which provides\nfirst class scope filtering support.\n\nThe optional `policyType` parameter can be used to filter the set of policies returned from this method."]
155 #[doc = ""]
156 #[doc = "Arguments:"]
157 #[doc = "* `organization`: The name of the Azure DevOps organization."]
158 #[doc = "* `project`: Project ID or project name"]
159 pub fn list(
160 &self,
161 organization: impl Into<String>,
162 project: impl Into<String>,
163 ) -> list::RequestBuilder {
164 list::RequestBuilder {
165 client: self.0.clone(),
166 organization: organization.into(),
167 project: project.into(),
168 scope: None,
169 top: None,
170 continuation_token: None,
171 policy_type: None,
172 }
173 }
174 #[doc = "Create a policy configuration of a given policy type."]
175 #[doc = ""]
176 #[doc = "Arguments:"]
177 #[doc = "* `organization`: The name of the Azure DevOps organization."]
178 #[doc = "* `body`: The policy configuration to create."]
179 #[doc = "* `project`: Project ID or project name"]
180 pub fn create(
181 &self,
182 organization: impl Into<String>,
183 body: impl Into<models::PolicyConfiguration>,
184 project: impl Into<String>,
185 ) -> create::RequestBuilder {
186 create::RequestBuilder {
187 client: self.0.clone(),
188 organization: organization.into(),
189 body: body.into(),
190 project: project.into(),
191 }
192 }
193 #[doc = "Get a policy configuration by its ID."]
194 #[doc = ""]
195 #[doc = "Arguments:"]
196 #[doc = "* `organization`: The name of the Azure DevOps organization."]
197 #[doc = "* `project`: Project ID or project name"]
198 #[doc = "* `configuration_id`: ID of the policy configuration"]
199 pub fn get(
200 &self,
201 organization: impl Into<String>,
202 project: impl Into<String>,
203 configuration_id: i32,
204 ) -> get::RequestBuilder {
205 get::RequestBuilder {
206 client: self.0.clone(),
207 organization: organization.into(),
208 project: project.into(),
209 configuration_id,
210 }
211 }
212 #[doc = "Update a policy configuration by its ID."]
213 #[doc = ""]
214 #[doc = "Arguments:"]
215 #[doc = "* `organization`: The name of the Azure DevOps organization."]
216 #[doc = "* `body`: The policy configuration to update."]
217 #[doc = "* `project`: Project ID or project name"]
218 #[doc = "* `configuration_id`: ID of the existing policy configuration to be updated."]
219 pub fn update(
220 &self,
221 organization: impl Into<String>,
222 body: impl Into<models::PolicyConfiguration>,
223 project: impl Into<String>,
224 configuration_id: i32,
225 ) -> update::RequestBuilder {
226 update::RequestBuilder {
227 client: self.0.clone(),
228 organization: organization.into(),
229 body: body.into(),
230 project: project.into(),
231 configuration_id,
232 }
233 }
234 #[doc = "Delete a policy configuration by its ID."]
235 #[doc = ""]
236 #[doc = "Arguments:"]
237 #[doc = "* `organization`: The name of the Azure DevOps organization."]
238 #[doc = "* `project`: Project ID or project name"]
239 #[doc = "* `configuration_id`: ID of the policy configuration to delete."]
240 pub fn delete(
241 &self,
242 organization: impl Into<String>,
243 project: impl Into<String>,
244 configuration_id: i32,
245 ) -> delete::RequestBuilder {
246 delete::RequestBuilder {
247 client: self.0.clone(),
248 organization: organization.into(),
249 project: project.into(),
250 configuration_id,
251 }
252 }
253 }
254 pub mod list {
255 use super::models;
256 #[cfg(not(target_arch = "wasm32"))]
257 use futures::future::BoxFuture;
258 #[cfg(target_arch = "wasm32")]
259 use futures::future::LocalBoxFuture as BoxFuture;
260 #[derive(Debug)]
261 pub struct Response(
262 azure_core::http::Response<
263 models::PolicyConfigurationList,
264 azure_core::http::JsonFormat,
265 >,
266 );
267 impl Response {
268 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfigurationList> {
269 self.0.into_body().await
270 }
271 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
272 self.0.into()
273 }
274 }
275 #[derive(Clone)]
276 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
277 #[doc = r""]
278 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
279 #[doc = r" parameters can be chained."]
280 #[doc = r""]
281 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
282 #[doc = r" converts the [`RequestBuilder`] into a future,"]
283 #[doc = r" executes the request and returns a `Result` with the parsed"]
284 #[doc = r" response."]
285 #[doc = r""]
286 #[doc = r" If you need lower-level access to the raw response details"]
287 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
288 #[doc = r" can finalize the request using the"]
289 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
290 #[doc = r" that resolves to a lower-level [`Response`] value."]
291 pub struct RequestBuilder {
292 pub(crate) client: super::super::Client,
293 pub(crate) organization: String,
294 pub(crate) project: String,
295 pub(crate) scope: Option<String>,
296 pub(crate) top: Option<i32>,
297 pub(crate) continuation_token: Option<String>,
298 pub(crate) policy_type: Option<String>,
299 }
300 impl RequestBuilder {
301 #[doc = "\\[Provided for legacy reasons\\] The scope on which a subset of policies is defined."]
302 pub fn scope(mut self, scope: impl Into<String>) -> Self {
303 self.scope = Some(scope.into());
304 self
305 }
306 #[doc = "Maximum number of policies to return."]
307 pub fn top(mut self, top: i32) -> Self {
308 self.top = Some(top);
309 self
310 }
311 #[doc = "The continuation token used for pagination."]
312 pub fn continuation_token(mut self, continuation_token: impl Into<String>) -> Self {
313 self.continuation_token = Some(continuation_token.into());
314 self
315 }
316 #[doc = "Filter returned policies to only this type"]
317 pub fn policy_type(mut self, policy_type: impl Into<String>) -> Self {
318 self.policy_type = Some(policy_type.into());
319 self
320 }
321 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
322 #[doc = ""]
323 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
324 #[doc = "However, this function can provide more flexibility when required."]
325 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
326 Box::pin({
327 let this = self.clone();
328 async move {
329 let url = this.url()?;
330 let mut req =
331 azure_core::http::Request::new(url, azure_core::http::Method::Get);
332 if let Some(auth_header) = this
333 .client
334 .token_credential()
335 .http_authorization_header(&this.client.scopes())
336 .await?
337 {
338 req.insert_header(
339 azure_core::http::headers::AUTHORIZATION,
340 auth_header,
341 );
342 }
343 if let Some(scope) = &this.scope {
344 req.url_mut().query_pairs_mut().append_pair("scope", scope);
345 }
346 if let Some(top) = &this.top {
347 req.url_mut()
348 .query_pairs_mut()
349 .append_pair("$top", &top.to_string());
350 }
351 if let Some(continuation_token) = &this.continuation_token {
352 req.url_mut()
353 .query_pairs_mut()
354 .append_pair("continuationToken", continuation_token);
355 }
356 if let Some(policy_type) = &this.policy_type {
357 req.url_mut()
358 .query_pairs_mut()
359 .append_pair("policyType", policy_type);
360 }
361 let req_body = azure_core::Bytes::new();
362 req.set_body(req_body);
363 Ok(Response(this.client.send(&mut req).await?.into()))
364 }
365 })
366 }
367 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
368 let mut url = azure_core::http::Url::parse(&format!(
369 "{}/{}/{}/_apis/policy/configurations",
370 self.client.endpoint(),
371 &self.organization,
372 &self.project
373 ))?;
374 let has_api_version_already = url
375 .query_pairs()
376 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
377 if !has_api_version_already {
378 url.query_pairs_mut().append_pair(
379 azure_core::http::headers::query_param::API_VERSION,
380 "7.1-preview",
381 );
382 }
383 Ok(url)
384 }
385 }
386 impl std::future::IntoFuture for RequestBuilder {
387 type Output = azure_core::Result<models::PolicyConfigurationList>;
388 type IntoFuture =
389 BoxFuture<'static, azure_core::Result<models::PolicyConfigurationList>>;
390 #[doc = "Returns a future that sends the request and returns the parsed response body."]
391 #[doc = ""]
392 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
393 #[doc = ""]
394 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
395 fn into_future(self) -> Self::IntoFuture {
396 Box::pin(async move { self.send().await?.into_body().await })
397 }
398 }
399 }
400 pub mod create {
401 use super::models;
402 #[cfg(not(target_arch = "wasm32"))]
403 use futures::future::BoxFuture;
404 #[cfg(target_arch = "wasm32")]
405 use futures::future::LocalBoxFuture as BoxFuture;
406 #[derive(Debug)]
407 pub struct Response(
408 azure_core::http::Response<models::PolicyConfiguration, azure_core::http::JsonFormat>,
409 );
410 impl Response {
411 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfiguration> {
412 self.0.into_body().await
413 }
414 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
415 self.0.into()
416 }
417 }
418 #[derive(Clone)]
419 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
420 #[doc = r""]
421 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
422 #[doc = r" parameters can be chained."]
423 #[doc = r""]
424 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
425 #[doc = r" converts the [`RequestBuilder`] into a future,"]
426 #[doc = r" executes the request and returns a `Result` with the parsed"]
427 #[doc = r" response."]
428 #[doc = r""]
429 #[doc = r" If you need lower-level access to the raw response details"]
430 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
431 #[doc = r" can finalize the request using the"]
432 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
433 #[doc = r" that resolves to a lower-level [`Response`] value."]
434 pub struct RequestBuilder {
435 pub(crate) client: super::super::Client,
436 pub(crate) organization: String,
437 pub(crate) body: models::PolicyConfiguration,
438 pub(crate) project: String,
439 }
440 impl RequestBuilder {
441 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
442 #[doc = ""]
443 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
444 #[doc = "However, this function can provide more flexibility when required."]
445 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
446 Box::pin({
447 let this = self.clone();
448 async move {
449 let url = this.url()?;
450 let mut req =
451 azure_core::http::Request::new(url, azure_core::http::Method::Post);
452 if let Some(auth_header) = this
453 .client
454 .token_credential()
455 .http_authorization_header(&this.client.scopes())
456 .await?
457 {
458 req.insert_header(
459 azure_core::http::headers::AUTHORIZATION,
460 auth_header,
461 );
462 }
463 req.insert_header("content-type", "application/json");
464 let req_body = azure_core::json::to_json(&this.body)?;
465 req.set_body(req_body);
466 Ok(Response(this.client.send(&mut req).await?.into()))
467 }
468 })
469 }
470 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
471 let mut url = azure_core::http::Url::parse(&format!(
472 "{}/{}/{}/_apis/policy/configurations",
473 self.client.endpoint(),
474 &self.organization,
475 &self.project
476 ))?;
477 let has_api_version_already = url
478 .query_pairs()
479 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
480 if !has_api_version_already {
481 url.query_pairs_mut().append_pair(
482 azure_core::http::headers::query_param::API_VERSION,
483 "7.1-preview",
484 );
485 }
486 Ok(url)
487 }
488 }
489 impl std::future::IntoFuture for RequestBuilder {
490 type Output = azure_core::Result<models::PolicyConfiguration>;
491 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyConfiguration>>;
492 #[doc = "Returns a future that sends the request and returns the parsed response body."]
493 #[doc = ""]
494 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
495 #[doc = ""]
496 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
497 fn into_future(self) -> Self::IntoFuture {
498 Box::pin(async move { self.send().await?.into_body().await })
499 }
500 }
501 }
502 pub mod get {
503 use super::models;
504 #[cfg(not(target_arch = "wasm32"))]
505 use futures::future::BoxFuture;
506 #[cfg(target_arch = "wasm32")]
507 use futures::future::LocalBoxFuture as BoxFuture;
508 #[derive(Debug)]
509 pub struct Response(
510 azure_core::http::Response<models::PolicyConfiguration, azure_core::http::JsonFormat>,
511 );
512 impl Response {
513 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfiguration> {
514 self.0.into_body().await
515 }
516 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
517 self.0.into()
518 }
519 }
520 #[derive(Clone)]
521 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
522 #[doc = r""]
523 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
524 #[doc = r" parameters can be chained."]
525 #[doc = r""]
526 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
527 #[doc = r" converts the [`RequestBuilder`] into a future,"]
528 #[doc = r" executes the request and returns a `Result` with the parsed"]
529 #[doc = r" response."]
530 #[doc = r""]
531 #[doc = r" If you need lower-level access to the raw response details"]
532 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
533 #[doc = r" can finalize the request using the"]
534 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
535 #[doc = r" that resolves to a lower-level [`Response`] value."]
536 pub struct RequestBuilder {
537 pub(crate) client: super::super::Client,
538 pub(crate) organization: String,
539 pub(crate) project: String,
540 pub(crate) configuration_id: i32,
541 }
542 impl RequestBuilder {
543 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
544 #[doc = ""]
545 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
546 #[doc = "However, this function can provide more flexibility when required."]
547 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
548 Box::pin({
549 let this = self.clone();
550 async move {
551 let url = this.url()?;
552 let mut req =
553 azure_core::http::Request::new(url, azure_core::http::Method::Get);
554 if let Some(auth_header) = this
555 .client
556 .token_credential()
557 .http_authorization_header(&this.client.scopes())
558 .await?
559 {
560 req.insert_header(
561 azure_core::http::headers::AUTHORIZATION,
562 auth_header,
563 );
564 }
565 let req_body = azure_core::Bytes::new();
566 req.set_body(req_body);
567 Ok(Response(this.client.send(&mut req).await?.into()))
568 }
569 })
570 }
571 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
572 let mut url = azure_core::http::Url::parse(&format!(
573 "{}/{}/{}/_apis/policy/configurations/{}",
574 self.client.endpoint(),
575 &self.organization,
576 &self.project,
577 &self.configuration_id
578 ))?;
579 let has_api_version_already = url
580 .query_pairs()
581 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
582 if !has_api_version_already {
583 url.query_pairs_mut().append_pair(
584 azure_core::http::headers::query_param::API_VERSION,
585 "7.1-preview",
586 );
587 }
588 Ok(url)
589 }
590 }
591 impl std::future::IntoFuture for RequestBuilder {
592 type Output = azure_core::Result<models::PolicyConfiguration>;
593 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyConfiguration>>;
594 #[doc = "Returns a future that sends the request and returns the parsed response body."]
595 #[doc = ""]
596 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
597 #[doc = ""]
598 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
599 fn into_future(self) -> Self::IntoFuture {
600 Box::pin(async move { self.send().await?.into_body().await })
601 }
602 }
603 }
604 pub mod update {
605 use super::models;
606 #[cfg(not(target_arch = "wasm32"))]
607 use futures::future::BoxFuture;
608 #[cfg(target_arch = "wasm32")]
609 use futures::future::LocalBoxFuture as BoxFuture;
610 #[derive(Debug)]
611 pub struct Response(
612 azure_core::http::Response<models::PolicyConfiguration, azure_core::http::JsonFormat>,
613 );
614 impl Response {
615 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfiguration> {
616 self.0.into_body().await
617 }
618 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
619 self.0.into()
620 }
621 }
622 #[derive(Clone)]
623 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
624 #[doc = r""]
625 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
626 #[doc = r" parameters can be chained."]
627 #[doc = r""]
628 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
629 #[doc = r" converts the [`RequestBuilder`] into a future,"]
630 #[doc = r" executes the request and returns a `Result` with the parsed"]
631 #[doc = r" response."]
632 #[doc = r""]
633 #[doc = r" If you need lower-level access to the raw response details"]
634 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
635 #[doc = r" can finalize the request using the"]
636 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
637 #[doc = r" that resolves to a lower-level [`Response`] value."]
638 pub struct RequestBuilder {
639 pub(crate) client: super::super::Client,
640 pub(crate) organization: String,
641 pub(crate) body: models::PolicyConfiguration,
642 pub(crate) project: String,
643 pub(crate) configuration_id: i32,
644 }
645 impl RequestBuilder {
646 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
647 #[doc = ""]
648 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
649 #[doc = "However, this function can provide more flexibility when required."]
650 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
651 Box::pin({
652 let this = self.clone();
653 async move {
654 let url = this.url()?;
655 let mut req =
656 azure_core::http::Request::new(url, azure_core::http::Method::Put);
657 if let Some(auth_header) = this
658 .client
659 .token_credential()
660 .http_authorization_header(&this.client.scopes())
661 .await?
662 {
663 req.insert_header(
664 azure_core::http::headers::AUTHORIZATION,
665 auth_header,
666 );
667 }
668 req.insert_header("content-type", "application/json");
669 let req_body = azure_core::json::to_json(&this.body)?;
670 req.set_body(req_body);
671 Ok(Response(this.client.send(&mut req).await?.into()))
672 }
673 })
674 }
675 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
676 let mut url = azure_core::http::Url::parse(&format!(
677 "{}/{}/{}/_apis/policy/configurations/{}",
678 self.client.endpoint(),
679 &self.organization,
680 &self.project,
681 &self.configuration_id
682 ))?;
683 let has_api_version_already = url
684 .query_pairs()
685 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
686 if !has_api_version_already {
687 url.query_pairs_mut().append_pair(
688 azure_core::http::headers::query_param::API_VERSION,
689 "7.1-preview",
690 );
691 }
692 Ok(url)
693 }
694 }
695 impl std::future::IntoFuture for RequestBuilder {
696 type Output = azure_core::Result<models::PolicyConfiguration>;
697 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyConfiguration>>;
698 #[doc = "Returns a future that sends the request and returns the parsed response body."]
699 #[doc = ""]
700 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
701 #[doc = ""]
702 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
703 fn into_future(self) -> Self::IntoFuture {
704 Box::pin(async move { self.send().await?.into_body().await })
705 }
706 }
707 }
708 pub mod delete {
709 use super::models;
710 #[cfg(not(target_arch = "wasm32"))]
711 use futures::future::BoxFuture;
712 #[cfg(target_arch = "wasm32")]
713 use futures::future::LocalBoxFuture as BoxFuture;
714 #[derive(Debug)]
715 pub struct Response(azure_core::http::Response<(), azure_core::http::NoFormat>);
716 impl Response {
717 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
718 self.0.into()
719 }
720 }
721 #[derive(Clone)]
722 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
723 #[doc = r""]
724 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
725 #[doc = r" parameters can be chained."]
726 #[doc = r""]
727 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
728 #[doc = r" converts the [`RequestBuilder`] into a future,"]
729 #[doc = r" executes the request and returns a `Result` with the parsed"]
730 #[doc = r" response."]
731 #[doc = r""]
732 #[doc = r" If you need lower-level access to the raw response details"]
733 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
734 #[doc = r" can finalize the request using the"]
735 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
736 #[doc = r" that resolves to a lower-level [`Response`] value."]
737 pub struct RequestBuilder {
738 pub(crate) client: super::super::Client,
739 pub(crate) organization: String,
740 pub(crate) project: String,
741 pub(crate) configuration_id: i32,
742 }
743 impl RequestBuilder {
744 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
745 #[doc = ""]
746 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
747 #[doc = "However, this function can provide more flexibility when required."]
748 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
749 Box::pin({
750 let this = self.clone();
751 async move {
752 let url = this.url()?;
753 let mut req =
754 azure_core::http::Request::new(url, azure_core::http::Method::Delete);
755 if let Some(auth_header) = this
756 .client
757 .token_credential()
758 .http_authorization_header(&this.client.scopes())
759 .await?
760 {
761 req.insert_header(
762 azure_core::http::headers::AUTHORIZATION,
763 auth_header,
764 );
765 }
766 let req_body = azure_core::Bytes::new();
767 req.set_body(req_body);
768 Ok(Response(this.client.send(&mut req).await?.into()))
769 }
770 })
771 }
772 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
773 let mut url = azure_core::http::Url::parse(&format!(
774 "{}/{}/{}/_apis/policy/configurations/{}",
775 self.client.endpoint(),
776 &self.organization,
777 &self.project,
778 &self.configuration_id
779 ))?;
780 let has_api_version_already = url
781 .query_pairs()
782 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
783 if !has_api_version_already {
784 url.query_pairs_mut().append_pair(
785 azure_core::http::headers::query_param::API_VERSION,
786 "7.1-preview",
787 );
788 }
789 Ok(url)
790 }
791 }
792 impl std::future::IntoFuture for RequestBuilder {
793 type Output = azure_core::Result<()>;
794 type IntoFuture = BoxFuture<'static, azure_core::Result<()>>;
795 #[doc = "Returns a future that sends the request and waits for the response."]
796 #[doc = ""]
797 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
798 #[doc = ""]
799 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
800 fn into_future(self) -> Self::IntoFuture {
801 Box::pin(async move {
802 let _rsp = self.send().await?;
803 Ok(())
804 })
805 }
806 }
807 }
808}
809pub mod revisions {
810 use super::models;
811 #[cfg(not(target_arch = "wasm32"))]
812 use futures::future::BoxFuture;
813 #[cfg(target_arch = "wasm32")]
814 use futures::future::LocalBoxFuture as BoxFuture;
815 pub struct Client(pub(crate) super::Client);
816 impl Client {
817 #[doc = "Retrieve all revisions for a given policy."]
818 #[doc = ""]
819 #[doc = "Arguments:"]
820 #[doc = "* `organization`: The name of the Azure DevOps organization."]
821 #[doc = "* `project`: Project ID or project name"]
822 #[doc = "* `configuration_id`: The policy configuration ID."]
823 pub fn list(
824 &self,
825 organization: impl Into<String>,
826 project: impl Into<String>,
827 configuration_id: i32,
828 ) -> list::RequestBuilder {
829 list::RequestBuilder {
830 client: self.0.clone(),
831 organization: organization.into(),
832 project: project.into(),
833 configuration_id,
834 top: None,
835 skip: None,
836 }
837 }
838 #[doc = "Retrieve a specific revision of a given policy by ID."]
839 #[doc = ""]
840 #[doc = "Arguments:"]
841 #[doc = "* `organization`: The name of the Azure DevOps organization."]
842 #[doc = "* `project`: Project ID or project name"]
843 #[doc = "* `configuration_id`: The policy configuration ID."]
844 #[doc = "* `revision_id`: The revision ID."]
845 pub fn get(
846 &self,
847 organization: impl Into<String>,
848 project: impl Into<String>,
849 configuration_id: i32,
850 revision_id: i32,
851 ) -> get::RequestBuilder {
852 get::RequestBuilder {
853 client: self.0.clone(),
854 organization: organization.into(),
855 project: project.into(),
856 configuration_id,
857 revision_id,
858 }
859 }
860 }
861 pub mod list {
862 use super::models;
863 #[cfg(not(target_arch = "wasm32"))]
864 use futures::future::BoxFuture;
865 #[cfg(target_arch = "wasm32")]
866 use futures::future::LocalBoxFuture as BoxFuture;
867 #[derive(Debug)]
868 pub struct Response(
869 azure_core::http::Response<
870 models::PolicyConfigurationList,
871 azure_core::http::JsonFormat,
872 >,
873 );
874 impl Response {
875 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfigurationList> {
876 self.0.into_body().await
877 }
878 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
879 self.0.into()
880 }
881 }
882 #[derive(Clone)]
883 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
884 #[doc = r""]
885 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
886 #[doc = r" parameters can be chained."]
887 #[doc = r""]
888 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
889 #[doc = r" converts the [`RequestBuilder`] into a future,"]
890 #[doc = r" executes the request and returns a `Result` with the parsed"]
891 #[doc = r" response."]
892 #[doc = r""]
893 #[doc = r" If you need lower-level access to the raw response details"]
894 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
895 #[doc = r" can finalize the request using the"]
896 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
897 #[doc = r" that resolves to a lower-level [`Response`] value."]
898 pub struct RequestBuilder {
899 pub(crate) client: super::super::Client,
900 pub(crate) organization: String,
901 pub(crate) project: String,
902 pub(crate) configuration_id: i32,
903 pub(crate) top: Option<i32>,
904 pub(crate) skip: Option<i32>,
905 }
906 impl RequestBuilder {
907 #[doc = "The number of revisions to retrieve."]
908 pub fn top(mut self, top: i32) -> Self {
909 self.top = Some(top);
910 self
911 }
912 #[doc = "The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100."]
913 pub fn skip(mut self, skip: i32) -> Self {
914 self.skip = Some(skip);
915 self
916 }
917 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
918 #[doc = ""]
919 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
920 #[doc = "However, this function can provide more flexibility when required."]
921 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
922 Box::pin({
923 let this = self.clone();
924 async move {
925 let url = this.url()?;
926 let mut req =
927 azure_core::http::Request::new(url, azure_core::http::Method::Get);
928 if let Some(auth_header) = this
929 .client
930 .token_credential()
931 .http_authorization_header(&this.client.scopes())
932 .await?
933 {
934 req.insert_header(
935 azure_core::http::headers::AUTHORIZATION,
936 auth_header,
937 );
938 }
939 if let Some(top) = &this.top {
940 req.url_mut()
941 .query_pairs_mut()
942 .append_pair("$top", &top.to_string());
943 }
944 if let Some(skip) = &this.skip {
945 req.url_mut()
946 .query_pairs_mut()
947 .append_pair("$skip", &skip.to_string());
948 }
949 let req_body = azure_core::Bytes::new();
950 req.set_body(req_body);
951 Ok(Response(this.client.send(&mut req).await?.into()))
952 }
953 })
954 }
955 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
956 let mut url = azure_core::http::Url::parse(&format!(
957 "{}/{}/{}/_apis/policy/configurations/{}/revisions",
958 self.client.endpoint(),
959 &self.organization,
960 &self.project,
961 &self.configuration_id
962 ))?;
963 let has_api_version_already = url
964 .query_pairs()
965 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
966 if !has_api_version_already {
967 url.query_pairs_mut().append_pair(
968 azure_core::http::headers::query_param::API_VERSION,
969 "7.1-preview",
970 );
971 }
972 Ok(url)
973 }
974 }
975 impl std::future::IntoFuture for RequestBuilder {
976 type Output = azure_core::Result<models::PolicyConfigurationList>;
977 type IntoFuture =
978 BoxFuture<'static, azure_core::Result<models::PolicyConfigurationList>>;
979 #[doc = "Returns a future that sends the request and returns the parsed response body."]
980 #[doc = ""]
981 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
982 #[doc = ""]
983 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
984 fn into_future(self) -> Self::IntoFuture {
985 Box::pin(async move { self.send().await?.into_body().await })
986 }
987 }
988 }
989 pub mod get {
990 use super::models;
991 #[cfg(not(target_arch = "wasm32"))]
992 use futures::future::BoxFuture;
993 #[cfg(target_arch = "wasm32")]
994 use futures::future::LocalBoxFuture as BoxFuture;
995 #[derive(Debug)]
996 pub struct Response(
997 azure_core::http::Response<models::PolicyConfiguration, azure_core::http::JsonFormat>,
998 );
999 impl Response {
1000 pub async fn into_body(self) -> azure_core::Result<models::PolicyConfiguration> {
1001 self.0.into_body().await
1002 }
1003 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1004 self.0.into()
1005 }
1006 }
1007 #[derive(Clone)]
1008 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1009 #[doc = r""]
1010 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1011 #[doc = r" parameters can be chained."]
1012 #[doc = r""]
1013 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1014 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1015 #[doc = r" executes the request and returns a `Result` with the parsed"]
1016 #[doc = r" response."]
1017 #[doc = r""]
1018 #[doc = r" If you need lower-level access to the raw response details"]
1019 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1020 #[doc = r" can finalize the request using the"]
1021 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1022 #[doc = r" that resolves to a lower-level [`Response`] value."]
1023 pub struct RequestBuilder {
1024 pub(crate) client: super::super::Client,
1025 pub(crate) organization: String,
1026 pub(crate) project: String,
1027 pub(crate) configuration_id: i32,
1028 pub(crate) revision_id: i32,
1029 }
1030 impl RequestBuilder {
1031 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1032 #[doc = ""]
1033 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1034 #[doc = "However, this function can provide more flexibility when required."]
1035 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1036 Box::pin({
1037 let this = self.clone();
1038 async move {
1039 let url = this.url()?;
1040 let mut req =
1041 azure_core::http::Request::new(url, azure_core::http::Method::Get);
1042 if let Some(auth_header) = this
1043 .client
1044 .token_credential()
1045 .http_authorization_header(&this.client.scopes())
1046 .await?
1047 {
1048 req.insert_header(
1049 azure_core::http::headers::AUTHORIZATION,
1050 auth_header,
1051 );
1052 }
1053 let req_body = azure_core::Bytes::new();
1054 req.set_body(req_body);
1055 Ok(Response(this.client.send(&mut req).await?.into()))
1056 }
1057 })
1058 }
1059 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1060 let mut url = azure_core::http::Url::parse(&format!(
1061 "{}/{}/{}/_apis/policy/configurations/{}/revisions/{}",
1062 self.client.endpoint(),
1063 &self.organization,
1064 &self.project,
1065 &self.configuration_id,
1066 &self.revision_id
1067 ))?;
1068 let has_api_version_already = url
1069 .query_pairs()
1070 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1071 if !has_api_version_already {
1072 url.query_pairs_mut().append_pair(
1073 azure_core::http::headers::query_param::API_VERSION,
1074 "7.1-preview",
1075 );
1076 }
1077 Ok(url)
1078 }
1079 }
1080 impl std::future::IntoFuture for RequestBuilder {
1081 type Output = azure_core::Result<models::PolicyConfiguration>;
1082 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyConfiguration>>;
1083 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1084 #[doc = ""]
1085 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1086 #[doc = ""]
1087 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1088 fn into_future(self) -> Self::IntoFuture {
1089 Box::pin(async move { self.send().await?.into_body().await })
1090 }
1091 }
1092 }
1093}
1094pub mod evaluations {
1095 use super::models;
1096 #[cfg(not(target_arch = "wasm32"))]
1097 use futures::future::BoxFuture;
1098 #[cfg(target_arch = "wasm32")]
1099 use futures::future::LocalBoxFuture as BoxFuture;
1100 pub struct Client(pub(crate) super::Client);
1101 impl Client {
1102 #[doc = "Retrieves a list of all the policy evaluation statuses for a specific pull request.\n\nEvaluations are retrieved using an artifact ID which uniquely identifies the pull request.\nTo generate an artifact ID for a pull request, use this template:\n```\nvstfs:///CodeReview/CodeReviewId/{projectId}/{pullRequestId}\n```"]
1103 #[doc = ""]
1104 #[doc = "Arguments:"]
1105 #[doc = "* `organization`: The name of the Azure DevOps organization."]
1106 #[doc = "* `project`: Project ID or project name"]
1107 #[doc = "* `artifact_id`: A string which uniquely identifies the target of a policy evaluation."]
1108 pub fn list(
1109 &self,
1110 organization: impl Into<String>,
1111 project: impl Into<String>,
1112 artifact_id: impl Into<String>,
1113 ) -> list::RequestBuilder {
1114 list::RequestBuilder {
1115 client: self.0.clone(),
1116 organization: organization.into(),
1117 project: project.into(),
1118 artifact_id: artifact_id.into(),
1119 include_not_applicable: None,
1120 top: None,
1121 skip: None,
1122 }
1123 }
1124 #[doc = "Gets the present evaluation state of a policy.\n\nEach policy which applies to a pull request will have an evaluation state which is specific to that policy running\nin the context of that pull request. Each evaluation is uniquely identified via a Guid. You can find all the policy\nevaluations for a specific pull request using the List operation of this controller."]
1125 #[doc = ""]
1126 #[doc = "Arguments:"]
1127 #[doc = "* `organization`: The name of the Azure DevOps organization."]
1128 #[doc = "* `project`: Project ID or project name"]
1129 #[doc = "* `evaluation_id`: ID of the policy evaluation to be retrieved."]
1130 pub fn get(
1131 &self,
1132 organization: impl Into<String>,
1133 project: impl Into<String>,
1134 evaluation_id: impl Into<String>,
1135 ) -> get::RequestBuilder {
1136 get::RequestBuilder {
1137 client: self.0.clone(),
1138 organization: organization.into(),
1139 project: project.into(),
1140 evaluation_id: evaluation_id.into(),
1141 }
1142 }
1143 #[doc = "Requeue the policy evaluation.\n\nSome policies define a \"requeue\" action which performs some policy-specific operation.\nYou can trigger this operation by updating an existing policy evaluation and setting the\nPolicyEvaluationRecord.Status field to Queued.\nAlthough any policy evaluation can be requeued, at present only build policies perform any action\nin response. Requeueing a build policy will queue a new build to run (cancelling any existing build which\nis running)."]
1144 #[doc = ""]
1145 #[doc = "Arguments:"]
1146 #[doc = "* `organization`: The name of the Azure DevOps organization."]
1147 #[doc = "* `project`: Project ID or project name"]
1148 #[doc = "* `evaluation_id`: ID of the policy evaluation to be retrieved."]
1149 pub fn requeue_policy_evaluation(
1150 &self,
1151 organization: impl Into<String>,
1152 project: impl Into<String>,
1153 evaluation_id: impl Into<String>,
1154 ) -> requeue_policy_evaluation::RequestBuilder {
1155 requeue_policy_evaluation::RequestBuilder {
1156 client: self.0.clone(),
1157 organization: organization.into(),
1158 project: project.into(),
1159 evaluation_id: evaluation_id.into(),
1160 }
1161 }
1162 }
1163 pub mod list {
1164 use super::models;
1165 #[cfg(not(target_arch = "wasm32"))]
1166 use futures::future::BoxFuture;
1167 #[cfg(target_arch = "wasm32")]
1168 use futures::future::LocalBoxFuture as BoxFuture;
1169 #[derive(Debug)]
1170 pub struct Response(
1171 azure_core::http::Response<
1172 models::PolicyEvaluationRecordList,
1173 azure_core::http::JsonFormat,
1174 >,
1175 );
1176 impl Response {
1177 pub async fn into_body(self) -> azure_core::Result<models::PolicyEvaluationRecordList> {
1178 self.0.into_body().await
1179 }
1180 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1181 self.0.into()
1182 }
1183 }
1184 #[derive(Clone)]
1185 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1186 #[doc = r""]
1187 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1188 #[doc = r" parameters can be chained."]
1189 #[doc = r""]
1190 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1191 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1192 #[doc = r" executes the request and returns a `Result` with the parsed"]
1193 #[doc = r" response."]
1194 #[doc = r""]
1195 #[doc = r" If you need lower-level access to the raw response details"]
1196 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1197 #[doc = r" can finalize the request using the"]
1198 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1199 #[doc = r" that resolves to a lower-level [`Response`] value."]
1200 pub struct RequestBuilder {
1201 pub(crate) client: super::super::Client,
1202 pub(crate) organization: String,
1203 pub(crate) project: String,
1204 pub(crate) artifact_id: String,
1205 pub(crate) include_not_applicable: Option<bool>,
1206 pub(crate) top: Option<i32>,
1207 pub(crate) skip: Option<i32>,
1208 }
1209 impl RequestBuilder {
1210 #[doc = "Some policies might determine that they do not apply to a specific pull request. Setting this parameter to true will return evaluation records even for policies which don't apply to this pull request."]
1211 pub fn include_not_applicable(mut self, include_not_applicable: bool) -> Self {
1212 self.include_not_applicable = Some(include_not_applicable);
1213 self
1214 }
1215 #[doc = "The number of policy evaluation records to retrieve."]
1216 pub fn top(mut self, top: i32) -> Self {
1217 self.top = Some(top);
1218 self
1219 }
1220 #[doc = "The number of policy evaluation records to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100."]
1221 pub fn skip(mut self, skip: i32) -> Self {
1222 self.skip = Some(skip);
1223 self
1224 }
1225 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1226 #[doc = ""]
1227 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1228 #[doc = "However, this function can provide more flexibility when required."]
1229 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1230 Box::pin({
1231 let this = self.clone();
1232 async move {
1233 let url = this.url()?;
1234 let mut req =
1235 azure_core::http::Request::new(url, azure_core::http::Method::Get);
1236 if let Some(auth_header) = this
1237 .client
1238 .token_credential()
1239 .http_authorization_header(&this.client.scopes())
1240 .await?
1241 {
1242 req.insert_header(
1243 azure_core::http::headers::AUTHORIZATION,
1244 auth_header,
1245 );
1246 }
1247 let artifact_id = &this.artifact_id;
1248 req.url_mut()
1249 .query_pairs_mut()
1250 .append_pair("artifactId", artifact_id);
1251 if let Some(include_not_applicable) = &this.include_not_applicable {
1252 req.url_mut().query_pairs_mut().append_pair(
1253 "includeNotApplicable",
1254 &include_not_applicable.to_string(),
1255 );
1256 }
1257 if let Some(top) = &this.top {
1258 req.url_mut()
1259 .query_pairs_mut()
1260 .append_pair("$top", &top.to_string());
1261 }
1262 if let Some(skip) = &this.skip {
1263 req.url_mut()
1264 .query_pairs_mut()
1265 .append_pair("$skip", &skip.to_string());
1266 }
1267 let req_body = azure_core::Bytes::new();
1268 req.set_body(req_body);
1269 Ok(Response(this.client.send(&mut req).await?.into()))
1270 }
1271 })
1272 }
1273 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1274 let mut url = azure_core::http::Url::parse(&format!(
1275 "{}/{}/{}/_apis/policy/evaluations",
1276 self.client.endpoint(),
1277 &self.organization,
1278 &self.project
1279 ))?;
1280 let has_api_version_already = url
1281 .query_pairs()
1282 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1283 if !has_api_version_already {
1284 url.query_pairs_mut().append_pair(
1285 azure_core::http::headers::query_param::API_VERSION,
1286 "7.1-preview",
1287 );
1288 }
1289 Ok(url)
1290 }
1291 }
1292 impl std::future::IntoFuture for RequestBuilder {
1293 type Output = azure_core::Result<models::PolicyEvaluationRecordList>;
1294 type IntoFuture =
1295 BoxFuture<'static, azure_core::Result<models::PolicyEvaluationRecordList>>;
1296 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1297 #[doc = ""]
1298 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1299 #[doc = ""]
1300 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1301 fn into_future(self) -> Self::IntoFuture {
1302 Box::pin(async move { self.send().await?.into_body().await })
1303 }
1304 }
1305 }
1306 pub mod get {
1307 use super::models;
1308 #[cfg(not(target_arch = "wasm32"))]
1309 use futures::future::BoxFuture;
1310 #[cfg(target_arch = "wasm32")]
1311 use futures::future::LocalBoxFuture as BoxFuture;
1312 #[derive(Debug)]
1313 pub struct Response(
1314 azure_core::http::Response<
1315 models::PolicyEvaluationRecord,
1316 azure_core::http::JsonFormat,
1317 >,
1318 );
1319 impl Response {
1320 pub async fn into_body(self) -> azure_core::Result<models::PolicyEvaluationRecord> {
1321 self.0.into_body().await
1322 }
1323 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1324 self.0.into()
1325 }
1326 }
1327 #[derive(Clone)]
1328 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1329 #[doc = r""]
1330 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1331 #[doc = r" parameters can be chained."]
1332 #[doc = r""]
1333 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1334 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1335 #[doc = r" executes the request and returns a `Result` with the parsed"]
1336 #[doc = r" response."]
1337 #[doc = r""]
1338 #[doc = r" If you need lower-level access to the raw response details"]
1339 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1340 #[doc = r" can finalize the request using the"]
1341 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1342 #[doc = r" that resolves to a lower-level [`Response`] value."]
1343 pub struct RequestBuilder {
1344 pub(crate) client: super::super::Client,
1345 pub(crate) organization: String,
1346 pub(crate) project: String,
1347 pub(crate) evaluation_id: String,
1348 }
1349 impl RequestBuilder {
1350 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1351 #[doc = ""]
1352 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1353 #[doc = "However, this function can provide more flexibility when required."]
1354 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1355 Box::pin({
1356 let this = self.clone();
1357 async move {
1358 let url = this.url()?;
1359 let mut req =
1360 azure_core::http::Request::new(url, azure_core::http::Method::Get);
1361 if let Some(auth_header) = this
1362 .client
1363 .token_credential()
1364 .http_authorization_header(&this.client.scopes())
1365 .await?
1366 {
1367 req.insert_header(
1368 azure_core::http::headers::AUTHORIZATION,
1369 auth_header,
1370 );
1371 }
1372 let req_body = azure_core::Bytes::new();
1373 req.set_body(req_body);
1374 Ok(Response(this.client.send(&mut req).await?.into()))
1375 }
1376 })
1377 }
1378 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1379 let mut url = azure_core::http::Url::parse(&format!(
1380 "{}/{}/{}/_apis/policy/evaluations/{}",
1381 self.client.endpoint(),
1382 &self.organization,
1383 &self.project,
1384 &self.evaluation_id
1385 ))?;
1386 let has_api_version_already = url
1387 .query_pairs()
1388 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1389 if !has_api_version_already {
1390 url.query_pairs_mut().append_pair(
1391 azure_core::http::headers::query_param::API_VERSION,
1392 "7.1-preview",
1393 );
1394 }
1395 Ok(url)
1396 }
1397 }
1398 impl std::future::IntoFuture for RequestBuilder {
1399 type Output = azure_core::Result<models::PolicyEvaluationRecord>;
1400 type IntoFuture =
1401 BoxFuture<'static, azure_core::Result<models::PolicyEvaluationRecord>>;
1402 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1403 #[doc = ""]
1404 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1405 #[doc = ""]
1406 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1407 fn into_future(self) -> Self::IntoFuture {
1408 Box::pin(async move { self.send().await?.into_body().await })
1409 }
1410 }
1411 }
1412 pub mod requeue_policy_evaluation {
1413 use super::models;
1414 #[cfg(not(target_arch = "wasm32"))]
1415 use futures::future::BoxFuture;
1416 #[cfg(target_arch = "wasm32")]
1417 use futures::future::LocalBoxFuture as BoxFuture;
1418 #[derive(Debug)]
1419 pub struct Response(
1420 azure_core::http::Response<
1421 models::PolicyEvaluationRecord,
1422 azure_core::http::JsonFormat,
1423 >,
1424 );
1425 impl Response {
1426 pub async fn into_body(self) -> azure_core::Result<models::PolicyEvaluationRecord> {
1427 self.0.into_body().await
1428 }
1429 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1430 self.0.into()
1431 }
1432 }
1433 #[derive(Clone)]
1434 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1435 #[doc = r""]
1436 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1437 #[doc = r" parameters can be chained."]
1438 #[doc = r""]
1439 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1440 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1441 #[doc = r" executes the request and returns a `Result` with the parsed"]
1442 #[doc = r" response."]
1443 #[doc = r""]
1444 #[doc = r" If you need lower-level access to the raw response details"]
1445 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1446 #[doc = r" can finalize the request using the"]
1447 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1448 #[doc = r" that resolves to a lower-level [`Response`] value."]
1449 pub struct RequestBuilder {
1450 pub(crate) client: super::super::Client,
1451 pub(crate) organization: String,
1452 pub(crate) project: String,
1453 pub(crate) evaluation_id: String,
1454 }
1455 impl RequestBuilder {
1456 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1457 #[doc = ""]
1458 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1459 #[doc = "However, this function can provide more flexibility when required."]
1460 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1461 Box::pin({
1462 let this = self.clone();
1463 async move {
1464 let url = this.url()?;
1465 let mut req =
1466 azure_core::http::Request::new(url, azure_core::http::Method::Patch);
1467 if let Some(auth_header) = this
1468 .client
1469 .token_credential()
1470 .http_authorization_header(&this.client.scopes())
1471 .await?
1472 {
1473 req.insert_header(
1474 azure_core::http::headers::AUTHORIZATION,
1475 auth_header,
1476 );
1477 }
1478 let req_body = azure_core::Bytes::new();
1479 req.set_body(req_body);
1480 Ok(Response(this.client.send(&mut req).await?.into()))
1481 }
1482 })
1483 }
1484 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1485 let mut url = azure_core::http::Url::parse(&format!(
1486 "{}/{}/{}/_apis/policy/evaluations/{}",
1487 self.client.endpoint(),
1488 &self.organization,
1489 &self.project,
1490 &self.evaluation_id
1491 ))?;
1492 let has_api_version_already = url
1493 .query_pairs()
1494 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1495 if !has_api_version_already {
1496 url.query_pairs_mut().append_pair(
1497 azure_core::http::headers::query_param::API_VERSION,
1498 "7.1-preview",
1499 );
1500 }
1501 Ok(url)
1502 }
1503 }
1504 impl std::future::IntoFuture for RequestBuilder {
1505 type Output = azure_core::Result<models::PolicyEvaluationRecord>;
1506 type IntoFuture =
1507 BoxFuture<'static, azure_core::Result<models::PolicyEvaluationRecord>>;
1508 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1509 #[doc = ""]
1510 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1511 #[doc = ""]
1512 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1513 fn into_future(self) -> Self::IntoFuture {
1514 Box::pin(async move { self.send().await?.into_body().await })
1515 }
1516 }
1517 }
1518}
1519pub mod types {
1520 use super::models;
1521 #[cfg(not(target_arch = "wasm32"))]
1522 use futures::future::BoxFuture;
1523 #[cfg(target_arch = "wasm32")]
1524 use futures::future::LocalBoxFuture as BoxFuture;
1525 pub struct Client(pub(crate) super::Client);
1526 impl Client {
1527 #[doc = "Retrieve all available policy types."]
1528 #[doc = ""]
1529 #[doc = "Arguments:"]
1530 #[doc = "* `organization`: The name of the Azure DevOps organization."]
1531 #[doc = "* `project`: Project ID or project name"]
1532 pub fn list(
1533 &self,
1534 organization: impl Into<String>,
1535 project: impl Into<String>,
1536 ) -> list::RequestBuilder {
1537 list::RequestBuilder {
1538 client: self.0.clone(),
1539 organization: organization.into(),
1540 project: project.into(),
1541 }
1542 }
1543 #[doc = "Retrieve a specific policy type by ID."]
1544 #[doc = ""]
1545 #[doc = "Arguments:"]
1546 #[doc = "* `organization`: The name of the Azure DevOps organization."]
1547 #[doc = "* `project`: Project ID or project name"]
1548 #[doc = "* `type_id`: The policy ID."]
1549 pub fn get(
1550 &self,
1551 organization: impl Into<String>,
1552 project: impl Into<String>,
1553 type_id: impl Into<String>,
1554 ) -> get::RequestBuilder {
1555 get::RequestBuilder {
1556 client: self.0.clone(),
1557 organization: organization.into(),
1558 project: project.into(),
1559 type_id: type_id.into(),
1560 }
1561 }
1562 }
1563 pub mod list {
1564 use super::models;
1565 #[cfg(not(target_arch = "wasm32"))]
1566 use futures::future::BoxFuture;
1567 #[cfg(target_arch = "wasm32")]
1568 use futures::future::LocalBoxFuture as BoxFuture;
1569 #[derive(Debug)]
1570 pub struct Response(
1571 azure_core::http::Response<models::PolicyTypeList, azure_core::http::JsonFormat>,
1572 );
1573 impl Response {
1574 pub async fn into_body(self) -> azure_core::Result<models::PolicyTypeList> {
1575 self.0.into_body().await
1576 }
1577 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1578 self.0.into()
1579 }
1580 }
1581 #[derive(Clone)]
1582 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1583 #[doc = r""]
1584 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1585 #[doc = r" parameters can be chained."]
1586 #[doc = r""]
1587 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1588 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1589 #[doc = r" executes the request and returns a `Result` with the parsed"]
1590 #[doc = r" response."]
1591 #[doc = r""]
1592 #[doc = r" If you need lower-level access to the raw response details"]
1593 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1594 #[doc = r" can finalize the request using the"]
1595 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1596 #[doc = r" that resolves to a lower-level [`Response`] value."]
1597 pub struct RequestBuilder {
1598 pub(crate) client: super::super::Client,
1599 pub(crate) organization: String,
1600 pub(crate) project: String,
1601 }
1602 impl RequestBuilder {
1603 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1604 #[doc = ""]
1605 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1606 #[doc = "However, this function can provide more flexibility when required."]
1607 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1608 Box::pin({
1609 let this = self.clone();
1610 async move {
1611 let url = this.url()?;
1612 let mut req =
1613 azure_core::http::Request::new(url, azure_core::http::Method::Get);
1614 if let Some(auth_header) = this
1615 .client
1616 .token_credential()
1617 .http_authorization_header(&this.client.scopes())
1618 .await?
1619 {
1620 req.insert_header(
1621 azure_core::http::headers::AUTHORIZATION,
1622 auth_header,
1623 );
1624 }
1625 let req_body = azure_core::Bytes::new();
1626 req.set_body(req_body);
1627 Ok(Response(this.client.send(&mut req).await?.into()))
1628 }
1629 })
1630 }
1631 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1632 let mut url = azure_core::http::Url::parse(&format!(
1633 "{}/{}/{}/_apis/policy/types",
1634 self.client.endpoint(),
1635 &self.organization,
1636 &self.project
1637 ))?;
1638 let has_api_version_already = url
1639 .query_pairs()
1640 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1641 if !has_api_version_already {
1642 url.query_pairs_mut().append_pair(
1643 azure_core::http::headers::query_param::API_VERSION,
1644 "7.1-preview",
1645 );
1646 }
1647 Ok(url)
1648 }
1649 }
1650 impl std::future::IntoFuture for RequestBuilder {
1651 type Output = azure_core::Result<models::PolicyTypeList>;
1652 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyTypeList>>;
1653 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1654 #[doc = ""]
1655 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1656 #[doc = ""]
1657 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1658 fn into_future(self) -> Self::IntoFuture {
1659 Box::pin(async move { self.send().await?.into_body().await })
1660 }
1661 }
1662 }
1663 pub mod get {
1664 use super::models;
1665 #[cfg(not(target_arch = "wasm32"))]
1666 use futures::future::BoxFuture;
1667 #[cfg(target_arch = "wasm32")]
1668 use futures::future::LocalBoxFuture as BoxFuture;
1669 #[derive(Debug)]
1670 pub struct Response(
1671 azure_core::http::Response<models::PolicyType, azure_core::http::JsonFormat>,
1672 );
1673 impl Response {
1674 pub async fn into_body(self) -> azure_core::Result<models::PolicyType> {
1675 self.0.into_body().await
1676 }
1677 pub fn into_raw_response(self) -> azure_core::http::BufResponse {
1678 self.0.into()
1679 }
1680 }
1681 #[derive(Clone)]
1682 #[doc = r" `RequestBuilder` provides a mechanism for setting optional parameters on a request."]
1683 #[doc = r""]
1684 #[doc = r" Each `RequestBuilder` parameter method call returns `Self`, so setting of multiple"]
1685 #[doc = r" parameters can be chained."]
1686 #[doc = r""]
1687 #[doc = r" To finalize and submit the request, invoke `.await`, which"]
1688 #[doc = r" converts the [`RequestBuilder`] into a future,"]
1689 #[doc = r" executes the request and returns a `Result` with the parsed"]
1690 #[doc = r" response."]
1691 #[doc = r""]
1692 #[doc = r" If you need lower-level access to the raw response details"]
1693 #[doc = r" (e.g. to inspect response headers or raw body data) then you"]
1694 #[doc = r" can finalize the request using the"]
1695 #[doc = r" [`RequestBuilder::send()`] method which returns a future"]
1696 #[doc = r" that resolves to a lower-level [`Response`] value."]
1697 pub struct RequestBuilder {
1698 pub(crate) client: super::super::Client,
1699 pub(crate) organization: String,
1700 pub(crate) project: String,
1701 pub(crate) type_id: String,
1702 }
1703 impl RequestBuilder {
1704 #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
1705 #[doc = ""]
1706 #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
1707 #[doc = "However, this function can provide more flexibility when required."]
1708 pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
1709 Box::pin({
1710 let this = self.clone();
1711 async move {
1712 let url = this.url()?;
1713 let mut req =
1714 azure_core::http::Request::new(url, azure_core::http::Method::Get);
1715 if let Some(auth_header) = this
1716 .client
1717 .token_credential()
1718 .http_authorization_header(&this.client.scopes())
1719 .await?
1720 {
1721 req.insert_header(
1722 azure_core::http::headers::AUTHORIZATION,
1723 auth_header,
1724 );
1725 }
1726 let req_body = azure_core::Bytes::new();
1727 req.set_body(req_body);
1728 Ok(Response(this.client.send(&mut req).await?.into()))
1729 }
1730 })
1731 }
1732 fn url(&self) -> azure_core::Result<azure_core::http::Url> {
1733 let mut url = azure_core::http::Url::parse(&format!(
1734 "{}/{}/{}/_apis/policy/types/{}",
1735 self.client.endpoint(),
1736 &self.organization,
1737 &self.project,
1738 &self.type_id
1739 ))?;
1740 let has_api_version_already = url
1741 .query_pairs()
1742 .any(|(k, _)| k == azure_core::http::headers::query_param::API_VERSION);
1743 if !has_api_version_already {
1744 url.query_pairs_mut().append_pair(
1745 azure_core::http::headers::query_param::API_VERSION,
1746 "7.1-preview",
1747 );
1748 }
1749 Ok(url)
1750 }
1751 }
1752 impl std::future::IntoFuture for RequestBuilder {
1753 type Output = azure_core::Result<models::PolicyType>;
1754 type IntoFuture = BoxFuture<'static, azure_core::Result<models::PolicyType>>;
1755 #[doc = "Returns a future that sends the request and returns the parsed response body."]
1756 #[doc = ""]
1757 #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
1758 #[doc = ""]
1759 #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
1760 fn into_future(self) -> Self::IntoFuture {
1761 Box::pin(async move { self.send().await?.into_body().await })
1762 }
1763 }
1764 }
1765}