Skip to content

Commit 6846a71

Browse files
committed
feat(billing): regenerate for resumeOrgSubscription (keep a subscription scheduled to end)
Claude-Session: https://claude.ai/code/session_01AGZDQg3Xnypqgym8SD8qSa
1 parent 85f0d1d commit 6846a71

2 files changed

Lines changed: 230 additions & 4 deletions

File tree

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
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.error_response import ErrorResponse
10+
from ...models.graph_subscription_response import GraphSubscriptionResponse
11+
from ...models.http_validation_error import HTTPValidationError
12+
from ...types import Response
13+
14+
15+
def _get_kwargs(
16+
org_id: str,
17+
subscription_id: str,
18+
) -> dict[str, Any]:
19+
20+
_kwargs: dict[str, Any] = {
21+
"method": "post",
22+
"url": "/v1/billing/subscriptions/{org_id}/subscription/{subscription_id}/resume".format(
23+
org_id=quote(str(org_id), safe=""),
24+
subscription_id=quote(str(subscription_id), safe=""),
25+
),
26+
}
27+
28+
return _kwargs
29+
30+
31+
def _parse_response(
32+
*, client: AuthenticatedClient | Client, response: httpx.Response
33+
) -> ErrorResponse | GraphSubscriptionResponse | HTTPValidationError | None:
34+
if response.status_code == 200:
35+
response_200 = GraphSubscriptionResponse.from_dict(response.json())
36+
37+
return response_200
38+
39+
if response.status_code == 400:
40+
response_400 = ErrorResponse.from_dict(response.json())
41+
42+
return response_400
43+
44+
if response.status_code == 401:
45+
response_401 = ErrorResponse.from_dict(response.json())
46+
47+
return response_401
48+
49+
if response.status_code == 403:
50+
response_403 = ErrorResponse.from_dict(response.json())
51+
52+
return response_403
53+
54+
if response.status_code == 404:
55+
response_404 = ErrorResponse.from_dict(response.json())
56+
57+
return response_404
58+
59+
if response.status_code == 422:
60+
response_422 = HTTPValidationError.from_dict(response.json())
61+
62+
return response_422
63+
64+
if response.status_code == 429:
65+
response_429 = ErrorResponse.from_dict(response.json())
66+
67+
return response_429
68+
69+
if response.status_code == 500:
70+
response_500 = ErrorResponse.from_dict(response.json())
71+
72+
return response_500
73+
74+
if client.raise_on_unexpected_status:
75+
raise errors.UnexpectedStatus(response.status_code, response.content)
76+
else:
77+
return None
78+
79+
80+
def _build_response(
81+
*, client: AuthenticatedClient | Client, response: httpx.Response
82+
) -> Response[ErrorResponse | GraphSubscriptionResponse | HTTPValidationError]:
83+
return Response(
84+
status_code=HTTPStatus(response.status_code),
85+
content=response.content,
86+
headers=response.headers,
87+
parsed=_parse_response(client=client, response=response),
88+
)
89+
90+
91+
def sync_detailed(
92+
org_id: str,
93+
subscription_id: str,
94+
*,
95+
client: AuthenticatedClient,
96+
) -> Response[ErrorResponse | GraphSubscriptionResponse | HTTPValidationError]:
97+
"""Keep Subscription
98+
99+
Takes back a cancellation scheduled for the end of the billing period, before that period ends: the
100+
subscription renews as before and nothing is torn down. A graph's subscription can be kept by an org
101+
owner; a repository seat by the member who holds it or an org owner or admin. An immediate
102+
cancellation cannot be taken back.
103+
104+
Args:
105+
org_id (str):
106+
subscription_id (str):
107+
108+
Raises:
109+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
110+
httpx.TimeoutException: If the request takes longer than Client.timeout.
111+
112+
Returns:
113+
Response[ErrorResponse | GraphSubscriptionResponse | HTTPValidationError]
114+
"""
115+
116+
kwargs = _get_kwargs(
117+
org_id=org_id,
118+
subscription_id=subscription_id,
119+
)
120+
121+
response = client.get_httpx_client().request(
122+
**kwargs,
123+
)
124+
125+
return _build_response(client=client, response=response)
126+
127+
128+
def sync(
129+
org_id: str,
130+
subscription_id: str,
131+
*,
132+
client: AuthenticatedClient,
133+
) -> ErrorResponse | GraphSubscriptionResponse | HTTPValidationError | None:
134+
"""Keep Subscription
135+
136+
Takes back a cancellation scheduled for the end of the billing period, before that period ends: the
137+
subscription renews as before and nothing is torn down. A graph's subscription can be kept by an org
138+
owner; a repository seat by the member who holds it or an org owner or admin. An immediate
139+
cancellation cannot be taken back.
140+
141+
Args:
142+
org_id (str):
143+
subscription_id (str):
144+
145+
Raises:
146+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
147+
httpx.TimeoutException: If the request takes longer than Client.timeout.
148+
149+
Returns:
150+
ErrorResponse | GraphSubscriptionResponse | HTTPValidationError
151+
"""
152+
153+
return sync_detailed(
154+
org_id=org_id,
155+
subscription_id=subscription_id,
156+
client=client,
157+
).parsed
158+
159+
160+
async def asyncio_detailed(
161+
org_id: str,
162+
subscription_id: str,
163+
*,
164+
client: AuthenticatedClient,
165+
) -> Response[ErrorResponse | GraphSubscriptionResponse | HTTPValidationError]:
166+
"""Keep Subscription
167+
168+
Takes back a cancellation scheduled for the end of the billing period, before that period ends: the
169+
subscription renews as before and nothing is torn down. A graph's subscription can be kept by an org
170+
owner; a repository seat by the member who holds it or an org owner or admin. An immediate
171+
cancellation cannot be taken back.
172+
173+
Args:
174+
org_id (str):
175+
subscription_id (str):
176+
177+
Raises:
178+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
179+
httpx.TimeoutException: If the request takes longer than Client.timeout.
180+
181+
Returns:
182+
Response[ErrorResponse | GraphSubscriptionResponse | HTTPValidationError]
183+
"""
184+
185+
kwargs = _get_kwargs(
186+
org_id=org_id,
187+
subscription_id=subscription_id,
188+
)
189+
190+
response = await client.get_async_httpx_client().request(**kwargs)
191+
192+
return _build_response(client=client, response=response)
193+
194+
195+
async def asyncio(
196+
org_id: str,
197+
subscription_id: str,
198+
*,
199+
client: AuthenticatedClient,
200+
) -> ErrorResponse | GraphSubscriptionResponse | HTTPValidationError | None:
201+
"""Keep Subscription
202+
203+
Takes back a cancellation scheduled for the end of the billing period, before that period ends: the
204+
subscription renews as before and nothing is torn down. A graph's subscription can be kept by an org
205+
owner; a repository seat by the member who holds it or an org owner or admin. An immediate
206+
cancellation cannot be taken back.
207+
208+
Args:
209+
org_id (str):
210+
subscription_id (str):
211+
212+
Raises:
213+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
214+
httpx.TimeoutException: If the request takes longer than Client.timeout.
215+
216+
Returns:
217+
ErrorResponse | GraphSubscriptionResponse | HTTPValidationError
218+
"""
219+
220+
return (
221+
await asyncio_detailed(
222+
org_id=org_id,
223+
subscription_id=subscription_id,
224+
client=client,
225+
)
226+
).parsed

