@@ -521,7 +521,6 @@ def get_repo(self, project_key, repository_slug):
521521 :param repository_slug: url-compatible repository identifier
522522 :return: Dictionary of request response
523523 """
524-
525524 if not self .cloud :
526525 url = 'rest/api/1.0/projects/{project}/repos/{repository}' \
527526 .format (project = project_key , repository = repository_slug )
@@ -1940,3 +1939,197 @@ def _get_paged(self, url, params):
19401939 response = self .get (url , params = params )
19411940 values += response .get ('values' )
19421941 return values
1942+
1943+ def get_project_conditions (self , project_key ):
1944+ """
1945+ Request type: GET
1946+ Return a page of defaults conditions with reviewers list that have been configured for this project.
1947+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264904368
1948+ :projectKey: str
1949+ :return:
1950+ """
1951+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/conditions' .format (
1952+ projectKey = project_key )
1953+ return (self .get (url ) or {})
1954+
1955+ def get_project_condition (self , project_key , id_condition ):
1956+ """
1957+ Request type: GET
1958+ Return a specific condition with reviewers list that has been configured for this project.
1959+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264901504
1960+ :projectKey: str - project key involved
1961+ :idCondition: int - condition id involved
1962+ :return:
1963+ """
1964+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/conditions/{idCondition}' .format (
1965+ projectKey = key ,
1966+ idCondition = id_condition )
1967+ return (self .get (url ) or {})
1968+
1969+ def create_project_condition (self , project_key , condition ):
1970+ """
1971+ Request type: POST
1972+ Create a new condition for this project.
1973+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264893584
1974+ :projectKey: str- project key involved
1975+ :data: condition: dictionary object
1976+ :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
1977+ :return:
1978+ """
1979+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/condition' .format (
1980+ projectKey = project_key )
1981+ return (self .post (url , data = condition ) or {})
1982+
1983+ def update_project_condition (self , project_key , condition , id_condition ):
1984+ """
1985+ Request type: PUT
1986+ Update a new condition for this project.
1987+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264927632
1988+ :projectKey: str- project key involved
1989+ :idCondition: int - condition id involved
1990+ :data: condition: dictionary object
1991+ :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
1992+ :return:
1993+ """
1994+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/condition/{idCondition}' .format (
1995+ projectKey = project_key ,
1996+ idCondition = id_condition )
1997+ return (self .put (url , data = condition ) or {})
1998+
1999+ def delete_project_condition (self , project_key , id_condition ):
2000+ """
2001+ Request type: DELETE
2002+ Delete a specific condition for this repository slug inside project.
2003+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264896304
2004+ :projectKey: str- project key involved
2005+ :idCondition: int - condition id involved
2006+ :return:
2007+ """
2008+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/condition/{idCondition}' .format (
2009+ projectKey = project_key ,
2010+ idCondition = id_condition )
2011+ return (self .delete (url ) or {})
2012+
2013+ def get_repo_conditions (self , project_key , repo_key ):
2014+ """
2015+ Request type: GET
2016+ Return a page of defaults conditions with reviewers list (type REPOSITORY or PROJECT) that have been configured for this repository slug inside project specified.
2017+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264928992
2018+ :projectKey: str- project key involved
2019+ :repoKey: str - repo key involved
2020+ :return:
2021+ """
2022+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/conditions' .format (
2023+ projectKey = project_key ,
2024+ repoKey = repo_key )
2025+ return (self .get (url ) or {})
2026+
2027+ def get_repo_project_conditions (self , project_key , repo_key ):
2028+ """
2029+ Request type: GET
2030+ Return a page of repository conditions (only type PROJECT) with reviewers list associated that have been configured for this repository slug inside project specified.
2031+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264928992
2032+ :projectKey: str- project key involved
2033+ :repoKey: str - repo key involved
2034+ :return:
2035+ """
2036+ TYPE_REPO = 'REPOSITORY'
2037+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/conditions' .format (
2038+ projectKey = project_key ,
2039+ repoKey = repo_key )
2040+
2041+ response = (self .get (url ) or {})
2042+ count = 0
2043+ for condition in response :
2044+ if condition ['scope' ]['type' ] == TYPE_REPO :
2045+ del response [count ]
2046+ count += 1
2047+ return response
2048+
2049+ def get_repo_repo_conditions (self , project_key , repo_key ):
2050+ """
2051+ Request type: GET
2052+ Return a page of repository conditions (only type REPOSITORY) with reviewers list associated that have been configured for this repository slug inside project specified.
2053+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264928992
2054+ :projectKey: str- project key involved
2055+ :repoKey: str - repo key involved
2056+ :return:
2057+ """
2058+ TYPE_PROYECT = 'PROJECT'
2059+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/conditions' .format (
2060+ projectKey = project_key ,
2061+ repoKey = repo_key )
2062+
2063+ response = (self .get (url ) or {})
2064+ count = 0
2065+ for condition in response :
2066+ if condition ['scope' ]['type' ] == TYPE_PROYECT :
2067+ del response [count ]
2068+ count += 1
2069+ return response
2070+
2071+ def get_repo_condition (self , project_key , repo_key , id_condition ):
2072+ """
2073+ Request type: GET
2074+ Return a specific condition with reviewers list that have been configured for this repository slug inside project specified.
2075+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264927632
2076+ :projectKey: str- project key involved
2077+ :repoKey: str - repo key involved
2078+ :idCondition: int - condition id involved
2079+ :return:
2080+ """
2081+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/conditions/{idCondition}' .format (
2082+ projectKey = project_key ,
2083+ repoKey = repo_key ,
2084+ idCondition = id_condition )
2085+ return (self .get (url ) or {})
2086+
2087+ def create_repo_condition (self , project_key , repo_key , condition ):
2088+ """
2089+ Request type: POST
2090+ Create a new condition for this repository slug inside project specified.
2091+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264908128
2092+ :projectKey: str- project key involved
2093+ :repoKey: str - repo key involved
2094+ :data: condition: dictionary object
2095+ :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
2096+ :return:
2097+ """
2098+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/condition' .format (
2099+ projectKey = project_key ,
2100+ repoKey = repo_key )
2101+ return (self .post (url , data = condition ) or {})
2102+
2103+ def update_repo_condition (self , project_key , repo_key , condition , id_condition ):
2104+ """
2105+ Request type: PUT
2106+ Update a specific condition for this repository slug inside project.
2107+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264927632
2108+ :projectKey: str- project key involved
2109+ :repoKey: str - repo key involved
2110+ :idCondition: int - condition id involved
2111+ :data: condition: dictionary object
2112+ :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
2113+ :return:
2114+ """
2115+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/condition/{idCondition}' .format (
2116+ projectKey = project_key ,
2117+ repoKey = repo_key ,
2118+ idCondition = id_condition )
2119+ return (self .put (url , data = condition ) or {})
2120+
2121+ def delete_repo_condition (self , project_key , repo_key , id_condition ):
2122+ """
2123+ Request type: DELETE
2124+ Delete a specific condition for this repository slug inside project.
2125+ For further information visit: https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm8287339888
2126+ :projectKey: str- project key involved
2127+ :repoKey: str - repo key involved
2128+ :idCondition: int - condition id involved
2129+ :return:
2130+ """
2131+ url = 'rest/default-reviewers/1.0/projects/{projectKey}/repos/{repoKey}/condition/{idCondition}' .format (
2132+ projectKey = project_key ,
2133+ repoKey = repo_key ,
2134+ idCondition = id_condition )
2135+ return (self .delete (url ) or {})
0 commit comments