atlassian-python-api 5.0.4__py3-none-any.whl → 5.0.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. atlassian/VERSION +1 -1
  2. atlassian/bamboo.py +1921 -29
  3. atlassian/bitbucket/__init__.py +407 -60
  4. atlassian/bitbucket/cloud/repositories/__init__.py +13 -4
  5. atlassian/bitbucket/cloud/repositories/groupPermissions.py +59 -0
  6. atlassian/bitbucket/cloud/repositories/pipelines.py +36 -5
  7. atlassian/bitbucket/cloud/repositories/pullRequests.py +9 -3
  8. atlassian/bitbucket/cloud/repositories/refs.py +22 -1
  9. atlassian/bitbucket/cloud/repositories/userPermissions.py +147 -0
  10. atlassian/bitbucket/cloud/workspaces/__init__.py +3 -1
  11. atlassian/bitbucket/cloud/workspaces/projects.py +4 -2
  12. atlassian/bitbucket/server/common/permissions.py +1 -1
  13. atlassian/bitbucket/server/globalPermissions.py +1 -1
  14. atlassian/bitbucket/server/projects/__init__.py +4 -2
  15. atlassian/bitbucket/server/projects/repos/__init__.py +30 -3
  16. atlassian/cloud_admin.py +1 -1
  17. atlassian/confluence/base.py +47 -2
  18. atlassian/confluence/cloud/__init__.py +412 -70
  19. atlassian/confluence/cloud/attachments.py +118 -0
  20. atlassian/confluence/cloud/blogposts.py +237 -0
  21. atlassian/confluence/cloud/cloud.py +291 -92
  22. atlassian/confluence/cloud/page_extras.py +145 -0
  23. atlassian/confluence/cloud/smart_links.py +94 -0
  24. atlassian/confluence/server/__init__.py +396 -214
  25. atlassian/confluence_base.py +71 -7
  26. atlassian/crowd.py +19 -11
  27. atlassian/insight.py +3 -3
  28. atlassian/jira/core_methods.py +31 -0
  29. atlassian/jira/jira_cloud.py +23 -2
  30. atlassian/jira/jira_server.py +829 -77
  31. atlassian/portfolio.py +15 -5
  32. atlassian/rest_client.py +56 -6
  33. atlassian/service_desk.py +373 -18
  34. atlassian/utils.py +17 -3
  35. {atlassian_python_api-5.0.4.dist-info → atlassian_python_api-5.0.6.dist-info}/METADATA +4 -7
  36. {atlassian_python_api-5.0.4.dist-info → atlassian_python_api-5.0.6.dist-info}/RECORD +39 -34
  37. {atlassian_python_api-5.0.4.dist-info → atlassian_python_api-5.0.6.dist-info}/WHEEL +1 -1
  38. {atlassian_python_api-5.0.4.dist-info → atlassian_python_api-5.0.6.dist-info}/licenses/LICENSE +0 -0
  39. {atlassian_python_api-5.0.4.dist-info → atlassian_python_api-5.0.6.dist-info}/top_level.txt +0 -0
atlassian/bamboo.py CHANGED
@@ -47,20 +47,22 @@ class Bamboo(AtlassianRestAPI):
47
47
  response.raise_for_status()
48
48
  response = response.json()
49
49
  except HTTPError as e:
50
- logging.error(f"Broken response: {e}")
51
- yield e
50
+ log.error(f"Broken response: {e}")
51
+ raise
52
52
  try:
53
53
  results = response[elements_key]
54
54
  size = 0
55
55
  # Check if we still can get results
56
- if size > max_results or results["size"] == 0:
56
+ if results["size"] == 0:
57
57
  return
58
58
  for r in results[element_key]:
59
+ if max_results is not None and size >= max_results:
60
+ return
59
61
  size += 1
60
62
  yield r
61
63
  except TypeError:
62
- logging.error(f"Broken response: {response}")
63
- yield response
64
+ log.error(f"Broken response: {response}")
65
+ raise
64
66
 
65
67
  def base_list_call(
66
68
  self,
@@ -87,16 +89,18 @@ class Bamboo(AtlassianRestAPI):
87
89
  # API representation for filtering by multiple labels.
88
90
  params["label"] = label if isinstance(label, str) else list(label)
89
91
  params.update(kwargs)
90
- if "elements_key" in kwargs and "element_key" in kwargs:
92
+ params["start-index"] = start_index
93
+ elements_key = params.pop("elements_key", None)
94
+ element_key = params.pop("element_key", None)
95
+ if elements_key and element_key:
91
96
  return self._get_generator(
92
97
  self.resource_url(resource),
93
98
  flags=flags,
94
99
  params=params,
95
- elements_key=kwargs["elements_key"],
96
- element_key=kwargs["element_key"],
100
+ elements_key=elements_key,
101
+ element_key=element_key,
97
102
  max_results=max_results,
98
103
  )
99
- params["start-index"] = start_index
100
104
  return self.get(self.resource_url(resource), flags=flags, params=params)
101
105
 
102
106
  """ Projects & Plans """
@@ -347,9 +351,12 @@ class Bamboo(AtlassianRestAPI):
347
351
  while params["start-index"] < size:
348
352
  results = self.get(self.resource_url("search/branches"), params=params)
349
353
  size = results["size"]
354
+ page_size = results["max-result"]
355
+ if page_size <= 0:
356
+ break
350
357
  for r in results["searchResults"]:
351
358
  yield r
352
- params["start-index"] += results["max-result"]
359
+ params["start-index"] += page_size
353
360
 
354
361
  def plan_branches(
355
362
  self,
@@ -454,6 +461,7 @@ class Bamboo(AtlassianRestAPI):
454
461
  max_results=25,
455
462
  include_all_states=False,
456
463
  build_state=None,
464
+ **kwargs,
457
465
  ):
458
466
  """
459
467
  Get results as generic method
@@ -471,6 +479,8 @@ class Bamboo(AtlassianRestAPI):
471
479
  :param include_all_states:
472
480
  :param build_state: Optional Bamboo result state, such as
473
481
  ``Successful`` or ``Failed``.
482
+ :param kwargs: Additional query parameters forwarded to the Bamboo
483
+ REST API.
474
484
  :return:
475
485
  """
476
486
  resource = "result"
@@ -500,7 +510,8 @@ class Bamboo(AtlassianRestAPI):
500
510
  elements_key="results",
501
511
  element_key="result",
502
512
  label=label,
503
- **params
513
+ **kwargs,
514
+ **params,
504
515
  ) # fmt: skip
505
516
 
506
517
  def latest_results(
@@ -587,6 +598,7 @@ class Bamboo(AtlassianRestAPI):
587
598
  max_results=25,
588
599
  include_all_states=False,
589
600
  build_state=None,
601
+ **kwargs,
590
602
  ):
591
603
  """
592
604
  Get Plan results
@@ -602,6 +614,8 @@ class Bamboo(AtlassianRestAPI):
602
614
  :param include_all_states:
603
615
  :param build_state: Optional Bamboo result state, such as
604
616
  ``Successful`` or ``Failed``.
617
+ :param kwargs: Additional query parameters passed to the Bamboo REST
618
+ API (for example ``issueStatus`` or ``jobKey`` filters).
605
619
  :return:
606
620
  """
607
621
  return self.results(
@@ -616,6 +630,7 @@ class Bamboo(AtlassianRestAPI):
616
630
  max_results=max_results,
617
631
  include_all_states=include_all_states,
618
632
  build_state=build_state,
633
+ **kwargs,
619
634
  )
620
635
 
