Skip to content

Commit d332b8a

Browse files
committed
Made the requested changes
1 parent 0a8cc3a commit d332b8a

6 files changed

Lines changed: 149 additions & 105 deletions

File tree

pyatlan/client/aio/oauth_client.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# Copyright 2025 Atlan Pte. Ltd.
2+
# Copyright 2026 Atlan Pte. Ltd.
33

44
from __future__ import annotations
55

@@ -18,9 +18,9 @@
1818
RoleGet,
1919
)
2020
from pyatlan.errors import ErrorCode
21-
from pyatlan.model.oauth_clients import (
22-
OAuthClient,
21+
from pyatlan.model.oauth_client import (
2322
OAuthClientCreateResponse,
23+
OAuthClientListResponse,
2424
OAuthClientResponse,
2525
)
2626

@@ -37,11 +37,11 @@ def __init__(self, client: AsyncApiCaller):
3737
)
3838
self._client = client
3939

40-
async def get_all(self) -> OAuthClientResponse:
40+
async def get_all(self) -> OAuthClientListResponse:
4141
"""
4242
Retrieves all OAuth clients defined in Atlan.
4343
44-
:returns: an OAuthClientResponse containing all OAuth clients
44+
:returns: an OAuthClientListResponse containing all OAuth clients
4545
:raises AtlanError: on any API communication issue
4646
"""
4747
endpoint, query_params = OAuthClientGetAll.prepare_request()
@@ -54,27 +54,27 @@ async def get(
5454
limit: Optional[int] = None,
5555
offset: int = 0,
5656
sort: Optional[str] = None,
57-
) -> OAuthClientResponse:
57+
) -> OAuthClientListResponse:
5858
"""
5959
Retrieves OAuth clients defined in Atlan with pagination support.
6060
6161
:param limit: maximum number of results to be returned
6262
:param offset: starting point for results to return, for paging
6363
:param sort: property by which to sort the results (e.g., 'createdAt' for descending)
64-
:returns: an OAuthClientResponse containing records and pagination info
64+
:returns: an OAuthClientListResponse containing records and pagination info
6565
:raises AtlanError: on any API communication issue
6666
"""
6767
endpoint, query_params = OAuthClientGet.prepare_request(limit, offset, sort)
6868
raw_json = await self._client._call_api(endpoint, query_params)
6969
return OAuthClientGet.process_response(raw_json)
7070