‎robosystems_client/api/subscriptions/change_subscription_plan.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def sync_detailed(
105105
106106
For repositories: synchronous tier change. For user graphs: use `POST
107107
/v1/graphs/{graph_id}/operations/change-tier` instead — this endpoint rejects graph tier changes.
108-
Requires org owner role.
108+
Members change their own seat; org owners and admins can change any member's by passing `user_id`.
109109
110110
Args:
111111
graph_id (str): Graph ID or repository name
@@ -141,7 +141,7 @@ def sync(
141141
142142
For repositories: synchronous tier change. For user graphs: use `POST
143143
/v1/graphs/{graph_id}/operations/change-tier` instead — this endpoint rejects graph tier changes.
144-
Requires org owner role.
144+
Members change their own seat; org owners and admins can change any member's by passing `user_id`.
145145
146146
Args:
147147
graph_id (str): Graph ID or repository name
@@ -172,7 +172,7 @@ async def asyncio_detailed(
172172
173173
For repositories: synchronous tier change. For user graphs: use `POST
174174
/v1/graphs/{graph_id}/operations/change-tier` instead — this endpoint rejects graph tier changes.
175-
Requires org owner role.
175+
Members change their own seat; org owners and admins can change any member's by passing `user_id`.
176176
177177
Args:
178178
graph_id (str): Graph ID or repository name
@@ -206,7 +206,7 @@ async def asyncio(
206206
207207
For repositories: synchronous tier change. For user graphs: use `POST
208208
/v1/graphs/{graph_id}/operations/change-tier` instead — this endpoint rejects graph tier changes.
209-
Requires org owner role.
209+
Members change their own seat; org owners and admins can change any member's by passing `user_id`.
210210
211211
Args:
212212
graph_id (str): Graph ID or repository name

0 commit comments

Comments
 (0)