diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b5001eeb44..dc0298ed9e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,26 @@ jobs: - name: Ensure importable run: | rye run python -c 'import cloudflare' + test: + name: test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rye + run: | + curl -sSf https://rye-up.com/get | bash + echo "$HOME/.rye/shims" >> $GITHUB_PATH + env: + RYE_VERSION: 0.24.0 + RYE_INSTALL_OPTION: '--yes' + + - name: Bootstrap + run: ./scripts/bootstrap + - name: Run tests + run: ./scripts/test examples: name: examples runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index a4b2f8c0bd3..0f9a66a9764 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ dist .env .envrc codegen.log +Brewfile.lock.json diff --git a/.stats.yml b/.stats.yml index df6ffb0697c..f189017b765 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1258 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b3772775d2fb2b6a241272ee7e25947401f425c5f89ba33c11dabd434a060aa7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f1479806ff9a382d425b33f45765681c248cf0895cd4fb79eec5b51a55ea23a.yml diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000000..492ca37bb07 --- /dev/null +++ b/Brewfile @@ -0,0 +1,2 @@ +brew "rye" + diff --git a/api.md b/api.md index 008d75599a8..59a85841e41 100644 --- a/api.md +++ b/api.md @@ -2559,16 +2559,22 @@ Methods: Types: ```python -from cloudflare.types.web3 import Hostname, HostnameDeleteResponse +from cloudflare.types.web3 import ( + HostnameCreateResponse, + HostnameListResponse, + HostnameDeleteResponse, + HostnameEditResponse, + HostnameGetResponse, +) ``` Methods: -- client.web3.hostnames.create(zone_identifier, \*\*params) -> Hostname -- client.web3.hostnames.list(zone_identifier) -> SyncSinglePage[Hostname] +- client.web3.hostnames.create(zone_identifier, \*\*params) -> HostnameCreateResponse +- client.web3.hostnames.list(zone_identifier) -> SyncSinglePage[HostnameListResponse] - client.web3.hostnames.delete(identifier, \*, zone_identifier) -> Optional -- client.web3.hostnames.edit(identifier, \*, zone_identifier, \*\*params) -> Hostname -- client.web3.hostnames.get(identifier, \*, zone_identifier) -> Hostname +- client.web3.hostnames.edit(identifier, \*, zone_identifier, \*\*params) -> HostnameEditResponse +- client.web3.hostnames.get(identifier, \*, zone_identifier) -> HostnameGetResponse ### IPFSUniversalPaths @@ -2577,13 +2583,16 @@ Methods: Types: ```python -from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList +from cloudflare.types.web3.hostnames.ipfs_universal_paths import ( + ContentListUpdateResponse, + ContentListGetResponse, +) ``` Methods: -- client.web3.hostnames.ipfs_universal_paths.content_lists.update(identifier, \*, zone_identifier, \*\*params) -> ContentList -- client.web3.hostnames.ipfs_universal_paths.content_lists.get(identifier, \*, zone_identifier) -> ContentList +- client.web3.hostnames.ipfs_universal_paths.content_lists.update(identifier, \*, zone_identifier, \*\*params) -> ContentListUpdateResponse +- client.web3.hostnames.ipfs_universal_paths.content_lists.get(identifier, \*, zone_identifier) -> ContentListGetResponse ##### Entries diff --git a/bin/check-env-state.py b/bin/check-env-state.py deleted file mode 100644 index e1b8b6cb39b..00000000000 --- a/bin/check-env-state.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Script that exits 1 if the current environment is not -in sync with the `requirements-dev.lock` file. -""" - -from pathlib import Path - -import importlib_metadata - - -def should_run_sync() -> bool: - dev_lock = Path(__file__).parent.parent.joinpath("requirements-dev.lock") - - for line in dev_lock.read_text().splitlines(): - if not line or line.startswith("#") or line.startswith("-e"): - continue - - dep, lock_version = line.split("==") - - try: - version = importlib_metadata.version(dep) - - if lock_version != version: - print(f"mismatch for {dep} current={version} lock={lock_version}") - return True - except Exception: - print(f"could not import {dep}") - return True - - return False - - -def main() -> None: - if should_run_sync(): - exit(1) - else: - exit(0) - - -if __name__ == "__main__": - main() diff --git a/bin/check-test-server b/bin/check-test-server deleted file mode 100755 index a6fa34950d1..00000000000 --- a/bin/check-test-server +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color - -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if is_overriding_api_base_url ; then - # If someone is running the tests against the live API, we can trust they know - # what they're doing and exit early. - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - - exit 0 -elif prism_is_running ; then - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo - - exit 0 -else - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "${YELLOW}To fix:${NC}" - echo - echo -e "1. Install Prism (requires Node 16+):" - echo - echo -e " With npm:" - echo -e " \$ ${YELLOW}npm install -g @stoplight/prism-cli${NC}" - echo - echo -e " With yarn:" - echo -e " \$ ${YELLOW}yarn global add @stoplight/prism-cli${NC}" - echo - echo -e "2. Run the mock server" - echo - echo -e " To run the server, pass in the path of your OpenAPI" - echo -e " spec to the prism command:" - echo - echo -e " \$ ${YELLOW}prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -fi diff --git a/bin/test b/bin/test deleted file mode 100755 index 60ede7a8428..00000000000 --- a/bin/test +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -bin/check-test-server && rye run pytest "$@" diff --git a/pyproject.toml b/pyproject.toml index fda2de82ca4..5143f304608 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ format = { chain = [ "fix:ruff", ]} "format:black" = "black ." -"format:docs" = "python bin/ruffen-docs.py README.md api.md" +"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md" "format:ruff" = "ruff format" "format:isort" = "isort ." @@ -192,5 +192,6 @@ known-first-party = ["cloudflare", "tests"] [tool.ruff.per-file-ignores] "bin/**.py" = ["T201", "T203"] +"scripts/**.py" = ["T201", "T203"] "tests/**.py" = ["T201", "T203"] "examples/**.py" = ["T201", "T203"] diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000000..29df07e77be --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then + brew bundle check >/dev/null 2>&1 || { + echo "==> Installing Homebrew dependencies…" + brew bundle + } +fi + +echo "==> Installing Python dependencies…" + +# experimental uv support makes installations significantly faster +rye config --set-bool behavior.use-uv=true + +rye sync diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000000..2a9ea4664bf --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +rye run format + diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000000..0cc68b51578 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +rye run lint + diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000000..5a8c35b725f --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000000..be01d044734 --- /dev/null +++ b/scripts/test @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +# Run tests +echo "==> Running tests" +rye run pytest "$@" diff --git a/bin/ruffen-docs.py b/scripts/utils/ruffen-docs.py similarity index 100% rename from bin/ruffen-docs.py rename to scripts/utils/ruffen-docs.py diff --git a/src/cloudflare/resources/web3/hostnames/hostnames.py b/src/cloudflare/resources/web3/hostnames/hostnames.py index 9bf5ac86e9a..d0dcae89c92 100644 --- a/src/cloudflare/resources/web3/hostnames/hostnames.py +++ b/src/cloudflare/resources/web3/hostnames/hostnames.py @@ -35,7 +35,10 @@ IPFSUniversalPathsResourceWithStreamingResponse, AsyncIPFSUniversalPathsResourceWithStreamingResponse, ) -from ....types.web3.hostname import Hostname +from ....types.web3.hostname_get_response import HostnameGetResponse +from ....types.web3.hostname_edit_response import HostnameEditResponse +from ....types.web3.hostname_list_response import HostnameListResponse +from ....types.web3.hostname_create_response import HostnameCreateResponse from ....types.web3.hostname_delete_response import HostnameDeleteResponse from .ipfs_universal_paths.ipfs_universal_paths import IPFSUniversalPathsResource, AsyncIPFSUniversalPathsResource @@ -68,7 +71,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameCreateResponse: """ Create Web3 Hostname @@ -106,9 +109,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameCreateResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameCreateResponse], ResultWrapper[HostnameCreateResponse]), ) def list( @@ -121,7 +124,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Hostname]: + ) -> SyncSinglePage[HostnameListResponse]: """ List Web3 Hostnames @@ -140,11 +143,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return self._get_api_list( f"/zones/{zone_identifier}/web3/hostnames", - page=SyncSinglePage[Hostname], + page=SyncSinglePage[HostnameListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Hostname, + model=HostnameListResponse, ) def delete( @@ -204,7 +207,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameEditResponse: """ Edit Web3 Hostname @@ -243,9 +246,9 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameEditResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameEditResponse], ResultWrapper[HostnameEditResponse]), ) def get( @@ -259,7 +262,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameGetResponse: """ Web3 Hostname Details @@ -287,9 +290,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameGetResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameGetResponse], ResultWrapper[HostnameGetResponse]), ) @@ -319,7 +322,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameCreateResponse: """ Create Web3 Hostname @@ -357,9 +360,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameCreateResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameCreateResponse], ResultWrapper[HostnameCreateResponse]), ) def list( @@ -372,7 +375,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Hostname, AsyncSinglePage[Hostname]]: + ) -> AsyncPaginator[HostnameListResponse, AsyncSinglePage[HostnameListResponse]]: """ List Web3 Hostnames @@ -391,11 +394,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return self._get_api_list( f"/zones/{zone_identifier}/web3/hostnames", - page=AsyncSinglePage[Hostname], + page=AsyncSinglePage[HostnameListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Hostname, + model=HostnameListResponse, ) async def delete( @@ -455,7 +458,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameEditResponse: """ Edit Web3 Hostname @@ -494,9 +497,9 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameEditResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameEditResponse], ResultWrapper[HostnameEditResponse]), ) async def get( @@ -510,7 +513,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Hostname: + ) -> HostnameGetResponse: """ Web3 Hostname Details @@ -538,9 +541,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Hostname]._unwrapper, + post_parser=ResultWrapper[HostnameGetResponse]._unwrapper, ), - cast_to=cast(Type[Hostname], ResultWrapper[Hostname]), + cast_to=cast(Type[HostnameGetResponse], ResultWrapper[HostnameGetResponse]), ) diff --git a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py index d8c028bfc32..75f6abaee0b 100644 --- a/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py +++ b/src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py @@ -33,7 +33,8 @@ make_request_options, ) from ......types.web3.hostnames.ipfs_universal_paths import content_list_update_params -from ......types.web3.hostnames.ipfs_universal_paths.content_list import ContentList +from ......types.web3.hostnames.ipfs_universal_paths.content_list_get_response import ContentListGetResponse +from ......types.web3.hostnames.ipfs_universal_paths.content_list_update_response import ContentListUpdateResponse __all__ = ["ContentListsResource", "AsyncContentListsResource"] @@ -64,7 +65,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentList: + ) -> ContentListUpdateResponse: """ Update IPFS Universal Path Gateway Content List @@ -103,9 +104,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentList]._unwrapper, + post_parser=ResultWrapper[ContentListUpdateResponse]._unwrapper, ), - cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), + cast_to=cast(Type[ContentListUpdateResponse], ResultWrapper[ContentListUpdateResponse]), ) def get( @@ -119,7 +120,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentList: + ) -> ContentListGetResponse: """ IPFS Universal Path Gateway Content List Details @@ -147,9 +148,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentList]._unwrapper, + post_parser=ResultWrapper[ContentListGetResponse]._unwrapper, ), - cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), + cast_to=cast(Type[ContentListGetResponse], ResultWrapper[ContentListGetResponse]), ) @@ -179,7 +180,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentList: + ) -> ContentListUpdateResponse: """ Update IPFS Universal Path Gateway Content List @@ -218,9 +219,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentList]._unwrapper, + post_parser=ResultWrapper[ContentListUpdateResponse]._unwrapper, ), - cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), + cast_to=cast(Type[ContentListUpdateResponse], ResultWrapper[ContentListUpdateResponse]), ) async def get( @@ -234,7 +235,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ContentList: + ) -> ContentListGetResponse: """ IPFS Universal Path Gateway Content List Details @@ -262,9 +263,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[ContentList]._unwrapper, + post_parser=ResultWrapper[ContentListGetResponse]._unwrapper, ), - cast_to=cast(Type[ContentList], ResultWrapper[ContentList]), + cast_to=cast(Type[ContentListGetResponse], ResultWrapper[ContentListGetResponse]), ) diff --git a/src/cloudflare/types/web3/__init__.py b/src/cloudflare/types/web3/__init__.py index 020395070ff..36227fdbc21 100644 --- a/src/cloudflare/types/web3/__init__.py +++ b/src/cloudflare/types/web3/__init__.py @@ -2,7 +2,10 @@ from __future__ import annotations -from .hostname import Hostname as Hostname from .hostname_edit_params import HostnameEditParams as HostnameEditParams +from .hostname_get_response import HostnameGetResponse as HostnameGetResponse from .hostname_create_params import HostnameCreateParams as HostnameCreateParams +from .hostname_edit_response import HostnameEditResponse as HostnameEditResponse +from .hostname_list_response import HostnameListResponse as HostnameListResponse +from .hostname_create_response import HostnameCreateResponse as HostnameCreateResponse from .hostname_delete_response import HostnameDeleteResponse as HostnameDeleteResponse diff --git a/src/cloudflare/types/web3/hostname_create_response.py b/src/cloudflare/types/web3/hostname_create_response.py new file mode 100644 index 00000000000..f3a47f5991b --- /dev/null +++ b/src/cloudflare/types/web3/hostname_create_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["HostnameCreateResponse"] + + +class HostnameCreateResponse(BaseModel): + id: Optional[str] = None + """Identifier""" + + created_on: Optional[datetime] = None + + description: Optional[str] = None + """An optional description of the hostname.""" + + dnslink: Optional[str] = None + """DNSLink value used if the target is ipfs.""" + + modified_on: Optional[datetime] = None + + name: Optional[str] = None + """The hostname that will point to the target gateway via CNAME.""" + + status: Optional[Literal["active", "pending", "deleting", "error"]] = None + """Status of the hostname's activation.""" + + target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None + """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostname_edit_response.py b/src/cloudflare/types/web3/hostname_edit_response.py new file mode 100644 index 00000000000..08f3c68b794 --- /dev/null +++ b/src/cloudflare/types/web3/hostname_edit_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["HostnameEditResponse"] + + +class HostnameEditResponse(BaseModel): + id: Optional[str] = None + """Identifier""" + + created_on: Optional[datetime] = None + + description: Optional[str] = None + """An optional description of the hostname.""" + + dnslink: Optional[str] = None + """DNSLink value used if the target is ipfs.""" + + modified_on: Optional[datetime] = None + + name: Optional[str] = None + """The hostname that will point to the target gateway via CNAME.""" + + status: Optional[Literal["active", "pending", "deleting", "error"]] = None + """Status of the hostname's activation.""" + + target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None + """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostname.py b/src/cloudflare/types/web3/hostname_get_response.py similarity index 92% rename from src/cloudflare/types/web3/hostname.py rename to src/cloudflare/types/web3/hostname_get_response.py index befb6b79bf1..f74ddcd7029 100644 --- a/src/cloudflare/types/web3/hostname.py +++ b/src/cloudflare/types/web3/hostname_get_response.py @@ -6,10 +6,10 @@ from ..._models import BaseModel -__all__ = ["Hostname"] +__all__ = ["HostnameGetResponse"] -class Hostname(BaseModel): +class HostnameGetResponse(BaseModel): id: Optional[str] = None """Identifier""" diff --git a/src/cloudflare/types/web3/hostname_list_response.py b/src/cloudflare/types/web3/hostname_list_response.py new file mode 100644 index 00000000000..bd9672b4687 --- /dev/null +++ b/src/cloudflare/types/web3/hostname_list_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["HostnameListResponse"] + + +class HostnameListResponse(BaseModel): + id: Optional[str] = None + """Identifier""" + + created_on: Optional[datetime] = None + + description: Optional[str] = None + """An optional description of the hostname.""" + + dnslink: Optional[str] = None + """DNSLink value used if the target is ipfs.""" + + modified_on: Optional[datetime] = None + + name: Optional[str] = None + """The hostname that will point to the target gateway via CNAME.""" + + status: Optional[Literal["active", "pending", "deleting", "error"]] = None + """Status of the hostname's activation.""" + + target: Optional[Literal["ethereum", "ipfs", "ipfs_universal_path"]] = None + """Target gateway of the hostname.""" diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py index c97af8e9619..24bd3fc782f 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/__init__.py @@ -2,5 +2,6 @@ from __future__ import annotations -from .content_list import ContentList as ContentList +from .content_list_get_response import ContentListGetResponse as ContentListGetResponse from .content_list_update_params import ContentListUpdateParams as ContentListUpdateParams +from .content_list_update_response import ContentListUpdateResponse as ContentListUpdateResponse diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py similarity index 78% rename from src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py rename to src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py index 3585768a617..6cf7e420bf5 100644 --- a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py @@ -5,9 +5,9 @@ from ....._models import BaseModel -__all__ = ["ContentList"] +__all__ = ["ContentListGetResponse"] -class ContentList(BaseModel): +class ContentListGetResponse(BaseModel): action: Optional[Literal["block"]] = None """Behavior of the content list.""" diff --git a/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py new file mode 100644 index 00000000000..d8948d62941 --- /dev/null +++ b/src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ContentListUpdateResponse"] + + +class ContentListUpdateResponse(BaseModel): + action: Optional[Literal["block"]] = None + """Behavior of the content list.""" diff --git a/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py b/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py index 9c682cddb81..f077db0339b 100644 --- a/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py +++ b/tests/api_resources/web3/hostnames/ipfs_universal_paths/test_content_lists.py @@ -9,7 +9,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList +from cloudflare.types.web3.hostnames.ipfs_universal_paths import ( + ContentListGetResponse, + ContentListUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -25,7 +28,7 @@ def test_method_update(self, client: Cloudflare) -> None: action="block", entries=[{}, {}, {}], ) - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -39,7 +42,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -53,7 +56,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -81,7 +84,7 @@ def test_method_get(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -93,7 +96,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -105,7 +108,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -135,7 +138,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: action="block", entries=[{}, {}, {}], ) - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -149,7 +152,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -163,7 +166,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListUpdateResponse, content_list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -191,7 +194,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -203,7 +206,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -215,7 +218,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" content_list = await response.parse() - assert_matches_type(ContentList, content_list, path=["response"]) + assert_matches_type(ContentListGetResponse, content_list, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/web3/test_hostnames.py b/tests/api_resources/web3/test_hostnames.py index d12712ea809..632648b6bda 100644 --- a/tests/api_resources/web3/test_hostnames.py +++ b/tests/api_resources/web3/test_hostnames.py @@ -10,7 +10,13 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.web3 import Hostname, HostnameDeleteResponse +from cloudflare.types.web3 import ( + HostnameGetResponse, + HostnameEditResponse, + HostnameListResponse, + HostnameCreateResponse, + HostnameDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", target="ipfs", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -34,7 +40,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -46,7 +52,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -58,7 +64,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -75,7 +81,7 @@ def test_method_list(self, client: Cloudflare) -> None: hostname = client.web3.hostnames.list( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -86,7 +92,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -97,7 +103,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(SyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(SyncSinglePage[HostnameListResponse], hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -162,7 +168,7 @@ def test_method_edit(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: @@ -172,7 +178,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: @@ -184,7 +190,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: @@ -196,7 +202,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -220,7 +226,7 @@ def test_method_get(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -232,7 +238,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -244,7 +250,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -272,7 +278,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", target="ipfs", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -282,7 +288,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -294,7 +300,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -306,7 +312,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameCreateResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -323,7 +329,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: hostname = await async_client.web3.hostnames.list( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -334,7 +340,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -345,7 +351,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(AsyncSinglePage[Hostname], hostname, path=["response"]) + assert_matches_type(AsyncSinglePage[HostnameListResponse], hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -410,7 +416,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -420,7 +426,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) description="This is my IPFS gateway.", dnslink="/ipns/onboarding.ipfs.cloudflare.com", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -432,7 +438,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -444,7 +450,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameEditResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True @@ -468,7 +474,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -480,7 +486,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -492,7 +498,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" hostname = await response.parse() - assert_matches_type(Hostname, hostname, path=["response"]) + assert_matches_type(HostnameGetResponse, hostname, path=["response"]) assert cast(Any, response.is_closed) is True