1use super::{configuration, Error};
12use crate::gen::apis::ResponseContent;
13use crate::gen::models;
14
15#[derive(Clone, Debug)]
17pub struct AddIssueTypesToContextParams {
18 pub field_id: String,
20 pub context_id: i64,
22 pub issue_type_ids: models::IssueTypeIds,
23}
24
25#[derive(Clone, Debug)]
27pub struct AssignProjectsToCustomFieldContextParams {
28 pub field_id: String,
30 pub context_id: i64,
32 pub project_ids: models::ProjectIds,
33}
34
35#[derive(Clone, Debug)]
37pub struct CreateCustomFieldContextParams {
38 pub field_id: String,
40 pub create_custom_field_context: models::CreateCustomFieldContext,
41}
42
43#[derive(Clone, Debug)]
45pub struct DeleteCustomFieldContextParams {
46 pub field_id: String,
48 pub context_id: i64,
50}
51
52#[derive(Clone, Debug)]
54pub struct GetContextsForFieldParams {
55 pub field_id: String,
57 pub is_any_issue_type: Option<bool>,
59 pub is_global_context: Option<bool>,
61 pub context_id: Option<Vec<i64>>,
63 pub start_at: Option<i64>,
65 pub max_results: Option<i32>,
67}
68
69#[derive(Clone, Debug)]
71pub struct GetCustomFieldContextsForProjectsAndIssueTypesParams {
72 pub field_id: String,
74 pub project_issue_type_mappings: models::ProjectIssueTypeMappings,
76 pub start_at: Option<i64>,
78 pub max_results: Option<i32>,
80}
81
82#[derive(Clone, Debug)]
84pub struct GetIssueTypeMappingsForContextsParams {
85 pub field_id: String,
87 pub context_id: Option<Vec<i64>>,
89 pub start_at: Option<i64>,
91 pub max_results: Option<i32>,
93}
94
95#[derive(Clone, Debug)]
97pub struct GetProjectContextMappingParams {
98 pub field_id: String,
100 pub context_id: Option<Vec<i64>>,
102 pub start_at: Option<i64>,
104 pub max_results: Option<i32>,
106}
107
108#[derive(Clone, Debug)]
110pub struct RemoveCustomFieldContextFromProjectsParams {
111 pub field_id: String,
113 pub context_id: i64,
115 pub project_ids: models::ProjectIds,
116}
117
118#[derive(Clone, Debug)]
120pub struct RemoveIssueTypesFromContextParams {
121 pub field_id: String,
123 pub context_id: i64,
125 pub issue_type_ids: models::IssueTypeIds,
126}
127
128#[derive(Clone, Debug)]
130pub struct UpdateCustomFieldContextParams {
131 pub field_id: String,
133 pub context_id: i64,
135 pub custom_field_context_update_details: models::CustomFieldContextUpdateDetails,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum AddIssueTypesToContextError {
142 Status400(),
143 Status401(),
144 Status403(),
145 Status404(),
146 Status409(),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum AssignProjectsToCustomFieldContextError {
154 Status400(),
155 Status401(),
156 Status403(),
157 Status404(),
158 UnknownValue(serde_json::Value),
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum CreateCustomFieldContextError {
165 Status400(),
166 Status401(),
167 Status404(),
168 Status409(),
169 UnknownValue(serde_json::Value),
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum DeleteCustomFieldContextError {
176 Status400(),
177 Status401(),
178 Status403(),
179 Status404(),
180 UnknownValue(serde_json::Value),
181}
182
183#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum GetContextsForFieldError {
187 Status401(),
188 Status403(),
189 Status404(),
190 UnknownValue(serde_json::Value),
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum GetCustomFieldContextsForProjectsAndIssueTypesError {
197 Status400(),
198 Status401(),
199 Status403(),
200 Status404(),
201 UnknownValue(serde_json::Value),
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum GetIssueTypeMappingsForContextsError {
208 Status401(),
209 Status403(),
210 UnknownValue(serde_json::Value),
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum GetProjectContextMappingError {
217 Status401(),
218 Status403(),
219 Status404(),
220 UnknownValue(serde_json::Value),
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum RemoveCustomFieldContextFromProjectsError {
227 Status400(),
228 Status401(),
229 Status403(),
230 Status404(),
231 UnknownValue(serde_json::Value),
232}
233
234#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(untagged)]
237pub enum RemoveIssueTypesFromContextError {
238 Status400(),
239 Status401(),
240 Status403(),
241 Status404(),
242 UnknownValue(serde_json::Value),
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum UpdateCustomFieldContextError {
249 Status400(),
250 Status401(),
251 Status403(),
252 Status404(),
253 UnknownValue(serde_json::Value),
254}
255
256pub async fn add_issue_types_to_context(
258 configuration: &configuration::Configuration,
259 params: AddIssueTypesToContextParams,
260) -> Result<serde_json::Value, Error<AddIssueTypesToContextError>> {
261 let field_id = params.field_id;
263 let context_id = params.context_id;
264 let issue_type_ids = params.issue_type_ids;
265
266 let local_var_client = &configuration.client;
267
268 let local_var_uri_str = format!(
269 "{}/rest/api/3/field/{fieldId}/context/{contextId}/issuetype",
270 configuration.base_path,
271 fieldId = crate::gen::apis::urlencode(field_id),
272 contextId = context_id
273 );
274 let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
275
276 if let Some(ref local_var_user_agent) = configuration.user_agent {
277 local_var_req_builder =
278 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
279 }
280 if let Some(ref local_var_token) = configuration.oauth_access_token {
281 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
282 };
283 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
284 local_var_req_builder = local_var_req_builder.basic_auth(
285 local_var_auth_conf.0.to_owned(),
286 local_var_auth_conf.1.to_owned(),
287 );
288 };
289 local_var_req_builder = local_var_req_builder.json(&issue_type_ids);
290
291 let local_var_req = local_var_req_builder.build()?;
292 let local_var_resp = local_var_client.execute(local_var_req).await?;
293
294 let local_var_status = local_var_resp.status();
295 let local_var_content = local_var_resp.text().await?;
296
297 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
298 serde_json::from_str(&local_var_content).map_err(Error::from)
299 } else {
300 let local_var_entity: Option<AddIssueTypesToContextError> =
301 serde_json::from_str(&local_var_content).ok();
302 let local_var_error = ResponseContent {
303 status: local_var_status,
304 content: local_var_content,
305 entity: local_var_entity,
306 };
307 Err(Error::ResponseError(local_var_error))
308 }
309}
310
311pub async fn assign_projects_to_custom_field_context(
313 configuration: &configuration::Configuration,
314 params: AssignProjectsToCustomFieldContextParams,
315) -> Result<serde_json::Value, Error<AssignProjectsToCustomFieldContextError>> {
316 let field_id = params.field_id;
318 let context_id = params.context_id;
319 let project_ids = params.project_ids;
320
321 let local_var_client = &configuration.client;
322
323 let local_var_uri_str = format!(
324 "{}/rest/api/3/field/{fieldId}/context/{contextId}/project",
325 configuration.base_path,
326 fieldId = crate::gen::apis::urlencode(field_id),
327 contextId = context_id
328 );
329 let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
330
331 if let Some(ref local_var_user_agent) = configuration.user_agent {
332 local_var_req_builder =
333 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
334 }
335 if let Some(ref local_var_token) = configuration.oauth_access_token {
336 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
337 };
338 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
339 local_var_req_builder = local_var_req_builder.basic_auth(
340 local_var_auth_conf.0.to_owned(),
341 local_var_auth_conf.1.to_owned(),
342 );
343 };
344 local_var_req_builder = local_var_req_builder.json(&project_ids);
345
346 let local_var_req = local_var_req_builder.build()?;
347 let local_var_resp = local_var_client.execute(local_var_req).await?;
348
349 let local_var_status = local_var_resp.status();
350 let local_var_content = local_var_resp.text().await?;
351
352 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
353 serde_json::from_str(&local_var_content).map_err(Error::from)
354 } else {
355 let local_var_entity: Option<AssignProjectsToCustomFieldContextError> =
356 serde_json::from_str(&local_var_content).ok();
357 let local_var_error = ResponseContent {
358 status: local_var_status,
359 content: local_var_content,
360 entity: local_var_entity,
361 };
362 Err(Error::ResponseError(local_var_error))
363 }
364}
365
366pub async fn create_custom_field_context(
368 configuration: &configuration::Configuration,
369 params: CreateCustomFieldContextParams,
370) -> Result<models::CreateCustomFieldContext, Error<CreateCustomFieldContextError>> {
371 let field_id = params.field_id;
373 let create_custom_field_context = params.create_custom_field_context;
374
375 let local_var_client = &configuration.client;
376
377 let local_var_uri_str = format!(
378 "{}/rest/api/3/field/{fieldId}/context",
379 configuration.base_path,
380 fieldId = crate::gen::apis::urlencode(field_id)
381 );
382 let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
383
384 if let Some(ref local_var_user_agent) = configuration.user_agent {
385 local_var_req_builder =
386 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
387 }
388 if let Some(ref local_var_token) = configuration.oauth_access_token {
389 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
390 };
391 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
392 local_var_req_builder = local_var_req_builder.basic_auth(
393 local_var_auth_conf.0.to_owned(),
394 local_var_auth_conf.1.to_owned(),
395 );
396 };
397 local_var_req_builder = local_var_req_builder.json(&create_custom_field_context);
398
399 let local_var_req = local_var_req_builder.build()?;
400 let local_var_resp = local_var_client.execute(local_var_req).await?;
401
402 let local_var_status = local_var_resp.status();
403 let local_var_content = local_var_resp.text().await?;
404
405 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
406 serde_json::from_str(&local_var_content).map_err(Error::from)
407 } else {
408 let local_var_entity: Option<CreateCustomFieldContextError> =
409 serde_json::from_str(&local_var_content).ok();
410 let local_var_error = ResponseContent {
411 status: local_var_status,
412 content: local_var_content,
413 entity: local_var_entity,
414 };
415 Err(Error::ResponseError(local_var_error))
416 }
417}
418
419pub async fn delete_custom_field_context(
421 configuration: &configuration::Configuration,
422 params: DeleteCustomFieldContextParams,
423) -> Result<serde_json::Value, Error<DeleteCustomFieldContextError>> {
424 let field_id = params.field_id;
426 let context_id = params.context_id;
427
428 let local_var_client = &configuration.client;
429
430 let local_var_uri_str = format!(
431 "{}/rest/api/3/field/{fieldId}/context/{contextId}",
432 configuration.base_path,
433 fieldId = crate::gen::apis::urlencode(field_id),
434 contextId = context_id
435 );
436 let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
437
438 if let Some(ref local_var_user_agent) = configuration.user_agent {
439 local_var_req_builder =
440 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
441 }
442 if let Some(ref local_var_token) = configuration.oauth_access_token {
443 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
444 };
445 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
446 local_var_req_builder = local_var_req_builder.basic_auth(
447 local_var_auth_conf.0.to_owned(),
448 local_var_auth_conf.1.to_owned(),
449 );
450 };
451
452 let local_var_req = local_var_req_builder.build()?;
453 let local_var_resp = local_var_client.execute(local_var_req).await?;
454
455 let local_var_status = local_var_resp.status();
456 let local_var_content = local_var_resp.text().await?;
457
458 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
459 serde_json::from_str(&local_var_content).map_err(Error::from)
460 } else {
461 let local_var_entity: Option<DeleteCustomFieldContextError> =
462 serde_json::from_str(&local_var_content).ok();
463 let local_var_error = ResponseContent {
464 status: local_var_status,
465 content: local_var_content,
466 entity: local_var_entity,
467 };
468 Err(Error::ResponseError(local_var_error))
469 }
470}
471
472pub async fn get_contexts_for_field(
474 configuration: &configuration::Configuration,
475 params: GetContextsForFieldParams,
476) -> Result<models::PageBeanCustomFieldContext, Error<GetContextsForFieldError>> {
477 let field_id = params.field_id;
479 let is_any_issue_type = params.is_any_issue_type;
480 let is_global_context = params.is_global_context;
481 let context_id = params.context_id;
482 let start_at = params.start_at;
483 let max_results = params.max_results;
484
485 let local_var_client = &configuration.client;
486
487 let local_var_uri_str = format!(
488 "{}/rest/api/3/field/{fieldId}/context",
489 configuration.base_path,
490 fieldId = crate::gen::apis::urlencode(field_id)
491 );
492 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
493
494 if let Some(ref local_var_str) = is_any_issue_type {
495 local_var_req_builder =
496 local_var_req_builder.query(&[("isAnyIssueType", &local_var_str.to_string())]);
497 }
498 if let Some(ref local_var_str) = is_global_context {
499 local_var_req_builder =
500 local_var_req_builder.query(&[("isGlobalContext", &local_var_str.to_string())]);
501 }
502 if let Some(ref local_var_str) = context_id {
503 local_var_req_builder = local_var_req_builder.query(&[(
504 "contextId",
505 &local_var_str
506 .into_iter()
507 .map(|p| p.to_string())
508 .collect::<Vec<String>>()
509 .join(",")
510 .to_string(),
511 )]);
512 }
513 if let Some(ref local_var_str) = start_at {
514 local_var_req_builder =
515 local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
516 }
517 if let Some(ref local_var_str) = max_results {
518 local_var_req_builder =
519 local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
520 }
521 if let Some(ref local_var_user_agent) = configuration.user_agent {
522 local_var_req_builder =
523 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
524 }
525 if let Some(ref local_var_token) = configuration.oauth_access_token {
526 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
527 };
528 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
529 local_var_req_builder = local_var_req_builder.basic_auth(
530 local_var_auth_conf.0.to_owned(),
531 local_var_auth_conf.1.to_owned(),
532 );
533 };
534
535 let local_var_req = local_var_req_builder.build()?;
536 let local_var_resp = local_var_client.execute(local_var_req).await?;
537
538 let local_var_status = local_var_resp.status();
539 let local_var_content = local_var_resp.text().await?;
540
541 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
542 serde_json::from_str(&local_var_content).map_err(Error::from)
543 } else {
544 let local_var_entity: Option<GetContextsForFieldError> =
545 serde_json::from_str(&local_var_content).ok();
546 let local_var_error = ResponseContent {
547 status: local_var_status,
548 content: local_var_content,
549 entity: local_var_entity,
550 };
551 Err(Error::ResponseError(local_var_error))
552 }
553}
554
555pub async fn get_custom_field_contexts_for_projects_and_issue_types(
557 configuration: &configuration::Configuration,
558 params: GetCustomFieldContextsForProjectsAndIssueTypesParams,
559) -> Result<
560 models::PageBeanContextForProjectAndIssueType,
561 Error<GetCustomFieldContextsForProjectsAndIssueTypesError>,
562> {
563 let field_id = params.field_id;
565 let project_issue_type_mappings = params.project_issue_type_mappings;
566 let start_at = params.start_at;
567 let max_results = params.max_results;
568
569 let local_var_client = &configuration.client;
570
571 let local_var_uri_str = format!(
572 "{}/rest/api/3/field/{fieldId}/context/mapping",
573 configuration.base_path,
574 fieldId = crate::gen::apis::urlencode(field_id)
575 );
576 let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
577
578 if let Some(ref local_var_str) = start_at {
579 local_var_req_builder =
580 local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
581 }
582 if let Some(ref local_var_str) = max_results {
583 local_var_req_builder =
584 local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
585 }
586 if let Some(ref local_var_user_agent) = configuration.user_agent {
587 local_var_req_builder =
588 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
589 }
590 if let Some(ref local_var_token) = configuration.oauth_access_token {
591 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
592 };
593 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
594 local_var_req_builder = local_var_req_builder.basic_auth(
595 local_var_auth_conf.0.to_owned(),
596 local_var_auth_conf.1.to_owned(),
597 );
598 };
599 local_var_req_builder = local_var_req_builder.json(&project_issue_type_mappings);
600
601 let local_var_req = local_var_req_builder.build()?;
602 let local_var_resp = local_var_client.execute(local_var_req).await?;
603
604 let local_var_status = local_var_resp.status();
605 let local_var_content = local_var_resp.text().await?;
606
607 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
608 serde_json::from_str(&local_var_content).map_err(Error::from)
609 } else {
610 let local_var_entity: Option<GetCustomFieldContextsForProjectsAndIssueTypesError> =
611 serde_json::from_str(&local_var_content).ok();
612 let local_var_error = ResponseContent {
613 status: local_var_status,
614 content: local_var_content,
615 entity: local_var_entity,
616 };
617 Err(Error::ResponseError(local_var_error))
618 }
619}
620
621pub async fn get_issue_type_mappings_for_contexts(
623 configuration: &configuration::Configuration,
624 params: GetIssueTypeMappingsForContextsParams,
625) -> Result<models::PageBeanIssueTypeToContextMapping, Error<GetIssueTypeMappingsForContextsError>>
626{
627 let field_id = params.field_id;
629 let context_id = params.context_id;
630 let start_at = params.start_at;
631 let max_results = params.max_results;
632
633 let local_var_client = &configuration.client;
634
635 let local_var_uri_str = format!(
636 "{}/rest/api/3/field/{fieldId}/context/issueTypeMapping",
637 configuration.base_path,
638 fieldId = crate::gen::apis::urlencode(field_id)
639 );
640 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
641
642 if let Some(ref local_var_str) = context_id {
643 local_var_req_builder = local_var_req_builder.query(&[(
644 "contextId",
645 &local_var_str
646 .into_iter()
647 .map(|p| p.to_string())
648 .collect::<Vec<String>>()
649 .join(",")
650 .to_string(),
651 )]);
652 }
653 if let Some(ref local_var_str) = start_at {
654 local_var_req_builder =
655 local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
656 }
657 if let Some(ref local_var_str) = max_results {
658 local_var_req_builder =
659 local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
660 }
661 if let Some(ref local_var_user_agent) = configuration.user_agent {
662 local_var_req_builder =
663 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
664 }
665 if let Some(ref local_var_token) = configuration.oauth_access_token {
666 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
667 };
668 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
669 local_var_req_builder = local_var_req_builder.basic_auth(
670 local_var_auth_conf.0.to_owned(),
671 local_var_auth_conf.1.to_owned(),
672 );
673 };
674
675 let local_var_req = local_var_req_builder.build()?;
676 let local_var_resp = local_var_client.execute(local_var_req).await?;
677
678 let local_var_status = local_var_resp.status();
679 let local_var_content = local_var_resp.text().await?;
680
681 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
682 serde_json::from_str(&local_var_content).map_err(Error::from)
683 } else {
684 let local_var_entity: Option<GetIssueTypeMappingsForContextsError> =
685 serde_json::from_str(&local_var_content).ok();
686 let local_var_error = ResponseContent {
687 status: local_var_status,
688 content: local_var_content,
689 entity: local_var_entity,
690 };
691 Err(Error::ResponseError(local_var_error))
692 }
693}
694
695pub async fn get_project_context_mapping(
697 configuration: &configuration::Configuration,
698 params: GetProjectContextMappingParams,
699) -> Result<models::PageBeanCustomFieldContextProjectMapping, Error<GetProjectContextMappingError>>
700{
701 let field_id = params.field_id;
703 let context_id = params.context_id;
704 let start_at = params.start_at;
705 let max_results = params.max_results;
706
707 let local_var_client = &configuration.client;
708
709 let local_var_uri_str = format!(
710 "{}/rest/api/3/field/{fieldId}/context/projectmapping",
711 configuration.base_path,
712 fieldId = crate::gen::apis::urlencode(field_id)
713 );
714 let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
715
716 if let Some(ref local_var_str) = context_id {
717 local_var_req_builder = local_var_req_builder.query(&[(
718 "contextId",
719 &local_var_str
720 .into_iter()
721 .map(|p| p.to_string())
722 .collect::<Vec<String>>()
723 .join(",")
724 .to_string(),
725 )]);
726 }
727 if let Some(ref local_var_str) = start_at {
728 local_var_req_builder =
729 local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
730 }
731 if let Some(ref local_var_str) = max_results {
732 local_var_req_builder =
733 local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
734 }
735 if let Some(ref local_var_user_agent) = configuration.user_agent {
736 local_var_req_builder =
737 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
738 }
739 if let Some(ref local_var_token) = configuration.oauth_access_token {
740 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
741 };
742 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
743 local_var_req_builder = local_var_req_builder.basic_auth(
744 local_var_auth_conf.0.to_owned(),
745 local_var_auth_conf.1.to_owned(),
746 );
747 };
748
749 let local_var_req = local_var_req_builder.build()?;
750 let local_var_resp = local_var_client.execute(local_var_req).await?;
751
752 let local_var_status = local_var_resp.status();
753 let local_var_content = local_var_resp.text().await?;
754
755 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
756 serde_json::from_str(&local_var_content).map_err(Error::from)
757 } else {
758 let local_var_entity: Option<GetProjectContextMappingError> =
759 serde_json::from_str(&local_var_content).ok();
760 let local_var_error = ResponseContent {
761 status: local_var_status,
762 content: local_var_content,
763 entity: local_var_entity,
764 };
765 Err(Error::ResponseError(local_var_error))
766 }
767}
768
769pub async fn remove_custom_field_context_from_projects(
771 configuration: &configuration::Configuration,
772 params: RemoveCustomFieldContextFromProjectsParams,
773) -> Result<serde_json::Value, Error<RemoveCustomFieldContextFromProjectsError>> {
774 let field_id = params.field_id;
776 let context_id = params.context_id;
777 let project_ids = params.project_ids;
778
779 let local_var_client = &configuration.client;
780
781 let local_var_uri_str = format!(
782 "{}/rest/api/3/field/{fieldId}/context/{contextId}/project/remove",
783 configuration.base_path,
784 fieldId = crate::gen::apis::urlencode(field_id),
785 contextId = context_id
786 );
787 let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
788
789 if let Some(ref local_var_user_agent) = configuration.user_agent {
790 local_var_req_builder =
791 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
792 }
793 if let Some(ref local_var_token) = configuration.oauth_access_token {
794 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
795 };
796 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
797 local_var_req_builder = local_var_req_builder.basic_auth(
798 local_var_auth_conf.0.to_owned(),
799 local_var_auth_conf.1.to_owned(),
800 );
801 };
802 local_var_req_builder = local_var_req_builder.json(&project_ids);
803
804 let local_var_req = local_var_req_builder.build()?;
805 let local_var_resp = local_var_client.execute(local_var_req).await?;
806
807 let local_var_status = local_var_resp.status();
808 let local_var_content = local_var_resp.text().await?;
809
810 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
811 serde_json::from_str(&local_var_content).map_err(Error::from)
812 } else {
813 let local_var_entity: Option<RemoveCustomFieldContextFromProjectsError> =
814 serde_json::from_str(&local_var_content).ok();
815 let local_var_error = ResponseContent {
816 status: local_var_status,
817 content: local_var_content,
818 entity: local_var_entity,
819 };
820 Err(Error::ResponseError(local_var_error))
821 }
822}
823
824pub async fn remove_issue_types_from_context(
826 configuration: &configuration::Configuration,
827 params: RemoveIssueTypesFromContextParams,
828) -> Result<serde_json::Value, Error<RemoveIssueTypesFromContextError>> {
829 let field_id = params.field_id;
831 let context_id = params.context_id;
832 let issue_type_ids = params.issue_type_ids;
833
834 let local_var_client = &configuration.client;
835
836 let local_var_uri_str = format!(
837 "{}/rest/api/3/field/{fieldId}/context/{contextId}/issuetype/remove",
838 configuration.base_path,
839 fieldId = crate::gen::apis::urlencode(field_id),
840 contextId = context_id
841 );
842 let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
843
844 if let Some(ref local_var_user_agent) = configuration.user_agent {
845 local_var_req_builder =
846 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
847 }
848 if let Some(ref local_var_token) = configuration.oauth_access_token {
849 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
850 };
851 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
852 local_var_req_builder = local_var_req_builder.basic_auth(
853 local_var_auth_conf.0.to_owned(),
854 local_var_auth_conf.1.to_owned(),
855 );
856 };
857 local_var_req_builder = local_var_req_builder.json(&issue_type_ids);
858
859 let local_var_req = local_var_req_builder.build()?;
860 let local_var_resp = local_var_client.execute(local_var_req).await?;
861
862 let local_var_status = local_var_resp.status();
863 let local_var_content = local_var_resp.text().await?;
864
865 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
866 serde_json::from_str(&local_var_content).map_err(Error::from)
867 } else {
868 let local_var_entity: Option<RemoveIssueTypesFromContextError> =
869 serde_json::from_str(&local_var_content).ok();
870 let local_var_error = ResponseContent {
871 status: local_var_status,
872 content: local_var_content,
873 entity: local_var_entity,
874 };
875 Err(Error::ResponseError(local_var_error))
876 }
877}
878
879pub async fn update_custom_field_context(
881 configuration: &configuration::Configuration,
882 params: UpdateCustomFieldContextParams,
883) -> Result<serde_json::Value, Error<UpdateCustomFieldContextError>> {
884 let field_id = params.field_id;
886 let context_id = params.context_id;
887 let custom_field_context_update_details = params.custom_field_context_update_details;
888
889 let local_var_client = &configuration.client;
890
891 let local_var_uri_str = format!(
892 "{}/rest/api/3/field/{fieldId}/context/{contextId}",
893 configuration.base_path,
894 fieldId = crate::gen::apis::urlencode(field_id),
895 contextId = context_id
896 );
897 let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
898
899 if let Some(ref local_var_user_agent) = configuration.user_agent {
900 local_var_req_builder =
901 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
902 }
903 if let Some(ref local_var_token) = configuration.oauth_access_token {
904 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
905 };
906 if let Some(ref local_var_auth_conf) = configuration.basic_auth {
907 local_var_req_builder = local_var_req_builder.basic_auth(
908 local_var_auth_conf.0.to_owned(),
909 local_var_auth_conf.1.to_owned(),
910 );
911 };
912 local_var_req_builder = local_var_req_builder.json(&custom_field_context_update_details);
913
914 let local_var_req = local_var_req_builder.build()?;
915 let local_var_resp = local_var_client.execute(local_var_req).await?;
916
917 let local_var_status = local_var_resp.status();
918 let local_var_content = local_var_resp.text().await?;
919
920 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
921 serde_json::from_str(&local_var_content).map_err(Error::from)
922 } else {
923 let local_var_entity: Option<UpdateCustomFieldContextError> =
924 serde_json::from_str(&local_var_content).ok();
925 let local_var_error = ResponseContent {
926 status: local_var_status,
927 content: local_var_content,
928 entity: local_var_entity,
929 };
930 Err(Error::ResponseError(local_var_error))
931 }
932}