Skip to content

Commit a8956db

Browse files
authored
Merge branch 'atlassian-api:master' into master
2 parents fd3c1b6 + b866ae7 commit a8956db

File tree

15 files changed

+521
-89
lines changed

15 files changed

+521
-89
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ jobs:
3030
.github/bump_version ./ minor > atlassian/VERSION
3131
make docker-qa PYTHON_VERSION=${{matrix.python-version}}
3232
- name: Creating coverage report
33-
if: ${{ ( matrix.python-version == '3.8' ) }}
34-
uses: codecov/codecov-action@v3
33+
uses: codecov/codecov-action@v4
3534
with:
3635
files: ./coverage.xml
37-
fail_ci_if_error: true
36+
fail_ci_if_error: false
3837
token: ${{ secrets.CODECOV_TOKEN }}

.readthedocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
# Required
66
version: 2
77

8+
build:
9+
os: ubuntu-lts-latest
10+
tools:
11+
python: "3.8"
12+
813
# Build documentation in the docs/ directory with Sphinx
914
sphinx:
1015
configuration: docs/conf.py

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.41.12
1+
3.41.14

atlassian/bamboo.py

Lines changed: 187 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ def projects(
104104
clover_enabled=False,
105105
max_results=25,
106106
):
107+
"""
108+
Get all Projects
109+
:param expand:
110+
:param favourite:
111+
:param clover_enabled:
112+
:param max_results:
113+
:return:
114+
"""
107115
return self.base_list_call(
108116
"project",
109117
expand=expand,
@@ -115,6 +123,14 @@ def projects(
115123
)
116124

117125
def project(self, project_key, expand=None, favourite=False, clover_enabled=False):
126+
"""
127+
Get a single project by the key
128+
:param project_key:
129+
:param expand:
130+
:param favourite:
131+
:param clover_enabled:
132+
:return:
133+
"""
118134
resource = "project/{}".format(project_key)
119135
return self.base_list_call(
120136
resource=resource,
@@ -125,8 +141,21 @@ def project(self, project_key, expand=None, favourite=False, clover_enabled=Fals
125141
max_results=25,
126142
)
127143

144+
def get_project(self, project_key):
145+
"""Method used to retrieve information for project specified as project key.
146+
Possible expand parameters: plans, list of plans for project. plans.plan, list of plans with plan details
147+
(only plans visible - READ permission for user)"""
148+
resource = "project/{}?showEmpty".format(project_key)
149+
return self.get(self.resource_url(resource))
150+
151+
def delete_project(self, project_key):
152+
"""Marks project for deletion. Project will be deleted by a batch job."""
153+
resource = "project/{}".format(project_key)
154+
return self.delete(self.resource_url(resource))
155+
128156
def project_plans(self, project_key, start_index=0, max_results=25):
129157
"""
158+
Get all build plans in a project
130159
Returns a generator with the plans in a given project.
131160
:param project_key: project key
132161
:param start_index:
@@ -153,6 +182,15 @@ def plans(
153182
start_index=0,
154183
max_results=25,
155184
):
185+
"""
186+
Get all build plans
187+
:param expand:
188+
:param favourite:
189+
:param clover_enabled:
190+
:param start_index:
191+
:param max_results:
192+
:return:
193+
"""
156194
return self.base_list_call(
157195
"plan",
158196
expand=expand,
@@ -234,6 +272,14 @@ def enable_plan(self, plan_key):
234272
""" Branches """
235273

236274
def search_branches(self, plan_key, include_default_branch=True, max_results=25, start=0):
275+
"""
276+
Search Branches
277+
:param plan_key:
278+
:param include_default_branch:
279+
:param max_results:
280+
:param start:
281+
:return:
282+
"""
237283
params = {
238284
"max-result": max_results,
239285
"start-index": start,
@@ -256,7 +302,16 @@ def plan_branches(
256302
clover_enabled=False,
257303
max_results=25,
258304
):
259-
"""api/1.0/plan/{projectKey}-{buildKey}/branch"""
305+
"""
306+
Get all plan Branches
307+
api/1.0/plan/{projectKey}-{buildKey}/branch
308+
:param plan_key:
309+
:param expand:
310+
:param favourite:
311+
:param clover_enabled:
312+
:param max_results:
313+
:return:
314+
"""
260315
resource = "plan/{}/branch".format(plan_key)
261316
return self.base_list_call(
262317
resource,
@@ -617,14 +672,30 @@ def comments(
617672
start_index=0,
618673
max_results=25,
619674
):
675+
"""
676+
Get comments for a specific build
677+
:param project_key:
678+
:param plan_key:
679+
:param build_number:
680+
:param start_index:
681+
:param max_results:
682+
:return:
683+
"""
620684
resource = "result/{}-{}-{}/comment".format(project_key, plan_key, build_number)
621685
params = {"start-index": start_index, "max-results": max_results}
622686
return self.get(self.resource_url(resource), params=params)
623687

624-
def create_comment(self, project_key, plan_key, build_number, comment, author=None):
688+
def create_comment(self, project_key, plan_key, build_number, comment):
689+
"""
690+
Create a comment for a specific build
691+
:param project_key:
692+
:param plan_key:
693+
:param build_number:
694+
:param comment:
695+
:return:
696+
"""
625697
resource = "result/{}-{}-{}/comment".format(project_key, plan_key, build_number)
626698
comment_data = {
627-
"author": author if author else self.username,
628699
"content": comment,
629700
}
630701
return self.post(self.resource_url(resource), data=comment_data)
@@ -637,15 +708,40 @@ def labels(
637708
start_index=0,
638709
max_results=25,
639710
):
711+
"""
712+
Get labels for a build
713+
:param project_key:
714+
:param plan_key:
715+
:param build_number:
716+
:param start_index:
717+
:param max_results:
718+
:return:
719+
"""
640720
resource = "result/{}-{}-{}/label".format(project_key, plan_key, build_number)
641721
params = {"start-index": start_index, "max-results": max_results}
642722
return self.get(self.resource_url(resource), params=params)
643723

644724
def create_label(self, project_key, plan_key, build_number, label):
725+
"""
726+
Create a label for a specific build
727+
:param project_key:
728+
:param plan_key:
729+
:param build_number:
730+
:param label:
731+
:return:
732+
"""
645733
resource = "result/{}-{}-{}/label".format(project_key, plan_key, build_number)
646734
return self.post(self.resource_url(resource), data={"name": label})
647735

648736
def delete_label(self, project_key, plan_key, build_number, label):
737+
"""
738+
Delete a label for a specific build
739+
:param project_key:
740+
:param plan_key:
741+
:param build_number:
742+
:param label:
743+
:return:
744+
"""
649745
resource = "result/{}-{}-{}/label/{}".format(project_key, plan_key, build_number, label)
650746
return self.delete(self.resource_url(resource))
651747

@@ -671,34 +767,43 @@ def get_projects(self):
671767
for project in r["projects"]["project"]:
672768
yield project
673769

674-
def get_project(self, project_key):
675-
"""Method used to retrieve information for project specified as project key.
676-
Possible expand parameters: plans, list of plans for project. plans.plan, list of plans with plan details
677-
(only plans visible - READ permission for user)"""
678-
resource = "project/{}?showEmpty".format(project_key)
679-
return self.get(self.resource_url(resource))
680-
681-
def delete_project(self, project_key):
682-
"""Marks project for deletion. Project will be deleted by a batch job."""
683-
resource = "project/{}".format(project_key)
684-
return self.delete(self.resource_url(resource))
685-
686770
""" Deployments """
687771

688772
def deployment_projects(self):
773+
"""
774+
Returns all deployment projects.
775+
:return:
776+
"""
689777
resource = "deploy/project/all"
690778
for project in self.get(self.resource_url(resource)):
691779
yield project
692780

693781
def deployment_project(self, project_id):
782+
"""
783+
Returns a deployment project.
784+
:param project_id:
785+
:return:
786+
"""
694787
resource = "deploy/project/{}".format(project_id)
695788
return self.get(self.resource_url(resource))
696789

697790
def delete_deployment_project(self, project_id):
791+
"""
792+
Deletes a deployment project.
793+
:param project_id:
794+
:return:
795+
"""
698796
resource = "deploy/project/{}".format(project_id)
699797
return self.delete(self.resource_url(resource))
700798

701799
def deployment_environment_results(self, env_id, expand=None, max_results=25):
800+
"""
801+
Get deployment environment results
802+
:param env_id:
803+
:param expand:
804+
:param max_results:
805+
:return:
806+
"""
702807
resource = "deploy/environment/{environmentId}/results".format(environmentId=env_id)
703808
params = {"max-result": max_results, "start-index": 0}
704809
size = 1
@@ -844,23 +949,6 @@ def get_users_not_in_group(self, group_name, filter_users="", start=0, limit=25)
844949
url = "rest/api/latest/admin/groups/{}/more-non-members".format(group_name)
845950
return self.get(url, params=params)
846951

847-
def get_build_queue(self, expand="queuedBuilds"):
848-
"""
849-
Lists all the builds waiting in the build queue, adds or removes a build from the build queue.
850-
May be used also to resume build on manual stage or rerun failed jobs.
851-
:return:
852-
"""
853-
params = {"expand": expand}
854-
return self.get("rest/api/latest/queue", params=params)
855-
856-
def get_deployment_queue(self, expand="queuedDeployments"):
857-
"""
858-
Provide list of deployment results scheduled for execution and waiting in queue.
859-
:return:
860-
"""
861-
params = {"expand": expand}
862-
return self.get("rest/api/latest/queue/deployment", params=params)
863-
864952
def get_deployment_users(self, deployment_id, filter_name=None, start=0, limit=25):
865953
"""
866954
Retrieve a list of users with their explicit permissions to given resource.
@@ -1022,6 +1110,23 @@ def grant_group_to_environment(self, environment_id, group, permissions):
10221110
def server_info(self):
10231111
return self.get(self.resource_url("info"))
10241112

1113+
def get_build_queue(self, expand="queuedBuilds"):
1114+
"""
1115+
Lists all the builds waiting in the build queue, adds or removes a build from the build queue.
1116+
May be used also to resume build on manual stage or rerun failed jobs.
1117+
:return:
1118+
"""
1119+
params = {"expand": expand}
1120+
return self.get("rest/api/latest/queue", params=params)
1121+
1122+
def get_deployment_queue(self, expand="queuedDeployments"):
1123+
"""
1124+
Provide list of deployment results scheduled for execution and waiting in queue.
1125+
:return:
1126+
"""
1127+
params = {"expand": expand}
1128+
return self.get("rest/api/latest/queue/deployment", params=params)
1129+
10251130
def agent_status(self, online=False):
10261131
"""
10271132
Provides a list of all agents.
@@ -1128,6 +1233,20 @@ def chart(
11281233
start_index=9,
11291234
max_results=25,
11301235
):
1236+
"""
1237+
Get chart data
1238+
:param report_key:
1239+
:param build_keys:
1240+
:param group_by_period:
1241+
:param date_filter:
1242+
:param date_from:
1243+
:param date_to:
1244+
:param width:
1245+
:param height:
1246+
:param start_index:
1247+
:param max_results:
1248+
:return:
1249+
"""
11311250
params = {
11321251
"reportKey": report_key,
11331252
"buildKeys": build_keys,
@@ -1173,6 +1292,8 @@ def health_check(self):
11731292
response = self.get("rest/supportHealthCheck/1.0/check/")
11741293
return response
11751294

1295+
"""Elastic Bamboo"""
1296+
11761297
def get_elastic_instance_logs(self, instance_id):
11771298
"""
11781299
Get logs from an EC2 instance
@@ -1201,7 +1322,7 @@ def create_elastic_configuration(self, json):
12011322

12021323
def get_elastic_configuration(self, configuration_id):
12031324
"""
1204-
Get informatin of an elastic configuration
1325+
Get information of an elastic configuration
12051326
:param configuration_id:
12061327
:return:
12071328
"""
@@ -1264,7 +1385,7 @@ def get_plugin_info(self, plugin_key):
12641385

12651386
def get_plugin_license_info(self, plugin_key):
12661387
"""
1267-
Provide plugin license info
1388+
Provide plugin license information
12681389
:return a json specific License query
12691390
"""
12701391
url = "rest/plugins/1.0/{plugin_key}-key/license".format(plugin_key=plugin_key)
@@ -1286,6 +1407,34 @@ def upload_plugin(self, plugin_path):
12861407
url = "rest/plugins/1.0/?token={upm_token}".format(upm_token=upm_token)
12871408
return self.post(url, files=files, headers=self.no_check_headers)
12881409

1410+
def disable_plugin(self, plugin_key):
1411+
"""
1412+
Disable a plugin
1413+
:param plugin_key:
1414+
:return:
1415+
"""
1416+
app_headers = {
1417+
"X-Atlassian-Token": "nocheck",
1418+
"Content-Type": "application/vnd.atl.plugins+json",
1419+
}
1420+
url = "rest/plugins/1.0/{plugin_key}-key".format(plugin_key=plugin_key)
1421+
data = {"status": "disabled"}
1422+
return self.put(url, data=data, headers=app_headers)
1423+
1424+
def enable_plugin(self, plugin_key):
1425+
"""
1426+
Enable a plugin
1427+
:param plugin_key:
1428+
:return:
1429+
"""
1430+
app_headers = {
1431+
"X-Atlassian-Token": "nocheck",
1432+
"Content-Type": "application/vnd.atl.plugins+json",
1433+
}
1434+
url = "rest/plugins/1.0/{plugin_key}-key".format(plugin_key=plugin_key)
1435+
data = {"status": "enabled"}
1436+
return self.put(url, data=data, headers=app_headers)
1437+
12891438
def delete_plugin(self, plugin_key):
12901439
"""
12911440
Delete plugin
@@ -1296,6 +1445,10 @@ def delete_plugin(self, plugin_key):
12961445
return self.delete(url)
12971446

12981447
def check_plugin_manager_status(self):
1448+
"""
1449+
Check plugin manager status
1450+
:return:
1451+
"""
12991452
url = "rest/plugins/latest/safe-mode"
13001453
return self.request(method="GET", path=url, headers=self.safe_mode_headers)
13011454

0 commit comments

Comments
 (0)