This commit is contained in:
Dale Myers 2022-04-25 14:36:46 +01:00
Родитель b17e4577c7
Коммит 50690c812b
2 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -217,6 +217,40 @@ class ADOBuildClient(ADOBaseClient):
response = self.http_client.delete(request_url)
self.http_client.validate_response(response)
def get_definitions(self, *, project_id: str) -> ADOResponse:
"""Get all definitions
:param project_id: The ID of the project
:returns: The project's definitions
"""
request_url = (
self.http_client.api_endpoint(project_id=project_id)
+ "/build/definitions?api-version=6.0"
)
response = self.http_client.get(request_url)
response_data = self.http_client.decode_response(response)
return self.http_client.extract_value(response_data)
def get_definition(self, *, project_id: str, definition_id: int) -> ADOResponse:
"""Get all definitions
:param project_id: The ID of the project
:param definition_id: The identifier of the definition to get
:returns: A definition
"""
request_url = (
self.http_client.api_endpoint(project_id=project_id)
+ f"/build/definitions/{definition_id}?api-version=6.0"
)
response = self.http_client.get(request_url)
return self.http_client.decode_response(response)
def delete_definition(self, *, project_id: str, definition_id: int) -> None:
"""Delete a definition and all associated builds.

Просмотреть файл

@ -327,3 +327,17 @@ class LibraryTests(unittest.TestCase):
assert leases is not None
break
def test_get_definitions(self):
"""Get definitions."""
for definition in self.client.builds.get_definitions(
project_id=self.test_config.project_id
):
definition_id = definition["id"]
full_definition = self.client.builds.get_definition(
project_id=self.test_config.project_id, definition_id=definition_id
)
assert full_definition is not None