7171
@validate_arguments
72-
async def get_by_id(self, client_id: str) -> OAuthClient:
72+
async def get_by_id(self, client_id: str) -> OAuthClientResponse:
7373
"""
7474
Retrieves the OAuth client with the specified client ID.
7575
7676
:param client_id: unique client identifier (e.g., 'oauth-client-xxx')
77-
:returns: the OAuthClient with the specified client ID
77+
:returns: the OAuthClientResponse with the specified client ID
7878
:raises AtlanError: on any API communication issue
7979
"""
8080
endpoint, query_params = OAuthClientGetById.prepare_request(client_id)
@@ -87,14 +87,14 @@ async def update(
8787
client_id: str,
8888
display_name: Optional[str] = None,
8989
description: Optional[str] = None,
90-
) -> OAuthClient:
90+
) -> OAuthClientResponse:
9191
"""
9292
Update an existing OAuth client with the provided settings.
9393
9494
:param client_id: unique client identifier (e.g., 'oauth-client-xxx')
9595
:param display_name: human-readable name for the OAuth client
9696
:param description: optional explanation of the OAuth client
97-
:returns: the updated OAuthClient
97+
:returns: the updated OAuthClientResponse
9898
:raises AtlanError: on any API communication issue
9999
"""
100100
endpoint, request_obj = OAuthClientUpdate.prepare_request(
@@ -135,17 +135,15 @@ async def create(
135135
name: str,
136136
role: str,
137137
description: Optional[str] = None,
138-
persona_qns: Optional[List[str]] = None,
138+
persona_qualified_names: Optional[List[str]] = None,
139139
) -> OAuthClientCreateResponse:
140140
"""
141141
Create a new OAuth client with the provided settings.
142142
143143
:param name: human-readable name for the OAuth client (displayed in UI)
144-
:param role: role description to assign to the OAuth client (e.g., 'Admin', 'Member',
145-
'Guest', 'Admins (Connections)'). This is matched against available role
146-
descriptions and the corresponding role name is used in the API payload.
144+
:param role: role description to assign to the OAuth client (e.g., 'Admin', 'Member').
147145
:param description: optional explanation of the OAuth client
148-
:param persona_qns: qualified names of personas to associate with the OAuth client
146+
:param persona_qualified_names: qualified names of personas to associate with the OAuth client
149147
:returns: the created OAuthClientCreateResponse (includes client_id and client_secret)
150148
:raises AtlanError: on any API communication issue
151149
:raises NotFoundError: if the specified role description is not found
@@ -159,7 +157,7 @@ async def create(
159157
display_name=name,
160158
role=resolved_role,
161159
description=description,
162-
persona_qns=persona_qns,
160+
persona_qualified_names=persona_qualified_names,
163161
)
164162
raw_json = await self._client._call_api(endpoint, request_obj=request_obj)
165163
return OAuthClientCreate.process_response(raw_json)

pyatlan/client/common/oauth_client.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
# Copyright 2025 Atlan Pte. Ltd.
2+
# Copyright 2026 Atlan Pte. Ltd.
33

44
from __future__ import annotations
55

6+
import json
67
from typing import Dict, List, Optional
78

89
from pyatlan.client.constants import (
@@ -13,9 +14,9 @@
1314
UPDATE_OAUTH_CLIENT,
1415
)
1516
from pyatlan.errors import ErrorCode
16-
from pyatlan.model.oauth_clients import (
17-
OAuthClient,
17+
from pyatlan.model.oauth_client import (
1818
OAuthClientCreateResponse,
19+
OAuthClientListResponse,
1920
OAuthClientRequest,
2021
OAuthClientResponse,
2122
)
@@ -35,14 +36,14 @@ def prepare_request() -> tuple:
3536
return GET_OAUTH_CLIENTS.format_path_with_params(), None
3637

3738
@staticmethod
38-
def process_response(raw_json: Dict) -> OAuthClientResponse:
39+
def process_response(raw_json: Dict) -> OAuthClientListResponse:
3940
"""
40-
Process the API response into an OAuthClientResponse object.
41+
Process the API response into an OAuthClientListResponse object.
4142
4243
:param raw_json: raw response from the API
43-
:returns: OAuthClientResponse with pagination info and records
44+
:returns: OAuthClientListResponse with pagination info and records
4445
"""
45-
return OAuthClientResponse(**raw_json)
46+
return OAuthClientListResponse(**raw_json)
4647

4748

4849
class OAuthClientGet:
@@ -74,14 +75,14 @@ def prepare_request(
7475
return GET_OAUTH_CLIENTS.format_path_with_params(), query_params
7576

7677
@staticmethod
77-
def process_response(raw_json: Dict) -> OAuthClientResponse:
78+
def process_response(raw_json: Dict) -> OAuthClientListResponse:
7879
"""
79-
Process the API response into an OAuthClientResponse object.
80+
Process the API response into an OAuthClientListResponse object.
8081
8182
:param raw_json: raw response from the API
82-
:returns: OAuthClientResponse with pagination info and records
83+
:returns: OAuthClientListResponse with pagination info and records
8384
"""
84-
return OAuthClientResponse(**raw_json)
85+
return OAuthClientListResponse(**raw_json)
8586

8687

8788
class OAuthClientGetById:
@@ -101,14 +102,14 @@ def prepare_request(client_id: str) -> tuple:
101102
return endpoint, None
102103

103104
@staticmethod
104-
def process_response(raw_json: Dict) -> OAuthClient:
105+
def process_response(raw_json: Dict) -> OAuthClientResponse:
105106
"""
106-
Process the API response into an OAuthClient object.
107+
Process the API response into an OAuthClientResponse object.
107108
108109
:param raw_json: raw response from the API
109-
:returns: OAuthClient object
110+
:returns: OAuthClientResponse object
110111
"""
111-
return OAuthClient(**raw_json)
112+
return OAuthClientResponse(**raw_json)
112113

113114

114115
class OAuthClientUpdate:
@@ -141,14 +142,14 @@ def prepare_request(
141142
return endpoint, request_dict
142143

143144
@staticmethod
144-
def process_response(raw_json: Dict) -> OAuthClient:
145+
def process_response(raw_json: Dict) -> OAuthClientResponse:
145146
"""
146-
Process the API response into an OAuthClient.
147+
Process the API response into an OAuthClientResponse.
147148
148149
:param raw_json: raw response from the API
149-
:returns: the updated OAuthClient
150+
:returns: the updated OAuthClientResponse
150151
"""
151-
return OAuthClient(**raw_json)
152+
return OAuthClientResponse(**raw_json)
152153

153154

154155
class OAuthClientPurge:
@@ -212,7 +213,6 @@ def build_roles_filter() -> str:
212213
213214
:returns: JSON filter string
214215
"""
215-
import json
216216

217217
return json.dumps({"$or": [{"level": "workspace"}, {"level": "admin-subrole"}]})
218218

@@ -221,7 +221,7 @@ def prepare_request(
221221
display_name: str,
222222
role: str,
223223
description: Optional[str] = None,
224-
persona_qns: Optional[List[str]] = None,
224+
persona_qualified_names: Optional[List[str]] = None,
225225
) -> tuple:
226226
"""
227227
Prepare the request for creating an OAuth client.
@@ -232,15 +232,15 @@ def prepare_request(
232232
:param display_name: human-readable name for the OAuth client
233233
:param role: role assigned to the OAuth client (must be the actual API value like '$admin')
234234
:param description: optional explanation of the OAuth client
235-
:param persona_qns: qualified names of personas to associate with the OAuth client
235+
:param persona_qualified_names: qualified names of personas to associate with the OAuth client
236236
:returns: tuple of (endpoint, request_dict)
237237
"""
238238
request = OAuthClientRequest(
239239
display_name=display_name,
240240
description=description,
241241
role=role,
242-
persona_qns=persona_qns,
243-
)
242+
persona_qualified_names=persona_qualified_names,
243+
) # type: ignore[call-arg]
244244
return CREATE_OAUTH_CLIENT.format_path_with_params(), request
245245