621
636
  def ordered_plan_results(
@@ -743,9 +758,9 @@ class Bamboo(AtlassianRestAPI):
743
758
  :param build_key: Take full build key, example: PROJECT-PLAN-8
744
759
  """
745
760
  custom_resource = "/build/admin/deletePlanResults.action"
746
- build_key = build_key.split("-")
747
- plan_key = f"{build_key[0]}-{build_key[1]}"
748
- build_number = build_key[2]
761
+ build_key_parts = build_key.split("-")
762
+ plan_key = "-".join(build_key_parts[:-1])
763
+ build_number = build_key_parts[-1]
749
764
  params = {"buildKey": plan_key, "buildNumber": build_number}
750
765
  return self.post(custom_resource, params=params, headers=self.form_token_headers)
751
766
 
@@ -890,7 +905,6 @@ class Bamboo(AtlassianRestAPI):
890
905
  resource = f"result/{project_key}-{plan_key}-{build_number}/label/{label}"
891
906
  return self.delete(self.resource_url(resource))
892
907
 
893
- @property
894
908
  def get_projects(self, start=0, limit=25):
895
909
  """Method used to list all projects defined in Bamboo.
896
910
  Projects without any plan are not listed.
@@ -960,9 +974,12 @@ class Bamboo(AtlassianRestAPI):
960
974
  while params["start-index"] < size:
961
975
  results = self.get(self.resource_url(resource), params=params)
962
976
  size = results["size"]
977
+ page_size = results["max-result"]
978
+ if page_size <= 0:
979
+ break
963
980
  for r in results["results"]:
964
981
  yield r
965
- params["start-index"] += results["max-result"]
982
+ params["start-index"] += page_size
966
983
 
967
984
  def deployment_dashboard(self, project_id=None):
968
985
  """
@@ -1110,7 +1127,7 @@ class Bamboo(AtlassianRestAPI):
1110
1127
  """
1111
1128
  params = {"limit": limit, "start": start}
1112
1129
  if filter_name:
1113
- params = {"name": filter_name}
1130
+ params["name"] = filter_name
1114
1131
  resource = f"permissions/deployment/{deployment_id}/users"
1115
1132
  return self.get(self.resource_url(resource), params=params)
1116
1133
 
@@ -1149,7 +1166,7 @@ class Bamboo(AtlassianRestAPI):
1149
1166
  """
1150
1167
  params = {"limit": limit, "start": start}
1151
1168
  if filter_name:
1152
- params = {"name": filter_name}
1169
+ params["name"] = filter_name
1153
1170
  resource = f"permissions/deployment/{deployment_id}/groups"
1154
1171
  return self.get(self.resource_url(resource), params=params)
1155
1172
 
@@ -1188,7 +1205,7 @@ class Bamboo(AtlassianRestAPI):
1188
1205
  """
1189
1206
  params = {"limit": limit, "start": start}
1190
1207
  if filter_name:
1191
- params = {"name": filter_name}
1208
+ params["name"] = filter_name
1192
1209
  resource = f"permissions/environment/{environment_id}/users"
1193
1210
  return self.get(self.resource_url(resource), params=params)
1194
1211
 
@@ -1227,7 +1244,7 @@ class Bamboo(AtlassianRestAPI):
1227
1244
  """
1228
1245
  params = {"limit": limit, "start": start}
1229
1246
  if filter_name:
1230
- params = {"name": filter_name}
1247
+ params["name"] = filter_name
1231
1248
  resource = f"permissions/environment/{environment_id}/groups"
1232
1249
  return self.get(self.resource_url(resource), params=params)
1233
1250
 
@@ -1361,23 +1378,23 @@ class Bamboo(AtlassianRestAPI):
1361
1378
 
1362
1379
  def get_plan_variables(self, plan_key):
1363
1380
  """Return variables configured for a plan."""
1364
- return self.get(self.resource_url(f"plan/{plan_key}/variable"))
1381
+ return self.get(self.resource_url(f"plan/{plan_key}/variables"))
1365
1382
 
1366
1383
  def get_plan_variable(self, plan_key, variable_name):
1367
1384
  """Return one plan variable by name."""
1368
- return self.get(self.resource_url(f"plan/{plan_key}/variable/{variable_name}"))
1385
+ return self.get(self.resource_url(f"plan/{plan_key}/variables/{variable_name}"))
1369
1386
 
1370
1387
  def create_plan_variable(self, plan_key, data):
1371
1388
  """Create a plan variable from Bamboo's variable request body."""
1372
- return self.post(self.resource_url(f"plan/{plan_key}/variable"), data=data)
1389
+ return self.post(self.resource_url(f"plan/{plan_key}/variables"), data=data)
1373
1390
 
1374
1391
  def update_plan_variable(self, plan_key, variable_name, data):
1375
1392
  """Update a plan variable."""
1376
- return self.put(self.resource_url(f"plan/{plan_key}/variable/{variable_name}"), data=data)
1393
+ return self.put(self.resource_url(f"plan/{plan_key}/variables/{variable_name}"), data=data)
1377
1394
 
1378
1395
  def delete_plan_variable(self, plan_key, variable_name):
1379
1396
  """Delete a plan variable."""
1380
- return self.delete(self.resource_url(f"plan/{plan_key}/variable/{variable_name}"))
1397
+ return self.delete(self.resource_url(f"plan/{plan_key}/variables/{variable_name}"))
1381
1398
 
1382
1399
  def activity(self, busy=None):
1383
1400
  """Return active online agents and their current build activity.
@@ -1561,7 +1578,7 @@ class Bamboo(AtlassianRestAPI):
1561
1578
  :param data: dict - deployment project representation
1562
1579
  :return: created deployment project
1563
1580
  """
1564
- return self.post(self.resource_url("deploy/project"), data=data)
1581
+ return self.put(self.resource_url("deploy/project"), data=data)
1565
1582
 
1566
1583
  def update_deployment_project(self, project_id, data):
1567
1584
  """
@@ -1570,7 +1587,7 @@ class Bamboo(AtlassianRestAPI):
1570
1587
  :param data: dict - deployment project representation
1571
1588
  :return:
1572
1589
  """
1573
- return self.put(self.resource_url(f"deploy/project/{project_id}"), data=data)
1590
+ return self.post(self.resource_url(f"deploy/project/{project_id}"), data=data)
1574
1591
 
1575
1592
  def create_deployment_environment(self, project_id, data):
1576
1593
  """
@@ -2411,7 +2428,6 @@ class Bamboo(AtlassianRestAPI):
2411
2428
  :param plugin_path:
2412
2429
  :return:
2413
2430
  """
2414
- files = {"plugin": open(plugin_path, "rb")}
2415
2431
  upm_token = self.request(
2416
2432
  method="GET",
2417
2433
  path="rest/plugins/1.0/",
@@ -2419,7 +2435,9 @@ class Bamboo(AtlassianRestAPI):
2419
2435
  trailing=True,
2420
2436
  ).headers["upm-token"]
2421
2437
  url = f"rest/plugins/1.0/?token={upm_token}"
2422
- return self.post(url, files=files, headers=self.no_check_headers)
2438
+ with open(plugin_path, "rb") as plugin_file:
2439
+ files = {"plugin": plugin_file}
2440
+ return self.post(url, files=files, headers=self.no_check_headers)
2423
2441
 
2424
2442
  def disable_plugin(self, plugin_key):
2425
2443
  """
@@ -2480,3 +2498,1877 @@ class Bamboo(AtlassianRestAPI):
2480
2498
  url = f"/plugins/1.0/{plugin_key}/license"
2481
2499
  data = {"rawLicense": raw_license}
2482
2500
  return self.put(url, data=data, headers=app_headers)
2501
+
2502
+ """Admin (root API)"""
2503
+
2504
+ def invalidate_user_sessions(self, name, user):
2505
+ """Invalidate active sessions of the given user
2506
+ :param name: name path parameter
2507
+ :param user: user path parameter
2508
+ :return:
2509
+ """
2510
+ return self.delete(self._admin_url(f"session/{name}"))
2511
+
2512
+ def get_configuration(self):
2513
+ """Retrieves ephemeral agents configuration.
2514
+ :return:
2515
+ """
2516
+ return self.get(self._admin_url("ephemeral/config"))
2517
+
2518
+ def get_configuration_1(self):
2519
+ """Retrieves global build and deployment expiry configuration for this Bamboo instance.
2520
+ :return:
2521
+ """
2522
+ return self.get(self._admin_url("expiry/configuration"))
2523
+
2524
+ def get_status(self):
2525
+ """Retrieves build and deployment expiry status.
2526
+ :return:
2527
+ """
2528
+ return self.get(self._admin_url("expiry/status"))
2529
+
2530
+ def get_jobs(self):
2531
+ """Gets the collection of jobs currently scheduled to run.
2532
+ :return:
2533
+ """
2534
+ return self.get(self._admin_url("scheduler/jobs"))
2535
+
2536
+ def get_system_info(self):
2537
+ """Read system information.
2538
+ :return:
2539
+ """
2540
+ return self.get(self._admin_url("systemInfo"))
2541
+
2542
+ def test_connection(self, data):
2543
+ """Test connection to ephemeral agents provider.
2544
+ :param data: request body (dict or list)
2545
+ :return:
2546
+ """
2547
+ return self.post(self._admin_url("ephemeral/config/test-connection"), data=data)
2548
+
2549
+ def trigger_job(self, data):
2550
+ """Trigger background job execution.
2551
+ :param data: request body (dict or list)
2552
+ :return:
2553
+ """
2554
+ return self.post(self._admin_url("scheduler/jobs/trigger"), data=data)
2555
+
2556
+ def rename_user_post(self, data, external_rename=None):
2557
+ """Renames specified user.
2558
+ :param external_rename: externalRename query parameter
2559
+ :param data: request body (dict or list)
2560
+ :return:
2561
+ """
2562
+ params = {}
2563
+ if external_rename is not None:
2564
+ params["externalRename"] = external_rename
2565
+ return self.post(self._admin_url("user"), params=params, data=data)
2566
+
2567
+ def save_configuration(self, data):
2568
+ """Modify ephemeral agents configuration.
2569
+ :param data: request body (dict or list)
2570
+ :return:
2571
+ """
2572
+ return self.put(self._admin_url("ephemeral/config"), data=data)
2573
+
2574
+ def set_configuration(self, data):
2575
+ """Update global build and deployment expiry configuration for this Bamboo instance. Partial configuration is not allowed (it will fail validation).
2576
+ :param data: request body (dict or list)
2577
+ :return:
2578
+ """
2579
+ return self.put(self._admin_url("expiry/configuration"), data=data)
2580
+
2581
+ def run(self):
2582
+ """Executes build and deployment expiry process. Will only start each process if it's not currently running.
2583
+ :return:
2584
+ """
2585
+ return self.put(self._admin_url("expiry/run"))
2586
+
2587
+ def rename_user_put(self, new_user_name, data, external_rename=None):
2588
+ """Renames specified user.
2589
+ :param new_user_name: newUserName path parameter
2590
+ :param external_rename: externalRename query parameter
2591
+ :param data: request body (dict or list)
2592
+ :return:
2593
+ """
2594
+ params = {}
2595
+ if external_rename is not None:
2596
+ params["externalRename"] = external_rename
2597
+ return self.put(self._admin_url(f"user/{new_user_name}"), params=params, data=data)
2598
+
2599
+ """Admin (users)"""
2600
+
2601
+ def remove_plan_custom_expiry_settings(self, plan_key):
2602
+ """Delete custom plan expiry settings.
2603
+ :param plan_key: planKey path parameter
2604
+ :return:
2605
+ """
2606
+ return self.delete(self.resource_url(f"admin/expiry/custom/plan/{plan_key}"))
2607
+
2608
+ def unassign_groups(self, name, data):
2609
+ """Remove a user from multiple groups. The authenticated user must have restricted administrative permission or higher to use this resource.
2610
+ :param name: name path parameter
2611
+ :param data: request body (dict or list)
2612
+ :return:
2613
+ """
2614
+ return self.delete(self.resource_url(f"admin/users/{name}/groups"), data=data)
2615
+
2616
+ def find_assigned_groups(self, name, filter=None, limit=None, start=None):
2617
+ """Retrieves a list of groups to which the user belongs. The authenticated user must have restricted administrative permission or higher to use this resource.
2618
+ :param name: name path parameter
2619
+ :param filter: filter query parameter
2620
+ :param limit: limit query parameter
2621
+ :param start: start query parameter
2622
+ :return:
2623
+ """
2624
+ params = {}
2625
+ if filter is not None:
2626
+ params["filter"] = filter
2627
+ if limit is not None:
2628
+ params["limit"] = limit
2629
+ if start is not None:
2630
+ params["start"] = start
2631
+ return self.get(self.resource_url(f"admin/users/{name}/assigned-groups"), params=params)
2632
+
2633
+ def find_unassigned_user_repository_aliases(self, name, filter=None, limit=None, start=None):
2634
+ """Retrieves a list of unlinked aliases to which the user does not belong. The authenticated user must have restricted administrative permission or higher to use this resource.
2635
+ :param name: name path parameter
2636
+ :param filter: filter query parameter
2637
+ :param limit: limit query parameter
2638
+ :param start: start query parameter
2639
+ :return:
2640
+ """
2641
+ params = {}
2642
+ if filter is not None:
2643
+ params["filter"] = filter
2644
+ if limit is not None:
2645
+ params["limit"] = limit
2646
+ if start is not None:
2647
+ params["start"] = start
2648
+ return self.get(self.resource_url(f"admin/users/{name}/unassigned-aliases"), params=params)
2649
+
2650
+ def find_unassigned_groups(self, name, filter=None, limit=None, start=None):
2651
+ """Retrieves a list of groups to which the user does not belong. The authenticated user must have restricted administrative permission or higher to use this resource.
2652
+ :param name: name path parameter
2653
+ :param filter: filter query parameter
2654
+ :param limit: limit query parameter
2655
+ :param start: start query parameter
2656
+ :return:
2657
+ """
2658
+ params = {}
2659
+ if filter is not None:
2660
+ params["filter"] = filter
2661
+ if limit is not None:
2662
+ params["limit"] = limit
2663
+ if start is not None:
2664
+ params["start"] = start
2665
+ return self.get(self.resource_url(f"admin/users/{name}/unassigned-groups"), params=params)
2666
+
2667
+ def assign_groups(self, name, data):
2668
+ """Add a user to multiple groups. The authenticated user must have restricted administrative permission or higher to use this resource.
2669
+ :param name: name path parameter
2670
+ :param data: request body (dict or list)
2671
+ :return:
2672
+ """
2673
+ return self.post(self.resource_url(f"admin/users/{name}/groups"), data=data)
2674
+
2675
+ """Agents & assignments"""
2676
+
2677
+ def delete_agent(self, agent_id):
2678
+ """Remove build agent.
2679
+ :param agent_id: agentId path parameter
2680
+ :return:
2681
+ """
2682
+ return self.delete(self.resource_url(f"agent/{agent_id}"))
2683
+
2684
+ def remove_assignment(self, executor_type=None, executor_id=None, entity_id=None, assignment_type=None):
2685
+ """Remove agent's assignment.
2686
+ :param executor_type: executorType query parameter
2687
+ :param executor_id: executorId query parameter
2688
+ :param entity_id: entityId query parameter
2689
+ :param assignment_type: assignmentType query parameter
2690
+ :return:
2691
+ """
2692
+ params = {}
2693
+ if executor_type is not None:
2694
+ params["executorType"] = executor_type
2695
+ if executor_id is not None:
2696
+ params["executorId"] = executor_id
2697
+ if entity_id is not None:
2698
+ params["entityId"] = entity_id
2699
+ if assignment_type is not None:
2700
+ params["assignmentType"] = assignment_type
2701
+ return self.delete(self.resource_url("agent/assignment"), params=params)
2702
+
2703
+ def remove_agent_assignment_from_job(self, job_key, executor_key):
2704
+ """Remove agent/image from list of dedicated executors for given job.
2705
+ :param job_key: jobKey path parameter
2706
+ :param executor_key: executorKey path parameter
2707
+ :return:
2708
+ """
2709
+ return self.delete(self.resource_url(f"config/job/{job_key}/agent-assignment/{executor_key}"))
2710
+
2711
+ def search_entity_for_agent(
2712
+ self,
2713
+ max_result=None,
2714
+ executor_type=None,
2715
+ search_term=None,
2716
+ executor_id=None,
2717
+ entity_type=None,
2718
+ start_index=None,
2719
+ assignment_type=None,
2720
+ ):
2721
+ """Search for assignments in specified entity's agents
2722
+ :param max_result: max-result query parameter
2723
+ :param executor_type: executorType query parameter
2724
+ :param search_term: searchTerm query parameter
2725
+ :param executor_id: executorId query parameter
2726
+ :param entity_type: entityType query parameter
2727
+ :param start_index: start-index query parameter
2728
+ :param assignment_type: assignmentType query parameter
2729
+ :return:
2730
+ """
2731
+ params = {}
2732
+ if max_result is not None:
2733
+ params["max-result"] = max_result
2734
+ if executor_type is not None:
2735
+ params["executorType"] = executor_type
2736
+ if search_term is not None:
2737
+ params["searchTerm"] = search_term
2738
+ if executor_id is not None:
2739
+ params["executorId"] = executor_id
2740
+ if entity_type is not None:
2741
+ params["entityType"] = entity_type
2742
+ if start_index is not None:
2743
+ params["start-index"] = start_index
2744
+ if assignment_type is not None:
2745
+ params["assignmentType"] = assignment_type
2746
+ return self.get(self.resource_url("agent/assignment/search"), params=params)
2747
+
2748
+ def find_assigned_agents_by_job(self, job_key):
2749
+ """Get a list of agents/images assigned to given job.
2750
+ :param job_key: jobKey path parameter
2751
+ :return:
2752
+ """
2753
+ return self.get(self.resource_url(f"config/job/{job_key}/agent-assignment"))
2754
+
2755
+ def find_possible_agents_for_job(self, job_key, max_result=None, search_term=None, start_index=None):
2756
+ """Get a list of agents/images/templates which can be dedicated for given job.
2757
+ :param job_key: jobKey path parameter
2758
+ :param max_result: max-result query parameter
2759
+ :param search_term: searchTerm query parameter
2760
+ :param start_index: start-index query parameter
2761
+ :return:
2762
+ """
2763
+ params = {}
2764
+ if max_result is not None:
2765
+ params["max-result"] = max_result
2766
+ if search_term is not None:
2767
+ params["searchTerm"] = search_term
2768
+ if start_index is not None:
2769
+ params["start-index"] = start_index
2770
+ return self.get(
2771
+ self.resource_url(f"config/job/{job_key}/agent-assignment/possible-agent-assignment"),
2772
+ params=params,
2773
+ )
2774
+
2775
+ def add_agent_assignment(self, executor_type=None, executor_id=None, entity_id=None, assignment_type=None):
2776
+ """Dedicate agent, elastic image or ephemeral template.
2777
+ :param executor_type: executorType query parameter
2778
+ :param executor_id: executorId query parameter
2779
+ :param entity_id: entityId query parameter
2780
+ :param assignment_type: assignmentType query parameter
2781
+ :return:
2782
+ """
2783
+ params = {}
2784
+ if executor_type is not None:
2785
+ params["executorType"] = executor_type
2786
+ if executor_id is not None:
2787
+ params["executorId"] = executor_id
2788
+ if entity_id is not None:
2789
+ params["entityId"] = entity_id
2790
+ if assignment_type is not None:
2791
+ params["assignmentType"] = assignment_type
2792
+ return self.post(self.resource_url("agent/assignment"), params=params)
2793
+
2794
+ def add_agent_assignment_for_job(self, job_key, data):
2795
+ """Add agent assignment for job. agentAssignmentKey is a map with one key-value: name - agentAssignmentKey.
2796
+ :param job_key: jobKey path parameter
2797
+ :param data: request body (dict or list)
2798
+ :return:
2799
+ """
2800
+ return self.post(self.resource_url(f"config/job/{job_key}/agent-assignment"), data=data)
2801
+
2802
+ def update_agent_capability(self, agent_id, capability_key, data):
2803
+ """Update existing agent capability. It's allowed to skip capability key at request payload.
2804
+ :param agent_id: agentId path parameter
2805
+ :param capability_key: capabilityKey path parameter
2806
+ :param data: request body (dict or list)
2807
+ :return:
2808
+ """
2809
+ return self.put(self.resource_url(f"agent/{agent_id}/capability/{capability_key}"), data=data)
2810
+
2811
+ """Avatars"""
2812
+
2813
+ def delete_avatar(self):
2814
+ """Deletes the current avatar for the currently authenticated user.
2815
+ :return:
2816
+ """
2817
+ return self.delete(self.resource_url("avatar/user/avatar.png"))
2818
+
2819
+ def retrieve_avatar(self, user_name, s=None):
2820
+ """Returns either the avatar file for a specified user or the gravatar URL. The priority order: custom user avatar as a file, gravatar URL, default avatar as a file. The endpoint supports Last-Modified/If-Modified-Since headers and sets cache policy with expiration equal by default to 90 seconds.
2821
+ :param user_name: userName path parameter
2822
+ :param s: s query parameter
2823
+ :return:
2824
+ """
2825
+ params = {}
2826
+ if s is not None:
2827
+ params["s"] = s
2828
+ return self.get(self.resource_url(f"avatar/user/{user_name}/avatar.png"), params=params)
2829
+
2830
+ def upload_avatar(self, data):
2831
+ """Updated the avatar for the currently authenticated user.
2832
+ :param data: request body (dict or list)
2833
+ :return:
2834
+ """
2835
+ return self.put(self.resource_url("avatar/user/avatar.png"), data=data)
2836
+
2837
+ """Deployments"""
2838
+
2839
+ def remove_agent_assignment_from_environment(self, environment_id, executor_key):
2840
+ """Remove agent/image from list of dedicated executors for given environment.
2841
+ :param environment_id: environmentId path parameter
2842
+ :param executor_key: executorKey path parameter
2843
+ :return:
2844
+ """
2845
+ return self.delete(
2846
+ self.resource_url(f"deploy/environment/{environment_id}/agent-assignment/{executor_key}"),
2847
+ )
2848
+
2849
+ def remove_requirement_from_environment(self, environment_id, requirement_id):
2850
+ """Removes a requirement for an environment.
2851
+ :param environment_id: environmentId path parameter
2852
+ :param requirement_id: requirementId path parameter
2853
+ :return:
2854
+ """
2855
+ return self.delete(
2856
+ self.resource_url(f"deploy/environment/{environment_id}/requirement/{requirement_id}"),
2857
+ )
2858
+
2859
+ def delete_environment_variable(self, environment_id, variable_name):
2860
+ """Delete the environment variable.
2861
+ :param environment_id: environmentId path parameter
2862
+ :param variable_name: variableName path parameter
2863
+ :return:
2864
+ """
2865
+ return self.delete(self.resource_url(f"deploy/environment/{environment_id}/variable/{variable_name}"))
2866
+
2867
+ def delete_repository_mapping(self, deployment_project_id, repository_id):
2868
+ """Remove approval to create plans in given deployment project by given repository.
2869
+ :param deployment_project_id: deploymentProjectId path parameter
2870
+ :param repository_id: repositoryId path parameter
2871
+ :return:
2872
+ """
2873
+ return self.delete(
2874
+ self.resource_url(f"deploy/project/{deployment_project_id}/repository/{repository_id}"),
2875
+ )
2876
+
2877
+ def get_all_deployment_projects(self):
2878
+ """Get all deployment projects. This method fetch all deployment projects visible to user. It's not optimized for instances with large count of deployment projects and environments, use paged versions instead.
2879
+ :return:
2880
+ """
2881
+ return self.get(self.resource_url("deploy/dashboard"))
2882
+
2883
+ def get_deployment_project(self, project_id):
2884
+ """Get deployment project environments with deployment status. It's not optimized for instances with large count of deployment projects and environments, use paged versions instead.
2885
+ :param project_id: projectId path parameter
2886
+ :return:
2887
+ """
2888
+ return self.get(self.resource_url(f"deploy/dashboard/{project_id}"))
2889
+
2890
+ def get_deployment_projects(self, filter=None, limit=None, start=None):
2891
+ """Get paginated deployment projects with environments list.
2892
+ :param filter: filter query parameter
2893
+ :param limit: limit query parameter
2894
+ :param start: start query parameter
2895
+ :return:
2896
+ """
2897
+ params = {}
2898
+ if filter is not None:
2899
+ params["filter"] = filter
2900
+ if limit is not None:
2901
+ params["limit"] = limit
2902
+ if start is not None:
2903
+ params["start"] = start
2904
+ return self.get(self.resource_url("deploy/dashboard/paginate"), params=params)
2905
+
2906
+ def get_paginate_deployment_project(self, project_id, filter=None, limit=None, start=None):
2907
+ """Get deployment project environments.
2908
+ :param project_id: projectId path parameter
2909
+ :param filter: filter query parameter
2910
+ :param limit: limit query parameter
2911
+ :param start: start query parameter
2912
+ :return:
2913
+ """
2914
+ params = {}
2915
+ if filter is not None:
2916
+ params["filter"] = filter
2917
+ if limit is not None:
2918
+ params["limit"] = limit
2919
+ if start is not None:
2920
+ params["start"] = start
2921
+ return self.get(self.resource_url(f"deploy/dashboard/paginate/{project_id}"), params=params)
2922
+
2923
+ def find_assigned_agents_by_environment(self, environment_id):
2924
+ """Get a list of agents/images assigned to given environment.
2925
+ :param environment_id: environmentId path parameter
2926
+ :return:
2927
+ """
2928
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/agent-assignment"))
2929
+
2930
+ def get_docker_pipelines_configuration(self, environment_id):
2931
+ """Get Docker configuration for given environment.
2932
+ :param environment_id: environmentId path parameter
2933
+ :return:
2934
+ """
2935
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/docker"))
2936
+
2937
+ def find_possible_agents_for_environment(self, environment_id, max_result=None, search_term=None, start_index=None):
2938
+ """Get a list of agents/images/templates which can be dedicated for given environment.
2939
+ :param environment_id: environmentId path parameter
2940
+ :param max_result: max-result query parameter
2941
+ :param search_term: searchTerm query parameter
2942
+ :param start_index: start-index query parameter
2943
+ :return:
2944
+ """
2945
+ params = {}
2946
+ if max_result is not None:
2947
+ params["max-result"] = max_result
2948
+ if search_term is not None:
2949
+ params["searchTerm"] = search_term
2950
+ if start_index is not None:
2951
+ params["start-index"] = start_index
2952
+ return self.get(
2953
+ self.resource_url(f"deploy/environment/{environment_id}/possible-agent-assignment"),
2954
+ params=params,
2955
+ )
2956
+
2957
+ def get_requirements_for_environment(self, environment_id):
2958
+ """Gets all the requirements of an environment.
2959
+ :param environment_id: environmentId path parameter
2960
+ :return:
2961
+ """
2962
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/requirement"))
2963
+
2964
+ def get_requirement_for_environment(self, environment_id, requirement_id):
2965
+ """Gets the details of a requirement for a given environment.
2966
+ :param environment_id: environmentId path parameter
2967
+ :param requirement_id: requirementId path parameter
2968
+ :return:
2969
+ """
2970
+ return self.get(
2971
+ self.resource_url(f"deploy/environment/{environment_id}/requirement/{requirement_id}"),
2972
+ )
2973
+
2974
+ def get_detailed_agent_matches_for_environment(self, environment_id):
2975
+ """Gets a detailed summary of the agents that are capable of running an environment, based of its requirements.
2976
+ :param environment_id: environmentId path parameter
2977
+ :return:
2978
+ """
2979
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/requirement/detailedSummary"))
2980
+
2981
+ def get_agent_matches_for_environment(self, environment_id):
2982
+ """Gets a summary of the agents that are capable of running an environment, based of its requirements.
2983
+ :param environment_id: environmentId path parameter
2984
+ :return:
2985
+ """
2986
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/requirement/summary"))
2987
+
2988
+ def get_environment_variable(self, environment_id, variable_name):
2989
+ """Get the environment variable by its name.
2990
+ :param environment_id: environmentId path parameter
2991
+ :param variable_name: variableName path parameter
2992
+ :return:
2993
+ """
2994
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/variable/{variable_name}"))
2995
+
2996
+ def get_all_environment_variables(self, environment_id):
2997
+ """Get a list of environment variables.
2998
+ :param environment_id: environmentId path parameter
2999
+ :return:
3000
+ """
3001
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}/variables"))
3002
+
3003
+ def get_jira_issue_status_for_project(self, issue_key):
3004
+ """Get all deployment projects associated with Jira issue key
3005
+ :param issue_key: issueKey path parameter
3006
+ :return:
3007
+ """
3008
+ return self.get(self.resource_url(f"deploy/issue-status/{issue_key}"))
3009
+
3010
+ def get_jira_issue_status_for_project_1(self, issue_key, deployment_project_id):
3011
+ """Get deployment project environments and versions associated with Jira issue
3012
+ :param issue_key: issueKey path parameter
3013
+ :param deployment_project_id: deploymentProjectId path parameter
3014
+ :return:
3015
+ """
3016
+ return self.get(self.resource_url(f"deploy/issue-status/{issue_key}/{deployment_project_id}"))
3017
+
3018
+ def get_possible_results(self, plan_key, deployment_project_id=None):
3019
+ """Get possible deployment results.
3020
+ :param deployment_project_id: deploymentProjectId query parameter
3021
+ :param plan_key: planKey query parameter
3022
+ :return:
3023
+ """
3024
+ params = {}
3025
+ if deployment_project_id is not None:
3026
+ params["deploymentProjectId"] = deployment_project_id
3027
+ if plan_key is not None:
3028
+ params["planKey"] = plan_key
3029
+ return self.get(self.resource_url("deploy/preview/possibleResults"), params=params)
3030
+
3031
+ def get_version_preview_1(
3032
+ self, previous_version_id=None, deployment_project_id=None, plan_key=None, result_key=None, build_number=None
3033
+ ):
3034
+ """Get a preview of the deployment version.
3035
+ :param previous_version_id: previousVersionId query parameter
3036
+ :param deployment_project_id: deploymentProjectId query parameter
3037
+ :param plan_key: planKey query parameter
3038
+ :param result_key: resultKey query parameter
3039
+ :param build_number: buildNumber query parameter
3040
+ :return:
3041
+ """
3042
+ params = {}
3043
+ if previous_version_id is not None:
3044
+ params["previousVersionId"] = previous_version_id
3045
+ if deployment_project_id is not None:
3046
+ params["deploymentProjectId"] = deployment_project_id
3047
+ if plan_key is not None:
3048
+ params["planKey"] = plan_key
3049
+ if result_key is not None:
3050
+ params["resultKey"] = result_key
3051
+ if build_number is not None:
3052
+ params["buildNumber"] = build_number
3053
+ return self.get(self.resource_url("deploy/preview/result"), params=params)
3054
+
3055
+ def get_version_preview(
3056
+ self, previous_version_id=None, version_id=None, deployment_project_id=None, version_name=None
3057
+ ):
3058
+ """Get a preview of the deployment version.
3059
+ :param previous_version_id: previousVersionId query parameter
3060
+ :param version_id: versionId query parameter
3061
+ :param deployment_project_id: deploymentProjectId query parameter
3062
+ :param version_name: versionName query parameter
3063
+ :return:
3064
+ """
3065
+ params = {}
3066
+ if previous_version_id is not None:
3067
+ params["previousVersionId"] = previous_version_id
3068
+ if version_id is not None:
3069
+ params["versionId"] = version_id
3070
+ if deployment_project_id is not None:
3071
+ params["deploymentProjectId"] = deployment_project_id
3072
+ if version_name is not None:
3073
+ params["versionName"] = version_name
3074
+ return self.get(self.resource_url("deploy/preview/version"), params=params)
3075
+
3076
+ def get_version_name(self, deployment_project_id, result_key=None):
3077
+ """Get version name.
3078
+ :param result_key: resultKey query parameter
3079
+ :param deployment_project_id: deploymentProjectId query parameter
3080
+ :return:
3081
+ """
3082
+ params = {}
3083
+ if result_key is not None:
3084
+ params["resultKey"] = result_key
3085
+ if deployment_project_id is not None:
3086
+ params["deploymentProjectId"] = deployment_project_id
3087
+ return self.get(self.resource_url("deploy/preview/versionName"), params=params)
3088
+
3089
+ def list_assigned_repositories(self, deployment_project_id):
3090
+ """List of repositories which granted to create/edit environment in given deployment project by Repository stored Bamboo Specs.
3091
+ :param deployment_project_id: deploymentProjectId path parameter
3092
+ :return:
3093
+ """
3094
+ return self.get(self.resource_url(f"deploy/project/{deployment_project_id}/repository"))
3095
+
3096
+ def search_available_repositories(self, deployment_project_id, max_result=None, search_term=None, start_index=None):
3097
+ """Search for linked repositories which can be granted to create/modify environment by Repository stored Bamboo Specs in given deployment project.
3098
+ :param deployment_project_id: deploymentProjectId path parameter
3099
+ :param max_result: max-result query parameter
3100
+ :param search_term: searchTerm query parameter
3101
+ :param start_index: start-index query parameter
3102
+ :return:
3103
+ """
3104
+ params = {}
3105
+ if max_result is not None:
3106
+ params["max-result"] = max_result
3107
+ if search_term is not None:
3108
+ params["searchTerm"] = search_term
3109
+ if start_index is not None:
3110
+ params["start-index"] = start_index
3111
+ return self.get(
3112
+ self.resource_url(f"deploy/project/{deployment_project_id}/repository/search"),
3113
+ params=params,
3114
+ )
3115
+
3116
+ def export_deployment_spec(self, deployment_project_id, package=None, format=None):
3117
+ """Export a deployment project to Bamboo Specs.
3118
+ :param deployment_project_id: deploymentProjectId path parameter
3119
+ :param package: package query parameter
3120
+ :param format: format query parameter
3121
+ :return:
3122
+ """
3123
+ params = {}
3124
+ if package is not None:
3125
+ params["package"] = package
3126
+ if format is not None:
3127
+ params["format"] = format
3128
+ return self.get(self.resource_url(f"deploy/project/{deployment_project_id}/specs"), params=params)
3129
+
3130
+ def get_deployment_project_versions(self, deployment_project_id, branch_key=None):
3131
+ """Get list of deployment versions.
3132
+ :param deployment_project_id: deploymentProjectId path parameter
3133
+ :param branch_key: branchKey query parameter
3134
+ :return:
3135
+ """
3136
+ params = {}
3137
+ if branch_key is not None:
3138
+ params["branchKey"] = branch_key
3139
+ return self.get(self.resource_url(f"deploy/project/{deployment_project_id}/version"), params=params)
3140
+
3141
+ def get_deployment_naming_preview(
3142
+ self, deployment_project_id, next_version_name, incrementable_variables=None, increment_numbers=None
3143
+ ):
3144
+ """Get deployment version name preview.
3145
+ :param deployment_project_id: deploymentProjectId path parameter
3146
+ :param next_version_name: nextVersionName query parameter
3147
+ :param incrementable_variables: incrementableVariables query parameter
3148
+ :param increment_numbers: incrementNumbers query parameter
3149
+ :return:
3150
+ """
3151
+ params = {}
3152
+ if next_version_name is not None:
3153
+ params["nextVersionName"] = next_version_name
3154
+ if incrementable_variables is not None:
3155
+ params["incrementableVariables"] = incrementable_variables
3156
+ if increment_numbers is not None:
3157
+ params["incrementNumbers"] = increment_numbers
3158
+ return self.get(
3159
+ self.resource_url(f"deploy/projectVersioning/{deployment_project_id}/namingPreview"),
3160
+ params=params,
3161
+ )
3162
+
3163
+ def get_next_deployment_versions(self, deployment_project_id, result_key=None):
3164
+ """Get next deployment version name.
3165
+ :param deployment_project_id: deploymentProjectId path parameter
3166
+ :param result_key: resultKey query parameter
3167
+ :return:
3168
+ """
3169
+ params = {}
3170
+ if result_key is not None:
3171
+ params["resultKey"] = result_key
3172
+ return self.get(
3173
+ self.resource_url(f"deploy/projectVersioning/{deployment_project_id}/nextVersion"),
3174
+ params=params,
3175
+ )
3176
+
3177
+ def get_variables_from_name(self, deployment_project_id, next_version_name):
3178
+ """Extract variables value from version name.
3179
+ :param deployment_project_id: deploymentProjectId path parameter
3180
+ :param next_version_name: nextVersionName query parameter
3181
+ :return:
3182
+ """
3183
+ params = {}
3184
+ if next_version_name is not None:
3185
+ params["nextVersionName"] = next_version_name
3186
+ return self.get(
3187
+ self.resource_url(f"deploy/projectVersioning/{deployment_project_id}/parseVariables"),
3188
+ params=params,
3189
+ )
3190
+
3191
+ def get_deployment_project_variables(self, deployment_project_id):
3192
+ """Get variables associated with deployment project.
3193
+ :param deployment_project_id: deploymentProjectId path parameter
3194
+ :return:
3195
+ """
3196
+ return self.get(self.resource_url(f"deploy/projectVersioning/{deployment_project_id}/variables"))
3197
+
3198
+ def get_deployment_result(self, deployment_result_id, include_logs=None):
3199
+ """Get result of version deployment to environment.
3200
+ :param deployment_result_id: deploymentResultId path parameter
3201
+ :param include_logs: includeLogs query parameter
3202
+ :return:
3203
+ """
3204
+ params = {}
3205
+ if include_logs is not None:
3206
+ params["includeLogs"] = include_logs
3207
+ return self.get(self.resource_url(f"deploy/result/{deployment_result_id}"), params=params)
3208
+
3209
+ def get_version_and_plan_result(self, deployment_version_id):
3210
+ """Get associated build result of deployment version.
3211
+ :param deployment_version_id: deploymentVersionId path parameter
3212
+ :return:
3213
+ """
3214
+ return self.get(self.resource_url(f"deploy/version/{deployment_version_id}/build-result"))
3215
+
3216
+ def get_latest_version_statuses(self, deployment_version_id):
3217
+ """Get the all users' latest statuses of deployment version.
3218
+ :param deployment_version_id: deploymentVersionId path parameter
3219
+ :return:
3220
+ """
3221
+ return self.get(self.resource_url(f"deploy/version/{deployment_version_id}/status"))
3222
+
3223
+ def add_agent_assignment_for_environment(self, environment_id, data):
3224
+ """Add agent assignment for environment. agentAssignmentKey is a map with one key-value: name - agentAssignmentKey.
3225
+ :param environment_id: environmentId path parameter
3226
+ :param data: request body (dict or list)
3227
+ :return:
3228
+ """
3229
+ return self.post(
3230
+ self.resource_url(f"deploy/environment/{environment_id}/agent-assignment"),
3231
+ data=data,
3232
+ )
3233
+
3234
+ def move_environment(self, environment_id, position, relative_environment_id):
3235
+ """Change environment position within deployment project.
3236
+ :param environment_id: environmentId path parameter
3237
+ :param position: position path parameter
3238
+ :param relative_environment_id: relativeEnvironmentId path parameter
3239
+ :return:
3240
+ """
3241
+ return self.post(
3242
+ self.resource_url(f"deploy/environment/{environment_id}/move/{position}/{relative_environment_id}"),
3243
+ )
3244
+
3245
+ def add_requirement_for_environment(self, environment_id, data):
3246
+ """Adds a requirement for a given environment.
3247
+ :param environment_id: environmentId path parameter
3248
+ :param data: request body (dict or list)
3249
+ :return:
3250
+ """
3251
+ return self.post(self.resource_url(f"deploy/environment/{environment_id}/requirement"), data=data)
3252
+
3253
+ def create_environment_variable(self, environment_id, data):
3254
+ """Create the environment variable.
3255
+ :param environment_id: environmentId path parameter
3256
+ :param data: request body (dict or list)
3257
+ :return:
3258
+ """
3259
+ return self.post(self.resource_url(f"deploy/environment/{environment_id}/variable"), data=data)
3260
+
3261
+ def add_assigned_repository(self, deployment_project_id, data):
3262
+ """Grant permission to create/edit plan in given deployment project by Bamboo Specs from given repository.
3263
+ :param deployment_project_id: deploymentProjectId path parameter
3264
+ :param data: request body (dict or list)
3265
+ :return:
3266
+ """
3267
+ return self.post(self.resource_url(f"deploy/project/{deployment_project_id}/repository"), data=data)
3268
+
3269
+ def update_version_status(self, deployment_version_id, new_status):
3270
+ """Update deployment version status.
3271
+ :param deployment_version_id: deploymentVersionId path parameter
3272
+ :param new_status: newStatus path parameter
3273
+ :return:
3274
+ """
3275
+ return self.post(self.resource_url(f"deploy/version/{deployment_version_id}/status/{new_status}"))
3276
+
3277
+ def save_docker_pipelines_configuration(self, environment_id, data):
3278
+ """Save Docker configuration for given environment.
3279
+ :param environment_id: environmentId path parameter
3280
+ :param data: request body (dict or list)
3281
+ :return:
3282
+ """
3283
+ return self.put(self.resource_url(f"deploy/environment/{environment_id}/docker"), data=data)
3284
+
3285
+ def update_environment_prerequisites(self, environment_id, data):
3286
+ """Updates the environment prerequisites.
3287
+ :param environment_id: environmentId path parameter
3288
+ :param data: request body (dict or list)
3289
+ :return:
3290
+ """
3291
+ return self.put(self.resource_url(f"deploy/environment/{environment_id}/prerequisites"), data=data)
3292
+
3293
+ def update_requirement_for_environment(self, environment_id, requirement_id, data):
3294
+ """Updates a requirement for a given environment.
3295
+ :param environment_id: environmentId path parameter
3296
+ :param requirement_id: requirementId path parameter
3297
+ :param data: request body (dict or list)
3298
+ :return:
3299
+ """
3300
+ return self.put(
3301
+ self.resource_url(f"deploy/environment/{environment_id}/requirement/{requirement_id}"),
3302
+ data=data,
3303
+ )
3304
+
3305
+ def update_environment_variable(self, environment_id, variable_name, data):
3306
+ """Update the environment variable.
3307
+ :param environment_id: environmentId path parameter
3308
+ :param variable_name: variableName path parameter
3309
+ :param data: request body (dict or list)
3310
+ :return:
3311
+ """
3312
+ return self.put(
3313
+ self.resource_url(f"deploy/environment/{environment_id}/variable/{variable_name}"),
3314
+ data=data,
3315
+ )
3316
+
3317
+ """Ephemeral agents"""
3318
+
3319
+ def delete_template_configuration(self, configuration_id):
3320
+ """Delete ephemeral template configuration.
3321
+ :param configuration_id: configurationId path parameter
3322
+ :return:
3323
+ """
3324
+ return self.delete(self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}"))
3325
+
3326
+ def delete_capability(self, configuration_id, name):
3327
+ """Remove ephemeral agent template capability.
3328
+ :param configuration_id: configurationId path parameter
3329
+ :param name: name path parameter
3330
+ :return:
3331
+ """
3332
+ return self.delete(
3333
+ self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}/capability/{name}"),
3334
+ )
3335
+
3336
+ def get_ephemeral_agent_pod_logs(self, pod, container_name=None, limit=None, after_timestamp=None):
3337
+ """Gets either pod or container related logs.
3338
+ :param pod: pod path parameter
3339
+ :param container_name: containerName query parameter
3340
+ :param limit: limit query parameter
3341
+ :param after_timestamp: afterTimestamp query parameter
3342
+ :return:
3343
+ """
3344
+ params = {}
3345
+ if container_name is not None:
3346
+ params["containerName"] = container_name
3347
+ if limit is not None:
3348
+ params["limit"] = limit
3349
+ if after_timestamp is not None:
3350
+ params["afterTimestamp"] = after_timestamp
3351
+ return self.get(self.resource_url(f"ephemeral/pod/{pod}/logs"), params=params)
3352
+
3353
+ def get_ephemeral_agent_pod_raw_logs(self, pod, container_name=None):
3354
+ """Gets either pod or container all logs in the raw, plain text form.
3355
+ :param pod: pod path parameter
3356
+ :param container_name: containerName query parameter
3357
+ :return:
3358
+ """
3359
+ params = {}
3360
+ if container_name is not None:
3361
+ params["containerName"] = container_name
3362
+ return self.get(self.resource_url(f"ephemeral/pod/{pod}/logs/raw"), params=params)
3363
+
3364
+ def get_template_configurations_page(self, filter=None, limit=None, start=None):
3365
+ """Fetch page of ephemeral templates.
3366
+ :param filter: filter query parameter
3367
+ :param limit: limit query parameter
3368
+ :param start: start query parameter
3369
+ :return:
3370
+ """
3371
+ params = {}
3372
+ if filter is not None:
3373
+ params["filter"] = filter
3374
+ if limit is not None:
3375
+ params["limit"] = limit
3376
+ if start is not None:
3377
+ params["start"] = start
3378
+ return self.get(self.resource_url("ephemeral/templateConfiguration"), params=params)
3379
+
3380
+ def get_template_configuration(self, configuration_id):
3381
+ """Gets ephemeral template configuration details.
3382
+ :param configuration_id: configurationId path parameter
3383
+ :return:
3384
+ """
3385
+ return self.get(self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}"))
3386
+
3387
+ def get_capabilities(self, configuration_id, limit=None, start=None):
3388
+ """Fetch page of ephemeral agent template capabilities.
3389
+ :param configuration_id: configurationId path parameter
3390
+ :param limit: limit query parameter
3391
+ :param start: start query parameter
3392
+ :return:
3393
+ """
3394
+ params = {}
3395
+ if limit is not None:
3396
+ params["limit"] = limit
3397
+ if start is not None:
3398
+ params["start"] = start
3399
+ return self.get(
3400
+ self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}/capability"),
3401
+ params=params,
3402
+ )
3403
+
3404
+ def create_template_configuration(self, data):
3405
+ """Create ephemeral template configuration.
3406
+ :param data: request body (dict or list)
3407
+ :return:
3408
+ """
3409
+ return self.post(self.resource_url("ephemeral/templateConfiguration"), data=data)
3410
+
3411
+ def add_capability(self, configuration_id, data):
3412
+ """Add ephemeral agent template capability.
3413
+ :param configuration_id: configurationId path parameter
3414
+ :param data: request body (dict or list)
3415
+ :return:
3416
+ """
3417
+ return self.post(
3418
+ self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}/capability"),
3419
+ data=data,
3420
+ )
3421
+
3422
+ def update_template_configuration(self, configuration_id, data):
3423
+ """Update ephemeral agent template.
3424
+ :param configuration_id: configurationId path parameter
3425
+ :param data: request body (dict or list)
3426
+ :return:
3427
+ """
3428
+ return self.put(self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}"), data=data)
3429
+
3430
+ def update_capability(self, configuration_id, data):
3431
+ """Update ephemeral agent template capability.
3432
+ :param configuration_id: configurationId path parameter
3433
+ :param data: request body (dict or list)
3434
+ :return:
3435
+ """
3436
+ return self.put(
3437
+ self.resource_url(f"ephemeral/templateConfiguration/{configuration_id}/capability"),
3438
+ data=data,
3439
+ )
3440
+
3441
+ """Global permissions"""
3442
+
3443
+ def remove_permissions_for_group_2(self, name, data, ignore=None):
3444
+ """Revokes global permissions from a given group.
3445
+ :param name: name path parameter
3446
+ :param ignore: ignore query parameter
3447
+ :param data: request body (dict or list)
3448
+ :return:
3449
+ """
3450
+ params = {}
3451
+ if ignore is not None:
3452
+ params["ignore"] = ignore
3453
+ return self.delete(self.resource_url(f"permissions/global/groups/{name}"), params=params, data=data)
3454
+
3455
+ def remove_permissions_for_role_2(self, name, data, ignore=None):
3456
+ """Revokes global permissions from a given role.
3457
+ :param name: name path parameter
3458
+ :param ignore: ignore query parameter
3459
+ :param data: request body (dict or list)
3460
+ :return:
3461
+ """
3462
+ params = {}
3463
+ if ignore is not None:
3464
+ params["ignore"] = ignore
3465
+ return self.delete(self.resource_url(f"permissions/global/roles/{name}"), params=params, data=data)
3466
+
3467
+ def remove_permissions_for_user_2(self, name, data, ignore=None):
3468
+ """Revokes global permissions from a given user.
3469
+ :param name: name path parameter
3470
+ :param ignore: ignore query parameter
3471
+ :param data: request body (dict or list)
3472
+ :return:
3473
+ """
3474
+ params = {}
3475
+ if ignore is not None:
3476
+ params["ignore"] = ignore
3477
+ return self.delete(self.resource_url(f"permissions/global/users/{name}"), params=params, data=data)
3478
+
3479
+ def get_available_groups_2(self, limit=None, start=None, name=None, ignore=None):
3480
+ """Returns list of groups which weren't granted explicitly any permissions. Resource is paged, returns single page of resources.
3481
+ :param limit: limit query parameter
3482
+ :param start: start query parameter
3483
+ :param name: name query parameter
3484
+ :param ignore: ignore query parameter
3485
+ :return:
3486
+ """
3487
+ params = {}
3488
+ if limit is not None:
3489
+ params["limit"] = limit
3490
+ if start is not None:
3491
+ params["start"] = start
3492
+ if name is not None:
3493
+ params["name"] = name
3494
+ if ignore is not None:
3495
+ params["ignore"] = ignore
3496
+ return self.get(self.resource_url("permissions/global/available-groups"), params=params)
3497
+
3498
+ def get_available_users_2(self, limit=None, start=None, name=None, ignore=None):
3499
+ """Returns list of users which weren't granted explicitly any permissions. Resource is paged, returns single page of resources.
3500
+ :param limit: limit query parameter
3501
+ :param start: start query parameter
3502
+ :param name: name query parameter
3503
+ :param ignore: ignore query parameter
3504
+ :return:
3505
+ """
3506
+ params = {}
3507
+ if limit is not None:
3508
+ params["limit"] = limit
3509
+ if start is not None:
3510
+ params["start"] = start
3511
+ if name is not None:
3512
+ params["name"] = name
3513
+ if ignore is not None:
3514
+ params["ignore"] = ignore
3515
+ return self.get(self.resource_url("permissions/global/available-users"), params=params)
3516
+
3517
+ def list_group_permissions_2(self, limit=None, start=None, name=None, ignore=None):
3518
+ """Retrieve a list of groups with their global permissions. The list can be filtered by some attributes. This resource is paged returns a single page of results.
3519
+ :param limit: limit query parameter
3520
+ :param start: start query parameter
3521
+ :param name: name query parameter
3522
+ :param ignore: ignore query parameter
3523
+ :return:
3524
+ """
3525
+ params = {}
3526
+ if limit is not None:
3527
+ params["limit"] = limit
3528
+ if start is not None:
3529
+ params["start"] = start
3530
+ if name is not None:
3531
+ params["name"] = name
3532
+ if ignore is not None:
3533
+ params["ignore"] = ignore
3534
+ return self.get(self.resource_url("permissions/global/groups"), params=params)
3535
+
3536
+ def list_role_permissions_2(self, limit=None, start=None, ignore=None):
3537
+ """Retrieve a list of roles with their global permissions. This resource is paged returns a single page of results, although only 2 roles are supported: LOGGED IN users, ANONYMOUS users
3538
+ :param limit: limit query parameter
3539
+ :param start: start query parameter
3540
+ :param ignore: ignore query parameter
3541
+ :return:
3542
+ """
3543
+ params = {}
3544
+ if limit is not None:
3545
+ params["limit"] = limit
3546
+ if start is not None:
3547
+ params["start"] = start
3548
+ if ignore is not None:
3549
+ params["ignore"] = ignore
3550
+ return self.get(self.resource_url("permissions/global/roles"), params=params)
3551
+
3552
+ def add_permissions_for_group_2(self, name, data, ignore=None):
3553
+ """Grants global permissions to a given group.
3554
+ :param name: name path parameter
3555
+ :param ignore: ignore query parameter
3556
+ :param data: request body (dict or list)
3557
+ :return:
3558
+ """
3559
+ params = {}
3560
+ if ignore is not None:
3561
+ params["ignore"] = ignore
3562
+ return self.put(self.resource_url(f"permissions/global/groups/{name}"), params=params, data=data)
3563
+
3564
+ def add_permissions_for_role_2(self, name, data, ignore=None):
3565
+ """Grants global permissions to a given role.
3566
+ :param name: name path parameter
3567
+ :param ignore: ignore query parameter
3568
+ :param data: request body (dict or list)
3569
+ :return:
3570
+ """
3571
+ params = {}
3572
+ if ignore is not None:
3573
+ params["ignore"] = ignore
3574
+ return self.put(self.resource_url(f"permissions/global/roles/{name}"), params=params, data=data)
3575
+
3576
+ def add_permissions_for_user_2(self, name, data, ignore=None):
3577
+ """Grants global permissions to a given user.
3578
+ :param name: name path parameter
3579
+ :param ignore: ignore query parameter
3580
+ :param data: request body (dict or list)
3581
+ :return:
3582
+ """
3583
+ params = {}
3584
+ if ignore is not None:
3585
+ params["ignore"] = ignore
3586
+ return self.put(self.resource_url(f"permissions/global/users/{name}"), params=params, data=data)
3587
+
3588
+ """Plans"""
3589
+
3590
+ def unmark_plan_favourite(self, project_key, build_key):
3591
+ """Remove plan from favorites.
3592
+ :param project_key: projectKey path parameter
3593
+ :param build_key: buildKey path parameter
3594
+ :return:
3595
+ """
3596
+ return self.delete(self.resource_url(f"plan/{project_key}-{build_key}/favourite"))
3597
+
3598
+ def remove_plan_label(self, project_key, build_key, label_name):
3599
+ """Remove label from plan.
3600
+ :param project_key: projectKey path parameter
3601
+ :param build_key: buildKey path parameter
3602
+ :param label_name: labelName path parameter
3603
+ :return:
3604
+ """
3605
+ return self.delete(self.resource_url(f"plan/{project_key}-{build_key}/label/{label_name}"))
3606
+
3607
+ def get_plan_artifact_definition(self, project_key, build_key, max_result=None, start_index=None):
3608
+ """Fetch plan's shared artifact definitions.
3609
+ :param project_key: projectKey path parameter
3610
+ :param build_key: buildKey path parameter
3611
+ :param max_result: max-result query parameter
3612
+ :param start_index: start-index query parameter
3613
+ :return:
3614
+ """
3615
+ params = {}
3616
+ if max_result is not None:
3617
+ params["max-result"] = max_result
3618
+ if start_index is not None:
3619
+ params["start-index"] = start_index
3620
+ return self.get(self.resource_url(f"plan/{project_key}-{build_key}/artifact"), params=params)
3621
+
3622
+ def get_issue_details(self, project_key, build_key, issue_key):
3623
+ """Fetch linked Jira issue details.
3624
+ :param project_key: projectKey path parameter
3625
+ :param build_key: buildKey path parameter
3626
+ :param issue_key: issueKey path parameter
3627
+ :return:
3628
+ """
3629
+ return self.get(self.resource_url(f"plan/{project_key}-{build_key}/issue/{issue_key}"))
3630
+
3631
+ def get_plan_labels(self, project_key, build_key):
3632
+ """List of labels for plan.
3633
+ :param project_key: projectKey path parameter
3634
+ :param build_key: buildKey path parameter
3635
+ :return:
3636
+ """
3637
+ return self.get(self.resource_url(f"plan/{project_key}-{build_key}/label"))
3638
+
3639
+ def enable_specs_for_branches(self, project_key, build_key):
3640
+ """Enable specs scanning for all branches.
3641
+ :param project_key: projectKey path parameter
3642
+ :param build_key: buildKey path parameter
3643
+ :return:
3644
+ """
3645
+ return self.post(self.resource_url(f"plan/{project_key}-{build_key}/branch/enableSpecsForBranches"))
3646
+
3647
+ def mark_plan_favourite(self, project_key, build_key):
3648
+ """Add plan to favourite.
3649
+ :param project_key: projectKey path parameter
3650
+ :param build_key: buildKey path parameter
3651
+ :return:
3652
+ """
3653
+ return self.post(self.resource_url(f"plan/{project_key}-{build_key}/favourite"))
3654
+
3655
+ def add_plan_label(self, project_key, build_key, data):
3656
+ """Add new label to plan.
3657
+ :param project_key: projectKey path parameter
3658
+ :param build_key: buildKey path parameter
3659
+ :param data: request body (dict or list)
3660
+ :return:
3661
+ """
3662
+ return self.post(self.resource_url(f"plan/{project_key}-{build_key}/label"), data=data)
3663
+
3664
+ def quarantine_test(self, project_key, build_key, test_id):
3665
+ """Quarantine plan's test.
3666
+ :param project_key: projectKey path parameter
3667
+ :param build_key: buildKey path parameter
3668
+ :param test_id: testId path parameter
3669
+ :return:
3670
+ """
3671
+ return self.post(self.resource_url(f"plan/{project_key}-{build_key}/test/{test_id}/quarantine"))
3672
+
3673
+ def unleash_test(self, project_key, build_key, test_id):
3674
+ """Unleash plan's test from quarantine.
3675
+ :param project_key: projectKey path parameter
3676
+ :param build_key: buildKey path parameter
3677
+ :param test_id: testId path parameter
3678
+ :return:
3679
+ """
3680
+ return self.post(self.resource_url(f"plan/{project_key}-{build_key}/test/{test_id}/unleash"))
3681
+
3682
+ """Projects & repositories"""
3683
+
3684
+ def delete_project_shared_credentials(self, project_key, shared_credential_id):
3685
+ """Deletes shared project credentials specified by id.
3686
+ :param project_key: projectKey path parameter
3687
+ :param shared_credential_id: sharedCredentialId path parameter
3688
+ :return:
3689
+ """
3690
+ return self.delete(
3691
+ self.resource_url(f"project/{project_key}/sharedCredentials/{shared_credential_id}"),
3692
+ )
3693
+
3694
+ def delete_project_variable(self, project_key, variable_name):
3695
+ """Delete the project variable.
3696
+ :param project_key: projectKey path parameter
3697
+ :param variable_name: variableName path parameter
3698
+ :return:
3699
+ """
3700
+ return self.delete(self.resource_url(f"project/{project_key}/variable/{variable_name}"))
3701
+
3702
+ def get_paginated_project_repositories(self, project_key, filter=None, limit=None, start=None):
3703
+ """Retrieves paginated project repositories specified by the project key.
3704
+ :param project_key: projectKey path parameter
3705
+ :param filter: filter query parameter
3706
+ :param limit: limit query parameter
3707
+ :param start: start query parameter
3708
+ :return:
3709
+ """
3710
+ params = {}
3711
+ if filter is not None:
3712
+ params["filter"] = filter
3713
+ if limit is not None:
3714
+ params["limit"] = limit
3715
+ if start is not None:
3716
+ params["start"] = start
3717
+ return self.get(self.resource_url(f"project/{project_key}/repositories"), params=params)
3718
+
3719
+ def search_available_repositories_1(self, project_key, search_term=None):
3720
+ """Search for linked repositories which can be granted to create plans by Repository stored Bamboo Specs in given project
3721
+ :param project_key: projectKey path parameter
3722
+ :param search_term: searchTerm query parameter
3723
+ :return:
3724
+ """
3725
+ params = {}
3726
+ if search_term is not None:
3727
+ params["searchTerm"] = search_term
3728
+ return self.get(self.resource_url(f"project/{project_key}/repository/search"), params=params)
3729
+
3730
+ def get_paginated_project_shared_credentials(self, project_key, filter=None, limit=None, start=None):
3731
+ """Retrieves paginated shared credentials for the project specified by the project key.
3732
+ :param project_key: projectKey path parameter
3733
+ :param filter: filter query parameter
3734
+ :param limit: limit query parameter
3735
+ :param start: start query parameter
3736
+ :return:
3737
+ """
3738
+ params = {}
3739
+ if filter is not None:
3740
+ params["filter"] = filter
3741
+ if limit is not None:
3742
+ params["limit"] = limit
3743
+ if start is not None:
3744
+ params["start"] = start
3745
+ return self.get(self.resource_url(f"project/{project_key}/sharedCredentials"), params=params)
3746
+
3747
+ def export_project_specs(self, project_key, package=None, format=None):
3748
+ """Export all of the plans for a project to Bamboo specs.
3749
+ :param project_key: projectKey path parameter
3750
+ :param package: package query parameter
3751
+ :param format: format query parameter
3752
+ :return:
3753
+ """
3754
+ params = {}
3755
+ if package is not None:
3756
+ params["package"] = package
3757
+ if format is not None:
3758
+ params["format"] = format
3759
+ return self.get(self.resource_url(f"project/{project_key}/specs"), params=params)
3760
+
3761
+ def get_project_variable(self, project_key, variable_name):
3762
+ """Retrieve the project variable by given name.
3763
+ :param project_key: projectKey path parameter
3764
+ :param variable_name: variableName path parameter
3765
+ :return:
3766
+ """
3767
+ return self.get(self.resource_url(f"project/{project_key}/variable/{variable_name}"))
3768
+
3769
+ def get_project_variables(self, project_key):
3770
+ """Retrieve the list of all variables for a project.
3771
+ :param project_key: projectKey path parameter
3772
+ :return:
3773
+ """
3774
+ return self.get(self.resource_url(f"project/{project_key}/variables"))
3775
+
3776
+ def create_project(self, data):
3777
+ """Create project.
3778
+ :param data: request body (dict or list)
3779
+ :return:
3780
+ """
3781
+ return self.post(self.resource_url("project"), data=data)
3782
+
3783
+ def create_or_update_variable(self, project_key, data):
3784
+ """Create or update project variable.
3785
+ :param project_key: projectKey path parameter
3786
+ :param data: request body (dict or list)
3787
+ :return:
3788
+ """
3789
+ return self.post(self.resource_url(f"project/{project_key}/variable"), data=data)
3790
+
3791
+ def enable_all_repositories_access(self, project_key, repository_id, data):
3792
+ """Enables access (i.e. allowing usage) to all project's repositories by the Bamboo Specs code stored in this repository.
3793
+ :param project_key: projectKey path parameter
3794
+ :param repository_id: repositoryId path parameter
3795
+ :param data: request body (dict or list)
3796
+ :return:
3797
+ """
3798
+ return self.put(
3799
+ self.resource_url(f"project/{project_key}/repository/{repository_id}/enableAllRepositoriesAccess"),
3800
+ data=data,
3801
+ )
3802
+
3803
+ """Repositories"""
3804
+
3805
+ def revoke_permission_to_use_repository_by_rss_repo(self, target_repository_id, repository_id):
3806
+ """Revoke access of RSS code stored in repository defined by repositoryId from repository defined by targetRepositoryId. Use this method when need to prevent usage of target repository by RSS code stored in repository referenced by repositoryId.
3807
+ :param target_repository_id: targetRepositoryId path parameter
3808
+ :param repository_id: repositoryId path parameter
3809
+ :return:
3810
+ """
3811
+ return self.delete(
3812
+ self.resource_url(f"repository/{target_repository_id}/rssrepository/{repository_id}"),
3813
+ )
3814
+
3815
+ def search_specs_branches(self, repository_id, search_term=None):
3816
+ """Search for divergent branches names (i.e. vcs branches that have RSS execution results).
3817
+ :param repository_id: repositoryId path parameter
3818
+ :param search_term: searchTerm query parameter
3819
+ :return:
3820
+ """
3821
+ params = {}
3822
+ if search_term is not None:
3823
+ params["searchTerm"] = search_term
3824
+ return self.get(self.resource_url(f"repository/{repository_id}/rssBranches"), params=params)
3825
+
3826
+ def get_rss_repositories_allowed_to_access_repository(self, repository_id):
3827
+ """Fetch list of RSS repositories which can use given repository by RSS code.
3828
+ :param repository_id: repositoryId path parameter
3829
+ :return:
3830
+ """
3831
+ return self.get(self.resource_url(f"repository/{repository_id}/rssrepository"))
3832
+
3833
+ def search_available_repositories_2(self, repository_id, search_term=None):
3834
+ """Search for existing linked repositories which can be granted to use given repository by RSS.
3835
+ :param repository_id: repositoryId path parameter
3836
+ :param search_term: searchTerm query parameter
3837
+ :return:
3838
+ """
3839
+ params = {}
3840
+ if search_term is not None:
3841
+ params["searchTerm"] = search_term
3842
+ return self.get(self.resource_url(f"repository/{repository_id}/rssrepository/search"), params=params)
3843
+
3844
+ def get_specs_detection_status(self, repository_id, max_result=None, branch=None):
3845
+ """Resource providing status of RSS processing for a given repository and optional branch.
3846
+ :param repository_id: repositoryId path parameter
3847
+ :param max_result: max-result query parameter
3848
+ :param branch: branch query parameter
3849
+ :return:
3850
+ """
3851
+ params = {}
3852
+ if max_result is not None:
3853
+ params["max-result"] = max_result
3854
+ if branch is not None:
3855
+ params["branch"] = branch
3856
+ return self.get(self.resource_url(f"repository/{repository_id}/scan/status"), params=params)
3857
+
3858
+ def find_usage(self, repository_id, max_plans=None, max_environments=None):
3859
+ """Search for usages of given repository.
3860
+ :param repository_id: repositoryId path parameter
3861
+ :param max_plans: max-plans query parameter
3862
+ :param max_environments: max-environments query parameter
3863
+ :return:
3864
+ """
3865
+ params = {}
3866
+ if max_plans is not None:
3867
+ params["max-plans"] = max_plans
3868
+ if max_environments is not None:
3869
+ params["max-environments"] = max_environments
3870
+ return self.get(self.resource_url(f"repository/{repository_id}/usage"), params=params)
3871
+
3872
+ def grant_rss_repository_access(self, repository_id, data):
3873
+ """Grant repository with RSS code to use target repository in build plans and deployments. If permission is not granted RSS import will fail when code tries to use target repository.
3874
+ :param repository_id: repositoryId path parameter
3875
+ :param data: request body (dict or list)
3876
+ :return:
3877
+ """
3878
+ return self.post(self.resource_url(f"repository/{repository_id}/rssrepository"), data=data)
3879
+
3880
+ def trigger_specs_scanning(self, repository_id, branch=None):
3881
+ """Resource for triggering Repository-stored Bamboo Specs in a 'forced' way. Successful requests to this resource will trigger Bamboo Specs execution even if standard processing would have been skipped (e.g. no new commits to process).
3882
+ :param repository_id: repositoryId path parameter
3883
+ :param branch: branch query parameter
3884
+ :return:
3885
+ """
3886
+ params = {}
3887
+ if branch is not None:
3888
+ params["branch"] = branch
3889
+ return self.post(self.resource_url(f"repository/{repository_id}/scanNow"), params=params)
3890
+
3891
+ def trigger_specs_scanning_1(self, name=None, repository_id=None, id=None, repository_name=None):
3892
+ """Webhook resource for triggering Repository-stored Bamboo Specs. Either repository ID or name must be provided via query parameters to identify the linked repository in which Bamboo Specs are defined.
3893
+ :param name: name query parameter
3894
+ :param repository_id: repositoryId query parameter
3895
+ :param id: id query parameter
3896
+ :param repository_name: repositoryName query parameter
3897
+ :return:
3898
+ """
3899
+ params = {}
3900
+ if name is not None:
3901
+ params["name"] = name
3902
+ if repository_id is not None:
3903
+ params["repositoryId"] = repository_id
3904
+ if id is not None:
3905
+ params["id"] = id
3906
+ if repository_name is not None:
3907
+ params["repositoryName"] = repository_name
3908
+ return self.post(self.resource_url("repository/scan"), params=params)
3909
+
3910
+ def enable_all_projects_access(self, repository_id, data):
3911
+ """Enables access (i.e. allowing modifications) for all Bamboo projects by the Bamboo Specs code stored in this repository. Changes in Bamboo Specs detected will trigger execution of Specs and thus an update of corresponding entities (such as build plans or deployments).
3912
+ :param repository_id: repositoryId path parameter
3913
+ :param data: request body (dict or list)
3914
+ :return:
3915
+ """
3916
+ return self.put(self.resource_url(f"repository/{repository_id}/enableAllProjectsAccess"), data=data)
3917
+
3918
+ def enable_all_repositories_access_1(self, repository_id, data):
3919
+ """Enables access (i.e. allowing usage in plans or deployment projects) for all Bamboo linked repositories by the Bamboo Specs code stored in this repository.
3920
+ :param repository_id: repositoryId path parameter
3921
+ :param data: request body (dict or list)
3922
+ :return:
3923
+ """
3924
+ return self.put(
3925
+ self.resource_url(f"repository/{repository_id}/enableAllRepositoriesAccess"),
3926
+ data=data,
3927
+ )
3928
+
3929
+ def enable_ci(self, repository_id, data):
3930
+ """Enables or disables detection of Bamboo Specs stored in the repository. If enabled, code changes detected in Bamboo Specs in new commits will trigger execution of Bamboo Specs and thus an update of corresponding entities (such as build plans, deployments or permissions).
3931
+ :param repository_id: repositoryId path parameter
3932
+ :param data: request body (dict or list)
3933
+ :return:
3934
+ """
3935
+ return self.put(self.resource_url(f"repository/{repository_id}/enableCi"), data=data)
3936
+
3937
+ def enable_project_creation(self, repository_id, data):
3938
+ """Enables build and deployment project creation by the Bamboo Specs code stored in this repository.
3939
+ :param repository_id: repositoryId path parameter
3940
+ :param data: request body (dict or list)
3941
+ :return:
3942
+ """
3943
+ return self.put(self.resource_url(f"repository/{repository_id}/enableProjectCreation"), data=data)
3944
+
3945
+ def test_connection_1(self, data):
3946
+ """Tests connection to a repository if the repository type supports connection testing. Request payload should contain repository configuration.
3947
+ :param data: request body (dict or list)
3948
+ :return:
3949
+ """
3950
+ return self.put(self.resource_url("repository/testConnection"), data=data)
3951
+
3952
+ """Build results"""
3953
+
3954
+ def remove_build_comment(self, project_key, build_key, build_number, comment_id):
3955
+ """Removes a comment from a build result.
3956
+ :param project_key: projectKey path parameter
3957
+ :param build_key: buildKey path parameter
3958
+ :param build_number: buildNumber path parameter
3959
+ :param comment_id: commentId path parameter
3960
+ :return:
3961
+ """
3962
+ return self.delete(
3963
+ self.resource_url(f"result/{project_key}-{build_key}-{build_number}/comment/{comment_id}"),
3964
+ )
3965
+
3966
+ def get_branch_history(
3967
+ self,
3968
+ project_key,
3969
+ build_key,
3970
+ branch_name,
3971
+ include_all_states=None,
3972
+ continuable=None,
3973
+ issue_key=None,
3974
+ max_results=None,
3975
+ start_index=None,
3976
+ label=None,
3977
+ buildstate=None,
3978
+ favourite=None,
3979
+ expand=None,
3980
+ life_cycle_state=None,
3981
+ ):
3982
+ """Provide list of build results for specified plan's branch. Plan might be top level plan (projectKey-planKey) or job plan (projectKey-planKey-jobKey).
3983
+ :param project_key: projectKey path parameter
3984
+ :param build_key: buildKey path parameter
3985
+ :param branch_name: branchName path parameter
3986
+ :param include_all_states: includeAllStates query parameter
3987
+ :param continuable: continuable query parameter
3988
+ :param issue_key: issueKey query parameter
3989
+ :param max_results: max-results query parameter
3990
+ :param start_index: start-index query parameter
3991
+ :param label: label query parameter
3992
+ :param buildstate: buildstate query parameter
3993
+ :param favourite: favourite query parameter
3994
+ :param expand: expand query parameter
3995
+ :param life_cycle_state: lifeCycleState query parameter
3996
+ :return:
3997
+ """
3998
+ params = {}
3999
+ if include_all_states is not None:
4000
+ params["includeAllStates"] = include_all_states
4001
+ if continuable is not None:
4002
+ params["continuable"] = continuable
4003
+ if issue_key is not None:
4004
+ params["issueKey"] = issue_key
4005
+ if max_results is not None:
4006
+ params["max-results"] = max_results
4007
+ if start_index is not None:
4008
+ params["start-index"] = start_index
4009
+ if label is not None:
4010
+ params["label"] = label
4011
+ if buildstate is not None:
4012
+ params["buildstate"] = buildstate
4013
+ if favourite is not None:
4014
+ params["favourite"] = favourite
4015
+ if expand is not None:
4016
+ params["expand"] = expand
4017
+ if life_cycle_state is not None:
4018
+ params["lifeCycleState"] = life_cycle_state
4019
+ return self.get(
4020
+ self.resource_url(f"result/{project_key}-{build_key}/branch/{branch_name}"),
4021
+ params=params,
4022
+ )
4023
+
4024
+ """Web sudo"""
4025
+
4026
+ def remove_web_sudo_from_session(self):
4027
+ """Remove web sudo from session.
4028
+ :return:
4029
+ """
4030
+ return self.delete(self.resource_url("websudo-session"))
4031
+
4032
+ def get_expiry(self):
4033
+ """Get the web sudo expiry from session.
4034
+ :return:
4035
+ """
4036
+ return self.get(self.resource_url("websudo-session"))
4037
+
4038
+ def refresh_web_sudo_session(self):
4039
+ """Refresh the web sudo expiry for the current session.
4040
+ :return:
4041
+ """
4042
+ return self.put(self.resource_url("websudo-session"))
4043
+
4044
+ """General"""
4045
+
4046
+ def get_all_services(self):
4047
+ """Provides list of available REST resources in Bamboo
4048
+ :return:
4049
+ """
4050
+ return self.get(self.resource_url(""))
4051
+
4052
+ """Build numbers & clone"""
4053
+
4054
+ def get_next_build_number(self, project_key, build_key):
4055
+ """Retrieve the next build number for a given plan or plan branch.
4056
+ :param project_key: projectKey path parameter
4057
+ :param build_key: buildKey path parameter
4058
+ :return:
4059
+ """
4060
+ return self.get(self.resource_url(f"buildNumber/{project_key}-{build_key}"))
4061
+
4062
+ def bump_build_number(self, project_key, build_key, data):
4063
+ """Bump the next build number for a given plan or plan branch to the specified value.
4064
+ :param project_key: projectKey path parameter
4065
+ :param build_key: buildKey path parameter
4066
+ :param data: request body (dict or list)
4067
+ :return:
4068
+ """
4069
+ return self.put(self.resource_url(f"buildNumber/{project_key}-{build_key}/bump"), data=data)
4070
+
4071
+ def get_clone(self, project_key, build_key, to_project_key, to_build_key):
4072
+ """Clone an existing Plan into a new one, possibly into different project.
4073
+ :param project_key: projectKey path parameter
4074
+ :param build_key: buildKey path parameter
4075
+ :param to_project_key: toProjectKey path parameter
4076
+ :param to_build_key: toBuildKey path parameter
4077
+ :return:
4078
+ """
4079
+ return self.put(self.resource_url(f"clone/{project_key}-{build_key}:{to_project_key}-{to_build_key}"))
4080
+
4081
+ """Server capabilities"""
4082
+
4083
+ def get_all_capabilities_on_server(self, max_result=None, search_term=None, last_group=None, start_index=None):
4084
+ """Provides a list of capabilities for a select list in the UI. Filterable and paginable.
4085
+ :param max_result: max-result query parameter
4086
+ :param search_term: searchTerm query parameter
4087
+ :param last_group: lastGroup query parameter
4088
+ :param start_index: start-index query parameter
4089
+ :return:
4090
+ """
4091
+ params = {}
4092
+ if max_result is not None:
4093
+ params["max-result"] = max_result
4094
+ if search_term is not None:
4095
+ params["searchTerm"] = search_term
4096
+ if last_group is not None:
4097
+ params["lastGroup"] = last_group
4098
+ if start_index is not None:
4099
+ params["start-index"] = start_index
4100
+ return self.get(self.resource_url("capability/groupedListing"), params=params)
4101
+
4102
+ """Plan summary charts"""
4103
+
4104
+ def get_plan_summary(self, build_keys=None):
4105
+ """Get plan summary.
4106
+ :param build_keys: buildKeys query parameter
4107
+ :return:
4108
+ """
4109
+ params = {}
4110
+ if build_keys is not None:
4111
+ params["buildKeys"] = build_keys
4112
+ return self.get(self.resource_url("chart/planSummary"), params=params)
4113
+
4114
+ """Plan dependencies"""
4115
+
4116
+ def search_for_available_plan_child_dependencies(
4117
+ self, project_key, build_key, search_term, max_result=None, start_index=None
4118
+ ):
4119
+ """Search for available plan child dependencies
4120
+ :param project_key: projectKey path parameter
4121
+ :param build_key: buildKey path parameter
4122
+ :param max_result: max-result query parameter
4123
+ :param search_term: searchTerm query parameter
4124
+ :param start_index: start-index query parameter
4125
+ :return:
4126
+ """
4127
+ params = {}
4128
+ if max_result is not None:
4129
+ params["max-result"] = max_result
4130
+ if search_term is not None:
4131
+ params["searchTerm"] = search_term
4132
+ if start_index is not None:
4133
+ params["start-index"] = start_index
4134
+ return self.get(
4135
+ self.resource_url(f"dependency/search/{project_key}-{build_key}/child"),
4136
+ params=params,
4137
+ )
4138
+
4139
+ def search_for_available_plan_parent_dependencies(
4140
+ self, project_key, build_key, search_term, max_result=None, start_index=None
4141
+ ):
4142
+ """Search for available plan parent dependencies
4143
+ :param project_key: projectKey path parameter
4144
+ :param build_key: buildKey path parameter
4145
+ :param max_result: max-result query parameter
4146
+ :param search_term: searchTerm query parameter
4147
+ :param start_index: start-index query parameter
4148
+ :return:
4149
+ """
4150
+ params = {}
4151
+ if max_result is not None:
4152
+ params["max-result"] = max_result
4153
+ if search_term is not None:
4154
+ params["searchTerm"] = search_term
4155
+ if start_index is not None:
4156
+ params["start-index"] = start_index
4157
+ return self.get(
4158
+ self.resource_url(f"dependency/search/{project_key}-{build_key}/parent"),
4159
+ params=params,
4160
+ )
4161
+
4162
+ """Job configuration"""
4163
+
4164
+ def get_docker_pipeline_configuration(self, job_key):
4165
+ """Retrieves Docker configuration for given job.
4166
+ :param job_key: jobKey path parameter
4167
+ :return:
4168
+ """
4169
+ return self.get(self.resource_url(f"job/{job_key}/docker"))
4170
+
4171
+ def set_docker_pipeline_configuration(self, job_key, data):
4172
+ """Updates Docker configuration for given job.
4173
+ :param job_key: jobKey path parameter
4174
+ :param data: request body (dict or list)
4175
+ :return:
4176
+ """
4177
+ return self.put(self.resource_url(f"job/{job_key}/docker"), data=data)
4178
+
4179
+ """Global search"""
4180
+
4181
+ def search(self, search_term=None, search_entity=None):
4182
+ """Performs a starts with search against projects, plans, plan branches, deployment projects
4183
+ :param search_term: searchTerm query parameter
4184
+ :param search_entity: searchEntity query parameter
4185
+ :return:
4186
+ """
4187
+ params = {}
4188
+ if search_term is not None:
4189
+ params["searchTerm"] = search_term
4190
+ if search_entity is not None:
4191
+ params["searchEntity"] = search_entity
4192
+ return self.get(self.resource_url("quicksearch"), params=params)
4193
+
4194
+ def search_authors(self, search_term, max_result=None, unlinked_only=None, start_index=None):
4195
+ """A starts-with search of authors based on their author name.
4196
+ :param max_result: max-result query parameter
4197
+ :param unlinked_only: unlinkedOnly query parameter
4198
+ :param search_term: searchTerm query parameter
4199
+ :param start_index: start-index query parameter
4200
+ :return:
4201
+ """
4202
+ params = {}
4203
+ if max_result is not None:
4204
+ params["max-result"] = max_result
4205
+ if unlinked_only is not None:
4206
+ params["unlinkedOnly"] = unlinked_only
4207
+ if search_term is not None:
4208
+ params["searchTerm"] = search_term
4209
+ if start_index is not None:
4210
+ params["start-index"] = start_index
4211
+ return self.get(self.resource_url("search/authors"), params=params)
4212
+
4213
+ def search_deployments(self, max_result=None, search_term=None, start_index=None, permission=None):
4214
+ """Performs a contains search against deployment project name.
4215
+ :param max_result: max-result query parameter
4216
+ :param search_term: searchTerm query parameter
4217
+ :param start_index: start-index query parameter
4218
+ :param permission: permission query parameter
4219
+ :return:
4220
+ """
4221
+ params = {}
4222
+ if max_result is not None:
4223
+ params["max-result"] = max_result
4224
+ if search_term is not None:
4225
+ params["searchTerm"] = search_term
4226
+ if start_index is not None:
4227
+ params["start-index"] = start_index
4228
+ if permission is not None:
4229
+ params["permission"] = permission
4230
+ return self.get(self.resource_url("search/deployments"), params=params)
4231
+
4232
+ def search_jobs(self, plan_key, max_result=None, search_term=None, start_index=None):
4233
+ """Performs a "starts with" search against full job name and full job key.
4234
+ :param plan_key: planKey path parameter
4235
+ :param max_result: max-result query parameter
4236
+ :param search_term: searchTerm query parameter
4237
+ :param start_index: start-index query parameter
4238
+ :return:
4239
+ """
4240
+ params = {}
4241
+ if max_result is not None:
4242
+ params["max-result"] = max_result
4243
+ if search_term is not None:
4244
+ params["searchTerm"] = search_term
4245
+ if start_index is not None:
4246
+ params["start-index"] = start_index
4247
+ return self.get(self.resource_url(f"search/jobs/{plan_key}"), params=params)
4248
+
4249
+ def search_projects(self, max_result=None, search_term=None, start_index=None, permission=None):
4250
+ """Performs a contains search against project name.
4251
+ :param max_result: max-result query parameter
4252
+ :param search_term: searchTerm query parameter
4253
+ :param start_index: start-index query parameter
4254
+ :param permission: permission query parameter
4255
+ :return:
4256
+ """
4257
+ params = {}
4258
+ if max_result is not None:
4259
+ params["max-result"] = max_result
4260
+ if search_term is not None:
4261
+ params["searchTerm"] = search_term
4262
+ if start_index is not None:
4263
+ params["start-index"] = start_index
4264
+ if permission is not None:
4265
+ params["permission"] = permission
4266
+ return self.get(self.resource_url("search/projects"), params=params)
4267
+
4268
+ def search_stages(self, plan_key, max_result=None, search_term=None, start_index=None, stage_id=None):
4269
+ """Performs a "starts with" search against full stage name.
4270
+ :param plan_key: planKey path parameter
4271
+ :param max_result: max-result query parameter
4272
+ :param search_term: searchTerm query parameter
4273
+ :param start_index: start-index query parameter
4274
+ :param stage_id: stageId query parameter
4275
+ :return:
4276
+ """
4277
+ params = {}
4278
+ if max_result is not None:
4279
+ params["max-result"] = max_result
4280
+ if search_term is not None:
4281
+ params["searchTerm"] = search_term
4282
+ if start_index is not None:
4283
+ params["start-index"] = start_index
4284
+ if stage_id is not None:
4285
+ params["stageId"] = stage_id
4286
+ return self.get(self.resource_url(f"search/stages/{plan_key}"), params=params)
4287
+
4288
+ def search_users(self, search_term, max_result=None, start_index=None):
4289
+ """A starts-with search of users based on their username, full-name and if allowed email address.
4290
+ :param max_result: max-result query parameter
4291
+ :param search_term: searchTerm query parameter
4292
+ :param start_index: start-index query parameter
4293
+ :return:
4294
+ """
4295
+ params = {}
4296
+ if max_result is not None:
4297
+ params["max-result"] = max_result
4298
+ if search_term is not None:
4299
+ params["searchTerm"] = search_term
4300
+ if start_index is not None:
4301
+ params["start-index"] = start_index
4302
+ return self.get(self.resource_url("search/users"), params=params)
4303
+
4304
+ def search_versions(
4305
+ self,
4306
+ deployment_project_id,
4307
+ max_result=None,
4308
+ branch_key=None,
4309
+ search_term=None,
4310
+ start_index=None,
4311
+ chronological_order=None,
4312
+ ):
4313
+ """Performs a contains search against a version name.
4314
+ :param max_result: max-result query parameter
4315
+ :param branch_key: branchKey query parameter
4316
+ :param search_term: searchTerm query parameter
4317
+ :param start_index: start-index query parameter
4318
+ :param deployment_project_id: deploymentProjectId query parameter
4319
+ :param chronological_order: chronologicalOrder query parameter
4320
+ :return:
4321
+ """
4322
+ params = {}
4323
+ if max_result is not None:
4324
+ params["max-result"] = max_result
4325
+ if branch_key is not None:
4326
+ params["branchKey"] = branch_key
4327
+ if search_term is not None:
4328
+ params["searchTerm"] = search_term
4329
+ if start_index is not None:
4330
+ params["start-index"] = start_index
4331
+ if deployment_project_id is not None:
4332
+ params["deploymentProjectId"] = deployment_project_id
4333
+ if chronological_order is not None:
4334
+ params["chronologicalOrder"] = chronological_order
4335
+ return self.get(self.resource_url("search/versions"), params=params)
4336
+
4337
+ """Server status"""
4338
+
4339
+ def get_status_2(self):
4340
+ """Returns the current status of the Bamboo node. This endpoint enables a basic status check on the status of a Bamboo node.
4341
+ :return:
4342
+ """
4343
+ return self.get(self.resource_url("status"))
4344
+
4345
+ """Utility"""
4346
+
4347
+ def encrypt(self, data):
4348
+ """Encrypts a given text based on the instance specific cipher. Encrypted data can be used i.a. in Repository-stored Specs. Feature can be enabled or disabled in Bamboo security configuration. Number of allowed requests per user is limited and can be modified in Bamboo security configuration.
4349
+ :param data: request body (dict or list)
4350
+ :return:
4351
+ """
4352
+ return self.post(self.resource_url("encrypt"), data=data)
4353
+
4354
+ """Elastic configuration"""
4355
+
4356
+ def update_all_image_ids(self, image_id, new_image_id):
4357
+ """Bulk update of all images AMI id.
4358
+ :param image_id: imageId path parameter
4359
+ :param new_image_id: newImageId query parameter
4360
+ :return:
4361
+ """
4362
+ params = {}
4363
+ if new_image_id is not None:
4364
+ params["newImageId"] = new_image_id
4365
+ return self.put(self.resource_url(f"elasticConfiguration/image-id/{image_id}"), params=params)
4366
+
4367
+ """Quick filters"""
4368
+
4369
+ def deactivate_filter(self, id):
4370
+ """Deactivates a quick filter for currently logged in user.
4371
+ :param id: id path parameter
4372
+ :return:
4373
+ """
4374
+ return self.put(self.resource_url(f"quickFilter/{id}/deactivate"))