Update api spec (#446)
* YOYO NEW API SPEC! * I have generated the latest API! --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
af55db8f70
commit
e3297b9b8f
File diff suppressed because it is too large
Load Diff
131
kittycad/api/users/update_subscription_for_user.py
Normal file
131
kittycad/api/users/update_subscription_for_user.py
Normal file
@ -0,0 +1,131 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.user_identifier import UserIdentifier
|
||||
from ...models.zoo_product_subscriptions import ZooProductSubscriptions
|
||||
from ...models.zoo_product_subscriptions_user_request import (
|
||||
ZooProductSubscriptionsUserRequest,
|
||||
)
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: UserIdentifier,
|
||||
body: ZooProductSubscriptionsUserRequest,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/users/{id}/payment/subscriptions".format(
|
||||
client.base_url,
|
||||
id=id,
|
||||
) # noqa: E501
|
||||
|
||||
headers: Dict[str, Any] = client.get_headers()
|
||||
cookies: Dict[str, Any] = client.get_cookies()
|
||||
|
||||
return {
|
||||
"url": url,
|
||||
"headers": headers,
|
||||
"cookies": cookies,
|
||||
"timeout": client.get_timeout(),
|
||||
"content": body.model_dump_json(),
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ZooProductSubscriptions, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ZooProductSubscriptions(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[ZooProductSubscriptions, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: UserIdentifier,
|
||||
body: ZooProductSubscriptionsUserRequest,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ZooProductSubscriptions, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.put(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: UserIdentifier,
|
||||
body: ZooProductSubscriptionsUserRequest,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ZooProductSubscriptions, Error]]:
|
||||
"""You must be a Zoo admin to perform this request.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
body=body,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: UserIdentifier,
|
||||
body: ZooProductSubscriptionsUserRequest,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ZooProductSubscriptions, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.put(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: UserIdentifier,
|
||||
body: ZooProductSubscriptionsUserRequest,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ZooProductSubscriptions, Error]]:
|
||||
"""You must be a Zoo admin to perform this request.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -161,6 +161,7 @@ from kittycad.api.users import (
|
||||
put_public_form,
|
||||
put_public_subscribe,
|
||||
put_user_form_self,
|
||||
update_subscription_for_user,
|
||||
update_user_privacy_settings,
|
||||
update_user_self,
|
||||
update_user_shortlink,
|
||||
@ -7590,6 +7591,69 @@ async def test_update_payment_balance_for_any_user_async():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_update_subscription_for_user():
|
||||
# Create our client.
|
||||
client = ClientFromEnv()
|
||||
|
||||
result: Optional[Union[ZooProductSubscriptions, Error]] = (
|
||||
update_subscription_for_user.sync(
|
||||
client=client,
|
||||
id=UserIdentifier("<string>"),
|
||||
body=ZooProductSubscriptionsUserRequest(
|
||||
modeling_app=ModelingAppIndividualSubscriptionTier.FREE,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(result, Error) or result is None:
|
||||
print(result)
|
||||
raise Exception("Error in response")
|
||||
|
||||
body: ZooProductSubscriptions = result
|
||||
print(body)
|
||||
|
||||
# OR if you need more info (e.g. status_code)
|
||||
response: Response[Optional[Union[ZooProductSubscriptions, Error]]] = (
|
||||
update_subscription_for_user.sync_detailed(
|
||||
client=client,
|
||||
id=UserIdentifier("<string>"),
|
||||
body=ZooProductSubscriptionsUserRequest(
|
||||
modeling_app=ModelingAppIndividualSubscriptionTier.FREE,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# OR run async
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skip
|
||||
async def test_update_subscription_for_user_async():
|
||||
# Create our client.
|
||||
client = ClientFromEnv()
|
||||
|
||||
result: Optional[
|
||||
Union[ZooProductSubscriptions, Error]
|
||||
] = await update_subscription_for_user.asyncio(
|
||||
client=client,
|
||||
id=UserIdentifier("<string>"),
|
||||
body=ZooProductSubscriptionsUserRequest(
|
||||
modeling_app=ModelingAppIndividualSubscriptionTier.FREE,
|
||||
),
|
||||
)
|
||||
|
||||
# OR run async with more info
|
||||
response: Response[
|
||||
Optional[Union[ZooProductSubscriptions, Error]]
|
||||
] = await update_subscription_for_user.asyncio_detailed(
|
||||
client=client,
|
||||
id=UserIdentifier("<string>"),
|
||||
body=ZooProductSubscriptionsUserRequest(
|
||||
modeling_app=ModelingAppIndividualSubscriptionTier.FREE,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_put_public_form():
|
||||
# Create our client.
|
||||
|
180
spec.json
180
spec.json
@ -16679,6 +16679,186 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/payment/subscriptions": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"users",
|
||||
"hidden"
|
||||
],
|
||||
"summary": "Update a subscription for a user.",
|
||||
"description": "You must be a Zoo admin to perform this request.",
|
||||
"operationId": "update_subscription_for_user",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "The user's identifier (uuid or email).",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserIdentifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ZooProductSubscriptionsUserRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"headers": {
|
||||
"Access-Control-Allow-Credentials": {
|
||||
"description": "Access-Control-Allow-Credentials header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Headers": {
|
||||
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Methods": {
|
||||
"description": "Access-Control-Allow-Methods header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Origin": {
|
||||
"description": "Access-Control-Allow-Origin header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Set-Cookie": {
|
||||
"description": "Set-Cookie header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"X-Api-Call-Id": {
|
||||
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
|
||||
"style": "simple",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ZooProductSubscriptions"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"4XX": {
|
||||
"$ref": "#/components/responses/Error"
|
||||
},
|
||||
"5XX": {
|
||||
"$ref": "#/components/responses/Error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"tags": [
|
||||
"hidden"
|
||||
],
|
||||
"summary": "OPTIONS endpoint.",
|
||||
"description": "This is necessary for some preflight requests, specifically POST, PUT, and DELETE.",
|
||||
"operationId": "options_update_subscription_for_user",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "The user's identifier (uuid or email).",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UserIdentifier"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "successful operation, no content",
|
||||
"headers": {
|
||||
"Access-Control-Allow-Credentials": {
|
||||
"description": "Access-Control-Allow-Credentials header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Headers": {
|
||||
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Methods": {
|
||||
"description": "Access-Control-Allow-Methods header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Access-Control-Allow-Origin": {
|
||||
"description": "Access-Control-Allow-Origin header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Set-Cookie": {
|
||||
"description": "Set-Cookie header.",
|
||||
"style": "simple",
|
||||
"schema": {
|
||||
"nullable": true,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"X-Api-Call-Id": {
|
||||
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
|
||||
"style": "simple",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"4XX": {
|
||||
"$ref": "#/components/responses/Error"
|
||||
},
|
||||
"5XX": {
|
||||
"$ref": "#/components/responses/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/website/form": {
|
||||
"put": {
|
||||
"tags": [
|
||||
|
Reference in New Issue
Block a user