Commit cf49d2a
authored
[MPT-18559] Adopt api client to audit and remove legacy mpt client (#168)
This pull request removes the legacy `MPTClient` implementation and its
usage throughout the codebase, fully migrating to the new
`mpt_api_client` package for Marketplace API interactions. All relevant
application logic, dependency injection, and tests have been updated to
use the new client, and the audit plugin API has been refactored to
leverage the new query interface, resulting in cleaner and more
maintainable code.
Migration to new Marketplace API client:
* Completely removed the legacy `cli.core.mpt.client.py` file and its
`MPTClient` and `client_from_account` implementations. All references to
these have been replaced with the new `mpt_api_client` package and its
`MPTClient` class.
[[1]](diffhunk://#diff-c1556732cf26919aa027ba9ed3ba39c2b8b3ba410235d15aed36470c9692b281L1-L85)
[[2]](diffhunk://#diff-31fd81db50cff29b241df3338586dd2dd49ff3f932daf686ec2101da4b913c19L2)
[[3]](diffhunk://#diff-31fd81db50cff29b241df3338586dd2dd49ff3f932daf686ec2101da4b913c19L19)
[[4]](diffhunk://#diff-8b37c37e1e6e8f71c9be14b72d40e0dfac87932b49653cebde9f1e1389b1b66bL5)
[[5]](diffhunk://#diff-1a492288536e42ccf8b3e90c7aa18c7968c654a4d31110067a13cef6fb1759ffL1-L80)
* Updated dependency injection in `AccountContainer` to provide only the
new API client via `create_api_mpt_client_from_account`, removing the
legacy client provider.
* Refactored all application code (`audit_plugin/app.py`) and tests to
use the new client creation function and updated mocks accordingly.
[[1]](diffhunk://#diff-0a11b924632def89cff0ee0e05f39cdcf601c928bb012ff09fc8b9e403b114bfL6-R6)
[[2]](diffhunk://#diff-0a11b924632def89cff0ee0e05f39cdcf601c928bb012ff09fc8b9e403b114bfL95-R95)
[[3]](diffhunk://#diff-0a11b924632def89cff0ee0e05f39cdcf601c928bb012ff09fc8b9e403b114bfL142-R142)
[[4]](diffhunk://#diff-8b37c37e1e6e8f71c9be14b72d40e0dfac87932b49653cebde9f1e1389b1b66bL16-L20)
[[5]](diffhunk://#diff-8b37c37e1e6e8f71c9be14b72d40e0dfac87932b49653cebde9f1e1389b1b66bL99)
[[6]](diffhunk://#diff-66fbbcba009b62a06d587e17f8f0470f686d5170cf10002d0c2e2aaea32eb708L24-L30)
[[7]](diffhunk://#diff-66fbbcba009b62a06d587e17f8f0470f686d5170cf10002d0c2e2aaea32eb708L50-L56)
[[8]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L38-R43)
[[9]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L52-R63)
[[10]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L79-R82)
Audit plugin API improvements:
* Refactored `get_audit_trail` and `get_audit_records_by_object` to use
the new query interface (`options`, `filter`, `select`, `fetch_page`)
instead of manually constructing query strings and endpoints, resulting
in more robust and readable code.
* Updated exception handling and error messages to be clearer and more
consistent in the audit plugin API.
Test suite updates:
* Removed all tests for the legacy client and replaced or updated tests
to mock the new client and its query interface, including changes to
fixtures and patching.
[[1]](diffhunk://#diff-1a492288536e42ccf8b3e90c7aa18c7968c654a4d31110067a13cef6fb1759ffL1-L80)
[[2]](diffhunk://#diff-51860b275c432c506213dfa8fee143965dfc1aeecfe4d38439e06f234b7d6e33L2-R96)
[[3]](diffhunk://#diff-8b37c37e1e6e8f71c9be14b72d40e0dfac87932b49653cebde9f1e1389b1b66bL16-L20)
[[4]](diffhunk://#diff-8b37c37e1e6e8f71c9be14b72d40e0dfac87932b49653cebde9f1e1389b1b66bL99)
[[5]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L38-R43)
[[6]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L52-R63)
[[7]](diffhunk://#diff-1b352cf74ff12715226e02ca5c895db1b150661ba1373af300c5cd756182c555L79-R82)
[[1]](diffhunk://#diff-c1556732cf26919aa027ba9ed3ba39c2b8b3ba410235d15aed36470c9692b281L1-L85)
[[2]](diffhunk://#diff-31fd81db50cff29b241df3338586dd2dd49ff3f932daf686ec2101da4b913c19L2)
[[3]](diffhunk://#diff-31fd81db50cff29b241df3338586dd2dd49ff3f932daf686ec2101da4b913c19L19)
[[4]](diffhunk://#diff-440d64ab776a9667c05fb518f6d3ab5b653172b8515f390e4fe4bbb9a125dfa7R5-R50)
[[5]](diffhunk://#diff-1a492288536e42ccf8b3e90c7aa18c7968c654a4d31110067a13cef6fb1759ffL1-L80)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
Closes [MPT-18559](https://softwareone.atlassian.net/browse/MPT-18559)
- Remove legacy MPTClient implementation and factory
(cli/core/mpt/client.py) and delete associated unit tests.
- Replace legacy client usage with mpt_api_client.MPTClient and its
fluent query/RQL API (options(), filter(), select(), fetch_page(),
RQLQuery).
- Update dependency injection: remove legacy mpt_client provider from
AccountContainer and use create_api_mpt_client_from_account
(cli/core/mpt/mpt_client) to provide the new client.
- Refactor audit plugin API (cli/plugins/audit_plugin/api.py) to use the
new client/query interface, select explicit fields, and standardize
error handling (Exit on missing records or API errors).
- Update audit plugin app code (cli/plugins/audit_plugin/app.py) to
instantiate the new client via create_api_mpt_client_from_account.
- Adjust tests and fixtures: remove legacy client fixtures and tests,
mock the new MPTClient fluent API and RQLQuery, migrate patching/imports
from cli.core.mpt.client to cli.core.mpt.mpt_client and mpt_api_client,
and update test flows accordingly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
[MPT-18559]:
https://softwareone.atlassian.net/browse/MPT-18559?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQFile tree
9 files changed
+225
-429
lines changed- cli
- core
- accounts
- mpt
- plugins/audit_plugin
- tests/cli
- core
- mpt
- plugins/audit_plugin
9 files changed
+225
-429
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | 18 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 10 | | |
13 | | - | |
14 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 33 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
| |||
96 | 90 | | |
97 | 91 | | |
98 | 92 | | |
99 | | - | |
100 | 93 | | |
101 | 94 | | |
102 | 95 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 26 | | |
32 | 27 | | |
33 | 28 | | |
| |||
47 | 42 | | |
48 | 43 | | |
49 | 44 | | |
50 | | - | |
| 45 | + | |
51 | 46 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 47 | | |
58 | 48 | | |
59 | 49 | | |
| |||
0 commit comments