246246
@staticmethod

pyatlan/client/oauth_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
RoleGet,
1818
)
1919
from pyatlan.errors import ErrorCode
20-
from pyatlan.model.oauth_clients import (
21-
OAuthClient,
20+
from pyatlan.model.oauth_client import (
2221
OAuthClientCreateResponse,
22+
OAuthClientListResponse,
2323
OAuthClientResponse,
2424
)
2525

@@ -38,11 +38,11 @@ def __init__(self, client: ApiCaller):
3838
)
3939
self._client = client
4040

41-
def get_all(self) -> OAuthClientResponse:
41+
def get_all(self) -> OAuthClientListResponse:
4242
"""
4343
Retrieves all OAuth clients defined in Atlan.
4444
45-
:returns: an OAuthClientResponse containing all OAuth clients
45+
:returns: an OAuthClientListResponse containing all OAuth clients
4646
:raises AtlanError: on any API communication issue
4747
"""
4848
endpoint, query_params = OAuthClientGetAll.prepare_request()
@@ -55,27 +55,27 @@ def get(
5555
limit: Optional[int] = None,
5656
offset: int = 0,
5757
sort: Optional[str] = None,
58-
) -> OAuthClientResponse:
58+
) -> OAuthClientListResponse:
5959
"""
6060
Retrieves OAuth clients defined in Atlan with pagination support.
6161
6262
:param limit: maximum number of results to be returned
6363
:param offset: starting point for results to return, for paging
6464
:param sort: property by which to sort the results (e.g., 'createdAt' for descending)
65-
:returns: an OAuthClientResponse containing records and pagination info
65+
:returns: an OAuthClientListResponse containing records and pagination info
6666
:raises AtlanError: on any API communication issue
6767
"""
6868
endpoint, query_params = OAuthClientGet.prepare_request(limit, offset, sort)
6969
raw_json = self._client._call_api(endpoint, query_params)
7070
return OAuthClientGet.process_response(raw_json)
7171

7272
@validate_arguments
73-
def get_by_id(self, client_id: str) -> OAuthClient:
73+
def get_by_id(self, client_id: str) -> OAuthClientResponse:
7474
"""
7575
Retrieves the OAuth client with the specified client ID.
7676
7777
:param client_id: unique client identifier (e.g., 'oauth-client-xxx')
78-
:returns: the OAuthClient with the specified client ID
78+
:returns: the OAuthClientResponse with the specified client ID
7979
:raises AtlanError: on any API communication issue
8080
"""
8181
endpoint, query_params = OAuthClientGetById.prepare_request(client_id)
@@ -88,14 +88,14 @@ def update(
8888
client_id: str,
8989
display_name: Optional[str] = None,
9090
description: Optional[str] = None,
91-
) -> OAuthClient:
91+
) -> OAuthClientResponse:
9292
"""
9393
Update an existing OAuth client with the provided settings.
9494
9595
:param client_id: unique client identifier (e.g., 'oauth-client-xxx')
9696
:param display_name: human-readable name for the OAuth client
9797
:param description: optional explanation of the OAuth client
98-
:returns: the updated OAuthClient
98+
:returns: the updated OAuthClientResponse
9999
:raises AtlanError: on any API communication issue
100100
"""
101101
endpoint, request_obj = OAuthClientUpdate.prepare_request(
@@ -136,15 +136,15 @@ def create(
136136
name: str,
137137
role: str,
138138
description: Optional[str] = None,
139-
persona_qns: Optional[List[str]] = None,
139+
persona_qualified_names: Optional[List[str]] = None,
140140
) -> OAuthClientCreateResponse:
141141
"""
142142
Create a new OAuth client with the provided settings.
143143
144144
:param name: human-readable name for the OAuth client (displayed in UI)
145145
:param role: role description to assign to the OAuth client (e.g., 'Admin', 'Member').
146146
:param description: optional explanation of the OAuth client
147-
:param persona_qns: qualified names of personas to associate with the OAuth client
147+
:param persona_qualified_names: qualified names of personas to associate with the OAuth client
148148
:returns: the created OAuthClientCreateResponse (includes client_id and client_secret)
149149
:raises AtlanError: on any API communication issue
150150
:raises NotFoundError: if the specified role description is not found
@@ -158,7 +158,7 @@ def create(
158158
display_name=name,
159159
role=resolved_role,
160160
description=description,
161-
persona_qns=persona_qns,
161+
persona_qualified_names=persona_qualified_names,
162162
)
163163
raw_json = self._client._call_api(endpoint, request_obj=request_obj)
164164
return OAuthClientCreate.process_response(raw_json)

0 commit comments

Comments
 (0)