Skip to content

Commit 5e328b6

Browse files
committed
Refactor report sharing functionality and enhance data models
- Updated the `share` method in `ReportClient` to accept a `publish_list_id` instead of a list of target graph IDs, aligning with the new sharing logic. - Modified the `ShareReportRequest` model to reflect the change from `target_graph_ids` to `publish_list_id`. - Added new fields `source_graph_id` and `entity_name` to `LedgerEntityResponse`, `ReportResponse`, and `SecurityResponse` models for improved data handling. - Updated `__init__.py` files to include new models and ensure proper exports. These changes enhance the report sharing capabilities and improve the overall data model structure for better integration and usability.
1 parent 7818df6 commit 5e328b6

22 files changed

Lines changed: 2362 additions & 10 deletions
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.add_members_request import AddMembersRequest
10+
from ...models.http_validation_error import HTTPValidationError
11+
from ...models.publish_list_member_response import PublishListMemberResponse
12+
from ...types import Response
13+
14+
15+
def _get_kwargs(
16+
graph_id: str,
17+
list_id: str,
18+
*,
19+
body: AddMembersRequest,
20+
) -> dict[str, Any]:
21+
headers: dict[str, Any] = {}
22+
23+
_kwargs: dict[str, Any] = {
24+
"method": "post",
25+
"url": "/v1/ledger/{graph_id}/publish-lists/{list_id}/members".format(
26+
graph_id=quote(str(graph_id), safe=""),
27+
list_id=quote(str(list_id), safe=""),
28+
),
29+
}
30+
31+
_kwargs["json"] = body.to_dict()
32+
33+
headers["Content-Type"] = "application/json"
34+
35+
_kwargs["headers"] = headers
36+
return _kwargs
37+
38+
39+
def _parse_response(
40+
*, client: AuthenticatedClient | Client, response: httpx.Response
41+
) -> HTTPValidationError | list[PublishListMemberResponse] | None:
42+
if response.status_code == 201:
43+
response_201 = []
44+
_response_201 = response.json()
45+
for response_201_item_data in _response_201:
46+
response_201_item = PublishListMemberResponse.from_dict(response_201_item_data)
47+
48+
response_201.append(response_201_item)
49+
50+
return response_201
51+
52+
if response.status_code == 422:
53+
response_422 = HTTPValidationError.from_dict(response.json())
54+
55+
return response_422
56+
57+
if client.raise_on_unexpected_status:
58+
raise errors.UnexpectedStatus(response.status_code, response.content)
59+
else:
60+
return None
61+
62+
63+
def _build_response(
64+
*, client: AuthenticatedClient | Client, response: httpx.Response
65+
) -> Response[HTTPValidationError | list[PublishListMemberResponse]]:
66+
return Response(
67+
status_code=HTTPStatus(response.status_code),
68+
content=response.content,
69+
headers=response.headers,
70+
parsed=_parse_response(client=client, response=response),
71+
)
72+
73+
74+
def sync_detailed(
75+
graph_id: str,
76+
list_id: str,
77+
*,
78+
client: AuthenticatedClient,
79+
body: AddMembersRequest,
80+
) -> Response[HTTPValidationError | list[PublishListMemberResponse]]:
81+
"""Add Members to Publish List
82+
83+
Args:
84+
graph_id (str):
85+
list_id (str):
86+
body (AddMembersRequest):
87+
88+
Raises:
89+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
90+
httpx.TimeoutException: If the request takes longer than Client.timeout.
91+
92+
Returns:
93+
Response[HTTPValidationError | list[PublishListMemberResponse]]
94+
"""
95+
96+
kwargs = _get_kwargs(
97+
graph_id=graph_id,
98+
list_id=list_id,
99+
body=body,
100+
)
101+
102+
response = client.get_httpx_client().request(
103+
**kwargs,
104+
)
105+
106+
return _build_response(client=client, response=response)
107+
108+
109+
def sync(
110+
graph_id: str,
111+
list_id: str,
112+
*,
113+
client: AuthenticatedClient,
114+
body: AddMembersRequest,
115+
) -> HTTPValidationError | list[PublishListMemberResponse] | None:
116+
"""Add Members to Publish List
117+
118+
Args:
119+
graph_id (str):
120+
list_id (str):
121+
body (AddMembersRequest):
122+
123+
Raises:
124+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
125+
httpx.TimeoutException: If the request takes longer than Client.timeout.
126+
127+
Returns:
128+
HTTPValidationError | list[PublishListMemberResponse]
129+
"""
130+
131+
return sync_detailed(
132+
graph_id=graph_id,
133+
list_id=list_id,
134+
client=client,
135+
body=body,
136+
).parsed
137+
138+
139+
async def asyncio_detailed(
140+
graph_id: str,
141+
list_id: str,
142+
*,
143+
client: AuthenticatedClient,
144+
body: AddMembersRequest,
145+
) -> Response[HTTPValidationError | list[PublishListMemberResponse]]:
146+
"""Add Members to Publish List
147+
148+
Args:
149+
graph_id (str):
150+
list_id (str):
151+
body (AddMembersRequest):
152+
153+
Raises:
154+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155+
httpx.TimeoutException: If the request takes longer than Client.timeout.
156+
157+
Returns:
158+
Response[HTTPValidationError | list[PublishListMemberResponse]]
159+
"""
160+
161+
kwargs = _get_kwargs(
162+
graph_id=graph_id,
163+
list_id=list_id,
164+
body=body,
165+
)
166+
167+
response = await client.get_async_httpx_client().request(**kwargs)
168+
169+
return _build_response(client=client, response=response)
170+
171+
172+
async def asyncio(
173+
graph_id: str,
174+
list_id: str,
175+
*,
176+
client: AuthenticatedClient,
177+
body: AddMembersRequest,
178+
) -> HTTPValidationError | list[PublishListMemberResponse] | None:
179+
"""Add Members to Publish List
180+
181+
Args:
182+
graph_id (str):
183+
list_id (str):
184+
body (AddMembersRequest):
185+
186+
Raises:
187+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
188+
httpx.TimeoutException: If the request takes longer than Client.timeout.
189+
190+
Returns:
191+
HTTPValidationError | list[PublishListMemberResponse]
192+
"""
193+
194+
return (
195+
await asyncio_detailed(
196+
graph_id=graph_id,
197+
list_id=list_id,
198+
client=client,
199+
body=body,
200+
)
201+
).parsed
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.create_publish_list_request import CreatePublishListRequest
10+
from ...models.http_validation_error import HTTPValidationError
11+
from ...models.publish_list_response import PublishListResponse
12+
from ...types import Response
13+
14+
15+
def _get_kwargs(
16+
graph_id: str,
17+
*,
18+
body: CreatePublishListRequest,
19+
) -> dict[str, Any]:
20+
headers: dict[str, Any] = {}
21+
22+
_kwargs: dict[str, Any] = {
23+
"method": "post",
24+
"url": "/v1/ledger/{graph_id}/publish-lists".format(
25+
graph_id=quote(str(graph_id), safe=""),
26+
),
27+
}
28+
29+
_kwargs["json"] = body.to_dict()
30+
31+
headers["Content-Type"] = "application/json"
32+
33+
_kwargs["headers"] = headers
34+
return _kwargs
35+
36+
37+
def _parse_response(
38+
*, client: AuthenticatedClient | Client, response: httpx.Response
39+
) -> HTTPValidationError | PublishListResponse | None:
40+
if response.status_code == 201:
41+
response_201 = PublishListResponse.from_dict(response.json())
42+
43+
return response_201
44+
45+
if response.status_code == 422:
46+
response_422 = HTTPValidationError.from_dict(response.json())
47+
48+
return response_422
49+
50+
if client.raise_on_unexpected_status:
51+
raise errors.UnexpectedStatus(response.status_code, response.content)
52+
else:
53+
return None
54+
55+
56+
def _build_response(
57+
*, client: AuthenticatedClient | Client, response: httpx.Response
58+
) -> Response[HTTPValidationError | PublishListResponse]:
59+
return Response(
60+
status_code=HTTPStatus(response.status_code),
61+
content=response.content,
62+
headers=response.headers,
63+
parsed=_parse_response(client=client, response=response),
64+
)
65+
66+
67+
def sync_detailed(
68+
graph_id: str,
69+
*,
70+
client: AuthenticatedClient,
71+
body: CreatePublishListRequest,
72+
) -> Response[HTTPValidationError | PublishListResponse]:
73+
"""Create Publish List
74+
75+
Args:
76+
graph_id (str):
77+
body (CreatePublishListRequest):
78+
79+
Raises:
80+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81+
httpx.TimeoutException: If the request takes longer than Client.timeout.
82+
83+
Returns:
84+
Response[HTTPValidationError | PublishListResponse]
85+
"""
86+
87+
kwargs = _get_kwargs(
88+
graph_id=graph_id,
89+
body=body,
90+
)
91+
92+
response = client.get_httpx_client().request(
93+
**kwargs,
94+
)
95+
96+
return _build_response(client=client, response=response)
97+
98+
99+
def sync(
100+
graph_id: str,
101+
*,
102+
client: AuthenticatedClient,
103+
body: CreatePublishListRequest,
104+
) -> HTTPValidationError | PublishListResponse | None:
105+
"""Create Publish List
106+
107+
Args:
108+
graph_id (str):
109+
body (CreatePublishListRequest):
110+
111+
Raises:
112+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113+
httpx.TimeoutException: If the request takes longer than Client.timeout.
114+
115+
Returns:
116+
HTTPValidationError | PublishListResponse
117+
"""
118+
119+
return sync_detailed(
120+
graph_id=graph_id,
121+
client=client,
122+
body=body,
123+
).parsed
124+
125+
126+
async def asyncio_detailed(
127+
graph_id: str,
128+
*,
129+
client: AuthenticatedClient,
130+
body: CreatePublishListRequest,
131+
) -> Response[HTTPValidationError | PublishListResponse]:
132+
"""Create Publish List
133+
134+
Args:
135+
graph_id (str):
136+
body (CreatePublishListRequest):
137+
138+
Raises:
139+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
140+
httpx.TimeoutException: If the request takes longer than Client.timeout.
141+
142+
Returns:
143+
Response[HTTPValidationError | PublishListResponse]
144+
"""
145+
146+
kwargs = _get_kwargs(
147+
graph_id=graph_id,
148+
body=body,
149+
)
150+
151+
response = await client.get_async_httpx_client().request(**kwargs)
152+
153+
return _build_response(client=client, response=response)
154+
155+
156+
async def asyncio(
157+
graph_id: str,
158+
*,
159+
client: AuthenticatedClient,
160+
body: CreatePublishListRequest,
161+
) -> HTTPValidationError | PublishListResponse | None:
162+
"""Create Publish List
163+
164+
Args:
165+
graph_id (str):
166+
body (CreatePublishListRequest):
167+
168+
Raises:
169+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
170+
httpx.TimeoutException: If the request takes longer than Client.timeout.
171+
172+
Returns:
173+
HTTPValidationError | PublishListResponse
174+
"""
175+
176+
return (
177+
await asyncio_detailed(
178+
graph_id=graph_id,
179+
client=client,
180+
body=body,
181+
)
182+
).parsed

0 commit comments

Comments
 (0)