Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #356

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 37 additions & 67 deletions api.md

Large diffs are not rendered by default.

102 changes: 41 additions & 61 deletions src/cloudflare/resources/addressing/address_maps/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Optional, cast
from typing import Type, Optional, cast

import httpx

Expand Down Expand Up @@ -75,22 +75,17 @@ def update(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AccountUpdateResponse],
self._put(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=maybe_transform(body, account_update_params.AccountUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountUpdateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AccountUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return self._put(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=maybe_transform(body, account_update_params.AccountUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountUpdateResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AccountUpdateResponse]], ResultWrapper[AccountUpdateResponse]),
)

def delete(
Expand Down Expand Up @@ -126,22 +121,17 @@ def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AccountDeleteResponse],
self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=maybe_transform(body, account_delete_params.AccountDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AccountDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=maybe_transform(body, account_delete_params.AccountDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AccountDeleteResponse]], ResultWrapper[AccountDeleteResponse]),
)


Expand Down Expand Up @@ -187,22 +177,17 @@ async def update(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AccountUpdateResponse],
await self._put(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=await async_maybe_transform(body, account_update_params.AccountUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountUpdateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AccountUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._put(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=await async_maybe_transform(body, account_update_params.AccountUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountUpdateResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AccountUpdateResponse]], ResultWrapper[AccountUpdateResponse]),
)

async def delete(
Expand Down Expand Up @@ -238,22 +223,17 @@ async def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AccountDeleteResponse],
await self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=await async_maybe_transform(body, account_delete_params.AccountDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AccountDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}",
body=await async_maybe_transform(body, account_delete_params.AccountDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AccountDeleteResponse]], ResultWrapper[AccountDeleteResponse]),
)


Expand Down
88 changes: 39 additions & 49 deletions src/cloudflare/resources/addressing/address_maps/address_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Type, Optional, cast
from typing import Type, Optional, cast

import httpx

Expand Down Expand Up @@ -95,7 +95,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMapCreateResponse:
) -> Optional[AddressMapCreateResponse]:
"""
Create a new address map under the account.

Expand Down Expand Up @@ -132,9 +132,9 @@ def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMapCreateResponse]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMapCreateResponse]]._unwrapper,
),
cast_to=cast(Type[AddressMapCreateResponse], ResultWrapper[AddressMapCreateResponse]),
cast_to=cast(Type[Optional[AddressMapCreateResponse]], ResultWrapper[AddressMapCreateResponse]),
)

def list(
Expand Down Expand Up @@ -208,22 +208,17 @@ def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AddressMapDeleteResponse],
self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}",
body=maybe_transform(body, address_map_delete_params.AddressMapDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AddressMapDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}",
body=maybe_transform(body, address_map_delete_params.AddressMapDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AddressMapDeleteResponse]], ResultWrapper[AddressMapDeleteResponse]),
)

def edit(
Expand All @@ -240,7 +235,7 @@ def edit(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMap:
) -> Optional[AddressMap]:
"""
Modify properties of an address map owned by the account.

Expand Down Expand Up @@ -288,9 +283,9 @@ def edit(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMap]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMap]]._unwrapper,
),
cast_to=cast(Type[AddressMap], ResultWrapper[AddressMap]),
cast_to=cast(Type[Optional[AddressMap]], ResultWrapper[AddressMap]),
)

def get(
Expand All @@ -304,7 +299,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMapGetResponse:
) -> Optional[AddressMapGetResponse]:
"""
Show a particular address map owned by the account.

Expand Down Expand Up @@ -332,9 +327,9 @@ def get(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMapGetResponse]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMapGetResponse]]._unwrapper,
),
cast_to=cast(Type[AddressMapGetResponse], ResultWrapper[AddressMapGetResponse]),
cast_to=cast(Type[Optional[AddressMapGetResponse]], ResultWrapper[AddressMapGetResponse]),
)


Expand Down Expand Up @@ -371,7 +366,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMapCreateResponse:
) -> Optional[AddressMapCreateResponse]:
"""
Create a new address map under the account.

Expand Down Expand Up @@ -408,9 +403,9 @@ async def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMapCreateResponse]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMapCreateResponse]]._unwrapper,
),
cast_to=cast(Type[AddressMapCreateResponse], ResultWrapper[AddressMapCreateResponse]),
cast_to=cast(Type[Optional[AddressMapCreateResponse]], ResultWrapper[AddressMapCreateResponse]),
)

def list(
Expand Down Expand Up @@ -484,22 +479,17 @@ async def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not address_map_id:
raise ValueError(f"Expected a non-empty value for `address_map_id` but received {address_map_id!r}")
return cast(
Optional[AddressMapDeleteResponse],
await self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}",
body=await async_maybe_transform(body, address_map_delete_params.AddressMapDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[AddressMapDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._delete(
f"/accounts/{account_id}/addressing/address_maps/{address_map_id}",
body=await async_maybe_transform(body, address_map_delete_params.AddressMapDeleteParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[AddressMapDeleteResponse]], ResultWrapper[AddressMapDeleteResponse]),
)

async def edit(
Expand All @@ -516,7 +506,7 @@ async def edit(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMap:
) -> Optional[AddressMap]:
"""
Modify properties of an address map owned by the account.

Expand Down Expand Up @@ -564,9 +554,9 @@ async def edit(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMap]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMap]]._unwrapper,
),
cast_to=cast(Type[AddressMap], ResultWrapper[AddressMap]),
cast_to=cast(Type[Optional[AddressMap]], ResultWrapper[AddressMap]),
)

async def get(
Expand All @@ -580,7 +570,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AddressMapGetResponse:
) -> Optional[AddressMapGetResponse]:
"""
Show a particular address map owned by the account.

Expand Down Expand Up @@ -608,9 +598,9 @@ async def get(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[AddressMapGetResponse]._unwrapper,
post_parser=ResultWrapper[Optional[AddressMapGetResponse]]._unwrapper,
),
cast_to=cast(Type[AddressMapGetResponse], ResultWrapper[AddressMapGetResponse]),
cast_to=cast(Type[Optional[AddressMapGetResponse]], ResultWrapper[AddressMapGetResponse]),
)


Expand Down
Loading