atlassian-python-api 5.0.3__py3-none-any.whl → 5.0.4__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.
atlassian/bamboo.py CHANGED
@@ -1076,7 +1076,7 @@ class Bamboo(AtlassianRestAPI):
1076
1076
  """
1077
1077
  params = {"limit": limit, "start": start}
1078
1078
  if filter_users:
1079
- params = {"filter": filter_users}
1079
+ params["filter"] = filter_users
1080
1080
  url = f"rest/api/latest/admin/groups/{group_name}/more-members"
1081
1081
  return self.get(url, params=params)
1082
1082
 
@@ -1092,7 +1092,7 @@ class Bamboo(AtlassianRestAPI):
1092
1092
  """
1093
1093
  params = {"limit": limit, "start": start}
1094
1094
  if filter_users:
1095
- params = {"filter": filter_users}
1095
+ params["filter"] = filter_users
1096
1096
 
1097
1097
  url = f"rest/api/latest/admin/groups/{group_name}/more-non-members"
1098
1098
  return self.get(url, params=params)
@@ -1489,6 +1489,823 @@ class Bamboo(AtlassianRestAPI):
1489
1489
  response = self.get("rest/supportHealthCheck/1.0/check/")
1490
1490
  return response
1491
1491
 
1492
+ """Responsibility"""
1493
+
1494
+ def get_broken_builds_by_user(self, username):
1495
+ """
1496
+ Get broken builds for which a user has taken responsibility.
1497
+ :param username: str - username
1498
+ :return: list of broken builds
1499
+ """
1500
+ return self.get(f"rest/responsibility/latest/brokenBuild/byUser/{username}")
1501
+
1502
+ def get_my_broken_builds(self):
1503
+ """Get broken builds for which the current user has taken responsibility."""
1504
+ return self.get("rest/responsibility/latest/brokenBuild/myBrokenBuilds")
1505
+
1506
+ def get_broken_build(self, plan_result_key_or_plan_key):
1507
+ """
1508
+ Get responsibility information for a broken build or plan.
1509
+ :param plan_result_key_or_plan_key: str - plan result key or plan key
1510
+ :return: responsibility info
1511
+ """
1512
+ return self.get(f"rest/responsibility/latest/brokenBuild/{plan_result_key_or_plan_key}")
1513
+
1514
+ def take_responsibility(self, plan_result_key_or_plan_key, username):
1515
+ """
1516
+ Take responsibility for a broken build.
1517
+ :param plan_result_key_or_plan_key: str - plan result key or plan key
1518
+ :param username: str - username taking responsibility
1519
+ :return:
1520
+ """
1521
+ return self.post(f"rest/responsibility/latest/brokenBuild/{plan_result_key_or_plan_key}/{username}")
1522
+
1523
+ def remove_responsibility(self, plan_result_key_or_plan_key, username):
1524
+ """
1525
+ Remove responsibility for a broken build.
1526
+ :param plan_result_key_or_plan_key: str - plan result key or plan key
1527
+ :param username: str - username
1528
+ :return:
1529
+ """
1530
+ return self.delete(f"rest/responsibility/latest/brokenBuild/{plan_result_key_or_plan_key}/{username}")
1531
+
1532
+ """Triggers"""
1533
+
1534
+ def remote_trigger_change_detection(self):
1535
+ """Trigger remote repository change detection for all linked repositories."""
1536
+ return self.post("rest/triggers/latest/remote/changeDetection")
1537
+
1538
+ """Access tokens"""
1539
+
1540
+ def get_access_tokens(self):
1541
+ """Get all access tokens for the current user."""
1542
+ return self.get(self.resource_url("access-token"))
1543
+
1544
+ def create_access_token(self):
1545
+ """Create a new access token for the current user."""
1546
+ return self.post(self.resource_url("access-token"))
1547
+
1548
+ def delete_access_token(self, token_id):
1549
+ """
1550
+ Delete an access token.
1551
+ :param token_id: str - token id
1552
+ :return:
1553
+ """
1554
+ return self.delete(self.resource_url(f"access-token/{token_id}"))
1555
+
1556
+ """Deployments"""
1557
+
1558
+ def create_deployment_project(self, data):
1559
+ """
1560
+ Create a new deployment project.
1561
+ :param data: dict - deployment project representation
1562
+ :return: created deployment project
1563
+ """
1564
+ return self.post(self.resource_url("deploy/project"), data=data)
1565
+
1566
+ def update_deployment_project(self, project_id, data):
1567
+ """
1568
+ Update a deployment project.
1569
+ :param project_id: str - deployment project id
1570
+ :param data: dict - deployment project representation
1571
+ :return:
1572
+ """
1573
+ return self.put(self.resource_url(f"deploy/project/{project_id}"), data=data)
1574
+
1575
+ def create_deployment_environment(self, project_id, data):
1576
+ """
1577
+ Create a deployment environment in a deployment project.
1578
+ :param project_id: str - deployment project id
1579
+ :param data: dict - environment representation
1580
+ :return: created environment
1581
+ """
1582
+ return self.post(self.resource_url(f"deploy/project/{project_id}/environment"), data=data)
1583
+
1584
+ def get_deployment_environment(self, environment_id):
1585
+ """
1586
+ Get a deployment environment.
1587
+ :param environment_id: str - environment id
1588
+ :return: environment
1589
+ """
1590
+ return self.get(self.resource_url(f"deploy/environment/{environment_id}"))
1591
+
1592
+ def update_deployment_environment(self, environment_id, data):
1593
+ """
1594
+ Update a deployment environment.
1595
+ :param environment_id: str - environment id
1596
+ :param data: dict - environment representation
1597
+ :return:
1598
+ """
1599
+ return self.put(self.resource_url(f"deploy/environment/{environment_id}"), data=data)
1600
+
1601
+ def delete_deployment_environment(self, environment_id):
1602
+ """
1603
+ Delete a deployment environment.
1604
+ :param environment_id: str - environment id
1605
+ :return:
1606
+ """
1607
+ return self.delete(self.resource_url(f"deploy/environment/{environment_id}"))
1608
+
1609
+ def get_deployment_versions(self, project_id, start=0, limit=25):
1610
+ """
1611
+ Get versions for a deployment project.
1612
+ :param project_id: str - deployment project id
1613
+ :param start: int - start index for paging
1614
+ :param limit: int - maximum number of results
1615
+ :return: versions
1616
+ """
1617
+ return self.get(
1618
+ self.resource_url(f"deploy/project/{project_id}/versions"),
1619
+ params={"start": start, "limit": limit},
1620
+ )
1621
+
1622
+ def create_deployment_version(self, project_id, data):
1623
+ """
1624
+ Create a deployment version.
1625
+ :param project_id: str - deployment project id
1626
+ :param data: dict - version representation
1627
+ :return: created version
1628
+ """
1629
+ return self.post(self.resource_url(f"deploy/project/{project_id}/version"), data=data)
1630
+
1631
+ def get_deployment_version(self, version_id):
1632
+ """
1633
+ Get a deployment version.
1634
+ :param version_id: str - version id
1635
+ :return: version
1636
+ """
1637
+ return self.get(self.resource_url(f"deploy/version/{version_id}"))
1638
+
1639
+ def delete_deployment_version(self, version_id):
1640
+ """
1641
+ Delete a deployment version.
1642
+ :param version_id: str - version id
1643
+ :return:
1644
+ """
1645
+ return self.delete(self.resource_url(f"deploy/version/{version_id}"))
1646
+
1647
+ def get_deployment_dashboard_paginate(self, project_id=None, start=0, limit=25):
1648
+ """
1649
+ Get paginated deployment dashboard.
1650
+ :param project_id: str - optional deployment project id
1651
+ :param start: int - start index
1652
+ :param limit: int - maximum number of results
1653
+ :return: dashboard data
1654
+ """
1655
+ resource = f"deploy/dashboard/paginate/{project_id}" if project_id else "deploy/dashboard/paginate"
1656
+ return self.get(self.resource_url(resource), params={"start": start, "limit": limit})
1657
+
1658
+ def get_deployment_dashboard_status(self, data):
1659
+ """
1660
+ Get deployment dashboard status for given environments.
1661
+ :param data: dict - request body with environment ids
1662
+ :return: dashboard status
1663
+ """
1664
+ return self.post(self.resource_url("deploy/dashboard/status"), data=data)
1665
+
1666
+ """Admin configuration"""
1667
+
1668
+ def _admin_url(self, resource):
1669
+ return f"rest/admin/latest/{resource}"
1670
+
1671
+ def get_artifact_handler_config(self, handler_name):
1672
+ """
1673
+ Get configuration for an artifact handler.
1674
+ :param handler_name: str - handler name (agentLocal, bambooRemote, s3, sftp)
1675
+ :return: configuration
1676
+ """
1677
+ return self.get(self._admin_url(f"artifactHandlers/{handler_name}"))
1678
+
1679
+ def update_artifact_handler_config(self, handler_name, data):
1680
+ """
1681
+ Update configuration for an artifact handler.
1682
+ :param handler_name: str - handler name
1683
+ :param data: dict - handler configuration
1684
+ :return:
1685
+ """
1686
+ return self.put(self._admin_url(f"artifactHandlers/{handler_name}"), data=data)
1687
+
1688
+ def get_agent_config(self):
1689
+ """Get agent configuration list."""
1690
+ return self.get(self._admin_url("config/agents"))
1691
+
1692
+ def get_offline_agent_removal_config(self):
1693
+ """Get offline agent removal configuration."""
1694
+ return self.get(self._admin_url("config/agents/offlineAgentRemoval"))
1695
+
1696
+ def update_offline_agent_removal_config(self, data):
1697
+ """
1698
+ Update offline agent removal configuration.
1699
+ :param data: dict - configuration
1700
+ :return:
1701
+ """
1702
+ return self.put(self._admin_url("config/agents/offlineAgentRemoval"), data=data)
1703
+
1704
+ def get_build_concurrency_config(self):
1705
+ """Get build concurrency configuration."""
1706
+ return self.get(self._admin_url("config/build/concurrency"))
1707
+
1708
+ def update_build_concurrency_config(self, data):
1709
+ """
1710
+ Update build concurrency configuration.
1711
+ :param data: dict - configuration
1712
+ :return:
1713
+ """
1714
+ return self.put(self._admin_url("config/build/concurrency"), data=data)
1715
+
1716
+ def get_build_monitoring_config(self):
1717
+ """Get build monitoring configuration."""
1718
+ return self.get(self._admin_url("config/build/monitoring"))
1719
+
1720
+ def update_build_monitoring_config(self, data):
1721
+ """
1722
+ Update build monitoring configuration.
1723
+ :param data: dict - configuration
1724
+ :return:
1725
+ """
1726
+ return self.put(self._admin_url("config/build/monitoring"), data=data)
1727
+
1728
+ def get_general_config(self):
1729
+ """Get general configuration."""
1730
+ return self.get(self._admin_url("config/general"))
1731
+
1732
+ def update_general_config(self, data):
1733
+ """
1734
+ Update general configuration.
1735
+ :param data: dict - configuration
1736
+ :return:
1737
+ """
1738
+ return self.put(self._admin_url("config/general"), data=data)
1739
+
1740
+ def get_mail_server_config(self):
1741
+ """Get mail server configuration."""
1742
+ return self.get(self._admin_url("config/mailServer"))
1743
+
1744
+ def update_mail_server_config(self, data):
1745
+ """
1746
+ Update mail server configuration.
1747
+ :param data: dict - configuration
1748
+ :return:
1749
+ """
1750
+ return self.put(self._admin_url("config/mailServer"), data=data)
1751
+
1752
+ def delete_mail_server_config(self):
1753
+ """Delete mail server configuration."""
1754
+ return self.delete(self._admin_url("config/mailServer"))
1755
+
1756
+ def get_im_server_config(self):
1757
+ """Get instant messaging server configuration."""
1758
+ return self.get(self._admin_url("config/imServer"))
1759
+
1760
+ def update_im_server_config(self, data):
1761
+ """
1762
+ Update instant messaging server configuration.
1763
+ :param data: dict - configuration
1764
+ :return:
1765
+ """
1766
+ return self.put(self._admin_url("config/imServer"), data=data)
1767
+
1768
+ def delete_im_server_config(self):
1769
+ """Delete instant messaging server configuration."""
1770
+ return self.delete(self._admin_url("config/imServer"))
1771
+
1772
+ def get_remote_agent_support_config(self):
1773
+ """Get remote agent support configuration."""
1774
+ return self.get(self._admin_url("config/remoteAgentSupport"))
1775
+
1776
+ def update_remote_agent_support_config(self, data):
1777
+ """
1778
+ Update remote agent support configuration.
1779
+ :param data: dict - configuration
1780
+ :return:
1781
+ """
1782
+ return self.put(self._admin_url("config/remoteAgentSupport"), data=data)
1783
+
1784
+ def get_quarantine_config(self):
1785
+ """Get quarantine configuration."""
1786
+ return self.get(self._admin_url("config/quarantine"))
1787
+
1788
+ def update_quarantine_config(self, data):
1789
+ """
1790
+ Update quarantine configuration.
1791
+ :param data: dict - configuration
1792
+ :return:
1793
+ """
1794
+ return self.put(self._admin_url("config/quarantine"), data=data)
1795
+
1796
+ def get_audit_log_config(self):
1797
+ """Get audit log configuration."""
1798
+ return self.get(self._admin_url("config/auditLog"))
1799
+
1800
+ def update_audit_log_config(self, data):
1801
+ """
1802
+ Update audit log configuration.
1803
+ :param data: dict - configuration
1804
+ :return:
1805
+ """
1806
+ return self.put(self._admin_url("config/auditLog"), data=data)
1807
+
1808
+ def get_dark_features(self):
1809
+ """Get all dark features."""
1810
+ return self.get(self._admin_url("darkFeatures"))
1811
+
1812
+ def get_dark_feature(self, key):
1813
+ """
1814
+ Get a dark feature.
1815
+ :param key: str - feature key
1816
+ :return: feature status
1817
+ """
1818
+ return self.get(self._admin_url(f"darkFeatures/{key}"))
1819
+
1820
+ def update_dark_feature(self, key, enabled):
1821
+ """
1822
+ Enable or disable a dark feature.
1823
+ :param key: str - feature key
1824
+ :param enabled: bool - enabled status
1825
+ :return:
1826
+ """
1827
+ return self.put(self._admin_url(f"darkFeatures/{key}"), data={"enabled": enabled})
1828
+
1829
+ def get_dark_feature_user(self, key, username):
1830
+ """
1831
+ Get dark feature status for a user.
1832
+ :param key: str - feature key
1833
+ :param username: str - username
1834
+ :return: feature status
1835
+ """
1836
+ return self.get(self._admin_url(f"darkFeatures/{key}/user/{username}"))
1837
+
1838
+ def update_dark_feature_user(self, key, username, enabled):
1839
+ """
1840
+ Enable or disable a dark feature for a user.
1841
+ :param key: str - feature key
1842
+ :param username: str - username
1843
+ :param enabled: bool - enabled status
1844
+ :return:
1845
+ """
1846
+ return self.put(self._admin_url(f"darkFeatures/{key}/user/{username}"), data={"enabled": enabled})
1847
+
1848
+ def get_global_variables(self):
1849
+ """Get all global variables."""
1850
+ return self.get(self._admin_url("globalVariables"))
1851
+
1852
+ def create_global_variable(self, data):
1853
+ """
1854
+ Create a global variable.
1855
+ :param data: dict - variable representation
1856
+ :return: created variable
1857
+ """
1858
+ return self.post(self._admin_url("globalVariables"), data=data)
1859
+
1860
+ def get_global_variable(self, variable_id):
1861
+ """
1862
+ Get a global variable.
1863
+ :param variable_id: str - variable id
1864
+ :return: variable
1865
+ """
1866
+ return self.get(self._admin_url(f"globalVariables/{variable_id}"))
1867
+
1868
+ def update_global_variable(self, variable_id, data):
1869
+ """
1870
+ Update a global variable.
1871
+ :param variable_id: str - variable id
1872
+ :param data: dict - variable representation
1873
+ :return:
1874
+ """
1875
+ return self.put(self._admin_url(f"globalVariables/{variable_id}"), data=data)
1876
+
1877
+ def delete_global_variable(self, variable_id):
1878
+ """
1879
+ Delete a global variable.
1880
+ :param variable_id: str - variable id
1881
+ :return:
1882
+ """
1883
+ return self.delete(self._admin_url(f"globalVariables/{variable_id}"))
1884
+
1885
+ def verify_global_variables(self, data):
1886
+ """
1887
+ Verify global variables.
1888
+ :param data: dict - variables to verify
1889
+ :return: verification result
1890
+ """
1891
+ return self.put(self._admin_url("globalVariables/verify"), data=data)
1892
+
1893
+ def get_security_settings(self):
1894
+ """Get security settings."""
1895
+ return self.get(self._admin_url("security/settings"))
1896
+
1897
+ def update_security_settings(self, data):
1898
+ """
1899
+ Update security settings.
1900
+ :param data: dict - security settings
1901
+ :return:
1902
+ """
1903
+ return self.put(self._admin_url("security/settings"), data=data)
1904
+
1905
+ def get_security_groups(self):
1906
+ """Get security groups."""
1907
+ return self.get(self._admin_url("security/groups"))
1908
+
1909
+ def create_security_group(self, data):
1910
+ """
1911
+ Create a security group.
1912
+ :param data: dict - group representation
1913
+ :return: created group
1914
+ """
1915
+ return self.post(self._admin_url("security/groups"), data=data)
1916
+
1917
+ def get_trusted_keys(self):
1918
+ """Get trusted keys."""
1919
+ return self.get(self._admin_url("security/trustedKey"))
1920
+
1921
+ def add_trusted_key(self, data):
1922
+ """
1923
+ Add a trusted key.
1924
+ :param data: dict - key representation
1925
+ :return: created key
1926
+ """
1927
+ return self.post(self._admin_url("security/trustedKey"), data=data)
1928
+
1929
+ def delete_trusted_key(self, key_id):
1930
+ """
1931
+ Delete a trusted key.
1932
+ :param key_id: str - key id
1933
+ :return:
1934
+ """
1935
+ return self.delete(self._admin_url(f"security/trustedKey/{key_id}"))
1936
+
1937
+ """Permissions"""
1938
+
1939
+ def _permission_url(self, resource_type, resource_id):
1940
+ return f"permissions/{resource_type}/{resource_id}"
1941
+
1942
+ def get_available_users_for_permission(self, resource_type, resource_id, start=0, limit=25):
1943
+ """
1944
+ Get users available for granting permission to a resource.
1945
+ :param resource_type: str - deployment, environment, project, plan, repository
1946
+ :param resource_id: str - resource id
1947
+ :param start: int - start index
1948
+ :param limit: int - maximum number of results
1949
+ :return: available users
1950
+ """
1951
+ return self.get(
1952
+ self.resource_url(self._permission_url(resource_type, resource_id) + "/available-users"),
1953
+ params={"start": start, "limit": limit},
1954
+ )
1955
+
1956
+ def get_available_groups_for_permission(self, resource_type, resource_id, start=0, limit=25):
1957
+ """
1958
+ Get groups available for granting permission to a resource.
1959
+ :param resource_type: str - deployment, environment, project, plan, repository
1960
+ :param resource_id: str - resource id
1961
+ :param start: int - start index
1962
+ :param limit: int - maximum number of results
1963
+ :return: available groups
1964
+ """
1965
+ return self.get(
1966
+ self.resource_url(self._permission_url(resource_type, resource_id) + "/available-groups"),
1967
+ params={"start": start, "limit": limit},
1968
+ )
1969
+
1970
+ def get_roles_for_permission(self, resource_type, resource_id):
1971
+ """
1972
+ Get roles with permissions for a resource.
1973
+ :param resource_type: str - deployment, environment, project, plan, repository
1974
+ :param resource_id: str - resource id
1975
+ :return: roles
1976
+ """
1977
+ return self.get(self.resource_url(self._permission_url(resource_type, resource_id) + "/roles"))
1978
+
1979
+ def grant_role_permission(self, resource_type, resource_id, role_name, permissions):
1980
+ """
1981
+ Grant permissions to a role for a resource.
1982
+ :param resource_type: str - deployment, environment, project, plan, repository
1983
+ :param resource_id: str - resource id
1984
+ :param role_name: str - role name
1985
+ :param permissions: list - list of permissions
1986
+ :return:
1987
+ """
1988
+ return self.put(
1989
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/roles/{role_name}"),
1990
+ data=permissions,
1991
+ )
1992
+
1993
+ def revoke_role_permission(self, resource_type, resource_id, role_name, permissions):
1994
+ """
1995
+ Revoke permissions from a role for a resource.
1996
+ :param resource_type: str - deployment, environment, project, plan, repository
1997
+ :param resource_id: str - resource id
1998
+ :param role_name: str - role name
1999
+ :param permissions: list - list of permissions
2000
+ :return:
2001
+ """
2002
+ return self.delete(
2003
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/roles/{role_name}"),
2004
+ data=permissions,
2005
+ )
2006
+
2007
+ def get_permission_users(self, resource_type, resource_id, filter_name=None, start=0, limit=25):
2008
+ """
2009
+ Get users with explicit permissions to a resource.
2010
+ :param resource_type: str - deployment, environment, project, plan, repository
2011
+ :param resource_id: str - resource id
2012
+ :param filter_name: str - optional name filter
2013
+ :param start: int - start index
2014
+ :param limit: int - maximum number of results
2015
+ :return: users
2016
+ """
2017
+ params = {"start": start, "limit": limit}
2018
+ if filter_name:
2019
+ params["name"] = filter_name
2020
+ return self.get(
2021
+ self.resource_url(self._permission_url(resource_type, resource_id) + "/users"),
2022
+ params=params,
2023
+ )
2024
+
2025
+ def grant_user_permission(self, resource_type, resource_id, user_name, permissions):
2026
+ """
2027
+ Grant permissions to a user for a resource.
2028
+ :param resource_type: str - deployment, environment, project, plan, repository
2029
+ :param resource_id: str - resource id
2030
+ :param user_name: str - username
2031
+ :param permissions: list - list of permissions
2032
+ :return:
2033
+ """
2034
+ return self.put(
2035
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/users/{user_name}"),
2036
+ data=permissions,
2037
+ )
2038
+
2039
+ def revoke_user_permission(self, resource_type, resource_id, user_name, permissions):
2040
+ """
2041
+ Revoke permissions from a user for a resource.
2042
+ :param resource_type: str - deployment, environment, project, plan, repository
2043
+ :param resource_id: str - resource id
2044
+ :param user_name: str - username
2045
+ :param permissions: list - list of permissions
2046
+ :return:
2047
+ """
2048
+ return self.delete(
2049
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/users/{user_name}"),
2050
+ data=permissions,
2051
+ )
2052
+
2053
+ def get_permission_groups(self, resource_type, resource_id, filter_name=None, start=0, limit=25):
2054
+ """
2055
+ Get groups with explicit permissions to a resource.
2056
+ :param resource_type: str - deployment, environment, project, plan, repository
2057
+ :param resource_id: str - resource id
2058
+ :param filter_name: str - optional name filter
2059
+ :param start: int - start index
2060
+ :param limit: int - maximum number of results
2061
+ :return: groups
2062
+ """
2063
+ params = {"start": start, "limit": limit}
2064
+ if filter_name:
2065
+ params["name"] = filter_name
2066
+ return self.get(
2067
+ self.resource_url(self._permission_url(resource_type, resource_id) + "/groups"),
2068
+ params=params,
2069
+ )
2070
+
2071
+ def grant_group_permission(self, resource_type, resource_id, group_name, permissions):
2072
+ """
2073
+ Grant permissions to a group for a resource.
2074
+ :param resource_type: str - deployment, environment, project, plan, repository
2075
+ :param resource_id: str - resource id
2076
+ :param group_name: str - group name
2077
+ :param permissions: list - list of permissions
2078
+ :return:
2079
+ """
2080
+ return self.put(
2081
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/groups/{group_name}"),
2082
+ data=permissions,
2083
+ )
2084
+
2085
+ def revoke_group_permission(self, resource_type, resource_id, group_name, permissions):
2086
+ """
2087
+ Revoke permissions from a group for a resource.
2088
+ :param resource_type: str - deployment, environment, project, plan, repository
2089
+ :param resource_id: str - resource id
2090
+ :param group_name: str - group name
2091
+ :param permissions: list - list of permissions
2092
+ :return:
2093
+ """
2094
+ return self.delete(
2095
+ self.resource_url(self._permission_url(resource_type, resource_id) + f"/groups/{group_name}"),
2096
+ data=permissions,
2097
+ )
2098
+
2099
+ """Admin users and groups"""
2100
+
2101
+ def get_users(self, start=0, limit=25):
2102
+ """
2103
+ Get a paginated list of users.
2104
+ :param start: int - start index
2105
+ :param limit: int - maximum number of results
2106
+ :return: users
2107
+ """
2108
+ return self.get(self.resource_url("admin/users"), params={"start": start, "limit": limit})
2109
+
2110
+ def create_user(self, data):
2111
+ """
2112
+ Create a new user.
2113
+ :param data: dict - user representation
2114
+ :return: created user
2115
+ """
2116
+ return self.post(self.resource_url("admin/users"), data=data)
2117
+
2118
+ def delete_user(self, username):
2119
+ """
2120
+ Delete a user.
2121
+ :param username: str - username
2122
+ :return:
2123
+ """
2124
+ return self.delete(self.resource_url(f"admin/users/{username}"))
2125
+
2126
+ def update_user_credentials(self, data):
2127
+ """
2128
+ Update user credentials.
2129
+ :param data: dict - credentials request
2130
+ :return:
2131
+ """
2132
+ return self.put(self.resource_url("admin/users/credentials"), data=data)
2133
+
2134
+ def rename_user(self, data):
2135
+ """
2136
+ Rename a user.
2137
+ :param data: dict - rename request
2138
+ :return:
2139
+ """
2140
+ return self.put(self.resource_url("admin/users/rename"), data=data)
2141
+
2142
+ def get_user_access_tokens(self, username):
2143
+ """
2144
+ Get access tokens for a user.
2145
+ :param username: str - username
2146
+ :return: access tokens
2147
+ """
2148
+ return self.get(self.resource_url(f"admin/users/{username}/access-token"))
2149
+
2150
+ def delete_user_access_token(self, username, token_id):
2151
+ """
2152
+ Delete an access token for a user.
2153
+ :param username: str - username
2154
+ :param token_id: str - token id
2155
+ :return:
2156
+ """
2157
+ return self.delete(self.resource_url(f"admin/users/{username}/access-token/{token_id}"))
2158
+
2159
+ def get_user_alias(self, username):
2160
+ """
2161
+ Get a user's alias.
2162
+ :param username: str - username
2163
+ :return: alias
2164
+ """
2165
+ return self.get(self.resource_url(f"admin/users/{username}/alias"))
2166
+
2167
+ def set_user_alias(self, username, data):
2168
+ """
2169
+ Set a user's alias.
2170
+ :param username: str - username
2171
+ :param data: dict - alias request
2172
+ :return:
2173
+ """
2174
+ return self.post(self.resource_url(f"admin/users/{username}/alias"), data=data)
2175
+
2176
+ def delete_user_alias(self, username):
2177
+ """
2178
+ Delete a user's alias.
2179
+ :param username: str - username
2180
+ :return:
2181
+ """
2182
+ return self.delete(self.resource_url(f"admin/users/{username}/alias"))
2183
+
2184
+ """Server and queue"""
2185
+
2186
+ def get_server(self):
2187
+ """Get Bamboo server information."""
2188
+ return self.get(self.resource_url("server"))
2189
+
2190
+ def get_server_nodes(self):
2191
+ """Get Bamboo server nodes."""
2192
+ return self.get(self.resource_url("server/nodes"))
2193
+
2194
+ def pause_server(self):
2195
+ """Pause the Bamboo server."""
2196
+ return self.post(self.resource_url("server/pause"))
2197
+
2198
+ def resume_server(self):
2199
+ """Resume the Bamboo server."""
2200
+ return self.post(self.resource_url("server/resume"))
2201
+
2202
+ def prepare_for_restart(self):
2203
+ """Prepare the Bamboo server for restart."""
2204
+ return self.put(self.resource_url("server/prepareForRestart"))
2205
+
2206
+ def get_current_user(self):
2207
+ """Get information about the current user."""
2208
+ return self.get(self.resource_url("currentUser"))
2209
+
2210
+ def remove_build_from_queue(self, project_key, build_key, build_number):
2211
+ """
2212
+ Remove a build from the queue.
2213
+ :param project_key: str - project key
2214
+ :param build_key: str - build key
2215
+ :param build_number: int - build number
2216
+ :return:
2217
+ """
2218
+ return self.delete(self.resource_url(f"queue/{project_key}-{build_key}-{build_number}"))
2219
+
2220
+ def pause_build_in_queue(self, project_key, build_key, build_number):
2221
+ """
2222
+ Pause a build in the queue.
2223
+ :param project_key: str - project key
2224
+ :param build_key: str - build key
2225
+ :param build_number: int - build number
2226
+ :return:
2227
+ """
2228
+ return self.put(self.resource_url(f"queue/{project_key}-{build_key}-{build_number}"))
2229
+
2230
+ def remove_deployment_from_queue(self, deployment_result_id):
2231
+ """
2232
+ Remove a deployment from the queue.
2233
+ :param deployment_result_id: str - deployment result id
2234
+ :return:
2235
+ """
2236
+ return self.delete(self.resource_url(f"queue/deployment/{deployment_result_id}"))
2237
+
2238
+ """Quick filters"""
2239
+
2240
+ def get_quick_filters(self):
2241
+ """Get all quick filters."""
2242
+ return self.get(self.resource_url("quickFilter"))
2243
+
2244
+ def create_quick_filter(self, data):
2245
+ """
2246
+ Create a quick filter.
2247
+ :param data: dict - filter representation
2248
+ :return: created filter
2249
+ """
2250
+ return self.post(self.resource_url("quickFilter"), data=data)
2251
+
2252
+ def get_active_quick_filters(self):
2253
+ """Get active quick filters."""
2254
+ return self.get(self.resource_url("quickFilter/active"))
2255
+
2256
+ def get_visible_quick_filters(self):
2257
+ """Get visible quick filters."""
2258
+ return self.get(self.resource_url("quickFilter/visible"))
2259
+
2260
+ def set_visible_quick_filters(self, data):
2261
+ """
2262
+ Set visible quick filters.
2263
+ :param data: dict - filter ids
2264
+ :return:
2265
+ """
2266
+ return self.put(self.resource_url("quickFilter/visible"), data=data)
2267
+
2268
+ def deactivate_quick_filters(self, data):
2269
+ """
2270
+ Deactivate quick filters.
2271
+ :param data: dict - filter ids
2272
+ :return:
2273
+ """
2274
+ return self.put(self.resource_url("quickFilter/deactivate"), data=data)
2275
+
2276
+ def get_quick_filter(self, filter_id):
2277
+ """
2278
+ Get a quick filter.
2279
+ :param filter_id: str - filter id
2280
+ :return: filter
2281
+ """
2282
+ return self.get(self.resource_url(f"quickFilter/{filter_id}"))
2283
+
2284
+ def update_quick_filter(self, filter_id, data):
2285
+ """
2286
+ Update a quick filter.
2287
+ :param filter_id: str - filter id
2288
+ :param data: dict - filter representation
2289
+ :return:
2290
+ """
2291
+ return self.put(self.resource_url(f"quickFilter/{filter_id}"), data=data)
2292
+
2293
+ def delete_quick_filter(self, filter_id):
2294
+ """
2295
+ Delete a quick filter.
2296
+ :param filter_id: str - filter id
2297
+ :return:
2298
+ """
2299
+ return self.delete(self.resource_url(f"quickFilter/{filter_id}"))
2300
+
2301
+ def activate_quick_filter(self, filter_id):
2302
+ """
2303
+ Activate a quick filter.
2304
+ :param filter_id: str - filter id
2305
+ :return:
2306
+ """
2307
+ return self.put(self.resource_url(f"quickFilter/{filter_id}/activate"))
2308
+
1492
2309
  """Elastic Bamboo"""
1493
2310
 
1494
2311
  def get_elastic_instance_logs(self, instance_id):