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): OpenAPI spec update via Stainless API #155

Merged
merged 1 commit into from
Mar 20, 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"),
)

zone_create_response = client.zones.create(
zone = client.zones.create(
account={"id": "023e105f4ecef8ad9ca31a8372d0c353"},
name="example.com",
type="full",
)
print(zone_create_response.id)
print(zone.id)
```

While you can provide a `api_email` keyword argument,
Expand All @@ -59,12 +59,12 @@ client = AsyncCloudflare(


async def main() -> None:
zone_create_response = await client.zones.create(
zone = await client.zones.create(
account={"id": "023e105f4ecef8ad9ca31a8372d0c353"},
name="example.com",
type="full",
)
print(zone_create_response.id)
print(zone.id)


asyncio.run(main())
Expand Down
32 changes: 10 additions & 22 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,16 @@ Methods:
Types:

```python
from cloudflare.types import (
Zone,
ZoneCreateResponse,
ZoneListResponse,
ZoneDeleteResponse,
ZoneEditResponse,
ZoneGetResponse,
)
from cloudflare.types import Zone, ZoneDeleteResponse
```

Methods:

- <code title="post /zones">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">create</a>(\*\*<a href="src/cloudflare/types/zone_create_params.py">params</a>) -> <a href="./src/cloudflare/types/zone_create_response.py">Optional</a></code>
- <code title="get /zones">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">list</a>(\*\*<a href="src/cloudflare/types/zone_list_params.py">params</a>) -> <a href="./src/cloudflare/types/zone_list_response.py">SyncV4PagePaginationArray[ZoneListResponse]</a></code>
- <code title="post /zones">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">create</a>(\*\*<a href="src/cloudflare/types/zone_create_params.py">params</a>) -> <a href="./src/cloudflare/types/zone.py">Optional</a></code>
- <code title="get /zones">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">list</a>(\*\*<a href="src/cloudflare/types/zone_list_params.py">params</a>) -> <a href="./src/cloudflare/types/zone.py">SyncV4PagePaginationArray[Zone]</a></code>
- <code title="delete /zones/{zone_id}">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">delete</a>(\*, zone_id) -> <a href="./src/cloudflare/types/zone_delete_response.py">Optional</a></code>
- <code title="patch /zones/{zone_id}">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">edit</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zone_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zone_edit_response.py">Optional</a></code>
- <code title="get /zones/{zone_id}">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/zone_get_response.py">Optional</a></code>
- <code title="patch /zones/{zone_id}">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">edit</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/zone_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zone.py">Optional</a></code>
- <code title="get /zones/{zone_id}">client.zones.<a href="./src/cloudflare/resources/zones/zones.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/zone.py">Optional</a></code>

## ActivationCheck

Expand Down Expand Up @@ -1664,27 +1657,22 @@ Types:
```python
from cloudflare.types.dns import (
DNSRecord,
RecordCreateResponse,
RecordUpdateResponse,
RecordListResponse,
RecordDeleteResponse,
RecordEditResponse,
RecordExportResponse,
RecordGetResponse,
RecordImportResponse,
RecordScanResponse,
)
```

Methods:

- <code title="post /zones/{zone_id}/dns_records">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_create_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/record_create_response.py">RecordCreateResponse</a></code>
- <code title="put /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">update</a>(dns_record_id, \*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_update_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/record_update_response.py">RecordUpdateResponse</a></code>
- <code title="get /zones/{zone_id}/dns_records">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_list_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/record_list_response.py">SyncV4PagePaginationArray[RecordListResponse]</a></code>
- <code title="post /zones/{zone_id}/dns_records">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_create_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/dns_record.py">DNSRecord</a></code>
- <code title="put /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">update</a>(dns_record_id, \*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_update_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/dns_record.py">DNSRecord</a></code>
- <code title="get /zones/{zone_id}/dns_records">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_list_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/dns_record.py">SyncV4PagePaginationArray[DNSRecord]</a></code>
- <code title="delete /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">delete</a>(dns_record_id, \*, zone_id) -> <a href="./src/cloudflare/types/dns/record_delete_response.py">Optional</a></code>
- <code title="patch /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">edit</a>(dns_record_id, \*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/record_edit_response.py">RecordEditResponse</a></code>
- <code title="patch /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">edit</a>(dns_record_id, \*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/dns_record.py">DNSRecord</a></code>
- <code title="get /zones/{zone_id}/dns_records/export">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">export</a>(\*, zone_id) -> str</code>
- <code title="get /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">get</a>(dns_record_id, \*, zone_id) -> <a href="./src/cloudflare/types/dns/record_get_response.py">RecordGetResponse</a></code>
- <code title="get /zones/{zone_id}/dns_records/{dns_record_id}">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">get</a>(dns_record_id, \*, zone_id) -> <a href="./src/cloudflare/types/dns/dns_record.py">DNSRecord</a></code>
- <code title="post /zones/{zone_id}/dns_records/import">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">import\_</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/dns/record_import_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/record_import_response.py">RecordImportResponse</a></code>
- <code title="post /zones/{zone_id}/dns_records/scan">client.dns.records.<a href="./src/cloudflare/resources/dns/records.py">scan</a>(\*, zone_id) -> <a href="./src/cloudflare/types/dns/record_scan_response.py">RecordScanResponse</a></code>

Expand Down
66 changes: 31 additions & 35 deletions src/cloudflare/resources/dns/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
)
from ..._wrappers import ResultWrapper
from ...types.dns import (
RecordGetResponse,
RecordEditResponse,
RecordListResponse,
DNSRecord,
RecordScanResponse,
RecordCreateResponse,
RecordDeleteResponse,
RecordImportResponse,
RecordUpdateResponse,
record_edit_params,
record_list_params,
record_create_params,
Expand Down Expand Up @@ -95,7 +91,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordCreateResponse:
) -> DNSRecord:
"""
Create a new DNS record for a zone.

Expand Down Expand Up @@ -141,7 +137,7 @@ def create(
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
RecordCreateResponse,
DNSRecord,
self._post(
f"/zones/{zone_id}/dns_records",
body=maybe_transform(
Expand All @@ -167,7 +163,7 @@ def create(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordCreateResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -214,7 +210,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordUpdateResponse:
) -> DNSRecord:
"""Overwrite an existing DNS record.

Notes:
Expand Down Expand Up @@ -263,7 +259,7 @@ def update(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordUpdateResponse,
DNSRecord,
self._put(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
body=maybe_transform(
Expand All @@ -289,7 +285,7 @@ def update(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordUpdateResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -339,7 +335,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncV4PagePaginationArray[RecordListResponse]:
) -> SyncV4PagePaginationArray[DNSRecord]:
"""
List, search, sort, and filter a zones' DNS records.

Expand Down Expand Up @@ -391,7 +387,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/dns_records",
page=SyncV4PagePaginationArray[RecordListResponse],
page=SyncV4PagePaginationArray[DNSRecord],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -416,7 +412,7 @@ def list(
record_list_params.RecordListParams,
),
),
model=cast(Any, RecordListResponse), # Union types cannot be passed in as arguments in the type system
model=cast(Any, DNSRecord), # Union types cannot be passed in as arguments in the type system
)

def delete(
Expand Down Expand Up @@ -505,7 +501,7 @@ def edit(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordEditResponse:
) -> DNSRecord:
"""Update an existing DNS record.

Notes:
Expand Down Expand Up @@ -554,7 +550,7 @@ def edit(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordEditResponse,
DNSRecord,
self._patch(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
body=maybe_transform(
Expand All @@ -580,7 +576,7 @@ def edit(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordEditResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -638,7 +634,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordGetResponse:
) -> DNSRecord:
"""
DNS Record Details

Expand All @@ -660,7 +656,7 @@ def get(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordGetResponse,
DNSRecord,
self._get(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
options=make_request_options(
Expand All @@ -671,7 +667,7 @@ def get(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordGetResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -832,7 +828,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordCreateResponse:
) -> DNSRecord:
"""
Create a new DNS record for a zone.

Expand Down Expand Up @@ -878,7 +874,7 @@ async def create(
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
RecordCreateResponse,
DNSRecord,
await self._post(
f"/zones/{zone_id}/dns_records",
body=await async_maybe_transform(
Expand All @@ -904,7 +900,7 @@ async def create(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordCreateResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -951,7 +947,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordUpdateResponse:
) -> DNSRecord:
"""Overwrite an existing DNS record.

Notes:
Expand Down Expand Up @@ -1000,7 +996,7 @@ async def update(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordUpdateResponse,
DNSRecord,
await self._put(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
body=await async_maybe_transform(
Expand All @@ -1026,7 +1022,7 @@ async def update(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordUpdateResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -1076,7 +1072,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[RecordListResponse, AsyncV4PagePaginationArray[RecordListResponse]]:
) -> AsyncPaginator[DNSRecord, AsyncV4PagePaginationArray[DNSRecord]]:
"""
List, search, sort, and filter a zones' DNS records.

Expand Down Expand Up @@ -1128,7 +1124,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/dns_records",
page=AsyncV4PagePaginationArray[RecordListResponse],
page=AsyncV4PagePaginationArray[DNSRecord],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -1153,7 +1149,7 @@ def list(
record_list_params.RecordListParams,
),
),
model=cast(Any, RecordListResponse), # Union types cannot be passed in as arguments in the type system
model=cast(Any, DNSRecord), # Union types cannot be passed in as arguments in the type system
)

async def delete(
Expand Down Expand Up @@ -1242,7 +1238,7 @@ async def edit(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordEditResponse:
) -> DNSRecord:
"""Update an existing DNS record.

Notes:
Expand Down Expand Up @@ -1291,7 +1287,7 @@ async def edit(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordEditResponse,
DNSRecord,
await self._patch(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
body=await async_maybe_transform(
Expand All @@ -1317,7 +1313,7 @@ async def edit(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordEditResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down Expand Up @@ -1375,7 +1371,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RecordGetResponse:
) -> DNSRecord:
"""
DNS Record Details

Expand All @@ -1397,7 +1393,7 @@ async def get(
if not dns_record_id:
raise ValueError(f"Expected a non-empty value for `dns_record_id` but received {dns_record_id!r}")
return cast(
RecordGetResponse,
DNSRecord,
await self._get(
f"/zones/{zone_id}/dns_records/{dns_record_id}",
options=make_request_options(
Expand All @@ -1408,7 +1404,7 @@ async def get(
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[RecordGetResponse]
Any, ResultWrapper[DNSRecord]
), # Union types cannot be passed in as arguments in the type system
),
)
Expand Down
Loading