diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ac9a2e75218..ff261bad783 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} USER vscode -RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.35.0" RYE_INSTALL_OPTION="--yes" bash +RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.44.0" RYE_INSTALL_OPTION="--yes" bash ENV PATH=/home/vscode/.rye/shims:$PATH -RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc +RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bbeb30b148c..c17fdc169fc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,6 +24,9 @@ } } } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": {} } // Features to add to the dev container. More info: https://containers.dev/features. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000000..0b518c0c98b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,60 @@ +name: Bug report +description: Report an issue or bug with this library +labels: ['bug'] +body: + - type: checkboxes + id: non_api + attributes: + label: Confirm this is a Python library issue and not an underlying Cloudflare API issue. + description: Issues with the underlying Cloudflare API should be reported via [Cloudflare Support](https://developers.cloudflare.com/support/contacting-cloudflare-support) + options: + - label: This is an issue with the Python library + required: true + - type: textarea + id: what-happened + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is, and any additional context. + placeholder: Tell us what you see! + validations: + required: true + - type: textarea + id: repro-steps + attributes: + label: To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. Fetch a '...' + 2. Update the '....' + 3. See error + validations: + required: true + - type: textarea + id: code-snippets + attributes: + label: Code snippets + description: If applicable, add code snippets to help explain your problem. + render: Python + validations: + required: false + - type: input + id: os + attributes: + label: OS + placeholder: macOS + validations: + required: true + - type: input + id: language-version + attributes: + label: Python version + placeholder: 3.9.0 + validations: + required: true + - type: input + id: lib-version + attributes: + label: Library version + placeholder: v4.0.0 + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0431334981b..83bedae0dfc 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,9 +1,5 @@ blank_issues_enabled: false contact_links: - - name: v3.0.0 Beta feedback - url: https://github.com/cloudflare/cloudflare-python/discussions/116 - about: | - If you have a feature request or feedback on our new v3 library, please comment in our discussion page. - name: Cloudflare support url: https://developers.cloudflare.com/support/contacting-cloudflare-support about: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05859c4703a..0722c756e37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,16 @@ name: CI on: push: - branches: - - main + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' pull_request: - branches: - - main - - next + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,19 +19,19 @@ concurrency: jobs: lint: + timeout-minutes: 10 name: lint - runs-on: ubuntu-latest - timeout-minutes: 5 - + runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install Rye run: | curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Install dependencies @@ -35,20 +39,61 @@ jobs: - name: Run lints run: ./scripts/lint + + build: + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + timeout-minutes: 10 + name: build + permissions: + contents: read + id-token: write + runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + steps: + - uses: actions/checkout@v6 + + - name: Install Rye + run: | + curl -sSf https://rye.astral.sh/get | bash + echo "$HOME/.rye/shims" >> $GITHUB_PATH + env: + RYE_VERSION: '0.44.0' + RYE_INSTALL_OPTION: '--yes' + + - name: Install dependencies + run: rye sync --all-features + + - name: Run build + run: rye build + + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/cloudflare-python' + id: github-oidc + uses: actions/github-script@v6 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Upload tarball + if: github.repository == 'stainless-sdks/cloudflare-python' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + run: ./scripts/utils/upload-artifact.sh + test: - name: test - runs-on: ubuntu-latest timeout-minutes: 30 - + name: test + runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install Rye run: | curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Bootstrap @@ -56,20 +101,22 @@ jobs: - name: Run tests run: ./scripts/test + examples: + timeout-minutes: 10 name: examples - runs-on: ubuntu-latest - timeout-minutes: 5 + runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.repository == 'cloudflare/cloudflare-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install Rye run: | curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Install dependencies run: | @@ -78,7 +125,8 @@ jobs: - env: CLOUDFLARE_ACCOUNT_ID: f037e56e89293a057740de681ac9abbe CLOUDFLARE_EMAIL: terraform-acceptance-test@cfapi.net - CLOUDFLARE_ZONE_ID: 0da42c8d2132a9ddaf714f9e7c92011 + CLOUDFLARE_ZONE_ID: 0da42c8d2132a9ddaf714f9e7c920711 CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }} run: | - rye run python ./examples/workers/ai/demo.py + rye run python ./examples/ai/demo.py + rye run python ./examples/dns/record.py diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml new file mode 100644 index 00000000000..b1ee63a0dd7 --- /dev/null +++ b/.github/workflows/detect-breaking-changes.yml @@ -0,0 +1,44 @@ +name: CI +on: + pull_request: + branches: + - main + - next + +jobs: + detect_breaking_changes: + runs-on: 'ubuntu-latest' + name: detect-breaking-changes + if: false + permissions: + contents: read + steps: + - name: Calculate fetch-depth + run: | + echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV + + - uses: actions/checkout@v6 + with: + # Ensure we can check out the pull request base in the script below. + fetch-depth: ${{ env.FETCH_DEPTH }} + + - name: Install Rye + run: | + curl -sSf https://rye.astral.sh/get | bash + echo "$HOME/.rye/shims" >> $GITHUB_PATH + env: + RYE_VERSION: '0.44.0' + RYE_INSTALL_OPTION: '--yes' + - name: Install dependencies + run: | + rye sync --all-features + - name: Detect removed symbols + run: | + rye run python scripts/detect-breaking-changes.py "${{ github.event.pull_request.base.sha }}" + + - name: Detect breaking changes + run: | + # Try to check out previous versions of the breaking change detection script. This ensures that + # we still detect breaking changes when entire files and their tests are removed. + git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true + ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }} \ No newline at end of file diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 60c0cde4031..b711a25bda7 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -14,14 +14,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install Rye run: | curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Publish to PyPI diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 1c932dfe391..41be236b980 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -2,6 +2,8 @@ name: Release Doctor on: pull_request: + branches: + - main workflow_dispatch: concurrency: @@ -16,7 +18,7 @@ jobs: if: github.repository == 'cloudflare/cloudflare-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Check release environment run: | diff --git a/.gitignore b/.gitignore index 87797408001..95ceb189aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .prism.log -.vscode _dev __pycache__ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b4b8d0ff516..1aa8e3f282a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.1.1" -} + ".": "5.0.0-beta.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 21a17687b3f..2dc0294f22e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,4 @@ -configured_endpoints: 1256 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-923d8c7667b68c786e6c026c4f4851798943c7d68ea055c0043d9253413c5847.yml +configured_endpoints: 2015 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-83f49bc3fa9273ef989d3e8bcd27f6fdaa7d04ae2519a91f4878f46acc501bb9.yml +openapi_spec_hash: 3f4be3af6f51eea4787dc8345f9ca9c1 +config_hash: 9d1829ed664bb3efa8638f98bb32cf46 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000000..5b01030785f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.analysis.importFormat": "relative", +} diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4dcb40087..13307919a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,652 @@ # Changelog +## 5.0.0-beta.1 (2026-02-13) + +Full Changelog: [v4.3.1...v5.0.0-beta.1](https://github.com/cloudflare/cloudflare-python/compare/v4.3.1...v5.0.0-beta.1) + +### Features + +* chore: IAC-312 update Pages models to ref renamed components ([1f77935](https://github.com/cloudflare/cloudflare-python/commit/1f7793527f61ab9d02cea60b1cb4acce4316c6dd)) +* chore: skip ai.tomarkdown prism tests ([42c44fb](https://github.com/cloudflare/cloudflare-python/commit/42c44fbe37f6f7aa6294c42e4fd8276682cf5f17)) +* chore: skip unsupported auth tests ([322d3f1](https://github.com/cloudflare/cloudflare-python/commit/322d3f12f4ccbbb0c7bac84ac9857b7170593fa5)) +* chore: use 'next' branch for go_sdk_version ([e311a42](https://github.com/cloudflare/cloudflare-python/commit/e311a428faedb698d15c2b898c9b0c65077f1158)) +* chore(abuse_report): unsupported auth scheme ([8b51de3](https://github.com/cloudflare/cloudflare-python/commit/8b51de36d9e5ce5d82bfbae12d0c46f9182c0544)) +* chore(abuse): rename path parameter ([dd0b6fb](https://github.com/cloudflare/cloudflare-python/commit/dd0b6fbd8042a4cde1625d945369b28d6e69bbb0)) +* docs: Deprecate API Shield Schema Validation resources ([40082c2](https://github.com/cloudflare/cloudflare-python/commit/40082c20665a01b760c0ad0057af417c6e942c01)) +* docs: WC-4152 Expose subdomain delete for workers ([fd04baa](https://github.com/cloudflare/cloudflare-python/commit/fd04baa03e03fe1601a0d3db991ddad1f4267f7d)) +* docs(zero_trust_gateway_policy): add /rules/tenants endpoint to Gateway API docs ([3c18fd3](https://github.com/cloudflare/cloudflare-python/commit/3c18fd307d5cf804eb9d68c8474d5ecc5f481a3e)) +* feat: add connectivity directory service APIs to openapi.stainless.yml ([fc06837](https://github.com/cloudflare/cloudflare-python/commit/fc06837d768b4291bbaa1d9a5e0d3303d0a82ba1)) +* feat: Add token validation to stainless config ([a1ddf7e](https://github.com/cloudflare/cloudflare-python/commit/a1ddf7ef6249fb36530a787bfa5987d1ce488e7f)) +* feat: DLP-3878 Switch DLP Predefined Profile endpoints ([43e4f93](https://github.com/cloudflare/cloudflare-python/commit/43e4f93b715142791c7fe39dd248e8592d978f34)) +* feat(abuse_reports): add abuse mitigations in Client API ([ce4789c](https://github.com/cloudflare/cloudflare-python/commit/ce4789cabe80d5833e3393fcd93c92d191c8d5f5)) +* feat(abuse_reports): Expose new abuse report endpoints. GET and LIST. ([b0fc29f](https://github.com/cloudflare/cloudflare-python/commit/b0fc29f708cd4c2fb4237dbe74959ff2b22dcac2)) +* feat(api): add AI Gateway Dynamic Routing endpoints ([db75dd8](https://github.com/cloudflare/cloudflare-python/commit/db75dd838142adbec3d22d28a111574dfd476a2b)) +* feat(api): add mcp portals endpoints ([70e068e](https://github.com/cloudflare/cloudflare-python/commit/70e068e9497013d0c8d8e7689ae87b3beafeeb46)) +* feat(api): RAG-395: add AI Search endpoints ([43a4557](https://github.com/cloudflare/cloudflare-python/commit/43a45575096e189de0cf3009fdd3caaf36fdd20f)) +* feat(api): RAG-586: enable terraform for AI Search instances and tokens ([f5c0d88](https://github.com/cloudflare/cloudflare-python/commit/f5c0d886a357bd3b5f8d565d0af62183edd5b0e2)) +* feat(d1): Add time travel `get_bookmark` and `restore` endpoints ([f2464a6](https://github.com/cloudflare/cloudflare-python/commit/f2464a663b082db061da32a6a50126095099e0bb)) +* feat(fraud): public docs for fraud API ([fd98170](https://github.com/cloudflare/cloudflare-python/commit/fd981700eda867a7bc37e087be5e68bb299963a3)) +* feat(iam): Add SSO Connectors resource to SDKs ([77960c9](https://github.com/cloudflare/cloudflare-python/commit/77960c9620d293937886791fb8c72b43abc1e19e)) +* feat(leaked_credentials_check): Add GET endpoint for leaked_credentials_check/detections ([2f1981a](https://github.com/cloudflare/cloudflare-python/commit/2f1981ab773104a1156e6d80b333274f955eb020)) +* feat(mcp_portals): enable sdks generation ([6965762](https://github.com/cloudflare/cloudflare-python/commit/69657624f4f9f83a41de3f4e927a047d798ca89e)) +* feat(pipelines): Configure SDKs/Terraform to use the new Pipelines, Streams, Sinks routes ([008556f](https://github.com/cloudflare/cloudflare-python/commit/008556f6aa27c2292c24c5ff368f37cce91e2e5b)) +* feat(r2_data_catalog): Configure SDKs/Terraform to use R2 Data Catalog routes ([385fea6](https://github.com/cloudflare/cloudflare-python/commit/385fea63a0a62eefe791920a946d0704c7c790db)) +* feat(radar): add BGP RPKI ASPA endpoints and fix SDK casings ([4146d0d](https://github.com/cloudflare/cloudflare-python/commit/4146d0dab88e791211bfd06c83129ebf8fc1835c)) +* feat(radar): add new group by dimension endpoints; deprecate to_markdown endpoint ([845fba2](https://github.com/cloudflare/cloudflare-python/commit/845fba278d6d58c6b4b8de8fa54d02efdc4dddee)) +* feat(silences): add a new alert silencing api ([1c555af](https://github.com/cloudflare/cloudflare-python/commit/1c555aff6759e40aeaf684ded92e51a2e4400345)) +* feat(tomarkdown): add new markdown supported endpoint ([6a4f824](https://github.com/cloudflare/cloudflare-python/commit/6a4f824f942f35cc8467cdaf950cfb2af4017949)) +* fix: Correctly reflect schema validation model <-> openapi mapping ([01fb118](https://github.com/cloudflare/cloudflare-python/commit/01fb1181dd1aedb409872013251a77912f00476b)) +* fix: move wvpc ([c357dad](https://github.com/cloudflare/cloudflare-python/commit/c357dadc80540a78f7505bc8f8dbcd2f1da69070)) +* fix: tabbing on realtime-kit api resources ([a4762dd](https://github.com/cloudflare/cloudflare-python/commit/a4762dd21ecf123322f80c7cba7f2caa5021efe2)) +* fix: unsupported auth scheme ([292a780](https://github.com/cloudflare/cloudflare-python/commit/292a7807015f76384abe88b86034bc5d1796a51b)) +* fix(ai_controls): incorrect use of standalone_api ([ebcb1d6](https://github.com/cloudflare/cloudflare-python/commit/ebcb1d6d9124a355b06ce80efb8869635bae5e3f)) +* fix(kv): use cursor_limit_pagination for KV list keys endpoint ([fc39041](https://github.com/cloudflare/cloudflare-python/commit/fc39041cfc7c93f3f063b2a016347e043d30a60c)) +* fix(total_tls): use upsert pattern for singleton zone setting ([f4f5156](https://github.com/cloudflare/cloudflare-python/commit/f4f51568c7bb95b99e92b5e867f98e4e96d4d538)) +* refactor(terraform): restructure origin_tls_client_auth to peer subresources ([00a2dec](https://github.com/cloudflare/cloudflare-python/commit/00a2decaebf66b8303de8d2c1e92c2f899d1d50e)) + + +### Bug Fixes + +* addressing issues in error handling for example script upload ([e3ea504](https://github.com/cloudflare/cloudflare-python/commit/e3ea504c648e1655b51d746fa7030df154d52c87)) +* lint ([b2cfe5e](https://github.com/cloudflare/cloudflare-python/commit/b2cfe5e773ebc2280795ad7e3ea3b5bac03891a2)) +* **types:** allow pyright to infer TypedDict types within SequenceNotStr ([5b81cac](https://github.com/cloudflare/cloudflare-python/commit/5b81cac7357d7699cd64425dc8ed983c3f5d6e21)) + + +### Chores + +* add missing docstrings ([f109470](https://github.com/cloudflare/cloudflare-python/commit/f1094708108fdc4fd20be9558da5a63791267746)) +* **api:** update composite API spec ([8f3ac3d](https://github.com/cloudflare/cloudflare-python/commit/8f3ac3d78abd667f0f513026ada715145db53d97)) +* **api:** update composite API spec ([f59a327](https://github.com/cloudflare/cloudflare-python/commit/f59a32729d5a0e3cc910bfbbce825365408d4f43)) +* **api:** update composite API spec ([44ae23e](https://github.com/cloudflare/cloudflare-python/commit/44ae23e668d8e78733e0c790d3cdfa5d0b828456)) +* **api:** update composite API spec ([2938b45](https://github.com/cloudflare/cloudflare-python/commit/2938b459e52c5fc3d3f90fbfbf7a25e86f2f8b4c)) +* **api:** update composite API spec ([63a5a9b](https://github.com/cloudflare/cloudflare-python/commit/63a5a9b8927addd36909719ef2c37f43592fc717)) +* **api:** update composite API spec ([3964451](https://github.com/cloudflare/cloudflare-python/commit/39644511ae930fe0654ed6c71367b2b2c0792690)) +* **api:** update composite API spec ([7c35696](https://github.com/cloudflare/cloudflare-python/commit/7c35696aacd53eda55f7afed449614dc9051607f)) +* **api:** update composite API spec ([ee266ad](https://github.com/cloudflare/cloudflare-python/commit/ee266ad2d14f1c00cc746e84bbe405cf2f71ffb9)) +* **api:** update composite API spec ([1cfeef4](https://github.com/cloudflare/cloudflare-python/commit/1cfeef43b5baea7c9e82341236049332e0cab369)) +* **api:** update composite API spec ([e4f787b](https://github.com/cloudflare/cloudflare-python/commit/e4f787b60357b0d9c91450378d6d8320effc8a68)) +* **api:** update composite API spec ([3b3e2d5](https://github.com/cloudflare/cloudflare-python/commit/3b3e2d5fe6f0f1b2f5be2e2ff2f25e2d59832a1a)) +* **api:** update composite API spec ([05e0e8a](https://github.com/cloudflare/cloudflare-python/commit/05e0e8a25f0c69e3f6475b70dd685886e4ff748a)) +* **api:** update composite API spec ([716ad5a](https://github.com/cloudflare/cloudflare-python/commit/716ad5a10b16be431dd4e7f086e2609f3ddf3287)) +* **api:** update composite API spec ([fdf3c53](https://github.com/cloudflare/cloudflare-python/commit/fdf3c53ebd686a638c148b594c40dbbc66878df6)) +* **api:** update composite API spec ([c5f5b46](https://github.com/cloudflare/cloudflare-python/commit/c5f5b4689841964444568309925a75f7d44a7106)) +* **api:** update composite API spec ([9468e7b](https://github.com/cloudflare/cloudflare-python/commit/9468e7b0127a3f42f699f9e8fa497883b5cbf667)) +* **api:** update composite API spec ([249fdaa](https://github.com/cloudflare/cloudflare-python/commit/249fdaabf3eccd032b4585a2d529319b624e7009)) +* **api:** update composite API spec ([19ae710](https://github.com/cloudflare/cloudflare-python/commit/19ae710f5a5be1fa2319377d6e311df8ac935b98)) +* **api:** update composite API spec ([9c3c799](https://github.com/cloudflare/cloudflare-python/commit/9c3c799f1ef7ebec5027205d2e975f1bb01331f4)) +* **api:** update composite API spec ([8462991](https://github.com/cloudflare/cloudflare-python/commit/84629915cdd6ed83dc4d4450701723e2cb227f15)) +* **api:** update composite API spec ([a1a9301](https://github.com/cloudflare/cloudflare-python/commit/a1a93016fb248072b68f97d2c6b5c2dc1a36f870)) +* **api:** update composite API spec ([7f435a6](https://github.com/cloudflare/cloudflare-python/commit/7f435a66ad6092c023bb9fa573ca7017b0732536)) +* **api:** update composite API spec ([76513bf](https://github.com/cloudflare/cloudflare-python/commit/76513bfd2cd1a14c2afb3a65f650e1a0edf2749e)) +* **api:** update composite API spec ([4540857](https://github.com/cloudflare/cloudflare-python/commit/4540857c66063e39e4629642d2b2917f40c73b20)) +* **api:** update composite API spec ([640eb58](https://github.com/cloudflare/cloudflare-python/commit/640eb586205bfd8bf88d515ede14028dc2f9fff9)) +* **api:** update composite API spec ([606e4de](https://github.com/cloudflare/cloudflare-python/commit/606e4de5f24a19a7e10fe8824319aa98fe439202)) +* **api:** update composite API spec ([be9579e](https://github.com/cloudflare/cloudflare-python/commit/be9579e6ec8271281f8497e67ec1f7ab76109b3c)) +* **api:** update composite API spec ([ef37bfc](https://github.com/cloudflare/cloudflare-python/commit/ef37bfc0eb3a5dd8f0bdb91d4e6bdf00f9a6b071)) +* **api:** update composite API spec ([f4cc575](https://github.com/cloudflare/cloudflare-python/commit/f4cc575aa429651cf7141fb47f542f1d8cab9a72)) +* **api:** update composite API spec ([0f87157](https://github.com/cloudflare/cloudflare-python/commit/0f8715705d70c0fe7f02f52ae605ce650486e6c5)) +* **api:** update composite API spec ([ac247ff](https://github.com/cloudflare/cloudflare-python/commit/ac247fffebbcbfff58ef6862247f2b72ff74c6f8)) +* **api:** update composite API spec ([3186483](https://github.com/cloudflare/cloudflare-python/commit/318648332d360503d6e0e1738d4ca87202535a96)) +* **api:** update composite API spec ([7464286](https://github.com/cloudflare/cloudflare-python/commit/7464286b3544db010af78b14ebec2e02609ddc75)) +* **api:** update composite API spec ([064478c](https://github.com/cloudflare/cloudflare-python/commit/064478cd35708cb0eb78b35abc5f4636bd514037)) +* **api:** update composite API spec ([a59d1b6](https://github.com/cloudflare/cloudflare-python/commit/a59d1b68755b777fc8a17018cb062d1a33db723a)) +* **api:** update composite API spec ([f5ca4cc](https://github.com/cloudflare/cloudflare-python/commit/f5ca4ccc70428b1e7614420defbde2a463091456)) +* **api:** update composite API spec ([622f384](https://github.com/cloudflare/cloudflare-python/commit/622f38474dcf9bd9e433189ac0e168c66dbebd7d)) +* **api:** update composite API spec ([64bc54f](https://github.com/cloudflare/cloudflare-python/commit/64bc54ff61983ffa129109dd013cf5bedd25d29d)) +* **api:** update composite API spec ([cb197df](https://github.com/cloudflare/cloudflare-python/commit/cb197dfe45ce225e6d441680e11260cb4c39d24f)) +* **api:** update composite API spec ([cd4f924](https://github.com/cloudflare/cloudflare-python/commit/cd4f924e73268c20f1af894dfd4707c8b18c955f)) +* **api:** update composite API spec ([4e9deac](https://github.com/cloudflare/cloudflare-python/commit/4e9deac8efe75518e113cc4d681929c5a1ae1d7d)) +* **api:** update composite API spec ([fee9ce0](https://github.com/cloudflare/cloudflare-python/commit/fee9ce09141ea3c314dfb6d746472e316e3b515d)) +* **api:** update composite API spec ([315c8eb](https://github.com/cloudflare/cloudflare-python/commit/315c8eb85a3f17299cd81a16ac092e4c85a012a5)) +* **api:** update composite API spec ([bb4311f](https://github.com/cloudflare/cloudflare-python/commit/bb4311fb705edab29746297b91f3478cd179afc8)) +* **api:** update composite API spec ([7e1d8b7](https://github.com/cloudflare/cloudflare-python/commit/7e1d8b72aff2b087f5e3a395a445573b74f0a2f7)) +* **api:** update composite API spec ([2cc2a3f](https://github.com/cloudflare/cloudflare-python/commit/2cc2a3fad9f2f1e9eeee0683a9cff9d330fd6357)) +* **api:** update composite API spec ([2cb9ef9](https://github.com/cloudflare/cloudflare-python/commit/2cb9ef9a29a81faff8fa34ee4e4edbe40f50d507)) +* **api:** update composite API spec ([7199aa3](https://github.com/cloudflare/cloudflare-python/commit/7199aa33f07a631aa066df6da6aa25a86bf3aca8)) +* **api:** update composite API spec ([46ce19f](https://github.com/cloudflare/cloudflare-python/commit/46ce19f5f170aa5b74c6071569666dd59186e3e9)) +* **api:** update composite API spec ([4900594](https://github.com/cloudflare/cloudflare-python/commit/49005943c184ab9f713e664434f05270ca97d619)) +* **api:** update composite API spec ([a009bd0](https://github.com/cloudflare/cloudflare-python/commit/a009bd0251a96e2eafee9411bbc669b82dfba342)) +* **api:** update composite API spec ([b07f0d6](https://github.com/cloudflare/cloudflare-python/commit/b07f0d6468e1cc1d8b5009b252b21a4d9bb0543d)) +* **api:** update composite API spec ([353e11e](https://github.com/cloudflare/cloudflare-python/commit/353e11eba442b1d75b1d42549abb26db9fe9f2c7)) +* **api:** update composite API spec ([b7c4b43](https://github.com/cloudflare/cloudflare-python/commit/b7c4b43635c91a1be5852d9542ca29362e80491b)) +* **api:** update composite API spec ([b8d1c66](https://github.com/cloudflare/cloudflare-python/commit/b8d1c661b9b34b6db72d65ef82db61494013b3ba)) +* **api:** update composite API spec ([93e3971](https://github.com/cloudflare/cloudflare-python/commit/93e39713d9e7d19cb67ec65a6fa9b5c9643d75ed)) +* **api:** update composite API spec ([3d5d0e0](https://github.com/cloudflare/cloudflare-python/commit/3d5d0e0407dec974128bcbf09d8c3b789b2dbcf6)) +* **api:** update composite API spec ([35670b1](https://github.com/cloudflare/cloudflare-python/commit/35670b1611cee8629a86f7e2795fac262dd3394f)) +* **api:** update composite API spec ([5fdf07b](https://github.com/cloudflare/cloudflare-python/commit/5fdf07be01036fb1c08e19f31c05ff995d75e01c)) +* **api:** update composite API spec ([2319591](https://github.com/cloudflare/cloudflare-python/commit/231959124ce85fd5cb6a2f639042459189f3626b)) +* **api:** update composite API spec ([3b70a95](https://github.com/cloudflare/cloudflare-python/commit/3b70a9544c85c451ba277875e1f6cb6188d866f3)) +* **api:** update composite API spec ([ea49058](https://github.com/cloudflare/cloudflare-python/commit/ea49058cc07ca8549b0b0e437af0bf80a92fc65a)) +* **api:** update composite API spec ([6734e9b](https://github.com/cloudflare/cloudflare-python/commit/6734e9ba95be37e8abf917e8e034a4fe8403017f)) +* **api:** update composite API spec ([5f5caef](https://github.com/cloudflare/cloudflare-python/commit/5f5caef1eed2c6a2c5cd80b77c2c7e01e19e57fc)) +* **api:** update composite API spec ([5d19869](https://github.com/cloudflare/cloudflare-python/commit/5d1986964f7344c79285a47c9bd4ae6928805ed5)) +* **api:** update composite API spec ([541c9fb](https://github.com/cloudflare/cloudflare-python/commit/541c9fb7974741641bcef74ba99f7b54f142e0b1)) +* **api:** update composite API spec ([ba5b5fc](https://github.com/cloudflare/cloudflare-python/commit/ba5b5fcd1936b0cadb189ba4c2c674dc6ec956e3)) +* **api:** update composite API spec ([7baa51c](https://github.com/cloudflare/cloudflare-python/commit/7baa51ccf00f66c8871156e674214504984dc066)) +* **api:** update composite API spec ([53d59f4](https://github.com/cloudflare/cloudflare-python/commit/53d59f439ba34edaf2628d89c2a1d7363693a38d)) +* **api:** update composite API spec ([25d603f](https://github.com/cloudflare/cloudflare-python/commit/25d603f8cb36473107bb739c1217a10becd82302)) +* **api:** update composite API spec ([9fd6645](https://github.com/cloudflare/cloudflare-python/commit/9fd66450b998a9b0bea72a8f3ac9fdcb26edd88a)) +* **api:** update composite API spec ([19d1d96](https://github.com/cloudflare/cloudflare-python/commit/19d1d96bae88d6af838574218fc09b541a94da81)) +* **api:** update composite API spec ([f9160a4](https://github.com/cloudflare/cloudflare-python/commit/f9160a47dec2c31bc7f591bc73bc9dff420d10f4)) +* **docs:** use environment variables for authentication in code snippets ([0d829a6](https://github.com/cloudflare/cloudflare-python/commit/0d829a65a46827fe7a69d0efc60af031791887f8)) +* fix inconsequential lint errors ([bf1eac9](https://github.com/cloudflare/cloudflare-python/commit/bf1eac94295240daa425636c03dbbb8ce46c4d52)) +* fix more inconsequential lint errors ([f280942](https://github.com/cloudflare/cloudflare-python/commit/f280942f4c95010c8387d5bff9c05de57ee293a6)) +* **internal:** codegen related update ([0bd5559](https://github.com/cloudflare/cloudflare-python/commit/0bd5559954615d6ef7b18b265af44c27b25988d3)) +* **internal:** codegen related update ([6e5b66f](https://github.com/cloudflare/cloudflare-python/commit/6e5b66f26b600dc345b0579264945fc3311f5269)) +* **internal:** codegen related update ([9fcecd5](https://github.com/cloudflare/cloudflare-python/commit/9fcecd5e59f6b2527c5bd3da7415929f12db34fb)) +* update lockfile ([bd43151](https://github.com/cloudflare/cloudflare-python/commit/bd431513e51b82bff2949adde8d5c1fbfd3cda81)) + + +### Documentation + +* add v5 migration guide ([9cf7252](https://github.com/cloudflare/cloudflare-python/commit/9cf725244aca719d2b130be1288341ab37085e84)) + +## 4.3.1 (2025-06-16) + +Full Changelog: [v4.3.0...v4.3.1](https://github.com/cloudflare/cloudflare-python/compare/v4.3.0...v4.3.1) + +### Bug Fixes + +* **api:** Update zone subscription paths ([8917497](https://github.com/cloudflare/cloudflare-python/commit/8917497520e4a1fcc97681685175ab4107e3041c)) + + +### Chores + +* **internal:** update conftest.py ([c8ae1c4](https://github.com/cloudflare/cloudflare-python/commit/c8ae1c4a73cc8d5804dfcfb059b102eb2443ca86)) + +## 4.3.0 (2025-06-16) + +Full Changelog: [v4.2.0...v4.3.0](https://github.com/cloudflare/cloudflare-python/compare/v4.2.0...v4.3.0) + +### Features + +* **api:** Add IAM User Groups and AutoRAG ([1cc4487](https://github.com/cloudflare/cloudflare-python/commit/1cc44875013c4f6e1b7629469972ddd130a4c244)) +* **api:** Add new bulk deletion endpoint for ZT infra targets ([a5f7dc7](https://github.com/cloudflare/cloudflare-python/commit/a5f7dc7757ea94f17f8bed472fb7671d369ae6e1)) +* **api:** api update ([eed581b](https://github.com/cloudflare/cloudflare-python/commit/eed581b90816807ee25b70fbe028f2dd9360b50b)) +* **api:** api update ([98fee4a](https://github.com/cloudflare/cloudflare-python/commit/98fee4a2925e1894d3c87836ce63f22b0772f2d6)) +* **api:** api update ([5b9ca58](https://github.com/cloudflare/cloudflare-python/commit/5b9ca588f552a6853f607f5162fcf025e577cc07)) +* **api:** api update ([5824050](https://github.com/cloudflare/cloudflare-python/commit/5824050255ae3685193082ac8eda5e705b1246b3)) +* **api:** api update ([666946a](https://github.com/cloudflare/cloudflare-python/commit/666946a5de14a0f79fec282673b994156f4b7ad4)) +* **api:** api update ([bde7bba](https://github.com/cloudflare/cloudflare-python/commit/bde7bba347aa677babad2c52ff37183a0ccb47a1)) +* **api:** api update ([638a408](https://github.com/cloudflare/cloudflare-python/commit/638a408467ca214e6210c0760fed7f886ef33f1d)) +* **api:** api update ([e8a25d6](https://github.com/cloudflare/cloudflare-python/commit/e8a25d6857ddc301eccf70a4ff8728d2d8295d06)) +* **api:** api update ([c6a8e46](https://github.com/cloudflare/cloudflare-python/commit/c6a8e46d6ab1b59728e97ed2e14ae7ed97d943bf)) +* **api:** api update ([dcfb003](https://github.com/cloudflare/cloudflare-python/commit/dcfb0036e671ef9c492619003589a6bff1ed993a)) +* **api:** api update ([c81d4ce](https://github.com/cloudflare/cloudflare-python/commit/c81d4cefa72e8e53e51f7b1e61f4ed4d101642bb)) +* **api:** api update ([ad5aa87](https://github.com/cloudflare/cloudflare-python/commit/ad5aa879fdb1532745d8581d09ccdd3023486173)) +* **api:** api update ([f0bc6f2](https://github.com/cloudflare/cloudflare-python/commit/f0bc6f2c1cc3cc716e61fe9af0600ce263f198b2)) +* **api:** api update ([ff06097](https://github.com/cloudflare/cloudflare-python/commit/ff06097767b46ce05ce5b3fd6ce262c28338f08a)) +* **api:** api update ([3cd208b](https://github.com/cloudflare/cloudflare-python/commit/3cd208b548b9c17b512998367c6c899007bd47f7)) +* **api:** api update ([694e7bd](https://github.com/cloudflare/cloudflare-python/commit/694e7bdd1981b22ee7b0ddde79b0f2116585969a)) +* **api:** api update ([63e9021](https://github.com/cloudflare/cloudflare-python/commit/63e9021ee79001b4c44d45cd0d56bd5270dc7409)) +* **api:** api update ([784cbd8](https://github.com/cloudflare/cloudflare-python/commit/784cbd8a41b2899ea033f263795429821be9c367)) +* **api:** api update ([c73f7da](https://github.com/cloudflare/cloudflare-python/commit/c73f7da0b97f7e3010dcd3bdc7df62f86f025b1c)) +* **api:** api update ([1239774](https://github.com/cloudflare/cloudflare-python/commit/1239774eaeb2c3f7cc6fd283183ac5d16f196f22)) +* **api:** api update ([70c6acb](https://github.com/cloudflare/cloudflare-python/commit/70c6acb46d69e637339c946cd22d8cacc52a26cb)) +* **api:** api update ([f430026](https://github.com/cloudflare/cloudflare-python/commit/f430026e5b88c6291a5947847d353b01b57ef118)) +* **api:** api update ([69d5705](https://github.com/cloudflare/cloudflare-python/commit/69d570549353c3103a925843e9e48918e39e270c)) +* **api:** api update ([953ea46](https://github.com/cloudflare/cloudflare-python/commit/953ea469bc86a43620d460e94ca1fb2c7ced5d3f)) +* **api:** api update ([ef0e953](https://github.com/cloudflare/cloudflare-python/commit/ef0e95365dae02d85d8fc62c1d68d43450c883e2)) +* **api:** api update ([677bc09](https://github.com/cloudflare/cloudflare-python/commit/677bc09c92b3d955a4703d09a8efc60cd6291c09)) +* **api:** api update ([1c06a6b](https://github.com/cloudflare/cloudflare-python/commit/1c06a6b21e1813f9721a842bbf66940fd14210d4)) +* **api:** api update ([ad75922](https://github.com/cloudflare/cloudflare-python/commit/ad75922803ada5f04c2495989a5cb8d9c371abac)) +* **api:** api update ([6fa8c01](https://github.com/cloudflare/cloudflare-python/commit/6fa8c01474d353c1f83436e54224e481b1106396)) +* **api:** api update ([e0fa8ba](https://github.com/cloudflare/cloudflare-python/commit/e0fa8ba5d60f7960fb626a52c20fd3a5b05ca2cc)) +* **api:** api update ([7ec9f75](https://github.com/cloudflare/cloudflare-python/commit/7ec9f75255ac5406c76af5d477c870f97e6522d8)) +* **api:** fix account ID types ([41069fe](https://github.com/cloudflare/cloudflare-python/commit/41069fe111a574d243f63137e8e8670ca2a1b093)) +* **client:** add follow_redirects request option ([88ec221](https://github.com/cloudflare/cloudflare-python/commit/88ec22171086bd1b87514daec0df62a0dcd01012)) +* **infrastructure_targets:** swap DELETE handler to new endpoint ([eb08f59](https://github.com/cloudflare/cloudflare-python/commit/eb08f599d6788bbba580129605a31256bb1ba1df)) + + +### Bug Fixes + +* add back kv.namespaces bulk methods ([5d271a4](https://github.com/cloudflare/cloudflare-python/commit/5d271a4267343bc82c45dc60635cd28ca30ebf98)) +* add missing properties ([5777e78](https://github.com/cloudflare/cloudflare-python/commit/5777e787d63491587c4eaf512e738cf49f5e70e5)) +* **AI:** Add explicit variant names for union types ([332065c](https://github.com/cloudflare/cloudflare-python/commit/332065cd40e8809b82dc5d3c2d998d1f752546e3)) +* **api:** 'name' and 'type' are required on dns_record ([d4795c5](https://github.com/cloudflare/cloudflare-python/commit/d4795c5d22c7b8ea28c3e9c1b6dcef59ac7285c2)) +* **client:** correctly parse binary response | stream ([fceaf95](https://github.com/cloudflare/cloudflare-python/commit/fceaf952e4f834bec6dffe0c4d6a9a40952096a0)) +* **config:** Diagnostic errors ([cb5769e](https://github.com/cloudflare/cloudflare-python/commit/cb5769e1395544547519f05995636b6e6001c414)) +* **DLP:** Add explicit variant names ([490c4a7](https://github.com/cloudflare/cloudflare-python/commit/490c4a7cf1367d011e590ce7132132a96ad539ab)) +* **docs/api:** remove references to nonexistent types ([e78bbed](https://github.com/cloudflare/cloudflare-python/commit/e78bbede6d92c10cd8de5df976a14d0a9de9ed07)) +* **workers:** correctly use multipart while uploading scripts ([#2661](https://github.com/cloudflare/cloudflare-python/issues/2661)) ([756dc87](https://github.com/cloudflare/cloudflare-python/commit/756dc87dde3a42c8d4c860ff2239c920c22014ec)) + + +### Chores + +* **api:** Fix edge IPs variant names ([fa43851](https://github.com/cloudflare/cloudflare-python/commit/fa43851595ab2ce4556e292ab1009dc57a6d90cb)) +* **api:** mark some methods as deprecated ([cc53052](https://github.com/cloudflare/cloudflare-python/commit/cc53052ce07fd4ae796ba897f143bbc76c4a5fc5)) +* **docs:** remove reference to rye shell ([8781542](https://github.com/cloudflare/cloudflare-python/commit/87815427341c4418c2458d31df8c290671fbacf6)) +* **docs:** remove unnecessary param examples ([07f3fd3](https://github.com/cloudflare/cloudflare-python/commit/07f3fd366edd14d22327fa351140df6561acc777)) +* **internal:** codegen related update ([09930a5](https://github.com/cloudflare/cloudflare-python/commit/09930a5ad4c577f26c2832697b95988969d8fba8)) +* **internal:** codegen related update ([5fdf1d6](https://github.com/cloudflare/cloudflare-python/commit/5fdf1d676b8ae8d13c20fa0044432326737fbd0d)) +* **tests:** add tests for httpx client instantiation & proxies ([0291352](https://github.com/cloudflare/cloudflare-python/commit/0291352a035c150268b15424dedb9127d1833d71)) +* **tests:** run tests in parallel ([cc4533e](https://github.com/cloudflare/cloudflare-python/commit/cc4533e3550032e8eecea3140411d7ff05ff9420)) + +## 4.2.0 (2025-05-21) + +Full Changelog: [v4.1.0...v4.2.0](https://github.com/cloudflare/cloudflare-python/compare/v4.1.0...v4.2.0) + +### Features + +* **access_settings:** add CRUD support ([5c405ce](https://github.com/cloudflare/cloudflare-python/commit/5c405cef8664b45d6d85b3676db276e5712469b9)) +* **api:** api update ([136a09b](https://github.com/cloudflare/cloudflare-python/commit/136a09be1f37d68344d02613e5c7ff1f50652edc)) +* **api:** api update ([607deba](https://github.com/cloudflare/cloudflare-python/commit/607deba07aa95ad3085e1ecac99fc2421c0898e8)) +* **api:** api update ([3a38efd](https://github.com/cloudflare/cloudflare-python/commit/3a38efda7b6d24ccb30a4809978f8c49db379aee)) +* **api:** api update ([19c0409](https://github.com/cloudflare/cloudflare-python/commit/19c0409fbe8a77a61e69bbd7964169681b59bb07)) +* **api:** api update ([3632e3d](https://github.com/cloudflare/cloudflare-python/commit/3632e3d656c1eda0c90987092087b64a9c18aba6)) +* **api:** api update ([4ed10d9](https://github.com/cloudflare/cloudflare-python/commit/4ed10d942594c33d4359616f782a4198934b190f)) +* **api:** api update ([542b143](https://github.com/cloudflare/cloudflare-python/commit/542b143d19eea09701796ca862dcefb790542f2e)) +* **api:** api update ([26e2711](https://github.com/cloudflare/cloudflare-python/commit/26e271148bea672aae2424afa34d1bbe05d5586b)) +* **api:** api update ([91316ee](https://github.com/cloudflare/cloudflare-python/commit/91316eea8a9d0a4780c65ad1680de3f357113d62)) +* **api:** api update ([bc7133d](https://github.com/cloudflare/cloudflare-python/commit/bc7133dd7f5fe6845d885e7e6727bfe6682ea441)) +* **api:** api update ([bb4bd21](https://github.com/cloudflare/cloudflare-python/commit/bb4bd218a1ae33d9dc4aea68975570a9c4255db0)) +* **api:** api update ([2914707](https://github.com/cloudflare/cloudflare-python/commit/29147073fa048ad2758fb72f6190ef8b7cb0b7e7)) +* **api:** api update ([03e79c1](https://github.com/cloudflare/cloudflare-python/commit/03e79c10da77b35afe7915ccb9eb560339841cae)) +* **api:** api update ([edfddf3](https://github.com/cloudflare/cloudflare-python/commit/edfddf31cf1cbc233e90341c3786bbcd873a72ea)) +* **api:** api update ([be32215](https://github.com/cloudflare/cloudflare-python/commit/be32215fc9f229ae6f61ab072bb4ebb3de4109f7)) +* **api:** api update ([5901900](https://github.com/cloudflare/cloudflare-python/commit/59019001da4fe85b326000e37df0e5cb61375945)) +* **api:** api update ([ba166b3](https://github.com/cloudflare/cloudflare-python/commit/ba166b369840ade49924dff938115976e3867a5c)) +* **api:** api update ([d487232](https://github.com/cloudflare/cloudflare-python/commit/d487232e264c310345b3ea85822e550af252c0a4)) +* **api:** api update ([17cb705](https://github.com/cloudflare/cloudflare-python/commit/17cb705744d081357d5f9c418ec3dfb45df60110)) +* **api:** api update ([5ad6267](https://github.com/cloudflare/cloudflare-python/commit/5ad6267fc27d8b5bdba1b5dc570528517ab58b9f)) +* **api:** api update ([f5d07b9](https://github.com/cloudflare/cloudflare-python/commit/f5d07b9dc10febfd488f5955b750820681b6ca33)) +* **api:** api update ([ef764d4](https://github.com/cloudflare/cloudflare-python/commit/ef764d481e5d0f305e887218feb8ccbcdfe2d220)) +* **api:** api update ([f381a98](https://github.com/cloudflare/cloudflare-python/commit/f381a9801f7adedb2738da815b891db8dcd3d26a)) +* **api:** api update ([a45728a](https://github.com/cloudflare/cloudflare-python/commit/a45728adfa9f6048f93f97fe99c63fae8e2847d3)) +* **api:** api update ([4f2fe11](https://github.com/cloudflare/cloudflare-python/commit/4f2fe11cd2be909af128e9d1d8278a96ff4a9456)) +* **api:** api update ([7e458e7](https://github.com/cloudflare/cloudflare-python/commit/7e458e7669fb07b0987b7253ef7e010a52164e90)) +* **api:** api update ([07074f1](https://github.com/cloudflare/cloudflare-python/commit/07074f15880e4ad944381ee7556740d34cb4de4d)) +* **api:** api update ([04834e7](https://github.com/cloudflare/cloudflare-python/commit/04834e7b5f2c48f81df53ae502d57de5846b2fd0)) +* **api:** api update ([ecc0b17](https://github.com/cloudflare/cloudflare-python/commit/ecc0b17e46459f45715591ab8a9c42fa53f58ae5)) +* **api:** api update ([6750cf3](https://github.com/cloudflare/cloudflare-python/commit/6750cf364f95deae9cbfcf7755a5f470d11d82fb)) +* **api:** api update ([0b00d97](https://github.com/cloudflare/cloudflare-python/commit/0b00d971c8df169d5c3985a70bd05f345339adea)) +* **api:** api update ([0e950d6](https://github.com/cloudflare/cloudflare-python/commit/0e950d65a750fb3741d8728c980e804d658c0306)) +* **api:** api update ([23d7f1c](https://github.com/cloudflare/cloudflare-python/commit/23d7f1ca8fda9c31fb1a5ce80ca815d01752e3d7)) +* **api:** api update ([0c6f4a1](https://github.com/cloudflare/cloudflare-python/commit/0c6f4a1c252af1b1da345bea53d0d85939950b23)) +* **api:** api update ([20295df](https://github.com/cloudflare/cloudflare-python/commit/20295df8880c0b22da4ba89d845fcb3d99490021)) +* **api:** api update ([ba2b47a](https://github.com/cloudflare/cloudflare-python/commit/ba2b47ac123e37d4043fe2d74a510ad3202bac7f)) +* **api:** api update ([676ac08](https://github.com/cloudflare/cloudflare-python/commit/676ac089f6b52fc9d26785684e88b74ae74dceb9)) +* **api:** api update ([9ca549e](https://github.com/cloudflare/cloudflare-python/commit/9ca549e242e8e5f537b951c4c24189491928e9f4)) +* **api:** api update ([71efbfa](https://github.com/cloudflare/cloudflare-python/commit/71efbfaf56891305d123d4078f48101fb0c608fe)) +* **api:** api update ([af68ef6](https://github.com/cloudflare/cloudflare-python/commit/af68ef6ac477d9305391318ea5e033f6e111c00e)) +* **api:** api update ([e749879](https://github.com/cloudflare/cloudflare-python/commit/e749879ab0abb0e2383c07efb2f0f546682d9ce7)) +* **api:** manual updates ([6fa22ed](https://github.com/cloudflare/cloudflare-python/commit/6fa22edc2ef43217056a5b0675753cb2341554aa)) +* **api:** manual updates ([e4d4ff5](https://github.com/cloudflare/cloudflare-python/commit/e4d4ff5267aade48da6bddfece3b6d52fb473c26)) +* **api:** update path placeholders ([d2d1c24](https://github.com/cloudflare/cloudflare-python/commit/d2d1c246d0c650e565057f1b98c40054aa693f12)) +* **device_settings:** swap list to get endpoint ([977d5c7](https://github.com/cloudflare/cloudflare-python/commit/977d5c72013c3c55bc235512ec619f90efa7bfc2)) +* **schema_validation:** add mapped endpoints ([7b3a51b](https://github.com/cloudflare/cloudflare-python/commit/7b3a51bc157feccbaee5b22dff61469849bcbf3f)) +* **threat_events:** add list support ([4beeff9](https://github.com/cloudflare/cloudflare-python/commit/4beeff9c87058ce7cb972b2f3826d127775d21eb)) + + +### Bug Fixes + +* **api:** fix path placeholders ([c8a0db8](https://github.com/cloudflare/cloudflare-python/commit/c8a0db8796322dc391619b9a76c8ce3f551eba2a)) +* **client:** fix bug in Python SDK when subresource has the same name as its parent ([c18a098](https://github.com/cloudflare/cloudflare-python/commit/c18a098640fd597a1fc12db31b40b923dc89101a)) +* **package:** support direct resource imports ([7e46269](https://github.com/cloudflare/cloudflare-python/commit/7e4626961b5c2a425cdee53a2062dcc1fe14f7cd)) +* **urlscanner:** don't unwwrap scan response ([5fe7ea9](https://github.com/cloudflare/cloudflare-python/commit/5fe7ea9b5b31ace57ed670a65c4b276fba5eee18)) + + +### Chores + +* **ci:** fix installation instructions ([a9bc47f](https://github.com/cloudflare/cloudflare-python/commit/a9bc47fb44bcaf750eb579c327f6a86bf18c6395)) +* **ci:** upload sdks to package manager ([c8af26d](https://github.com/cloudflare/cloudflare-python/commit/c8af26d72d6e0c48acdd9518c42fbfb28809dd45)) +* **internal:** avoid errors for isinstance checks on proxies ([7b734a1](https://github.com/cloudflare/cloudflare-python/commit/7b734a186d2ca69066a75956fcc47ccbe02df0b1)) +* **internal:** codegen related update ([b1fdd11](https://github.com/cloudflare/cloudflare-python/commit/b1fdd1187e9179cb3fd7c92779140d9b6bdc08fd)) + +## 4.1.0 (2025-03-18) + +Full Changelog: [v4.0.0...v4.1.0](https://github.com/cloudflare/cloudflare-python/compare/v4.0.0...v4.1.0) + +### Features + +* **ai_gateway:** add urls support ([#2539](https://github.com/cloudflare/cloudflare-python/issues/2539)) ([650366e](https://github.com/cloudflare/cloudflare-python/commit/650366eb7f562d7ff3f9cdcdc713a0dac4eef742)) +* **api:** api update ([#2472](https://github.com/cloudflare/cloudflare-python/issues/2472)) ([6b81c50](https://github.com/cloudflare/cloudflare-python/commit/6b81c502a95ebe8973614434039e87fbf7c59bcb)) +* **api:** api update ([#2473](https://github.com/cloudflare/cloudflare-python/issues/2473)) ([eb8ac49](https://github.com/cloudflare/cloudflare-python/commit/eb8ac49d7eed6aa5c5a6ff45aaa8b582013976ea)) +* **api:** api update ([#2474](https://github.com/cloudflare/cloudflare-python/issues/2474)) ([f7a03e2](https://github.com/cloudflare/cloudflare-python/commit/f7a03e224765a2162b5f74ab8ea36eef76fa7237)) +* **api:** api update ([#2476](https://github.com/cloudflare/cloudflare-python/issues/2476)) ([48bdd22](https://github.com/cloudflare/cloudflare-python/commit/48bdd220c6b7ab8ea54853cf6ef7862de9e89e56)) +* **api:** api update ([#2477](https://github.com/cloudflare/cloudflare-python/issues/2477)) ([da2ce0d](https://github.com/cloudflare/cloudflare-python/commit/da2ce0dcaf3806da245f6a9b040d8b5d17d992d3)) +* **api:** api update ([#2478](https://github.com/cloudflare/cloudflare-python/issues/2478)) ([94e997a](https://github.com/cloudflare/cloudflare-python/commit/94e997ac4f6ccf4eeb97726f67139790b6477a95)) +* **api:** api update ([#2479](https://github.com/cloudflare/cloudflare-python/issues/2479)) ([b49f05d](https://github.com/cloudflare/cloudflare-python/commit/b49f05d2186c4166171570236b639f7e77aabd2e)) +* **api:** api update ([#2480](https://github.com/cloudflare/cloudflare-python/issues/2480)) ([b27f1bb](https://github.com/cloudflare/cloudflare-python/commit/b27f1bbc27264c0fe8ee683052e0b698deb91a58)) +* **api:** api update ([#2489](https://github.com/cloudflare/cloudflare-python/issues/2489)) ([7f6d335](https://github.com/cloudflare/cloudflare-python/commit/7f6d33530f1cec482662ad53611ef62d63bcad25)) +* **api:** api update ([#2492](https://github.com/cloudflare/cloudflare-python/issues/2492)) ([12d3ff5](https://github.com/cloudflare/cloudflare-python/commit/12d3ff52795e5da6c30f90ce659f8d4d0bacab18)) +* **api:** api update ([#2493](https://github.com/cloudflare/cloudflare-python/issues/2493)) ([9061b65](https://github.com/cloudflare/cloudflare-python/commit/9061b659bcae3340e18e75eb8178e654a39361a0)) +* **api:** api update ([#2495](https://github.com/cloudflare/cloudflare-python/issues/2495)) ([28d11c6](https://github.com/cloudflare/cloudflare-python/commit/28d11c6027d2ff4546b4f48f929a1140da015740)) +* **api:** api update ([#2496](https://github.com/cloudflare/cloudflare-python/issues/2496)) ([538f71d](https://github.com/cloudflare/cloudflare-python/commit/538f71df81d2181e7724a73b86c181ce3f9b479d)) +* **api:** api update ([#2497](https://github.com/cloudflare/cloudflare-python/issues/2497)) ([e826a02](https://github.com/cloudflare/cloudflare-python/commit/e826a024ab9bad3105cde190ab1e8717ebda80bb)) +* **api:** api update ([#2500](https://github.com/cloudflare/cloudflare-python/issues/2500)) ([b8f02a0](https://github.com/cloudflare/cloudflare-python/commit/b8f02a087be93011eb24532eea5a4c5c0c61dbd1)) +* **api:** api update ([#2501](https://github.com/cloudflare/cloudflare-python/issues/2501)) ([b8b3891](https://github.com/cloudflare/cloudflare-python/commit/b8b3891a42db6f5a1631ceddf5ab581d224e0b40)) +* **api:** api update ([#2502](https://github.com/cloudflare/cloudflare-python/issues/2502)) ([345ac45](https://github.com/cloudflare/cloudflare-python/commit/345ac45b5700bc3d80005c61d716792e39fa4c99)) +* **api:** api update ([#2503](https://github.com/cloudflare/cloudflare-python/issues/2503)) ([80fdb8f](https://github.com/cloudflare/cloudflare-python/commit/80fdb8f78726e093afbfb6e966df4a5b74ded3c9)) +* **api:** api update ([#2516](https://github.com/cloudflare/cloudflare-python/issues/2516)) ([b6adc14](https://github.com/cloudflare/cloudflare-python/commit/b6adc142da1c6f6693c6c41ff3fde485aedd588d)) +* **api:** api update ([#2517](https://github.com/cloudflare/cloudflare-python/issues/2517)) ([401b717](https://github.com/cloudflare/cloudflare-python/commit/401b717505df1746f6ffbbf7f111e7c93e6fae4a)) +* **api:** api update ([#2518](https://github.com/cloudflare/cloudflare-python/issues/2518)) ([e1a2474](https://github.com/cloudflare/cloudflare-python/commit/e1a2474555a21af53b67e13be76d4c99dfbe4814)) +* **api:** api update ([#2520](https://github.com/cloudflare/cloudflare-python/issues/2520)) ([151a44a](https://github.com/cloudflare/cloudflare-python/commit/151a44a584d21d4acbf2459513c585ef937eb984)) +* **api:** api update ([#2522](https://github.com/cloudflare/cloudflare-python/issues/2522)) ([fc6d9d6](https://github.com/cloudflare/cloudflare-python/commit/fc6d9d6359390476e531499034ab114baeb1bcfe)) +* **api:** api update ([#2523](https://github.com/cloudflare/cloudflare-python/issues/2523)) ([43ebeee](https://github.com/cloudflare/cloudflare-python/commit/43ebeee56dea63a55d23665e70ae2a0391d9e66b)) +* **api:** api update ([#2528](https://github.com/cloudflare/cloudflare-python/issues/2528)) ([cc14467](https://github.com/cloudflare/cloudflare-python/commit/cc14467fce380ffe7d1baddb678415b319d48e22)) +* **api:** api update ([#2530](https://github.com/cloudflare/cloudflare-python/issues/2530)) ([4def3c7](https://github.com/cloudflare/cloudflare-python/commit/4def3c7bb1f0fa1189fb0d0e644f54e6453f27ad)) +* **api:** api update ([#2531](https://github.com/cloudflare/cloudflare-python/issues/2531)) ([4aef71e](https://github.com/cloudflare/cloudflare-python/commit/4aef71e490884d29a3e3d8f5cdd97101a464bc3b)) +* **api:** api update ([#2533](https://github.com/cloudflare/cloudflare-python/issues/2533)) ([d231762](https://github.com/cloudflare/cloudflare-python/commit/d23176293003e4788c907ff0417f5470aaa4a31b)) +* **api:** api update ([#2534](https://github.com/cloudflare/cloudflare-python/issues/2534)) ([6bae2c2](https://github.com/cloudflare/cloudflare-python/commit/6bae2c2223a2047270110c8d1cd934e69ef306a9)) +* **api:** api update ([#2535](https://github.com/cloudflare/cloudflare-python/issues/2535)) ([d3821d2](https://github.com/cloudflare/cloudflare-python/commit/d3821d225922bf8bae3484c498e440d4e90dc194)) +* **api:** api update ([#2537](https://github.com/cloudflare/cloudflare-python/issues/2537)) ([7cace87](https://github.com/cloudflare/cloudflare-python/commit/7cace874090689ada3ea6b099e7f304e6b7da6a1)) +* **api:** api update ([#2544](https://github.com/cloudflare/cloudflare-python/issues/2544)) ([7ea429d](https://github.com/cloudflare/cloudflare-python/commit/7ea429d47d7741d1062eded3374c25f6f5965868)) +* **api:** api update ([#2547](https://github.com/cloudflare/cloudflare-python/issues/2547)) ([7b0ce60](https://github.com/cloudflare/cloudflare-python/commit/7b0ce60f9a2ea2b7b7560cbc7da733247f31d63b)) +* **api:** api update ([#2549](https://github.com/cloudflare/cloudflare-python/issues/2549)) ([aca2b76](https://github.com/cloudflare/cloudflare-python/commit/aca2b76e0daa7bef7936aee794b9cbf173ac4e4d)) +* **api:** manual updates ([#2491](https://github.com/cloudflare/cloudflare-python/issues/2491)) ([e93ce12](https://github.com/cloudflare/cloudflare-python/commit/e93ce12a62dc48376a2fafba968a2eeff7f83345)) +* **api:** manual updates ([#2513](https://github.com/cloudflare/cloudflare-python/issues/2513)) ([71e522b](https://github.com/cloudflare/cloudflare-python/commit/71e522b756012338f5909c2644b18c62b430cc0f)) +* **api:** manual updates ([#2526](https://github.com/cloudflare/cloudflare-python/issues/2526)) ([f0b7af9](https://github.com/cloudflare/cloudflare-python/commit/f0b7af9d7cbad933520d3e50657d4762c2ca156d)) +* **api:** manual updates ([#2527](https://github.com/cloudflare/cloudflare-python/issues/2527)) ([aa892cc](https://github.com/cloudflare/cloudflare-python/commit/aa892cc55f7fb177521c2b2010bf760a9975c7cd)) +* **api:** rename browsing_rendering to browser_rendering ([#2488](https://github.com/cloudflare/cloudflare-python/issues/2488)) ([6b3425f](https://github.com/cloudflare/cloudflare-python/commit/6b3425fe978466d1536f77212c4ac36c93aa6105)) +* **browser_rendering:** move methods to top level ([#2490](https://github.com/cloudflare/cloudflare-python/issues/2490)) ([19e4cb0](https://github.com/cloudflare/cloudflare-python/commit/19e4cb01cff0811129fbac3e0f474f04532be483)) +* **browsing_rendering:** add support for subresources ([#2484](https://github.com/cloudflare/cloudflare-python/issues/2484)) ([6739a41](https://github.com/cloudflare/cloudflare-python/commit/6739a4123bcf82fe58143ac51e69f590be8c1822)) +* **cloudforce_one:** fix scans model ([#2504](https://github.com/cloudflare/cloudflare-python/issues/2504)) ([23e94c9](https://github.com/cloudflare/cloudflare-python/commit/23e94c9ee7ae82bc2931d077874a9a17dd8bfec3)) +* **dns_settings:** fix hierarchy ([#2514](https://github.com/cloudflare/cloudflare-python/issues/2514)) ([a95d254](https://github.com/cloudflare/cloudflare-python/commit/a95d254cf22932f9f22e3e27171ae7efe35e6abd)) +* **dns:** split account and zone DNS settings ([#2507](https://github.com/cloudflare/cloudflare-python/issues/2507)) ([6a80948](https://github.com/cloudflare/cloudflare-python/commit/6a809488ff2fd32ef13ad1dc37c1d9a052b79b98)) +* **internal:** group browser rendering ([#2508](https://github.com/cloudflare/cloudflare-python/issues/2508)) ([349e280](https://github.com/cloudflare/cloudflare-python/commit/349e280cd359544242e6c78cacce97f437cf9125)) +* **magic_cloud_networking:** add endpoint mappings ([#2550](https://github.com/cloudflare/cloudflare-python/issues/2550)) ([f0a6a21](https://github.com/cloudflare/cloudflare-python/commit/f0a6a21ceb592b32ea1079abfd42278f1da3d392)) +* **radar:** add compromised credential endpoints ([#2552](https://github.com/cloudflare/cloudflare-python/issues/2552)) ([99c9845](https://github.com/cloudflare/cloudflare-python/commit/99c9845e2548528a5ea0fc1099d3b5c39a165dae)) +* **radar:** add DNS endpoint ([#2487](https://github.com/cloudflare/cloudflare-python/issues/2487)) ([a5d4c51](https://github.com/cloudflare/cloudflare-python/commit/a5d4c51312ec12691f9fa4aa1e5ff3721d927d0a)) +* **threat_events:** fix create endpoint ([#2532](https://github.com/cloudflare/cloudflare-python/issues/2532)) ([0a45fe8](https://github.com/cloudflare/cloudflare-python/commit/0a45fe8002fa64e2dda4fb7e91badb43e0436bcc)) +* **threat_events:** shuffle endpoints from POST => PATCH ([#2525](https://github.com/cloudflare/cloudflare-python/issues/2525)) ([dc037a9](https://github.com/cloudflare/cloudflare-python/commit/dc037a9b9385fc979e11f64e5b576bef3d2a2d0a)) +* **vpc_flows:** add token support ([#2485](https://github.com/cloudflare/cloudflare-python/issues/2485)) ([904614f](https://github.com/cloudflare/cloudflare-python/commit/904614f85526fa63f3eee05532f6285c2c5d0cdd)) +* **waiting_rooms:** add account level list API ([#2524](https://github.com/cloudflare/cloudflare-python/issues/2524)) ([d10fb45](https://github.com/cloudflare/cloudflare-python/commit/d10fb45195b6b6d4b689bc5629877a7dee91a74b)) +* **workers:** add in secrets endpoints ([#2540](https://github.com/cloudflare/cloudflare-python/issues/2540)) ([0f3127d](https://github.com/cloudflare/cloudflare-python/commit/0f3127d57e8675a30f10caf8ba052651e5f75954)) +* **workflows:** add `bulk` support ([#2551](https://github.com/cloudflare/cloudflare-python/issues/2551)) ([45d91e2](https://github.com/cloudflare/cloudflare-python/commit/45d91e2a032aac5b4d1471027dbcd50e873dd0c8)) + + +### Bug Fixes + +* **api:** missing union discriminator naming ([#2548](https://github.com/cloudflare/cloudflare-python/issues/2548)) ([8c842a3](https://github.com/cloudflare/cloudflare-python/commit/8c842a3fc5e1fb641bb1cb279f5b143ed980bbed)) +* **ci:** ensure pip is always available ([#2543](https://github.com/cloudflare/cloudflare-python/issues/2543)) ([5ab256e](https://github.com/cloudflare/cloudflare-python/commit/5ab256eb4d93222012a808fde8a119a60a4a8bc3)) +* **ci:** remove publishing patch ([#2546](https://github.com/cloudflare/cloudflare-python/issues/2546)) ([2316376](https://github.com/cloudflare/cloudflare-python/commit/2316376a75b6a6ff41e1d1d7510206aa050ece09)) +* **internal:** remove port scans pending path fixes ([#2498](https://github.com/cloudflare/cloudflare-python/issues/2498)) ([f3c8131](https://github.com/cloudflare/cloudflare-python/commit/f3c81313a8878f84abdfcd6b6f9af48126ece4c5)) +* **r2_custom_domain:** update path placeholders to de-duplicate internal values ([#2506](https://github.com/cloudflare/cloudflare-python/issues/2506)) ([1288828](https://github.com/cloudflare/cloudflare-python/commit/1288828790c8cb3ddc38e81fb4e870406a0caab9)) +* **workers_for_platforms:** remove cyclic import due to model ([#2542](https://github.com/cloudflare/cloudflare-python/issues/2542)) ([7d9d338](https://github.com/cloudflare/cloudflare-python/commit/7d9d3381eacc52694d477b388165a26f77bde9b5)) + + +### Chores + +* **docs:** update client docstring ([#2483](https://github.com/cloudflare/cloudflare-python/issues/2483)) ([e98bd28](https://github.com/cloudflare/cloudflare-python/commit/e98bd2880f1f33083e0ce1e585bcaa635eda4176)) +* **internal:** bump rye to 0.44.0 ([#2536](https://github.com/cloudflare/cloudflare-python/issues/2536)) ([b1a4155](https://github.com/cloudflare/cloudflare-python/commit/b1a4155e83b067684f202159ad4b6f2b1d3c5283)) +* **internal:** codegen related update ([#2475](https://github.com/cloudflare/cloudflare-python/issues/2475)) ([329c314](https://github.com/cloudflare/cloudflare-python/commit/329c314d1756618ef5434817f1077173041a0ebc)) +* **internal:** codegen related update ([#2505](https://github.com/cloudflare/cloudflare-python/issues/2505)) ([ea4d061](https://github.com/cloudflare/cloudflare-python/commit/ea4d06178fa05d7907edd1d2869d566c80a1a567)) +* **internal:** codegen related update ([#2511](https://github.com/cloudflare/cloudflare-python/issues/2511)) ([d8e67ed](https://github.com/cloudflare/cloudflare-python/commit/d8e67ede7ad1363353b09e93d29951df62b87ed5)) +* **internal:** codegen related update ([#2512](https://github.com/cloudflare/cloudflare-python/issues/2512)) ([ee0fa76](https://github.com/cloudflare/cloudflare-python/commit/ee0fa7627138689a4115a9a54e3c504d9ef2d7a9)) +* **internal:** mark VPC and PDF as initialisms ([#2486](https://github.com/cloudflare/cloudflare-python/issues/2486)) ([f0b00be](https://github.com/cloudflare/cloudflare-python/commit/f0b00beeebe149cc989e6c398b5f9ccfd2dce33b)) +* **internal:** remove extra empty newlines ([#2529](https://github.com/cloudflare/cloudflare-python/issues/2529)) ([b1cabe6](https://github.com/cloudflare/cloudflare-python/commit/b1cabe63a9238d0e00cbde50b1a8d1843e26b03b)) +* **internal:** remove unused http client options forwarding ([#2494](https://github.com/cloudflare/cloudflare-python/issues/2494)) ([db37526](https://github.com/cloudflare/cloudflare-python/commit/db375269cd6e68fc5b184384d15f5290e6b63cb7)) + + +### Documentation + +* update URLs from stainlessapi.com to stainless.com ([#2481](https://github.com/cloudflare/cloudflare-python/issues/2481)) ([fe98b1d](https://github.com/cloudflare/cloudflare-python/commit/fe98b1da5bed21d62ff14cb1c84f8f89da4a03ac)) + +## 4.0.0 (2025-01-13) + +Full Changelog: [v3.1.1...v4.0.0](https://github.com/cloudflare/cloudflare-python/compare/v3.1.1...v4.0.0) + +### ⚠ BREAKING CHANGES + +* **addressing:** reshuffle relationship in the namespace to align with the product ([#2322](https://github.com/cloudflare/cloudflare-python/issues/2322)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2310](https://github.com/cloudflare/cloudflare-python/issues/2310)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2309](https://github.com/cloudflare/cloudflare-python/issues/2309)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2308](https://github.com/cloudflare/cloudflare-python/issues/2308)) +* **loa_documents:** move download subresource into parent as `get` ([#2304](https://github.com/cloudflare/cloudflare-python/issues/2304)) +* **addressing:** move service bindings to dedicated namespace ([#2303](https://github.com/cloudflare/cloudflare-python/issues/2303)) +* **ai:** move to dedicated namespace ([#2269](https://github.com/cloudflare/cloudflare-python/issues/2269)) +* **kv:** move analytics under existing namespace ([#2239](https://github.com/cloudflare/cloudflare-python/issues/2239)) +* **zone_transfers:** move under DNS namespace ([#2234](https://github.com/cloudflare/cloudflare-python/issues/2234)) +* **dnssec:** move under DNS namespace ([#2233](https://github.com/cloudflare/cloudflare-python/issues/2233)) +* **url_scanner:** swap all methods to be v2 only ([#2231](https://github.com/cloudflare/cloudflare-python/issues/2231)) +* **warp_connector:** move under zero trust namespace ([#2220](https://github.com/cloudflare/cloudflare-python/issues/2220)) + +### Features + +* **addressing:** move service bindings to dedicated namespace ([#2303](https://github.com/cloudflare/cloudflare-python/issues/2303)) ([b9a842b](https://github.com/cloudflare/cloudflare-python/commit/b9a842b5a8d4351337422919805d0baf1ec1660d)) +* **addressing:** reshuffle relationship in the namespace to align with the product ([#2322](https://github.com/cloudflare/cloudflare-python/issues/2322)) ([e6a1bfa](https://github.com/cloudflare/cloudflare-python/commit/e6a1bfad0b9885222c8dbec059dd132ba1a21e30)) +* **ai:** add support for search endpoints and finetunes ([#2305](https://github.com/cloudflare/cloudflare-python/issues/2305)) ([4493d6c](https://github.com/cloudflare/cloudflare-python/commit/4493d6c280dae6cfc3ed1c4cb798e51a81061485)) +* **ai:** move AI back to dedicated namespace ([#2277](https://github.com/cloudflare/cloudflare-python/issues/2277)) ([674c2ce](https://github.com/cloudflare/cloudflare-python/commit/674c2cec279102aa762e31ac6407e41a03f40352)) +* **ai:** move to dedicated namespace ([#2269](https://github.com/cloudflare/cloudflare-python/issues/2269)) ([90d0608](https://github.com/cloudflare/cloudflare-python/commit/90d0608e7aaef397b418be05e847c9c4baf41eb8)) +* **api:** Add new Aegis zone setting ([#2319](https://github.com/cloudflare/cloudflare-python/issues/2319)) ([dce9437](https://github.com/cloudflare/cloudflare-python/commit/dce94373dcd139a5fb4d77708f5b4a8a23716438)) +* **api:** Add PATCH zone hold update method ([#2268](https://github.com/cloudflare/cloudflare-python/issues/2268)) ([f21869f](https://github.com/cloudflare/cloudflare-python/commit/f21869ffa917b954d9d35c451942fca34fd1284a)) +* **api:** api shield operations updates; rename discovery resource ([#2296](https://github.com/cloudflare/cloudflare-python/issues/2296)) ([e7936f6](https://github.com/cloudflare/cloudflare-python/commit/e7936f6b3d285bc4243641a66b1c1d7404eb1328)) +* **api:** api update ([#2124](https://github.com/cloudflare/cloudflare-python/issues/2124)) ([e03ce04](https://github.com/cloudflare/cloudflare-python/commit/e03ce048f9686baf14fca16b30d9a20278257f59)) +* **api:** api update ([#2125](https://github.com/cloudflare/cloudflare-python/issues/2125)) ([798b1a0](https://github.com/cloudflare/cloudflare-python/commit/798b1a044e3042346af9c8d301586fa59c67aedf)) +* **api:** api update ([#2126](https://github.com/cloudflare/cloudflare-python/issues/2126)) ([fe787a3](https://github.com/cloudflare/cloudflare-python/commit/fe787a344a1c5f06ceaef8ff8805e7c8072feb19)) +* **api:** api update ([#2127](https://github.com/cloudflare/cloudflare-python/issues/2127)) ([eef643f](https://github.com/cloudflare/cloudflare-python/commit/eef643fdd935224ade161660b54b1758710948d5)) +* **api:** api update ([#2129](https://github.com/cloudflare/cloudflare-python/issues/2129)) ([ff2f5dc](https://github.com/cloudflare/cloudflare-python/commit/ff2f5dc939fc3b3799c875a765a91ee11bdcbd83)) +* **api:** api update ([#2130](https://github.com/cloudflare/cloudflare-python/issues/2130)) ([f57867d](https://github.com/cloudflare/cloudflare-python/commit/f57867db827b54228dd31bf1054fadd1ea808460)) +* **api:** api update ([#2131](https://github.com/cloudflare/cloudflare-python/issues/2131)) ([e077e34](https://github.com/cloudflare/cloudflare-python/commit/e077e34c2219779e808540d268e90f1298b6334f)) +* **api:** api update ([#2132](https://github.com/cloudflare/cloudflare-python/issues/2132)) ([f0898d4](https://github.com/cloudflare/cloudflare-python/commit/f0898d4b3752c6e035f91eb22555a0cc112c8026)) +* **api:** api update ([#2133](https://github.com/cloudflare/cloudflare-python/issues/2133)) ([22d878b](https://github.com/cloudflare/cloudflare-python/commit/22d878bc6dfebc68e65dae946330f01b79b380b7)) +* **api:** api update ([#2135](https://github.com/cloudflare/cloudflare-python/issues/2135)) ([29e0389](https://github.com/cloudflare/cloudflare-python/commit/29e038971efe26a45daaa9b0ac5eab248922f0a7)) +* **api:** api update ([#2136](https://github.com/cloudflare/cloudflare-python/issues/2136)) ([b132a0d](https://github.com/cloudflare/cloudflare-python/commit/b132a0d47fa5b9bdf74271df8be5e9b36095a444)) +* **api:** api update ([#2140](https://github.com/cloudflare/cloudflare-python/issues/2140)) ([385c772](https://github.com/cloudflare/cloudflare-python/commit/385c77263a4515a9c587302d1d94f4a714c9d031)) +* **api:** api update ([#2142](https://github.com/cloudflare/cloudflare-python/issues/2142)) ([0b5a5d0](https://github.com/cloudflare/cloudflare-python/commit/0b5a5d0f0b62f5b9a21e50cb7b4209315a9cb7df)) +* **api:** api update ([#2143](https://github.com/cloudflare/cloudflare-python/issues/2143)) ([2f10d9c](https://github.com/cloudflare/cloudflare-python/commit/2f10d9cc4c1c7d74b011da95e8c94971dccc4a0b)) +* **api:** api update ([#2146](https://github.com/cloudflare/cloudflare-python/issues/2146)) ([c1e8143](https://github.com/cloudflare/cloudflare-python/commit/c1e8143d4fa54667933c9ab50c80b7ee12f0f872)) +* **api:** api update ([#2147](https://github.com/cloudflare/cloudflare-python/issues/2147)) ([abbd9f7](https://github.com/cloudflare/cloudflare-python/commit/abbd9f710f32647ae8987b5cd370c1b1eda158a3)) +* **api:** api update ([#2148](https://github.com/cloudflare/cloudflare-python/issues/2148)) ([178ca7e](https://github.com/cloudflare/cloudflare-python/commit/178ca7e20f6350a13a37b23451ddafc3d77a4a6b)) +* **api:** api update ([#2149](https://github.com/cloudflare/cloudflare-python/issues/2149)) ([b6ca4bd](https://github.com/cloudflare/cloudflare-python/commit/b6ca4bd513190d7b1af48e24cee69340a6158ebd)) +* **api:** api update ([#2150](https://github.com/cloudflare/cloudflare-python/issues/2150)) ([99d9133](https://github.com/cloudflare/cloudflare-python/commit/99d91330f715e705244cc698978cd2ab8548966a)) +* **api:** api update ([#2151](https://github.com/cloudflare/cloudflare-python/issues/2151)) ([0ac8d45](https://github.com/cloudflare/cloudflare-python/commit/0ac8d45b16a19d823b1e04bc2417f6e2a3461cc2)) +* **api:** api update ([#2159](https://github.com/cloudflare/cloudflare-python/issues/2159)) ([1629b7f](https://github.com/cloudflare/cloudflare-python/commit/1629b7f549d9f66bb92b0f6d39e204a164431447)) +* **api:** api update ([#2160](https://github.com/cloudflare/cloudflare-python/issues/2160)) ([bc2b5c4](https://github.com/cloudflare/cloudflare-python/commit/bc2b5c431ad0ad27f107f5ba766ea0c07dfd0177)) +* **api:** api update ([#2161](https://github.com/cloudflare/cloudflare-python/issues/2161)) ([441bcec](https://github.com/cloudflare/cloudflare-python/commit/441bcecde63c193c9e08800ce6ad6f43c022282b)) +* **api:** api update ([#2162](https://github.com/cloudflare/cloudflare-python/issues/2162)) ([5244425](https://github.com/cloudflare/cloudflare-python/commit/5244425b52f1f512931708f879270cd7d287f1d0)) +* **api:** api update ([#2163](https://github.com/cloudflare/cloudflare-python/issues/2163)) ([c2770ee](https://github.com/cloudflare/cloudflare-python/commit/c2770eec423f26d1ecad8a1f836ed5001acce4b1)) +* **api:** api update ([#2167](https://github.com/cloudflare/cloudflare-python/issues/2167)) ([44c9de7](https://github.com/cloudflare/cloudflare-python/commit/44c9de7f4e4f1d294960ef892fe90ba1ed1c65b6)) +* **api:** api update ([#2168](https://github.com/cloudflare/cloudflare-python/issues/2168)) ([86eff89](https://github.com/cloudflare/cloudflare-python/commit/86eff892d605f019f725d914670f442057d8f3fc)) +* **api:** api update ([#2169](https://github.com/cloudflare/cloudflare-python/issues/2169)) ([94403aa](https://github.com/cloudflare/cloudflare-python/commit/94403aa020be977db4313269f5faaaa9a6119a00)) +* **api:** api update ([#2170](https://github.com/cloudflare/cloudflare-python/issues/2170)) ([bfd27f8](https://github.com/cloudflare/cloudflare-python/commit/bfd27f86e196194e3e05330391574cb1d60ff46c)) +* **api:** api update ([#2171](https://github.com/cloudflare/cloudflare-python/issues/2171)) ([f704605](https://github.com/cloudflare/cloudflare-python/commit/f70460538170f4af2d320fe0f46417afba060a0b)) +* **api:** api update ([#2172](https://github.com/cloudflare/cloudflare-python/issues/2172)) ([abbdc97](https://github.com/cloudflare/cloudflare-python/commit/abbdc97e686c637f0479816fc4c1fd158edadc4f)) +* **api:** api update ([#2173](https://github.com/cloudflare/cloudflare-python/issues/2173)) ([9e7ca11](https://github.com/cloudflare/cloudflare-python/commit/9e7ca11b0d9bac42d697b89bb021fd0010aa32cc)) +* **api:** api update ([#2175](https://github.com/cloudflare/cloudflare-python/issues/2175)) ([d22a2de](https://github.com/cloudflare/cloudflare-python/commit/d22a2debd32f0b14a7587317d9a7a8e26e4065d9)) +* **api:** api update ([#2179](https://github.com/cloudflare/cloudflare-python/issues/2179)) ([d39c7b5](https://github.com/cloudflare/cloudflare-python/commit/d39c7b51908c22ed91b2e7f68cb64ebf05bfabb9)) +* **api:** api update ([#2180](https://github.com/cloudflare/cloudflare-python/issues/2180)) ([90be13d](https://github.com/cloudflare/cloudflare-python/commit/90be13db56fb6d1ae93dfa11c80580efc7f98d1c)) +* **api:** api update ([#2181](https://github.com/cloudflare/cloudflare-python/issues/2181)) ([f3c2bb4](https://github.com/cloudflare/cloudflare-python/commit/f3c2bb42b357660881be9cce0dad1b2651e8f3de)) +* **api:** api update ([#2188](https://github.com/cloudflare/cloudflare-python/issues/2188)) ([09acf0a](https://github.com/cloudflare/cloudflare-python/commit/09acf0aba6d4a44ba3ccd8ef3ebcd06bfd10c21a)) +* **api:** api update ([#2197](https://github.com/cloudflare/cloudflare-python/issues/2197)) ([8fb8e8b](https://github.com/cloudflare/cloudflare-python/commit/8fb8e8b2abb398b42890d0dd11590e646e29184b)) +* **api:** api update ([#2198](https://github.com/cloudflare/cloudflare-python/issues/2198)) ([1cad830](https://github.com/cloudflare/cloudflare-python/commit/1cad8304d05e4eee21adb38dde942a27b93b17cc)) +* **api:** api update ([#2199](https://github.com/cloudflare/cloudflare-python/issues/2199)) ([2d5cecb](https://github.com/cloudflare/cloudflare-python/commit/2d5cecb75287ac39d04f04f6ffdcb982f080ff6d)) +* **api:** api update ([#2200](https://github.com/cloudflare/cloudflare-python/issues/2200)) ([5be5fe6](https://github.com/cloudflare/cloudflare-python/commit/5be5fe6c91b8e8ef2fee80ef96eefcbb37f901ac)) +* **api:** api update ([#2201](https://github.com/cloudflare/cloudflare-python/issues/2201)) ([dc752c1](https://github.com/cloudflare/cloudflare-python/commit/dc752c1096a02d869d6cd66f08c180fbfcd92989)) +* **api:** api update ([#2202](https://github.com/cloudflare/cloudflare-python/issues/2202)) ([ace26df](https://github.com/cloudflare/cloudflare-python/commit/ace26df932afdff7531a4797aff9e38563fa3bb0)) +* **api:** api update ([#2203](https://github.com/cloudflare/cloudflare-python/issues/2203)) ([1c97b11](https://github.com/cloudflare/cloudflare-python/commit/1c97b11edd92b89f75685022c95adf0c8167bb0c)) +* **api:** api update ([#2205](https://github.com/cloudflare/cloudflare-python/issues/2205)) ([291389c](https://github.com/cloudflare/cloudflare-python/commit/291389c5d24ff8040ad88143cf76591b71464706)) +* **api:** api update ([#2206](https://github.com/cloudflare/cloudflare-python/issues/2206)) ([546cb1c](https://github.com/cloudflare/cloudflare-python/commit/546cb1c67c6cff1bb71f1df9ecbcc8752f9cce00)) +* **api:** api update ([#2209](https://github.com/cloudflare/cloudflare-python/issues/2209)) ([458a4a5](https://github.com/cloudflare/cloudflare-python/commit/458a4a57c8ef88b19fdacd6e63c24ab1c9191ecc)) +* **api:** api update ([#2211](https://github.com/cloudflare/cloudflare-python/issues/2211)) ([51a0005](https://github.com/cloudflare/cloudflare-python/commit/51a00052d14453eaabd073d7d2fa44f012e5174c)) +* **api:** api update ([#2212](https://github.com/cloudflare/cloudflare-python/issues/2212)) ([19d7551](https://github.com/cloudflare/cloudflare-python/commit/19d7551f7918da44de4d6ac0631655bfcca4a9f5)) +* **api:** api update ([#2216](https://github.com/cloudflare/cloudflare-python/issues/2216)) ([272e71c](https://github.com/cloudflare/cloudflare-python/commit/272e71cf393077037e2098dcedf13e6999fc0a6a)) +* **api:** api update ([#2219](https://github.com/cloudflare/cloudflare-python/issues/2219)) ([88819fc](https://github.com/cloudflare/cloudflare-python/commit/88819fcc48e653a284c6df579b6786276ef83ded)) +* **api:** api update ([#2221](https://github.com/cloudflare/cloudflare-python/issues/2221)) ([0f01824](https://github.com/cloudflare/cloudflare-python/commit/0f018249fc22949f98487b7cc9689fe45646572a)) +* **api:** api update ([#2223](https://github.com/cloudflare/cloudflare-python/issues/2223)) ([2e9734b](https://github.com/cloudflare/cloudflare-python/commit/2e9734b0e74ebf65e1da9e8eadab28947015c786)) +* **api:** api update ([#2227](https://github.com/cloudflare/cloudflare-python/issues/2227)) ([ace3716](https://github.com/cloudflare/cloudflare-python/commit/ace371689884dc6d1e494776aa5960c71c59e2aa)) +* **api:** api update ([#2237](https://github.com/cloudflare/cloudflare-python/issues/2237)) ([adc6f6b](https://github.com/cloudflare/cloudflare-python/commit/adc6f6bc433fe077c51a2f4700eaa541fed9a587)) +* **api:** api update ([#2238](https://github.com/cloudflare/cloudflare-python/issues/2238)) ([84bc37c](https://github.com/cloudflare/cloudflare-python/commit/84bc37c6caabf0e22cb9e09f0c12e3a86c82135a)) +* **api:** api update ([#2243](https://github.com/cloudflare/cloudflare-python/issues/2243)) ([86ca907](https://github.com/cloudflare/cloudflare-python/commit/86ca907944e3d48bdd2c929295f5ccaca3371fd1)) +* **api:** api update ([#2244](https://github.com/cloudflare/cloudflare-python/issues/2244)) ([0978d14](https://github.com/cloudflare/cloudflare-python/commit/0978d147d0022c95225976d5e457fd49eddbd5b2)) +* **api:** api update ([#2245](https://github.com/cloudflare/cloudflare-python/issues/2245)) ([c12dfc0](https://github.com/cloudflare/cloudflare-python/commit/c12dfc071a9e2307c27dd5e9b81444754a1f3646)) +* **api:** api update ([#2247](https://github.com/cloudflare/cloudflare-python/issues/2247)) ([38a93e7](https://github.com/cloudflare/cloudflare-python/commit/38a93e757989c56d759debf0f9767a1f0b3049ce)) +* **api:** api update ([#2266](https://github.com/cloudflare/cloudflare-python/issues/2266)) ([e738082](https://github.com/cloudflare/cloudflare-python/commit/e738082ba761fadc1648e5fec4d85c3bcf113bc7)) +* **api:** api update ([#2273](https://github.com/cloudflare/cloudflare-python/issues/2273)) ([fcf96f7](https://github.com/cloudflare/cloudflare-python/commit/fcf96f73182777bd9242d6fa55d8921ba001cb59)) +* **api:** api update ([#2276](https://github.com/cloudflare/cloudflare-python/issues/2276)) ([d77a47e](https://github.com/cloudflare/cloudflare-python/commit/d77a47e7ecccfeb3dd045e6759b7ccc9f1250ef1)) +* **api:** api update ([#2284](https://github.com/cloudflare/cloudflare-python/issues/2284)) ([982f95a](https://github.com/cloudflare/cloudflare-python/commit/982f95ad5ff7f0271c47f65517ab98bd45dd81ce)) +* **api:** api update ([#2285](https://github.com/cloudflare/cloudflare-python/issues/2285)) ([9cae1f0](https://github.com/cloudflare/cloudflare-python/commit/9cae1f099fde4204821ce3d1cf53f823d340b9ed)) +* **api:** api update ([#2286](https://github.com/cloudflare/cloudflare-python/issues/2286)) ([efa8fcb](https://github.com/cloudflare/cloudflare-python/commit/efa8fcb9241f5dc73d020ba959b5b5c9914362d6)) +* **api:** api update ([#2288](https://github.com/cloudflare/cloudflare-python/issues/2288)) ([52ec839](https://github.com/cloudflare/cloudflare-python/commit/52ec8391c9efe608740ce3118fdd5b6f4fc1e0c7)) +* **api:** api update ([#2290](https://github.com/cloudflare/cloudflare-python/issues/2290)) ([db76849](https://github.com/cloudflare/cloudflare-python/commit/db7684993cff9cde91b0ad21637801cda763e5d7)) +* **api:** api update ([#2291](https://github.com/cloudflare/cloudflare-python/issues/2291)) ([17a3ce1](https://github.com/cloudflare/cloudflare-python/commit/17a3ce1057e0e3b2392fe9131cad1dd75511bfc3)) +* **api:** api update ([#2292](https://github.com/cloudflare/cloudflare-python/issues/2292)) ([5408013](https://github.com/cloudflare/cloudflare-python/commit/5408013619994ba4cc5559774e09a6d42d9abe82)) +* **api:** api update ([#2293](https://github.com/cloudflare/cloudflare-python/issues/2293)) ([f2cdcdc](https://github.com/cloudflare/cloudflare-python/commit/f2cdcdc4d6b545df85cd2f1f0b5de6889d787221)) +* **api:** api update ([#2294](https://github.com/cloudflare/cloudflare-python/issues/2294)) ([17db44d](https://github.com/cloudflare/cloudflare-python/commit/17db44d1b1a346c9e4fcb098a18133cc96a2b4de)) +* **api:** api update ([#2297](https://github.com/cloudflare/cloudflare-python/issues/2297)) ([1d4bea4](https://github.com/cloudflare/cloudflare-python/commit/1d4bea4918fedf83c7e3d23237130767c448f58c)) +* **api:** api update ([#2298](https://github.com/cloudflare/cloudflare-python/issues/2298)) ([2085a9e](https://github.com/cloudflare/cloudflare-python/commit/2085a9ea0312b66a6d354c0ccbfb167339ce43ba)) +* **api:** api update ([#2299](https://github.com/cloudflare/cloudflare-python/issues/2299)) ([429c4ee](https://github.com/cloudflare/cloudflare-python/commit/429c4ee023eeeaf05139c7cf98719686d44d0417)) +* **api:** api update ([#2313](https://github.com/cloudflare/cloudflare-python/issues/2313)) ([6c97352](https://github.com/cloudflare/cloudflare-python/commit/6c97352fd404cffb799f6862d7f00860ad93493d)) +* **api:** api update ([#2315](https://github.com/cloudflare/cloudflare-python/issues/2315)) ([09f456c](https://github.com/cloudflare/cloudflare-python/commit/09f456c084a2ac37f19adcc41b3807256d1ae6f7)) +* **api:** api update ([#2317](https://github.com/cloudflare/cloudflare-python/issues/2317)) ([c6cf3dc](https://github.com/cloudflare/cloudflare-python/commit/c6cf3dc770cff467edcc5d2f6a408bb66be11c7a)) +* **api:** api update ([#2318](https://github.com/cloudflare/cloudflare-python/issues/2318)) ([9229d53](https://github.com/cloudflare/cloudflare-python/commit/9229d539d1e8c2872af176744cabe7c1604fb93f)) +* **api:** api update ([#2320](https://github.com/cloudflare/cloudflare-python/issues/2320)) ([bdb21a5](https://github.com/cloudflare/cloudflare-python/commit/bdb21a52db862066a29a86e2a38477cc9ed9e040)) +* **api:** api update ([#2343](https://github.com/cloudflare/cloudflare-python/issues/2343)) ([1bd37b9](https://github.com/cloudflare/cloudflare-python/commit/1bd37b9d644696f4b5181791810fe39c57654796)) +* **api:** api update ([#2344](https://github.com/cloudflare/cloudflare-python/issues/2344)) ([4423d8f](https://github.com/cloudflare/cloudflare-python/commit/4423d8f45b52ba3cf221c995e066e5d0cff67e9e)) +* **api:** api update ([#2347](https://github.com/cloudflare/cloudflare-python/issues/2347)) ([8225a83](https://github.com/cloudflare/cloudflare-python/commit/8225a833982b22e8d5ef3a9bbe725a97fca7b7e3)) +* **api:** api update ([#2355](https://github.com/cloudflare/cloudflare-python/issues/2355)) ([1dedfa9](https://github.com/cloudflare/cloudflare-python/commit/1dedfa998d98b9dd8cde54f23f01fb65a0fe93bd)) +* **api:** clean up indirect models ([#2155](https://github.com/cloudflare/cloudflare-python/issues/2155)) ([503ab54](https://github.com/cloudflare/cloudflare-python/commit/503ab54a5afff1d832a1f9243bda27ad982e3451)) +* **api:** clean up missing model references ([#2138](https://github.com/cloudflare/cloudflare-python/issues/2138)) ([74f433a](https://github.com/cloudflare/cloudflare-python/commit/74f433a9e010471cfa87af98c2586195fb764c5d)) +* **api:** clean up missing models ([#2178](https://github.com/cloudflare/cloudflare-python/issues/2178)) ([bd94126](https://github.com/cloudflare/cloudflare-python/commit/bd94126a86d0cf376a8856a9c8077600285f2b70)) +* **api:** fix internal URL mappings ([#2267](https://github.com/cloudflare/cloudflare-python/issues/2267)) ([165bc8c](https://github.com/cloudflare/cloudflare-python/commit/165bc8c274b7f6688b95f018fd86d312a5de0a17)) +* **api:** introduce bulk operation methods ([#2177](https://github.com/cloudflare/cloudflare-python/issues/2177)) ([3fd5de2](https://github.com/cloudflare/cloudflare-python/commit/3fd5de24f338955457a1b47fa0fea3d7bfc796cc)) +* **api:** manual updates ([#2164](https://github.com/cloudflare/cloudflare-python/issues/2164)) ([3f20b98](https://github.com/cloudflare/cloudflare-python/commit/3f20b98dee636ed17903cff36351c66e97ac1795)) +* **api:** manual updates ([#2195](https://github.com/cloudflare/cloudflare-python/issues/2195)) ([2de0fb0](https://github.com/cloudflare/cloudflare-python/commit/2de0fb0b3f46aefd97d06e22b6441a573ee228a2)) +* **api:** manual updates ([#2207](https://github.com/cloudflare/cloudflare-python/issues/2207)) ([d40b099](https://github.com/cloudflare/cloudflare-python/commit/d40b09962fc1e3d0f96c2cace0a29a81ff4b026c)) +* **api:** manual updates ([#2226](https://github.com/cloudflare/cloudflare-python/issues/2226)) ([7065932](https://github.com/cloudflare/cloudflare-python/commit/70659321d956ea2512f2a0f7e33c4c198c34ee91)) +* **api:** manual updates ([#2255](https://github.com/cloudflare/cloudflare-python/issues/2255)) ([f70b142](https://github.com/cloudflare/cloudflare-python/commit/f70b142bfe940e4e6566e9e1f815ecda7b5dbe99)) +* **api:** manual updates ([#2295](https://github.com/cloudflare/cloudflare-python/issues/2295)) ([a3043d4](https://github.com/cloudflare/cloudflare-python/commit/a3043d4a8cc00e9c63597e5a6baabd6d207ceb63)) +* **api:** manual updates ([#2301](https://github.com/cloudflare/cloudflare-python/issues/2301)) ([91253c2](https://github.com/cloudflare/cloudflare-python/commit/91253c2a7c5245101caa220f8f44833d8a937008)) +* **api:** manual updates ([#2302](https://github.com/cloudflare/cloudflare-python/issues/2302)) ([df84d3a](https://github.com/cloudflare/cloudflare-python/commit/df84d3a36679693d2bed6ee4f8a73d82fb7fa8ef)) +* **api:** manual updates ([#2312](https://github.com/cloudflare/cloudflare-python/issues/2312)) ([f7ca287](https://github.com/cloudflare/cloudflare-python/commit/f7ca287ebc2001eb8e2c153fbf72561d05a5da63)) +* **api:** manual updates ([#2325](https://github.com/cloudflare/cloudflare-python/issues/2325)) ([2a2e199](https://github.com/cloudflare/cloudflare-python/commit/2a2e1991f7d1831ccd1010fedb699df1f91c89a9)) +* **api:** manual updates ([#2326](https://github.com/cloudflare/cloudflare-python/issues/2326)) ([7e80cb8](https://github.com/cloudflare/cloudflare-python/commit/7e80cb872d94c564f1eef0c8db3f141bcd864259)) +* **api:** manual updates ([#2349](https://github.com/cloudflare/cloudflare-python/issues/2349)) ([878ae25](https://github.com/cloudflare/cloudflare-python/commit/878ae25e6b05626f0b9fc97ecb37728cb54279fd)) +* **api:** manual updates ([#2351](https://github.com/cloudflare/cloudflare-python/issues/2351)) ([85fd586](https://github.com/cloudflare/cloudflare-python/commit/85fd5868a8e6b38f6ba46f06bd7688678892e106)) +* **api:** map in new endpoints for account owned tokens, dns setting views and worker assets ([#2144](https://github.com/cloudflare/cloudflare-python/issues/2144)) ([6e79a67](https://github.com/cloudflare/cloudflare-python/commit/6e79a67fbf36ca0f2325356f7d1137d84f5cb1fc)) +* **api:** map more endpoints ([#2287](https://github.com/cloudflare/cloudflare-python/issues/2287)) ([ce7f872](https://github.com/cloudflare/cloudflare-python/commit/ce7f87207e24de6804309af06b84dfc11c9dded2)) +* **api:** mark JSON as initialism ([#2324](https://github.com/cloudflare/cloudflare-python/issues/2324)) ([da91e21](https://github.com/cloudflare/cloudflare-python/commit/da91e219eda9065b5703aa70bbbcc9340cacf5de)) +* **api:** remap models for magic visibility ([#2128](https://github.com/cloudflare/cloudflare-python/issues/2128)) ([dae1150](https://github.com/cloudflare/cloudflare-python/commit/dae115058bdea915f5aa5b386a68c4387b356ef6)) +* **api:** remove unneeded DNS transforms ([#2341](https://github.com/cloudflare/cloudflare-python/issues/2341)) ([11683b6](https://github.com/cloudflare/cloudflare-python/commit/11683b6141096c18d14e01d11892bd177bdd3040)) +* **api:** skip authorization failures in prism ([#2323](https://github.com/cloudflare/cloudflare-python/issues/2323)) ([cc90fdc](https://github.com/cloudflare/cloudflare-python/commit/cc90fdc42244a7110a6365c66c10bbc1ca9ea46b)) +* **api:** update api shield operation endpoint ([#2348](https://github.com/cloudflare/cloudflare-python/issues/2348)) ([61a852b](https://github.com/cloudflare/cloudflare-python/commit/61a852b624877c54705bb5b5e7648e424cfe9a57)) +* **api:** Update verb on PATCH zone hold method ([#2275](https://github.com/cloudflare/cloudflare-python/issues/2275)) ([5c57d32](https://github.com/cloudflare/cloudflare-python/commit/5c57d32bf17901ec1e258cdbefad49f0f3e2ed06)) +* **api:** update via SDK Studio ([#2182](https://github.com/cloudflare/cloudflare-python/issues/2182)) ([660adfd](https://github.com/cloudflare/cloudflare-python/commit/660adfde851b2e4110bd98070ac7dd684ba009cc)) +* **api:** update via SDK Studio ([#2183](https://github.com/cloudflare/cloudflare-python/issues/2183)) ([cda5a42](https://github.com/cloudflare/cloudflare-python/commit/cda5a42a9ed789b99ae168e52e99255bbf1d946f)) +* **api:** update via SDK Studio ([#2184](https://github.com/cloudflare/cloudflare-python/issues/2184)) ([838f684](https://github.com/cloudflare/cloudflare-python/commit/838f684bb71ddb6f9fc0a8b4830340a14421f15c)) +* **api:** update via SDK Studio ([#2185](https://github.com/cloudflare/cloudflare-python/issues/2185)) ([e727768](https://github.com/cloudflare/cloudflare-python/commit/e727768f549e968b5f906f768a46a7930d59ab4f)) +* **api:** update via SDK Studio ([#2187](https://github.com/cloudflare/cloudflare-python/issues/2187)) ([4e1d81a](https://github.com/cloudflare/cloudflare-python/commit/4e1d81a1640edbde3a58fa79451c0d4287c8abd9)) +* **api:** update via SDK Studio ([#2189](https://github.com/cloudflare/cloudflare-python/issues/2189)) ([93cfe28](https://github.com/cloudflare/cloudflare-python/commit/93cfe2870ad304ba87c7a055685f12121a470b53)) +* **api:** update via SDK Studio ([#2190](https://github.com/cloudflare/cloudflare-python/issues/2190)) ([4b59193](https://github.com/cloudflare/cloudflare-python/commit/4b5919334b2d9d758c1d48e3aca466322c061752)) +* **api:** update via SDK Studio ([#2191](https://github.com/cloudflare/cloudflare-python/issues/2191)) ([b480965](https://github.com/cloudflare/cloudflare-python/commit/b48096544baf31b65ec0a2a7f2279eee8716110f)) +* **api:** update via SDK Studio ([#2192](https://github.com/cloudflare/cloudflare-python/issues/2192)) ([f1b6c86](https://github.com/cloudflare/cloudflare-python/commit/f1b6c86ef5d49e369db6d6edd33527cf06796110)) +* **api:** update via SDK Studio ([#2193](https://github.com/cloudflare/cloudflare-python/issues/2193)) ([d4deaed](https://github.com/cloudflare/cloudflare-python/commit/d4deaed06b6f87c079b07c8b2d00dbe7c857be5c)) +* **api:** update via SDK Studio ([#2194](https://github.com/cloudflare/cloudflare-python/issues/2194)) ([9949651](https://github.com/cloudflare/cloudflare-python/commit/9949651a0667f934d1de17a4ee564a82e313b42f)) +* **cloud_connector:** define body param name ([#2314](https://github.com/cloudflare/cloudflare-python/issues/2314)) ([b04ba76](https://github.com/cloudflare/cloudflare-python/commit/b04ba760dcdc0f7f47edc48613f3f8ee26ba7dc4)) +* **content_scanning:** introduce support ([#2254](https://github.com/cloudflare/cloudflare-python/issues/2254)) ([39bd39c](https://github.com/cloudflare/cloudflare-python/commit/39bd39c5446fe5e7861577fd60a33bbf47ab0459)) +* Delete examples/.keep ([ebd0a3a](https://github.com/cloudflare/cloudflare-python/commit/ebd0a3af400c8a5581c536ec33c2cdaa8c47c230)) +* **dex:** add commands support ([#2248](https://github.com/cloudflare/cloudflare-python/issues/2248)) ([8b5316e](https://github.com/cloudflare/cloudflare-python/commit/8b5316e41c3f991f3d00e8056d6fcc6691ebd315)) +* **dlp:** disable problematic test ([#2261](https://github.com/cloudflare/cloudflare-python/issues/2261)) ([560801e](https://github.com/cloudflare/cloudflare-python/commit/560801e9823b6d14b0fcc81f0dae6a01bf803fdc)) +* **dlp:** skip tests for `entries` update due to HTTP 422 in prism ([#2331](https://github.com/cloudflare/cloudflare-python/issues/2331)) ([0a952c0](https://github.com/cloudflare/cloudflare-python/commit/0a952c0532b30863206e11482f4bca004376012d)) +* **dns_firewall:** break out into standalone package ([#2235](https://github.com/cloudflare/cloudflare-python/issues/2235)) ([34e5a29](https://github.com/cloudflare/cloudflare-python/commit/34e5a2986d27893aad15ba1a5fb2b52b906b742e)) +* **dns:** add models for batch operations and response ([#2339](https://github.com/cloudflare/cloudflare-python/issues/2339)) ([645adba](https://github.com/cloudflare/cloudflare-python/commit/645adba8004c7d1331534c1929cedcd78f990341)) +* **dns:** fix model oneOf ([#2278](https://github.com/cloudflare/cloudflare-python/issues/2278)) ([e5c69df](https://github.com/cloudflare/cloudflare-python/commit/e5c69df85f4b6fb713998a9637b2cec4bf736103)) +* **dns:** remove `delta` model ([#2242](https://github.com/cloudflare/cloudflare-python/issues/2242)) ([571fe0e](https://github.com/cloudflare/cloudflare-python/commit/571fe0eafb49c9354dd72c8108deec22f6e7cced)) +* **dnssec:** move under DNS namespace ([#2233](https://github.com/cloudflare/cloudflare-python/issues/2233)) ([40cb3e1](https://github.com/cloudflare/cloudflare-python/commit/40cb3e10a7f55565fcdeacc7a72541c8ad995f26)) +* **examples:** update paths to reflect namespace changes ([#2334](https://github.com/cloudflare/cloudflare-python/issues/2334)) ([7af6c00](https://github.com/cloudflare/cloudflare-python/commit/7af6c0025b2560a9360a7db24d22e39855c5162d)) +* fix(project): constrain incompatible httpx and pydantic versions ([cb5fbad](https://github.com/cloudflare/cloudflare-python/commit/cb5fbad85238e1d69486c5b0f462bbb2dfc4a196)) +* **fleet_status:** update path placeholders to match conventions ([#2153](https://github.com/cloudflare/cloudflare-python/issues/2153)) ([66d6d48](https://github.com/cloudflare/cloudflare-python/commit/66d6d48e74d138083aaeaa23f3ffd61421cea0e5)) +* generate more types that are used as request bodies ([#2263](https://github.com/cloudflare/cloudflare-python/issues/2263)) ([acbdc24](https://github.com/cloudflare/cloudflare-python/commit/acbdc24863007e8325b9418442177b4c8c8872f7)) +* **iam:** fix model mappings ([#2154](https://github.com/cloudflare/cloudflare-python/issues/2154)) ([354f6d2](https://github.com/cloudflare/cloudflare-python/commit/354f6d28d063a98f23f0164d8d2f52077f541f3f)) +* **infrastructure_targets:** add bulk endpoints ([#2246](https://github.com/cloudflare/cloudflare-python/issues/2246)) ([e2f5e1b](https://github.com/cloudflare/cloudflare-python/commit/e2f5e1b186e276930e96fb0c6abe3367769a1c38)) +* **internal:** update path placeholders ([#2224](https://github.com/cloudflare/cloudflare-python/issues/2224)) ([2cad4a0](https://github.com/cloudflare/cloudflare-python/commit/2cad4a00e9468813e3c41bf22e7bac67e7abdcd3)) +* **kv:** move analytics under existing namespace ([#2239](https://github.com/cloudflare/cloudflare-python/issues/2239)) ([375bc8c](https://github.com/cloudflare/cloudflare-python/commit/375bc8c56e744bc1dfaefc9a508b263d40298c8d)) +* **leaked_credential_check:** add terraform resource ([#2229](https://github.com/cloudflare/cloudflare-python/issues/2229)) ([2b35234](https://github.com/cloudflare/cloudflare-python/commit/2b35234067d54ac83fcf2936cda096ebc00326c9)) +* **list_item:** remove duplicated `anyOf` properties from component ([#2342](https://github.com/cloudflare/cloudflare-python/issues/2342)) ([2a3b8c5](https://github.com/cloudflare/cloudflare-python/commit/2a3b8c5c9564a4fed1ec85e2be1347d0e9dc324a)) +* **loa_documents:** move download subresource into parent as `get` ([#2304](https://github.com/cloudflare/cloudflare-python/issues/2304)) ([c10d3b7](https://github.com/cloudflare/cloudflare-python/commit/c10d3b7485614eb6db9095970cfde190d2d04f26)) +* **origin_post_quantum_encryption:** swap PUT for PATCH operation ([#2321](https://github.com/cloudflare/cloudflare-python/issues/2321)) ([f6b6e83](https://github.com/cloudflare/cloudflare-python/commit/f6b6e83986b80b1efdc20a5cac129d7690f8ce0b)) +* **pagerules:** rename namespace to page_rules ([#2262](https://github.com/cloudflare/cloudflare-python/issues/2262)) ([72b7def](https://github.com/cloudflare/cloudflare-python/commit/72b7defac7788d481c84975c2fdd78a94a0692f1)) +* **python:** expand `model_type` rename to paths as well ([#2156](https://github.com/cloudflare/cloudflare-python/issues/2156)) ([9abf6d5](https://github.com/cloudflare/cloudflare-python/commit/9abf6d52c26439bf77583070e71b0826df8d424d)) +* **r2_bucket:** add `cors` support ([#2196](https://github.com/cloudflare/cloudflare-python/issues/2196)) ([8ed5f71](https://github.com/cloudflare/cloudflare-python/commit/8ed5f71bba52a6946622b7f5067beaea27ccc39e)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2308](https://github.com/cloudflare/cloudflare-python/issues/2308)) ([5dfdcbd](https://github.com/cloudflare/cloudflare-python/commit/5dfdcbd6e17515a4aca686e85b16c49e1149640f)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2309](https://github.com/cloudflare/cloudflare-python/issues/2309)) ([fd63955](https://github.com/cloudflare/cloudflare-python/commit/fd6395586b30e623f1bab71ac00fea7357411e14)) +* **r2:** rename `cf-r2-jurisdiction` to more usable `jurisdiction` parameter ([#2310](https://github.com/cloudflare/cloudflare-python/issues/2310)) ([a1ef1be](https://github.com/cloudflare/cloudflare-python/commit/a1ef1be8af3964536e101ad12a6f93016dc301da)) +* release: 3.1.1 ([6a4602a](https://github.com/cloudflare/cloudflare-python/commit/6a4602abc1823f5736310de65b31ea2e61150966)) +* swap DNS example to A ([792e093](https://github.com/cloudflare/cloudflare-python/commit/792e09384144e5dd93f95ac3698d4d43446172f0)) +* **tokens:** move condition and policy to shared models ([#2158](https://github.com/cloudflare/cloudflare-python/issues/2158)) ([f92d492](https://github.com/cloudflare/cloudflare-python/commit/f92d4929376afd516df711cf1c924f6271968e02)) +* **tokens:** move token value model to shared ([#2157](https://github.com/cloudflare/cloudflare-python/issues/2157)) ([8c246c1](https://github.com/cloudflare/cloudflare-python/commit/8c246c1361c13e2b1fb113c60ce53a136be44c64)) +* **url_scanner:** swap all methods to be v2 only ([#2231](https://github.com/cloudflare/cloudflare-python/issues/2231)) ([3823729](https://github.com/cloudflare/cloudflare-python/commit/3823729022c9ca725dcedde6aa63c219fa995ee5)) +* **urlscanner:** swap to v2 create ([#2225](https://github.com/cloudflare/cloudflare-python/issues/2225)) ([c04d762](https://github.com/cloudflare/cloudflare-python/commit/c04d762fc05726d68830b088d7fbfd84894fbf32)) +* **warp_connector:** move under zero trust namespace ([#2220](https://github.com/cloudflare/cloudflare-python/issues/2220)) ([de07ba2](https://github.com/cloudflare/cloudflare-python/commit/de07ba24fc81f72885d59f10b4c8e7eef9826944)) +* **workers:** add routes support ([#2279](https://github.com/cloudflare/cloudflare-python/issues/2279)) ([0991241](https://github.com/cloudflare/cloudflare-python/commit/0991241905ea11aa4a19918ec1bce63ce7600202)) +* **zero_trust_device_certificates:** update path placeholders ([#2204](https://github.com/cloudflare/cloudflare-python/issues/2204)) ([f43f392](https://github.com/cloudflare/cloudflare-python/commit/f43f3928ec1abb15151cfb82934de2d20a8e3fed)) +* **zero_trust_device:** reshuffle structure to allow use of custom and default ([#2137](https://github.com/cloudflare/cloudflare-python/issues/2137)) ([e323e62](https://github.com/cloudflare/cloudflare-python/commit/e323e62645bbaac3203bf0119217834683babfef)) +* **zero_trust_organization:** swap to upsert for creation ([#2186](https://github.com/cloudflare/cloudflare-python/issues/2186)) ([eeb6d8e](https://github.com/cloudflare/cloudflare-python/commit/eeb6d8eeb3a39e1a86b557a29a161ff92fd047fe)) +* **zone_settings:** update `origin_max_http_version` model ([#2311](https://github.com/cloudflare/cloudflare-python/issues/2311)) ([20fbd7d](https://github.com/cloudflare/cloudflare-python/commit/20fbd7d260eb6b14adf3b2529aa4b2614eaaabec)) +* **zone_transfers:** move under DNS namespace ([#2234](https://github.com/cloudflare/cloudflare-python/issues/2234)) ([c3cd782](https://github.com/cloudflare/cloudflare-python/commit/c3cd782dea8308b6a4586f596a535ef740369d67)) + + +### Bug Fixes + +* **api:** better support union schemas with common properties ([#2340](https://github.com/cloudflare/cloudflare-python/issues/2340)) ([e6ff06c](https://github.com/cloudflare/cloudflare-python/commit/e6ff06cb56f6b79e789064217e7ee50f6644ce82)) +* **client:** compat with new httpx 0.28.0 release ([#2228](https://github.com/cloudflare/cloudflare-python/issues/2228)) ([a369813](https://github.com/cloudflare/cloudflare-python/commit/a3698135b838d03f700276109276727471b76ecf)) +* **client:** only call .close() when needed ([#2330](https://github.com/cloudflare/cloudflare-python/issues/2330)) ([349d7af](https://github.com/cloudflare/cloudflare-python/commit/349d7af56845d29df10a1f6666c303e6169e2620)) +* correctly handle deserialising `cls` fields ([#2350](https://github.com/cloudflare/cloudflare-python/issues/2350)) ([a1e865f](https://github.com/cloudflare/cloudflare-python/commit/a1e865f0270d6ee3381b03d1c6d37c2bbbf218dd)) +* **example:** update example to reflect new structure ([d723b37](https://github.com/cloudflare/cloudflare-python/commit/d723b3769b26da7e6110fe831b8b83c6da492cd1)) +* **internal:** add cleaner handling of DNS unions ([#2270](https://github.com/cloudflare/cloudflare-python/issues/2270)) ([582142f](https://github.com/cloudflare/cloudflare-python/commit/582142f123d8a0558f692a2ebd7d611565ce7a98)) +* **project:** constrain incompatible httpx and pydantic versions ([00f4d23](https://github.com/cloudflare/cloudflare-python/commit/00f4d2345834d04ddd3bb343360b2edccc5ca060)) +* **types:** correct forward usage ([41a2158](https://github.com/cloudflare/cloudflare-python/commit/41a215873a52150ce039f36e8733abca5725b030)) +* **types:** work around cyclical import error ([10e2b12](https://github.com/cloudflare/cloudflare-python/commit/10e2b1241cf85c916a60db52fc1707bd88535eff)) +* **urlscanner:** fix invalid schema definition for plain text ([#2256](https://github.com/cloudflare/cloudflare-python/issues/2256)) ([db72d31](https://github.com/cloudflare/cloudflare-python/commit/db72d31b7cc2e4ca249e71c36603a3393c61f093)) +* **waiting_room_rules:** define `body_param_name` for bulk rules endpoint ([#2139](https://github.com/cloudflare/cloudflare-python/issues/2139)) ([a88b77d](https://github.com/cloudflare/cloudflare-python/commit/a88b77db25873cf057bece8a86e3a6b64746caf4)) + + +### Reverts + +* fix(project): constrain incompatible httpx and pydantic versions ([4823b68](https://github.com/cloudflare/cloudflare-python/commit/4823b68243dc8c0b26b3c479a08ee607115f8108)) + + +### Chores + +* add missing isclass check ([#2316](https://github.com/cloudflare/cloudflare-python/issues/2316)) ([a271105](https://github.com/cloudflare/cloudflare-python/commit/a271105854ad21137adef848f77bcb71f8083e77)) +* **examples:** fix DNS record example ([520a260](https://github.com/cloudflare/cloudflare-python/commit/520a260515f5bc041ae3ac81351665d3aceee7ed)) +* fix cyclical imports ([#2353](https://github.com/cloudflare/cloudflare-python/issues/2353)) ([7f83adf](https://github.com/cloudflare/cloudflare-python/commit/7f83adf1533becfec870dd0da2082a0d4c28cec9)) +* **internal:** add support for TypeAliasType ([#2265](https://github.com/cloudflare/cloudflare-python/issues/2265)) ([f68f721](https://github.com/cloudflare/cloudflare-python/commit/f68f721a33eaa613afd35659b2ab597fe4fa6330)) +* **internal:** bump httpx dependency ([#2328](https://github.com/cloudflare/cloudflare-python/issues/2328)) ([799c954](https://github.com/cloudflare/cloudflare-python/commit/799c954083db83726ed5be6a7b0b53713f258f3f)) +* **internal:** bump pydantic dependency ([#2251](https://github.com/cloudflare/cloudflare-python/issues/2251)) ([ff3807c](https://github.com/cloudflare/cloudflare-python/commit/ff3807c96489abd5a16254e242ee51be7e72696d)) +* **internal:** bump pyright ([#2232](https://github.com/cloudflare/cloudflare-python/issues/2232)) ([7d503e6](https://github.com/cloudflare/cloudflare-python/commit/7d503e6c363aa6f78603c9df0bce20edb33a9d50)) +* **internal:** bump pyright ([#2264](https://github.com/cloudflare/cloudflare-python/issues/2264)) ([72e5f89](https://github.com/cloudflare/cloudflare-python/commit/72e5f89f7dec1bb5d37dc374f16858373250ff5b)) +* **internal:** codegen related update ([#2176](https://github.com/cloudflare/cloudflare-python/issues/2176)) ([c810755](https://github.com/cloudflare/cloudflare-python/commit/c810755564d385aceab09b2d3afb6b2186a0a19c)) +* **internal:** codegen related update ([#2213](https://github.com/cloudflare/cloudflare-python/issues/2213)) ([5bf1ef5](https://github.com/cloudflare/cloudflare-python/commit/5bf1ef5e81c43c69294d9c230fb730ebfbee1174)) +* **internal:** codegen related update ([#2214](https://github.com/cloudflare/cloudflare-python/issues/2214)) ([515e68c](https://github.com/cloudflare/cloudflare-python/commit/515e68c5bd6ca9215e35e4d118a0bf9d4dff3e31)) +* **internal:** codegen related update ([#2217](https://github.com/cloudflare/cloudflare-python/issues/2217)) ([09de961](https://github.com/cloudflare/cloudflare-python/commit/09de961772df5289817225b381b41a39073e3037)) +* **internal:** codegen related update ([#2218](https://github.com/cloudflare/cloudflare-python/issues/2218)) ([55b8cff](https://github.com/cloudflare/cloudflare-python/commit/55b8cff543096383728c16394cd10af26c2736ee)) +* **internal:** codegen related update ([#2230](https://github.com/cloudflare/cloudflare-python/issues/2230)) ([1156419](https://github.com/cloudflare/cloudflare-python/commit/1156419c4db1c9cbdc155e0c9a655bda7f16cfea)) +* **internal:** codegen related update ([#2253](https://github.com/cloudflare/cloudflare-python/issues/2253)) ([89e9982](https://github.com/cloudflare/cloudflare-python/commit/89e9982bc2c713aa32c4f39dfd4fe8f02fa6cee8)) +* **internal:** codegen related update ([#2282](https://github.com/cloudflare/cloudflare-python/issues/2282)) ([712c994](https://github.com/cloudflare/cloudflare-python/commit/712c9942761fcae1277545d7814ae07d88a3191e)) +* **internal:** codegen related update ([#2289](https://github.com/cloudflare/cloudflare-python/issues/2289)) ([9cb1e41](https://github.com/cloudflare/cloudflare-python/commit/9cb1e41da92e3610e53562529c702b4cc4a51935)) +* **internal:** codegen related update ([#2300](https://github.com/cloudflare/cloudflare-python/issues/2300)) ([73ec2ba](https://github.com/cloudflare/cloudflare-python/commit/73ec2ba285e5b6693234649f595acae1ed3cda52)) +* **internal:** codegen related update ([#2327](https://github.com/cloudflare/cloudflare-python/issues/2327)) ([ff79b8b](https://github.com/cloudflare/cloudflare-python/commit/ff79b8b6b1ff0fa3c6bb78095e661da4ef89ef6d)) +* **internal:** codegen related update ([#2337](https://github.com/cloudflare/cloudflare-python/issues/2337)) ([e0e0068](https://github.com/cloudflare/cloudflare-python/commit/e0e006853574be398ffa3d3d052b5be42148b1cf)) +* **internal:** exclude mypy from running on tests ([#2222](https://github.com/cloudflare/cloudflare-python/issues/2222)) ([ee088e9](https://github.com/cloudflare/cloudflare-python/commit/ee088e9f998ac5ea8e1e0b2f307c8840c4650580)) +* **internal:** fix formatting ([a824f1b](https://github.com/cloudflare/cloudflare-python/commit/a824f1b1ea42835c2e997410497b93bc4534db04)) +* **internal:** fix some typos ([#2283](https://github.com/cloudflare/cloudflare-python/issues/2283)) ([6b98f7a](https://github.com/cloudflare/cloudflare-python/commit/6b98f7a14e94290f6d289395d1317d6764221a0f)) +* **internal:** remove some duplicated imports ([#2272](https://github.com/cloudflare/cloudflare-python/issues/2272)) ([2fe9a70](https://github.com/cloudflare/cloudflare-python/commit/2fe9a7082bce51ad786821210d444dfa17594dfa)) +* **internal:** skip broken tests ([#2345](https://github.com/cloudflare/cloudflare-python/issues/2345)) ([9228d48](https://github.com/cloudflare/cloudflare-python/commit/9228d480c3839e95ad5bfeb70758ce4db9befa74)) +* **internal:** updated imports ([#2274](https://github.com/cloudflare/cloudflare-python/issues/2274)) ([352b69d](https://github.com/cloudflare/cloudflare-python/commit/352b69df4352df21f9259eced108f9f93ffcd82b)) +* make the `Omit` type public ([#2241](https://github.com/cloudflare/cloudflare-python/issues/2241)) ([4b2bf34](https://github.com/cloudflare/cloudflare-python/commit/4b2bf34d7bd2e0e12b8af49e0347b404c73e44e6)) +* rebuild project due to codegen change ([#2134](https://github.com/cloudflare/cloudflare-python/issues/2134)) ([fdc0bb6](https://github.com/cloudflare/cloudflare-python/commit/fdc0bb6474d791e8fc51adf31e1d2fa8997367e9)) +* rebuild project due to codegen change ([#2141](https://github.com/cloudflare/cloudflare-python/issues/2141)) ([1914be1](https://github.com/cloudflare/cloudflare-python/commit/1914be19fb8b7a98ebda76a3199520acb48a57f2)) +* rebuild project due to codegen change ([#2145](https://github.com/cloudflare/cloudflare-python/issues/2145)) ([6473ee6](https://github.com/cloudflare/cloudflare-python/commit/6473ee69bc6eeaa8b03084a8b0f80420acf1cbc2)) +* rebuild project due to codegen change ([#2165](https://github.com/cloudflare/cloudflare-python/issues/2165)) ([877e8c2](https://github.com/cloudflare/cloudflare-python/commit/877e8c2484c620c3f2b9ac70e26732ef7fcb9afa)) +* rebuild project due to codegen change ([#2174](https://github.com/cloudflare/cloudflare-python/issues/2174)) ([dbebda3](https://github.com/cloudflare/cloudflare-python/commit/dbebda3f4635aed4452e12ff11ea3af2c89f33f2)) +* remove now unused `cached-property` dep ([#2208](https://github.com/cloudflare/cloudflare-python/issues/2208)) ([9218b3b](https://github.com/cloudflare/cloudflare-python/commit/9218b3b48b37ee5d40681aa1395382da18d45862)) +* small refactors ([#2306](https://github.com/cloudflare/cloudflare-python/issues/2306)) ([8edd6d6](https://github.com/cloudflare/cloudflare-python/commit/8edd6d6cbd12b34c420ef2e8b8f2db87390ceb50)) +* switch to TypeAliasType for request tracer ([332f48d](https://github.com/cloudflare/cloudflare-python/commit/332f48d846b2af88a4133e71248ee0d69f5d68b1)) +* updates ([#2260](https://github.com/cloudflare/cloudflare-python/issues/2260)) ([d2f86b6](https://github.com/cloudflare/cloudflare-python/commit/d2f86b69e9268d2151638115b3fdbc3af3094eb9)) +* updates ([#2352](https://github.com/cloudflare/cloudflare-python/issues/2352)) ([b241f5b](https://github.com/cloudflare/cloudflare-python/commit/b241f5b4f5b5607462169164a376bc66c368775b)) +* use TypeAliasType for Pydantic v2 only ([da884ff](https://github.com/cloudflare/cloudflare-python/commit/da884ff78bc24160254501c427d5fac838f0aafc)) +* workaround circular import error ([#2210](https://github.com/cloudflare/cloudflare-python/issues/2210)) ([eb4ca16](https://github.com/cloudflare/cloudflare-python/commit/eb4ca167049be8517da3a422ca80696733550116)) + + +### Documentation + +* **api.md:** fix return type annotations ([#2215](https://github.com/cloudflare/cloudflare-python/issues/2215)) ([ce08157](https://github.com/cloudflare/cloudflare-python/commit/ce08157eefb2cee486cee2e4e0551e849daca7bf)) +* fix typos ([#2336](https://github.com/cloudflare/cloudflare-python/issues/2336)) ([5a0030a](https://github.com/cloudflare/cloudflare-python/commit/5a0030a63d92763c38338682b6fc91ea4ac5a381)) +* **readme:** example snippet for client context manager ([#2280](https://github.com/cloudflare/cloudflare-python/issues/2280)) ([54e1a34](https://github.com/cloudflare/cloudflare-python/commit/54e1a34f48a56f8403e7bd55722a2023894d91a1)) +* **readme:** fix http client proxies example ([#2252](https://github.com/cloudflare/cloudflare-python/issues/2252)) ([3f9fd35](https://github.com/cloudflare/cloudflare-python/commit/3f9fd35d891c13d409dca89c1d640d73db0a3b01)) + ## 3.1.0 (2024-07-16) Full Changelog: [v3.0.1...v3.1.0](https://github.com/cloudflare/cloudflare-python/compare/v3.0.1...v3.1.0) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 655bcd3b39d..f6d738cea14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,13 @@ ### With Rye -We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version. +We use [Rye](https://rye.astral.sh/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run: -After installing Rye, you'll just have to run this command: +```sh +$ ./scripts/bootstrap +``` + +Or [install Rye manually](https://rye.astral.sh/guide/installation/) and run: ```sh $ rye sync --all-features @@ -13,8 +17,7 @@ $ rye sync --all-features You can then run scripts using `rye run python script.py` or by activating the virtual environment: ```sh -$ rye shell -# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work +# Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work $ source .venv/bin/activate # now you can omit the `rye run` prefix @@ -31,25 +34,25 @@ $ pip install -r requirements-dev.lock ## Modifying/Adding code -Most of the SDK is generated code, and any modified code will be overridden on the next generation. The -`src/cloudflare/lib/` and `examples/` directories are exceptions and will never be overridden. +Most of the SDK is generated code. Modifications to code will be persisted between generations, but may +result in merge conflicts between manual patches and changes from the generator. The generator will never +modify the contents of the `src/cloudflare/lib/` and `examples/` directories. ## Adding and running examples -All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or -added to. +All files in the `examples/` directory are not modified by the generator and can be freely edited or added to. -```bash +```py # add an example to examples/.py #!/usr/bin/env -S rye run python … ``` -``` -chmod +x examples/.py +```sh +$ chmod +x examples/.py # run the example against your api -./examples/.py +$ ./examples/.py ``` ## Using the repository from source @@ -58,8 +61,8 @@ If you’d like to use the repository from source, you can either install from g To install via git: -```bash -pip install git+ssh://git@github.com/cloudflare/cloudflare-python.git +```sh +$ pip install git+ssh://git@github.com/cloudflare/cloudflare-python.git ``` Alternatively, you can build from source and install the wheel file: @@ -68,29 +71,29 @@ Building this package will create two files in the `dist/` directory, a `.tar.gz To create a distributable version of the library, all you have to do is run this command: -```bash -rye build +```sh +$ rye build # or -python -m build +$ python -m build ``` Then to install: ```sh -pip install ./path-to-wheel-file.whl +$ pip install ./path-to-wheel-file.whl ``` ## Running tests Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. -```bash +```sh # you will need npm installed -npx prism mock path/to/your/openapi.yml +$ npx prism mock path/to/your/openapi.yml ``` -```bash -rye run pytest +```sh +$ ./scripts/test ``` ## Linting and formatting @@ -100,14 +103,14 @@ This repository uses [ruff](https://github.com/astral-sh/ruff) and To lint: -```bash -rye run lint +```sh +$ ./scripts/lint ``` To format and fix all ruff issues automatically: -```bash -rye run format +```sh +$ ./scripts/format ``` ## Publishing and releases diff --git a/LICENSE b/LICENSE index 827fca03dd8..27db488677c 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Cloudflare + Copyright 2026 Cloudflare Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 2175e1eeb78..9f9d4b169a7 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,23 @@ # Cloudflare Python API library -[![PyPI version](https://img.shields.io/pypi/v/cloudflare.svg)](https://pypi.org/project/cloudflare/) + +[![PyPI version](https://img.shields.io/pypi/v/cloudflare.svg?label=pypi%20(stable))](https://pypi.org/project/cloudflare/) -The Cloudflare Python library provides convenient access to the Cloudflare REST API from any Python 3.7+ +The Cloudflare Python library provides convenient access to the Cloudflare REST API from any Python 3.9+ application. The library includes type definitions for all request params and response fields, and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx). +It is generated with [Stainless](https://www.stainless.com/). + +## MCP Server + +Use the Cloudflare MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cloudflare-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsb3VkZmxhcmUtbWNwIl19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cloudflare-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cloudflare-mcp%22%5D%7D) + +> Note: You may need to set environment variables in your MCP client. + ## Documentation The REST API documentation can be found on [developers.cloudflare.com](https://developers.cloudflare.com/api). The full API of this library can be found in [api.md](api.md). @@ -14,7 +26,7 @@ The REST API documentation can be found on [developers.cloudflare.com](https://d ```sh # install from PyPI -pip install cloudflare +pip install --pre cloudflare ``` ## Usage @@ -26,10 +38,7 @@ import os from cloudflare import Cloudflare client = Cloudflare( - # This is the default and can be omitted - api_email=os.environ.get("CLOUDFLARE_EMAIL"), - # This is the default and can be omitted - api_key=os.environ.get("CLOUDFLARE_API_KEY"), + api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) zone = client.zones.create( @@ -55,10 +64,7 @@ import asyncio from cloudflare import AsyncCloudflare client = AsyncCloudflare( - # This is the default and can be omitted - api_email=os.environ.get("CLOUDFLARE_EMAIL"), - # This is the default and can be omitted - api_key=os.environ.get("CLOUDFLARE_API_KEY"), + api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) @@ -76,6 +82,42 @@ asyncio.run(main()) Functionality between the synchronous and asynchronous clients is otherwise identical. +### With aiohttp + +By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend. + +You can enable this by installing `aiohttp`: + +```sh +# install from PyPI +pip install --pre cloudflare[aiohttp] +``` + +Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: + +```python +import os +import asyncio +from cloudflare import DefaultAioHttpClient +from cloudflare import AsyncCloudflare + + +async def main() -> None: + async with AsyncCloudflare( + api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted + http_client=DefaultAioHttpClient(), + ) as client: + zone = await client.zones.create( + account={"id": "023e105f4ecef8ad9ca31a8372d0c353"}, + name="example.com", + type="full", + ) + print(zone.id) + + +asyncio.run(main()) +``` + ## Using types Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like: @@ -92,7 +134,7 @@ List methods in the Cloudflare API are paginated. This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually: ```python -import cloudflare +from cloudflare import Cloudflare client = Cloudflare() @@ -108,7 +150,7 @@ Or, asynchronously: ```python import asyncio -import cloudflare +from cloudflare import AsyncCloudflare client = AsyncCloudflare() @@ -141,11 +183,47 @@ Or just work directly with the returned data: ```python first_page = await client.accounts.list() for account in first_page.result: - print(account) + print(account.id) # Remove `await` for non-async usage. ``` +## Nested params + +Nested parameters are dictionaries, typed using `TypedDict`, for example: + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +zone = client.zones.create( + account={}, + name="example.com", +) +print(zone.account) +``` + +## File uploads + +Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`. + +```python +from pathlib import Path +from cloudflare import Cloudflare + +client = Cloudflare() + +client.kv.namespaces.values.update( + key_name="My-Key", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + namespace_id="0f2ac74b498b48028cb68387c421e279", + value=Path("/path/to/file"), +) +``` + +The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically. + ## Handling errors When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `cloudflare.APIConnectionError` is raised. @@ -176,7 +254,7 @@ except cloudflare.APIStatusError as e: print(e.response) ``` -Error codes are as followed: +Error codes are as follows: | Status Code | Error Type | | ----------- | -------------------------- | @@ -215,7 +293,7 @@ client.with_options(max_retries=5).zones.get( ### Timeouts By default requests time out after 1 minute. You can configure this with a `timeout` option, -which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object: +which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object: ```python from cloudflare import Cloudflare @@ -247,12 +325,14 @@ Note that requests that time out are [retried twice by default](#retries). We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module. -You can enable logging by setting the environment variable `CLOUDFLARE_LOG` to `debug`. +You can enable logging by setting the environment variable `CLOUDFLARE_LOG` to `info`. ```shell -$ export CLOUDFLARE_LOG=debug +$ export CLOUDFLARE_LOG=info ``` +Or to `debug` for more verbose logging. + ### How to tell whether `None` means `null` or missing In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`: @@ -319,8 +399,7 @@ If you need to access undocumented endpoints, params, or response properties, th #### Undocumented endpoints To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other -http verbs. Options on the client will be respected (such as retries) will be respected when making this -request. +http verbs. Options on the client will be respected (such as retries) when making this request. ```py import httpx @@ -349,39 +428,67 @@ can also get all the extra fields on the Pydantic model as a dict with You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including: -- Support for proxies -- Custom transports +- Support for [proxies](https://www.python-httpx.org/advanced/proxies/) +- Custom [transports](https://www.python-httpx.org/advanced/transports/) - Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality ```python +import httpx from cloudflare import Cloudflare, DefaultHttpxClient client = Cloudflare( # Or use the `CLOUDFLARE_BASE_URL` env var base_url="http://my.test.server.example.com:8083", http_client=DefaultHttpxClient( - proxies="http://my.test.proxy.example.com", + proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0"), ), ) ``` +You can also customize the client on a per-request basis by using `with_options()`: + +```python +client.with_options(http_client=DefaultHttpxClient(...)) +``` + ### Managing HTTP resources By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting. +```py +from cloudflare import Cloudflare + +with Cloudflare() as client: + # make requests here + ... + +# HTTP client is now closed +``` + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: 1. Changes that only affect static types, without breaking runtime behavior. -1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +1. Changes to library internals which are technically public but not intended or documented for external use. 1. Changes that we do not expect to impact the vast majority of users in practice. -> [!WARNING] -> In addition to the above, changes to type names, structure or methods _may_ occur as we stabilise the automated codegen pipeline. This will be removed in the future once we are further along and the service owner OpenAPI schemas have reached a higher maturity level where changes are not as constant. -> If this isn't suitable for your project, we recommend pinning to a known version or using the previous major version. +### Determining the installed version + +If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version. + +You can determine the version that is being used at runtime with: + +```py +import cloudflare +print(cloudflare.__version__) +``` ## Requirements -Python 3.7 or higher. +Python 3.9 or higher. + +## Contributing + +See [the contributing documentation](./CONTRIBUTING.md). diff --git a/SECURITY.md b/SECURITY.md index 0735c892994..f04da23d126 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,3 +1,3 @@ # Reporting Security Vulnerabilities -Please see [this page](https://www.cloudflare.com/.well-known/security.txt) for information on how to report a vulnerability to Cloudflare. Thanks! +Please see [this page](https://www.cloudflare.com/.well-known/security.txt) for information on how to report a vulnerability to Cloudflare. Thanks! \ No newline at end of file diff --git a/api.md b/api.md index b2c35ac9ccd..890a848cb44 100644 --- a/api.md +++ b/api.md @@ -14,10 +14,18 @@ from cloudflare.types import ( PaginationInfo, Permission, PermissionGrant, + RatePlan, ResponseInfo, Result, Role, SortDirection, + Subscription, + SubscriptionComponent, + SubscriptionZone, + Token, + TokenConditionCIDRList, + TokenPolicy, + TokenValue, ) ``` @@ -26,56 +34,133 @@ from cloudflare.types import ( Types: ```python -from cloudflare.types.accounts import ( - Account, - AccountUpdateResponse, - AccountListResponse, - AccountGetResponse, -) +from cloudflare.types.accounts import Account, AccountDeleteResponse ``` Methods: -- client.accounts.update(\*, account_id, \*\*params) -> object -- client.accounts.list(\*\*params) -> SyncV4PagePaginationArray[object] -- client.accounts.get(\*, account_id) -> object +- client.accounts.create(\*\*params) -> Optional[Account] +- client.accounts.update(\*, account_id, \*\*params) -> Optional[Account] +- client.accounts.list(\*\*params) -> SyncV4PagePaginationArray[Account] +- client.accounts.delete(\*, account_id) -> Optional[AccountDeleteResponse] +- client.accounts.get(\*, account_id) -> Optional[Account] ## Members Types: ```python -from cloudflare.types.accounts import ( - Status, - UserWithInviteCode, - MemberCreateResponse, - MemberUpdateResponse, - MemberListResponse, - MemberDeleteResponse, - MemberGetResponse, -) +from cloudflare.types.accounts import Status, MemberDeleteResponse ``` Methods: -- client.accounts.members.create(\*, account_id, \*\*params) -> Optional -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Optional -- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] -- client.accounts.members.delete(member_id, \*, account_id) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> Optional +- client.accounts.members.create(\*, account_id, \*\*params) -> Optional[Member] +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Optional[Member] +- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Member] +- client.accounts.members.delete(member_id, \*, account_id) -> Optional[MemberDeleteResponse] +- client.accounts.members.get(member_id, \*, account_id) -> Optional[Member] ## Roles +Methods: + +- client.accounts.roles.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Role] +- client.accounts.roles.get(role_id, \*, account_id) -> Optional[Role] + +## Subscriptions + +Types: + +```python +from cloudflare.types.accounts import SubscriptionDeleteResponse +``` + +Methods: + +- client.accounts.subscriptions.create(\*, account_id, \*\*params) -> Subscription +- client.accounts.subscriptions.update(subscription_identifier, \*, account_id, \*\*params) -> Subscription +- client.accounts.subscriptions.delete(subscription_identifier, \*, account_id) -> SubscriptionDeleteResponse +- client.accounts.subscriptions.get(\*, account_id) -> SyncSinglePage[Subscription] + +## Tokens + +Types: + +```python +from cloudflare.types.accounts import TokenCreateResponse, TokenDeleteResponse, TokenVerifyResponse +``` + +Methods: + +- client.accounts.tokens.create(\*, account_id, \*\*params) -> Optional[TokenCreateResponse] +- client.accounts.tokens.update(token_id, \*, account_id, \*\*params) -> Optional[Token] +- client.accounts.tokens.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Token] +- client.accounts.tokens.delete(token_id, \*, account_id) -> Optional[TokenDeleteResponse] +- client.accounts.tokens.get(token_id, \*, account_id) -> Optional[Token] +- client.accounts.tokens.verify(\*, account_id) -> Optional[TokenVerifyResponse] + +### PermissionGroups + +Types: + +```python +from cloudflare.types.accounts.tokens import PermissionGroupListResponse, PermissionGroupGetResponse +``` + +Methods: + +- client.accounts.tokens.permission_groups.list(\*, account_id, \*\*params) -> SyncSinglePage[PermissionGroupListResponse] +- client.accounts.tokens.permission_groups.get(\*, account_id, \*\*params) -> Optional[PermissionGroupGetResponse] + +### Value + +Methods: + +- client.accounts.tokens.value.update(token_id, \*, account_id, \*\*params) -> str + +## Logs + +### Audit + +Types: + +```python +from cloudflare.types.accounts.logs import AuditListResponse +``` + +Methods: + +- client.accounts.logs.audit.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[AuditListResponse] + +# Organizations + +Types: + +```python +from cloudflare.types.organizations import Organization, OrganizationDeleteResponse +``` + +Methods: + +- client.organizations.create(\*\*params) -> Organization +- client.organizations.update(organization_id, \*\*params) -> Organization +- client.organizations.list(\*\*params) -> SyncSinglePage[Organization] +- client.organizations.delete(organization_id) -> OrganizationDeleteResponse +- client.organizations.get(organization_id) -> Organization + +## OrganizationProfile + Types: ```python -from cloudflare.types.accounts import RoleGetResponse +from cloudflare.types.organizations import OrganizationProfile ``` Methods: -- client.accounts.roles.list(\*, account_id) -> SyncSinglePage[Role] -- client.accounts.roles.get(role_id, \*, account_id) -> object +- client.organizations.organization_profile.update(organization_id, \*\*params) -> None +- client.organizations.organization_profile.get(organization_id) -> Result # OriginCACertificates @@ -84,30 +169,28 @@ Types: ```python from cloudflare.types.origin_ca_certificates import ( OriginCACertificate, - OriginCACertificateCreateResponse, OriginCACertificateDeleteResponse, - OriginCACertificateGetResponse, ) ``` Methods: -- client.origin_ca_certificates.create(\*\*params) -> Optional -- client.origin_ca_certificates.list(\*\*params) -> SyncSinglePage[OriginCACertificate] -- client.origin_ca_certificates.delete(certificate_id) -> Optional -- client.origin_ca_certificates.get(certificate_id) -> Optional +- client.origin_ca_certificates.create(\*\*params) -> Optional[OriginCACertificate] +- client.origin_ca_certificates.list(\*\*params) -> SyncV4PagePaginationArray[OriginCACertificate] +- client.origin_ca_certificates.delete(certificate_id) -> Optional[OriginCACertificateDeleteResponse] +- client.origin_ca_certificates.get(certificate_id) -> Optional[OriginCACertificate] # IPs Types: ```python -from cloudflare.types.ips import IPs, JDCloudIPs, IPListResponse +from cloudflare.types.ips import IPs, IPListResponse ``` Methods: -- client.ips.list(\*\*params) -> Optional +- client.ips.list(\*\*params) -> Optional[IPListResponse] # Memberships @@ -124,10 +207,10 @@ from cloudflare.types.memberships import ( Methods: -- client.memberships.update(membership_id, \*\*params) -> Optional +- client.memberships.update(membership_id, \*\*params) -> Optional[MembershipUpdateResponse] - client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] -- client.memberships.delete(membership_id) -> Optional -- client.memberships.get(membership_id) -> Optional +- client.memberships.delete(membership_id) -> Optional[MembershipDeleteResponse] +- client.memberships.get(membership_id) -> Optional[MembershipGetResponse] # User @@ -139,8 +222,8 @@ from cloudflare.types.user import UserEditResponse, UserGetResponse Methods: -- client.user.edit(\*\*params) -> object -- client.user.get() -> object +- client.user.edit(\*\*params) -> Optional[UserEditResponse] +- client.user.get() -> Optional[UserGetResponse] ## AuditLogs @@ -179,79 +262,59 @@ Methods: Types: ```python -from cloudflare.types.user import Invite, InviteEditResponse, InviteGetResponse +from cloudflare.types.user import Invite ``` Methods: - client.user.invites.list() -> SyncSinglePage[Invite] -- client.user.invites.edit(invite_id, \*\*params) -> object -- client.user.invites.get(invite_id) -> object +- client.user.invites.edit(invite_id, \*\*params) -> Optional[Invite] +- client.user.invites.get(invite_id) -> Optional[Invite] ## Organizations Types: ```python -from cloudflare.types.user import Organization, OrganizationDeleteResponse, OrganizationGetResponse +from cloudflare.types.user import Organization, OrganizationDeleteResponse ``` Methods: - client.user.organizations.list(\*\*params) -> SyncV4PagePaginationArray[Organization] - client.user.organizations.delete(organization_id) -> OrganizationDeleteResponse -- client.user.organizations.get(organization_id) -> object +- client.user.organizations.get(organization_id) -> object ## Subscriptions Types: ```python -from cloudflare.types.user import ( - RatePlan, - Subscription, - SubscriptionComponent, - SubscriptionZone, - SubscriptionUpdateResponse, - SubscriptionDeleteResponse, - SubscriptionEditResponse, - SubscriptionGetResponse, -) +from cloudflare.types.user import SubscriptionUpdateResponse, SubscriptionDeleteResponse ``` Methods: - client.user.subscriptions.update(identifier, \*\*params) -> SubscriptionUpdateResponse - client.user.subscriptions.delete(identifier) -> SubscriptionDeleteResponse -- client.user.subscriptions.edit(identifier, \*\*params) -> SubscriptionEditResponse -- client.user.subscriptions.get() -> Optional +- client.user.subscriptions.get() -> SyncSinglePage[Subscription] ## Tokens Types: ```python -from cloudflare.types.user import ( - CIDRList, - Policy, - Token, - TokenCreateResponse, - TokenUpdateResponse, - TokenListResponse, - TokenDeleteResponse, - TokenGetResponse, - TokenVerifyResponse, -) +from cloudflare.types.user import TokenCreateResponse, TokenDeleteResponse, TokenVerifyResponse ``` Methods: -- client.user.tokens.create(\*\*params) -> Optional -- client.user.tokens.update(token_id, \*\*params) -> object -- client.user.tokens.list(\*\*params) -> SyncV4PagePaginationArray[object] -- client.user.tokens.delete(token_id) -> Optional -- client.user.tokens.get(token_id) -> object -- client.user.tokens.verify() -> Optional +- client.user.tokens.create(\*\*params) -> Optional[TokenCreateResponse] +- client.user.tokens.update(token_id, \*\*params) -> Optional[Token] +- client.user.tokens.list(\*\*params) -> SyncV4PagePaginationArray[Token] +- client.user.tokens.delete(token_id) -> Optional[TokenDeleteResponse] +- client.user.tokens.get(token_id) -> Optional[Token] +- client.user.tokens.verify() -> Optional[TokenVerifyResponse] ### PermissionGroups @@ -263,19 +326,13 @@ from cloudflare.types.user.tokens import PermissionGroupListResponse Methods: -- client.user.tokens.permission_groups.list() -> SyncSinglePage[object] +- client.user.tokens.permission_groups.list(\*\*params) -> SyncSinglePage[PermissionGroupListResponse] ### Value -Types: - -```python -from cloudflare.types.user.tokens import Value -``` - Methods: -- client.user.tokens.value.update(token_id, \*\*params) -> str +- client.user.tokens.value.update(token_id, \*\*params) -> str # Zones @@ -287,11 +344,11 @@ from cloudflare.types.zones import Type, Zone, ZoneDeleteResponse Methods: -- client.zones.create(\*\*params) -> Optional +- client.zones.create(\*\*params) -> Optional[Zone] - client.zones.list(\*\*params) -> SyncV4PagePaginationArray[Zone] -- client.zones.delete(\*, zone_id) -> Optional -- client.zones.edit(\*, zone_id, \*\*params) -> Optional -- client.zones.get(\*, zone_id) -> Optional +- client.zones.delete(\*, zone_id) -> Optional[ZoneDeleteResponse] +- client.zones.edit(\*, zone_id, \*\*params) -> Optional[Zone] +- client.zones.get(\*, zone_id) -> Optional[Zone] ## ActivationCheck @@ -303,7 +360,7 @@ from cloudflare.types.zones import ActivationCheckTriggerResponse Methods: -- client.zones.activation_check.trigger(\*, zone_id) -> Optional +- client.zones.activation_check.trigger(\*, zone_id) -> Optional[ActivationCheckTriggerResponse] ## Settings @@ -312,6 +369,7 @@ Types: ```python from cloudflare.types.zones import ( AdvancedDDoS, + Aegis, AlwaysOnline, AlwaysUseHTTPS, AutomaticHTTPSRewrites, @@ -334,9 +392,7 @@ from cloudflare.types.zones import ( IPGeolocation, IPV6, MinTLSVersion, - Minify, Mirage, - MobileRedirect, NEL, OpportunisticEncryption, OpportunisticOnion, @@ -369,8 +425,8 @@ from cloudflare.types.zones import ( Methods: -- client.zones.settings.edit(setting_id, \*, zone_id, \*\*params) -> Optional -- client.zones.settings.get(setting_id, \*, zone_id) -> Optional +- client.zones.settings.edit(setting_id, \*, zone_id, \*\*params) -> Optional[SettingEditResponse] +- client.zones.settings.get(setting_id, \*, zone_id) -> Optional[SettingGetResponse] ## CustomNameservers @@ -382,8 +438,8 @@ from cloudflare.types.zones import CustomNameserverUpdateResponse, CustomNameser Methods: -- client.zones.custom_nameservers.update(\*, zone_id, \*\*params) -> Optional -- client.zones.custom_nameservers.get(\*, zone_id) -> Optional +- client.zones.custom_nameservers.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomNameserverUpdateResponse] +- client.zones.custom_nameservers.get(\*, zone_id) -> CustomNameserverGetResponse ## Holds @@ -396,7 +452,8 @@ from cloudflare.types.zones import ZoneHold Methods: - client.zones.holds.create(\*, zone_id, \*\*params) -> ZoneHold -- client.zones.holds.delete(\*, zone_id, \*\*params) -> Optional +- client.zones.holds.delete(\*, zone_id, \*\*params) -> ZoneHold +- client.zones.holds.edit(\*, zone_id, \*\*params) -> ZoneHold - client.zones.holds.get(\*, zone_id) -> ZoneHold ## Subscriptions @@ -404,14 +461,43 @@ Methods: Types: ```python -from cloudflare.types.zones import SubscriptionCreateResponse, SubscriptionGetResponse +from cloudflare.types.zones import ( + SubscriptionCreateResponse, + SubscriptionUpdateResponse, + SubscriptionGetResponse, +) +``` + +Methods: + +- client.zones.subscriptions.create(\*, zone_id, \*\*params) -> SubscriptionCreateResponse +- client.zones.subscriptions.update(\*, zone_id, \*\*params) -> SubscriptionUpdateResponse +- client.zones.subscriptions.get(\*, zone_id) -> SubscriptionGetResponse + +## Plans + +Types: + +```python +from cloudflare.types.zones import AvailableRatePlan +``` + +Methods: + +- client.zones.plans.list(\*, zone_id) -> SyncSinglePage[AvailableRatePlan] +- client.zones.plans.get(plan_identifier, \*, zone_id) -> AvailableRatePlan + +## RatePlans + +Types: + +```python +from cloudflare.types.zones import RatePlanGetResponse ``` Methods: -- client.zones.subscriptions.create(identifier, \*\*params) -> SubscriptionCreateResponse -- client.zones.subscriptions.list(account_identifier) -> SyncSinglePage[Subscription] -- client.zones.subscriptions.get(identifier) -> SubscriptionGetResponse +- client.zones.rate_plans.get(\*, zone_id) -> SyncSinglePage[RatePlanGetResponse] # LoadBalancers @@ -488,7 +574,24 @@ from cloudflare.types.load_balancers.monitors import ReferenceGetResponse Methods: -- client.load_balancers.monitors.references.get(monitor_id, \*, account_id) -> Optional +- client.load_balancers.monitors.references.get(monitor_id, \*, account_id) -> SyncSinglePage[ReferenceGetResponse] + +## MonitorGroups + +Types: + +```python +from cloudflare.types.load_balancers import MonitorGroup +``` + +Methods: + +- client.load_balancers.monitor_groups.create(\*, account_id, \*\*params) -> MonitorGroup +- client.load_balancers.monitor_groups.update(monitor_group_id, \*, account_id, \*\*params) -> MonitorGroup +- client.load_balancers.monitor_groups.list(\*, account_id) -> SyncSinglePage[MonitorGroup] +- client.load_balancers.monitor_groups.delete(monitor_group_id, \*, account_id) -> MonitorGroup +- client.load_balancers.monitor_groups.edit(monitor_group_id, \*, account_id, \*\*params) -> MonitorGroup +- client.load_balancers.monitor_groups.get(monitor_group_id, \*, account_id) -> MonitorGroup ## Pools @@ -504,6 +607,7 @@ Methods: - client.load_balancers.pools.update(pool_id, \*, account_id, \*\*params) -> Pool - client.load_balancers.pools.list(\*, account_id, \*\*params) -> SyncSinglePage[Pool] - client.load_balancers.pools.delete(pool_id, \*, account_id) -> PoolDeleteResponse +- client.load_balancers.pools.bulk_edit(\*, account_id, \*\*params) -> SyncSinglePage[Pool] - client.load_balancers.pools.edit(pool_id, \*, account_id, \*\*params) -> Pool - client.load_balancers.pools.get(pool_id, \*, account_id) -> Pool @@ -530,7 +634,7 @@ from cloudflare.types.load_balancers.pools import ReferenceGetResponse Methods: -- client.load_balancers.pools.references.get(pool_id, \*, account_id) -> Optional +- client.load_balancers.pools.references.get(pool_id, \*, account_id) -> SyncSinglePage[ReferenceGetResponse] ## Previews @@ -562,12 +666,12 @@ Methods: Types: ```python -from cloudflare.types.load_balancers import SearchGetResponse +from cloudflare.types.load_balancers import SearchListResponse ``` Methods: -- client.load_balancers.searches.get(\*, account_id, \*\*params) -> Optional +- client.load_balancers.searches.list(\*, account_id, \*\*params) -> SyncV4PagePagination[SearchListResponse] # Cache @@ -579,7 +683,7 @@ from cloudflare.types.cache import CachePurgeResponse Methods: -- client.cache.purge(\*, zone_id, \*\*params) -> Optional +- client.cache.purge(\*, zone_id, \*\*params) -> Optional[CachePurgeResponse] ## CacheReserve @@ -599,10 +703,10 @@ from cloudflare.types.cache import ( Methods: -- client.cache.cache_reserve.clear(\*, zone_id, \*\*params) -> CacheReserveClearResponse -- client.cache.cache_reserve.edit(\*, zone_id, \*\*params) -> CacheReserveEditResponse -- client.cache.cache_reserve.get(\*, zone_id) -> CacheReserveGetResponse -- client.cache.cache_reserve.status(\*, zone_id) -> CacheReserveStatusResponse +- client.cache.cache_reserve.clear(\*, zone_id, \*\*params) -> Optional[CacheReserveClearResponse] +- client.cache.cache_reserve.edit(\*, zone_id, \*\*params) -> Optional[CacheReserveEditResponse] +- client.cache.cache_reserve.get(\*, zone_id) -> Optional[CacheReserveGetResponse] +- client.cache.cache_reserve.status(\*, zone_id) -> Optional[CacheReserveStatusResponse] ## SmartTieredCache @@ -618,9 +722,9 @@ from cloudflare.types.cache import ( Methods: -- client.cache.smart_tiered_cache.delete(\*, zone_id) -> SmartTieredCacheDeleteResponse -- client.cache.smart_tiered_cache.edit(\*, zone_id, \*\*params) -> SmartTieredCacheEditResponse -- client.cache.smart_tiered_cache.get(\*, zone_id) -> SmartTieredCacheGetResponse +- client.cache.smart_tiered_cache.delete(\*, zone_id) -> Optional[SmartTieredCacheDeleteResponse] +- client.cache.smart_tiered_cache.edit(\*, zone_id, \*\*params) -> Optional[SmartTieredCacheEditResponse] +- client.cache.smart_tiered_cache.get(\*, zone_id) -> Optional[SmartTieredCacheGetResponse] ## Variants @@ -629,7 +733,7 @@ Types: ```python from cloudflare.types.cache import ( CacheVariant, - CacheVariantIdentifier, + VariantDeleteResponse, VariantEditResponse, VariantGetResponse, ) @@ -637,9 +741,9 @@ from cloudflare.types.cache import ( Methods: -- client.cache.variants.delete(\*, zone_id) -> CacheVariant -- client.cache.variants.edit(\*, zone_id, \*\*params) -> VariantEditResponse -- client.cache.variants.get(\*, zone_id) -> VariantGetResponse +- client.cache.variants.delete(\*, zone_id) -> Optional[VariantDeleteResponse] +- client.cache.variants.edit(\*, zone_id, \*\*params) -> Optional[VariantEditResponse] +- client.cache.variants.get(\*, zone_id) -> Optional[VariantGetResponse] ## RegionalTieredCache @@ -655,22 +759,16 @@ from cloudflare.types.cache import ( Methods: -- client.cache.regional_tiered_cache.edit(\*, zone_id, \*\*params) -> RegionalTieredCacheEditResponse -- client.cache.regional_tiered_cache.get(\*, zone_id) -> RegionalTieredCacheGetResponse +- client.cache.regional_tiered_cache.edit(\*, zone_id, \*\*params) -> Optional[RegionalTieredCacheEditResponse] +- client.cache.regional_tiered_cache.get(\*, zone_id) -> Optional[RegionalTieredCacheGetResponse] # SSL ## Analyze -Types: - -```python -from cloudflare.types.ssl import AnalyzeCreateResponse -``` - Methods: -- client.ssl.analyze.create(\*, zone_id, \*\*params) -> Optional +- client.ssl.analyze.create(\*, zone_id, \*\*params) -> object ## CertificatePacks @@ -682,6 +780,7 @@ from cloudflare.types.ssl import ( RequestValidity, Status, ValidationMethod, + CertificatePackCreateResponse, CertificatePackListResponse, CertificatePackDeleteResponse, CertificatePackEditResponse, @@ -691,22 +790,11 @@ from cloudflare.types.ssl import ( Methods: -- client.ssl.certificate_packs.list(\*, zone_id, \*\*params) -> SyncSinglePage[object] -- client.ssl.certificate_packs.delete(certificate_pack_id, \*, zone_id) -> Optional -- client.ssl.certificate_packs.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional -- client.ssl.certificate_packs.get(certificate_pack_id, \*, zone_id) -> Optional - -### Order - -Types: - -```python -from cloudflare.types.ssl.certificate_packs import OrderCreateResponse -``` - -Methods: - -- client.ssl.certificate_packs.order.create(\*, zone_id, \*\*params) -> Optional +- client.ssl.certificate_packs.create(\*, zone_id, \*\*params) -> Optional[CertificatePackCreateResponse] +- client.ssl.certificate_packs.list(\*, zone_id, \*\*params) -> SyncSinglePage[CertificatePackListResponse] +- client.ssl.certificate_packs.delete(certificate_pack_id, \*, zone_id) -> Optional[CertificatePackDeleteResponse] +- client.ssl.certificate_packs.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional[CertificatePackEditResponse] +- client.ssl.certificate_packs.get(certificate_pack_id, \*, zone_id) -> Optional[CertificatePackGetResponse] ### Quota @@ -718,7 +806,7 @@ from cloudflare.types.ssl.certificate_packs import QuotaGetResponse Methods: -- client.ssl.certificate_packs.quota.get(\*, zone_id) -> Optional +- client.ssl.certificate_packs.quota.get(\*, zone_id) -> Optional[QuotaGetResponse] ## Recommendations @@ -730,7 +818,7 @@ from cloudflare.types.ssl import RecommendationGetResponse Methods: -- client.ssl.recommendations.get(zone_identifier) -> Optional +- client.ssl.recommendations.get(\*, zone_id) -> RecommendationGetResponse ## Universal @@ -744,8 +832,8 @@ from cloudflare.types.ssl.universal import UniversalSSLSettings Methods: -- client.ssl.universal.settings.edit(\*, zone_id, \*\*params) -> Optional -- client.ssl.universal.settings.get(\*, zone_id) -> Optional +- client.ssl.universal.settings.edit(\*, zone_id, \*\*params) -> Optional[UniversalSSLSettings] +- client.ssl.universal.settings.get(\*, zone_id) -> Optional[UniversalSSLSettings] ## Verification @@ -757,29 +845,8 @@ from cloudflare.types.ssl import Verification, VerificationEditResponse, Verific Methods: -- client.ssl.verification.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional -- client.ssl.verification.get(\*, zone_id, \*\*params) -> Optional - -# Subscriptions - -Types: - -```python -from cloudflare.types.subscriptions import ( - SubscriptionCreateResponse, - SubscriptionUpdateResponse, - SubscriptionDeleteResponse, - SubscriptionGetResponse, -) -``` - -Methods: - -- client.subscriptions.create(identifier, \*\*params) -> SubscriptionCreateResponse -- client.subscriptions.update(subscription_identifier, \*, account_identifier, \*\*params) -> SubscriptionUpdateResponse -- client.subscriptions.list(account_identifier) -> SyncSinglePage[Subscription] -- client.subscriptions.delete(subscription_identifier, \*, account_identifier) -> SubscriptionDeleteResponse -- client.subscriptions.get(identifier) -> SubscriptionGetResponse +- client.ssl.verification.edit(certificate_pack_id, \*, zone_id, \*\*params) -> Optional[VerificationEditResponse] +- client.ssl.verification.get(\*, zone_id, \*\*params) -> Optional[VerificationGetResponse] # ACM @@ -788,13 +855,19 @@ Methods: Types: ```python -from cloudflare.types.acm import CertificateAuthority, TotalTLSCreateResponse, TotalTLSGetResponse +from cloudflare.types.acm import ( + CertificateAuthority, + TotalTLSUpdateResponse, + TotalTLSEditResponse, + TotalTLSGetResponse, +) ``` Methods: -- client.acm.total_tls.create(\*, zone_id, \*\*params) -> Optional -- client.acm.total_tls.get(\*, zone_id) -> Optional +- client.acm.total_tls.update(\*, zone_id, \*\*params) -> Optional[TotalTLSUpdateResponse] +- client.acm.total_tls.edit(\*, zone_id, \*\*params) -> Optional[TotalTLSEditResponse] +- client.acm.total_tls.get(\*, zone_id) -> Optional[TotalTLSGetResponse] # Argo @@ -821,33 +894,8 @@ from cloudflare.types.argo import TieredCachingEditResponse, TieredCachingGetRes Methods: -- client.argo.tiered_caching.edit(\*, zone_id, \*\*params) -> TieredCachingEditResponse -- client.argo.tiered_caching.get(\*, zone_id) -> TieredCachingGetResponse - -# Plans - -Types: - -```python -from cloudflare.types.plans import AvailableRatePlan -``` - -Methods: - -- client.plans.list(zone_identifier) -> SyncSinglePage[AvailableRatePlan] -- client.plans.get(plan_identifier, \*, zone_identifier) -> AvailableRatePlan - -# RatePlans - -Types: - -```python -from cloudflare.types.rate_plans import RatePlan, RatePlanGetResponse -``` - -Methods: - -- client.rate_plans.get(zone_identifier) -> Optional +- client.argo.tiered_caching.edit(\*, zone_id, \*\*params) -> Optional[TieredCachingEditResponse] +- client.argo.tiered_caching.get(\*, zone_id) -> Optional[TieredCachingGetResponse] # CertificateAuthorities @@ -866,8 +914,8 @@ from cloudflare.types.certificate_authorities import ( Methods: -- client.certificate_authorities.hostname_associations.update(\*, zone_id, \*\*params) -> Optional -- client.certificate_authorities.hostname_associations.get(\*, zone_id, \*\*params) -> Optional +- client.certificate_authorities.hostname_associations.update(\*, zone_id, \*\*params) -> Optional[HostnameAssociationUpdateResponse] +- client.certificate_authorities.hostname_associations.get(\*, zone_id, \*\*params) -> Optional[HostnameAssociationGetResponse] # ClientCertificates @@ -879,11 +927,11 @@ from cloudflare.types.client_certificates import ClientCertificate Methods: -- client.client_certificates.create(\*, zone_id, \*\*params) -> Optional +- client.client_certificates.create(\*, zone_id, \*\*params) -> Optional[ClientCertificate] - client.client_certificates.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[ClientCertificate] -- client.client_certificates.delete(client_certificate_id, \*, zone_id) -> Optional -- client.client_certificates.edit(client_certificate_id, \*, zone_id) -> Optional -- client.client_certificates.get(client_certificate_id, \*, zone_id) -> Optional +- client.client_certificates.delete(client_certificate_id, \*, zone_id) -> Optional[ClientCertificate] +- client.client_certificates.edit(client_certificate_id, \*, zone_id, \*\*params) -> Optional[ClientCertificate] +- client.client_certificates.get(client_certificate_id, \*, zone_id) -> Optional[ClientCertificate] # CustomCertificates @@ -894,32 +942,23 @@ from cloudflare.types.custom_certificates import ( CustomCertificate, GeoRestrictions, Status, - CustomCertificateCreateResponse, CustomCertificateDeleteResponse, - CustomCertificateEditResponse, - CustomCertificateGetResponse, ) ``` Methods: -- client.custom_certificates.create(\*, zone_id, \*\*params) -> Optional +- client.custom_certificates.create(\*, zone_id, \*\*params) -> Optional[CustomCertificate] - client.custom_certificates.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[CustomCertificate] -- client.custom_certificates.delete(custom_certificate_id, \*, zone_id) -> Optional -- client.custom_certificates.edit(custom_certificate_id, \*, zone_id, \*\*params) -> Optional -- client.custom_certificates.get(custom_certificate_id, \*, zone_id) -> Optional +- client.custom_certificates.delete(custom_certificate_id, \*, zone_id) -> Optional[CustomCertificateDeleteResponse] +- client.custom_certificates.edit(custom_certificate_id, \*, zone_id, \*\*params) -> Optional[CustomCertificate] +- client.custom_certificates.get(custom_certificate_id, \*, zone_id) -> Optional[CustomCertificate] ## Prioritize -Types: - -```python -from cloudflare.types.custom_certificates import PrioritizeUpdateResponse -``` - Methods: -- client.custom_certificates.prioritize.update(\*, zone_id, \*\*params) -> Optional +- client.custom_certificates.prioritize.update(\*, zone_id, \*\*params) -> SyncSinglePage[CustomCertificate] # CustomHostnames @@ -941,11 +980,11 @@ from cloudflare.types.custom_hostnames import ( Methods: -- client.custom_hostnames.create(\*, zone_id, \*\*params) -> Optional +- client.custom_hostnames.create(\*, zone_id, \*\*params) -> Optional[CustomHostnameCreateResponse] - client.custom_hostnames.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[CustomHostnameListResponse] - client.custom_hostnames.delete(custom_hostname_id, \*, zone_id) -> CustomHostnameDeleteResponse -- client.custom_hostnames.edit(custom_hostname_id, \*, zone_id, \*\*params) -> Optional -- client.custom_hostnames.get(custom_hostname_id, \*, zone_id) -> Optional +- client.custom_hostnames.edit(custom_hostname_id, \*, zone_id, \*\*params) -> Optional[CustomHostnameEditResponse] +- client.custom_hostnames.get(custom_hostname_id, \*, zone_id) -> Optional[CustomHostnameGetResponse] ## FallbackOrigin @@ -961,38 +1000,110 @@ from cloudflare.types.custom_hostnames import ( Methods: -- client.custom_hostnames.fallback_origin.update(\*, zone_id, \*\*params) -> Optional -- client.custom_hostnames.fallback_origin.delete(\*, zone_id) -> Optional -- client.custom_hostnames.fallback_origin.get(\*, zone_id) -> Optional +- client.custom_hostnames.fallback_origin.update(\*, zone_id, \*\*params) -> Optional[FallbackOriginUpdateResponse] +- client.custom_hostnames.fallback_origin.delete(\*, zone_id) -> Optional[FallbackOriginDeleteResponse] +- client.custom_hostnames.fallback_origin.get(\*, zone_id) -> Optional[FallbackOriginGetResponse] + +## CertificatePack + +### Certificates + +Types: + +```python +from cloudflare.types.custom_hostnames.certificate_pack import ( + CertificateUpdateResponse, + CertificateDeleteResponse, +) +``` + +Methods: + +- client.custom_hostnames.certificate_pack.certificates.update(certificate_id, \*, zone_id, custom_hostname_id, certificate_pack_id, \*\*params) -> Optional[CertificateUpdateResponse] +- client.custom_hostnames.certificate_pack.certificates.delete(certificate_id, \*, zone_id, custom_hostname_id, certificate_pack_id) -> CertificateDeleteResponse # CustomNameservers Types: ```python -from cloudflare.types.custom_nameservers import ( - CustomNameserver, - CustomNameserverDeleteResponse, - CustomNameserverAvailabiltyResponse, - CustomNameserverGetResponse, +from cloudflare.types.custom_nameservers import CustomNameserver, CustomNameserverDeleteResponse +``` + +Methods: + +- client.custom_nameservers.create(\*, account_id, \*\*params) -> Optional[CustomNameserver] +- client.custom_nameservers.delete(custom_ns_id, \*, account_id) -> SyncSinglePage[CustomNameserverDeleteResponse] +- client.custom_nameservers.get(\*, account_id) -> SyncSinglePage[CustomNameserver] + +# DNSFirewall + +Types: + +```python +from cloudflare.types.dns_firewall import ( + AttackMitigation, + FirewallIPs, + UpstreamIPs, + DNSFirewallCreateResponse, + DNSFirewallListResponse, + DNSFirewallDeleteResponse, + DNSFirewallEditResponse, + DNSFirewallGetResponse, ) ``` Methods: -- client.custom_nameservers.create(\*, account_id, \*\*params) -> Optional -- client.custom_nameservers.delete(custom_ns_id, \*, account_id) -> Optional -- client.custom_nameservers.availabilty(\*, account_id) -> Optional -- client.custom_nameservers.get(\*, account_id) -> Optional +- client.dns_firewall.create(\*, account_id, \*\*params) -> Optional[DNSFirewallCreateResponse] +- client.dns_firewall.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DNSFirewallListResponse] +- client.dns_firewall.delete(dns_firewall_id, \*, account_id) -> Optional[DNSFirewallDeleteResponse] +- client.dns_firewall.edit(dns_firewall_id, \*, account_id, \*\*params) -> Optional[DNSFirewallEditResponse] +- client.dns_firewall.get(dns_firewall_id, \*, account_id) -> Optional[DNSFirewallGetResponse] + +## Analytics + +### Reports + +Methods: + +- client.dns_firewall.analytics.reports.get(dns_firewall_id, \*, account_id, \*\*params) -> Optional[Report] + +#### Bytimes + +Methods: + +- client.dns_firewall.analytics.reports.bytimes.get(dns_firewall_id, \*, account_id, \*\*params) -> Optional[ByTime] + +## ReverseDNS + +Types: + +```python +from cloudflare.types.dns_firewall import ReverseDNSEditResponse, ReverseDNSGetResponse +``` + +Methods: + +- client.dns_firewall.reverse_dns.edit(dns_firewall_id, \*, account_id, \*\*params) -> Optional[ReverseDNSEditResponse] +- client.dns_firewall.reverse_dns.get(dns_firewall_id, \*, account_id) -> Optional[ReverseDNSGetResponse] # DNS +## DNSSEC + Types: ```python -from cloudflare.types.dns import DNSAnalyticsNominalMetric, DNSAnalyticsQuery +from cloudflare.types.dns import DNSSEC, DNSSECDeleteResponse ``` +Methods: + +- client.dns.dnssec.delete(\*, zone_id) -> str +- client.dns.dnssec.edit(\*, zone_id, \*\*params) -> Optional[DNSSEC] +- client.dns.dnssec.get(\*, zone_id) -> Optional[DNSSEC] + ## Records Types: @@ -1001,6 +1112,8 @@ Types: from cloudflare.types.dns import ( ARecord, AAAARecord, + BatchPatch, + BatchPut, CAARecord, CERTRecord, CNAMERecord, @@ -1013,8 +1126,7 @@ from cloudflare.types.dns import ( NSRecord, PTRRecord, Record, - RecordMetadata, - RecordProcessTiming, + RecordResponse, RecordTags, SMIMEARecord, SRVRecord, @@ -1025,133 +1137,457 @@ from cloudflare.types.dns import ( TXTRecord, URIRecord, RecordDeleteResponse, + RecordBatchResponse, RecordExportResponse, RecordImportResponse, RecordScanResponse, + RecordScanReviewResponse, + RecordScanTriggerResponse, ) ``` Methods: -- client.dns.records.create(\*, zone_id, \*\*params) -> Optional -- client.dns.records.update(dns_record_id, \*, zone_id, \*\*params) -> Optional -- client.dns.records.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Record] -- client.dns.records.delete(dns_record_id, \*, zone_id) -> Optional -- client.dns.records.edit(dns_record_id, \*, zone_id, \*\*params) -> Optional +- client.dns.records.create(\*, zone_id, \*\*params) -> Optional[RecordResponse] +- client.dns.records.update(dns_record_id, \*, zone_id, \*\*params) -> Optional[RecordResponse] +- client.dns.records.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[RecordResponse] +- client.dns.records.delete(dns_record_id, \*, zone_id) -> Optional[RecordDeleteResponse] +- client.dns.records.batch(\*, zone_id, \*\*params) -> Optional[RecordBatchResponse] +- client.dns.records.edit(dns_record_id, \*, zone_id, \*\*params) -> Optional[RecordResponse] - client.dns.records.export(\*, zone_id) -> str -- client.dns.records.get(dns_record_id, \*, zone_id) -> Optional -- client.dns.records.import\_(\*, zone_id, \*\*params) -> Optional -- client.dns.records.scan(\*, zone_id, \*\*params) -> Optional +- client.dns.records.get(dns_record_id, \*, zone_id) -> Optional[RecordResponse] +- client.dns.records.import\_(\*, zone_id, \*\*params) -> Optional[RecordImportResponse] +- client.dns.records.scan(\*, zone_id, \*\*params) -> Optional[RecordScanResponse] +- client.dns.records.scan_list(\*, zone_id) -> SyncSinglePage[RecordResponse] +- client.dns.records.scan_review(\*, zone_id, \*\*params) -> Optional[RecordScanReviewResponse] +- client.dns.records.scan_trigger(\*, zone_id) -> RecordScanTriggerResponse ## Settings +### Zone + Types: ```python -from cloudflare.types.dns import DNSSetting, Nameserver, SettingEditResponse, SettingGetResponse +from cloudflare.types.dns.settings import ZoneEditResponse, ZoneGetResponse ``` Methods: -- client.dns.settings.edit(\*, account_id, zone_id, \*\*params) -> Optional -- client.dns.settings.get(\*, account_id, zone_id) -> Optional - -## Analytics +- client.dns.settings.zone.edit(\*, zone_id, \*\*params) -> Optional[ZoneEditResponse] +- client.dns.settings.zone.get(\*, zone_id) -> Optional[ZoneGetResponse] -### Reports +### Account Types: ```python -from cloudflare.types.dns.analytics import Report +from cloudflare.types.dns.settings import AccountEditResponse, AccountGetResponse ``` Methods: -- client.dns.analytics.reports.get(\*, zone_id, \*\*params) -> Optional +- client.dns.settings.account.edit(\*, account_id, \*\*params) -> Optional[AccountEditResponse] +- client.dns.settings.account.get(\*, account_id) -> Optional[AccountGetResponse] -#### Bytimes +#### Views Types: ```python -from cloudflare.types.dns.analytics.reports import ByTime +from cloudflare.types.dns.settings.account import ( + ViewCreateResponse, + ViewListResponse, + ViewDeleteResponse, + ViewEditResponse, + ViewGetResponse, +) ``` Methods: -- client.dns.analytics.reports.bytimes.get(\*, zone_id, \*\*params) -> Optional +- client.dns.settings.account.views.create(\*, account_id, \*\*params) -> Optional[ViewCreateResponse] +- client.dns.settings.account.views.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ViewListResponse] +- client.dns.settings.account.views.delete(view_id, \*, account_id) -> Optional[ViewDeleteResponse] +- client.dns.settings.account.views.edit(view_id, \*, account_id, \*\*params) -> Optional[ViewEditResponse] +- client.dns.settings.account.views.get(view_id, \*, account_id) -> Optional[ViewGetResponse] + +## Analytics -## Firewall +### Reports Types: ```python -from cloudflare.types.dns import ( - AttackMitigation, - Firewall, - FirewallIPs, - UpstreamIPs, - FirewallDeleteResponse, -) +from cloudflare.types.dns.analytics import Report ``` Methods: -- client.dns.firewall.create(\*, account_id, \*\*params) -> Optional -- client.dns.firewall.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Firewall] -- client.dns.firewall.delete(dns_firewall_id, \*, account_id) -> Optional -- client.dns.firewall.edit(dns_firewall_id, \*, account_id, \*\*params) -> Optional -- client.dns.firewall.get(dns_firewall_id, \*, account_id) -> Optional +- client.dns.analytics.reports.get(\*, zone_id, \*\*params) -> Optional[Report] -### Analytics +#### Bytimes Types: ```python -from cloudflare.types.dns.firewall import Delta +from cloudflare.types.dns.analytics.reports import ByTime ``` -#### Reports - Methods: -- client.dns.firewall.analytics.reports.get(dns_firewall_id, \*, account_id, \*\*params) -> Optional - -##### Bytimes - -Methods: +- client.dns.analytics.reports.bytimes.get(\*, zone_id, \*\*params) -> Optional[ByTime] -- client.dns.firewall.analytics.reports.bytimes.get(dns_firewall_id, \*, account_id, \*\*params) -> Optional +## ZoneTransfers -# DNSSEC +### ForceAXFR Types: ```python -from cloudflare.types.dnssec import DNSSEC, DNSSECDeleteResponse +from cloudflare.types.dns.zone_transfers import ForceAXFR ``` Methods: -- client.dnssec.delete(\*, zone_id) -> Optional -- client.dnssec.edit(\*, zone_id, \*\*params) -> Optional -- client.dnssec.get(\*, zone_id) -> Optional +- client.dns.zone_transfers.force_axfr.create(\*, zone_id, \*\*params) -> str -# EmailRouting +### Incoming Types: ```python -from cloudflare.types.email_routing import Settings -``` - -Methods: - -- client.email_routing.disable(zone_identifier, \*\*params) -> Optional -- client.email_routing.enable(zone_identifier, \*\*params) -> Optional -- client.email_routing.get(zone_identifier) -> Optional - +from cloudflare.types.dns.zone_transfers import ( + Incoming, + IncomingCreateResponse, + IncomingUpdateResponse, + IncomingDeleteResponse, + IncomingGetResponse, +) +``` + +Methods: + +- client.dns.zone_transfers.incoming.create(\*, zone_id, \*\*params) -> Optional[IncomingCreateResponse] +- client.dns.zone_transfers.incoming.update(\*, zone_id, \*\*params) -> Optional[IncomingUpdateResponse] +- client.dns.zone_transfers.incoming.delete(\*, zone_id) -> Optional[IncomingDeleteResponse] +- client.dns.zone_transfers.incoming.get(\*, zone_id) -> Optional[IncomingGetResponse] + +### Outgoing + +Types: + +```python +from cloudflare.types.dns.zone_transfers import ( + DisableTransfer, + EnableTransfer, + Outgoing, + OutgoingStatus, + OutgoingCreateResponse, + OutgoingUpdateResponse, + OutgoingDeleteResponse, + OutgoingForceNotifyResponse, + OutgoingGetResponse, +) +``` + +Methods: + +- client.dns.zone_transfers.outgoing.create(\*, zone_id, \*\*params) -> Optional[OutgoingCreateResponse] +- client.dns.zone_transfers.outgoing.update(\*, zone_id, \*\*params) -> Optional[OutgoingUpdateResponse] +- client.dns.zone_transfers.outgoing.delete(\*, zone_id) -> Optional[OutgoingDeleteResponse] +- client.dns.zone_transfers.outgoing.disable(\*, zone_id, \*\*params) -> str +- client.dns.zone_transfers.outgoing.enable(\*, zone_id, \*\*params) -> str +- client.dns.zone_transfers.outgoing.force_notify(\*, zone_id, \*\*params) -> str +- client.dns.zone_transfers.outgoing.get(\*, zone_id) -> Optional[OutgoingGetResponse] + +#### Status + +Methods: + +- client.dns.zone_transfers.outgoing.status.get(\*, zone_id) -> str + +### ACLs + +Types: + +```python +from cloudflare.types.dns.zone_transfers import ACL, ACLDeleteResponse +``` + +Methods: + +- client.dns.zone_transfers.acls.create(\*, account_id, \*\*params) -> Optional[ACL] +- client.dns.zone_transfers.acls.update(acl_id, \*, account_id, \*\*params) -> Optional[ACL] +- client.dns.zone_transfers.acls.list(\*, account_id) -> SyncSinglePage[ACL] +- client.dns.zone_transfers.acls.delete(acl_id, \*, account_id) -> Optional[ACLDeleteResponse] +- client.dns.zone_transfers.acls.get(acl_id, \*, account_id) -> Optional[ACL] + +### Peers + +Types: + +```python +from cloudflare.types.dns.zone_transfers import Peer, PeerDeleteResponse +``` + +Methods: + +- client.dns.zone_transfers.peers.create(\*, account_id, \*\*params) -> Optional[Peer] +- client.dns.zone_transfers.peers.update(peer_id, \*, account_id, \*\*params) -> Optional[Peer] +- client.dns.zone_transfers.peers.list(\*, account_id) -> SyncSinglePage[Peer] +- client.dns.zone_transfers.peers.delete(peer_id, \*, account_id) -> Optional[PeerDeleteResponse] +- client.dns.zone_transfers.peers.get(peer_id, \*, account_id) -> Optional[Peer] + +### TSIGs + +Types: + +```python +from cloudflare.types.dns.zone_transfers import TSIG, TSIGDeleteResponse +``` + +Methods: + +- client.dns.zone_transfers.tsigs.create(\*, account_id, \*\*params) -> Optional[TSIG] +- client.dns.zone_transfers.tsigs.update(tsig_id, \*, account_id, \*\*params) -> Optional[TSIG] +- client.dns.zone_transfers.tsigs.list(\*, account_id) -> SyncSinglePage[TSIG] +- client.dns.zone_transfers.tsigs.delete(tsig_id, \*, account_id) -> Optional[TSIGDeleteResponse] +- client.dns.zone_transfers.tsigs.get(tsig_id, \*, account_id) -> Optional[TSIG] + +# EmailSecurity + +## Investigate + +Types: + +```python +from cloudflare.types.email_security import InvestigateListResponse, InvestigateGetResponse +``` + +Methods: + +- client.email_security.investigate.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[InvestigateListResponse] +- client.email_security.investigate.get(postfix_id, \*, account_id) -> InvestigateGetResponse + +### Detections + +Types: + +```python +from cloudflare.types.email_security.investigate import DetectionGetResponse +``` + +Methods: + +- client.email_security.investigate.detections.get(postfix_id, \*, account_id) -> DetectionGetResponse + +### Preview + +Types: + +```python +from cloudflare.types.email_security.investigate import PreviewCreateResponse, PreviewGetResponse +``` + +Methods: + +- client.email_security.investigate.preview.create(\*, account_id, \*\*params) -> PreviewCreateResponse +- client.email_security.investigate.preview.get(postfix_id, \*, account_id) -> PreviewGetResponse + +### Raw + +Types: + +```python +from cloudflare.types.email_security.investigate import RawGetResponse +``` + +Methods: + +- client.email_security.investigate.raw.get(postfix_id, \*, account_id) -> RawGetResponse + +### Trace + +Types: + +```python +from cloudflare.types.email_security.investigate import TraceGetResponse +``` + +Methods: + +- client.email_security.investigate.trace.get(postfix_id, \*, account_id) -> TraceGetResponse + +### Move + +Types: + +```python +from cloudflare.types.email_security.investigate import MoveCreateResponse, MoveBulkResponse +``` + +Methods: + +- client.email_security.investigate.move.create(postfix_id, \*, account_id, \*\*params) -> SyncSinglePage[MoveCreateResponse] +- client.email_security.investigate.move.bulk(\*, account_id, \*\*params) -> SyncSinglePage[MoveBulkResponse] + +### Reclassify + +Methods: + +- client.email_security.investigate.reclassify.create(postfix_id, \*, account_id, \*\*params) -> object + +### Release + +Types: + +```python +from cloudflare.types.email_security.investigate import ReleaseBulkResponse +``` + +Methods: + +- client.email_security.investigate.release.bulk(\*, account_id, \*\*params) -> SyncSinglePage[ReleaseBulkResponse] + +## Settings + +### AllowPolicies + +Types: + +```python +from cloudflare.types.email_security.settings import ( + AllowPolicyCreateResponse, + AllowPolicyListResponse, + AllowPolicyDeleteResponse, + AllowPolicyEditResponse, + AllowPolicyGetResponse, +) +``` + +Methods: + +- client.email_security.settings.allow_policies.create(\*, account_id, \*\*params) -> AllowPolicyCreateResponse +- client.email_security.settings.allow_policies.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AllowPolicyListResponse] +- client.email_security.settings.allow_policies.delete(policy_id, \*, account_id) -> AllowPolicyDeleteResponse +- client.email_security.settings.allow_policies.edit(policy_id, \*, account_id, \*\*params) -> AllowPolicyEditResponse +- client.email_security.settings.allow_policies.get(policy_id, \*, account_id) -> AllowPolicyGetResponse + +### BlockSenders + +Types: + +```python +from cloudflare.types.email_security.settings import ( + BlockSenderCreateResponse, + BlockSenderListResponse, + BlockSenderDeleteResponse, + BlockSenderEditResponse, + BlockSenderGetResponse, +) +``` + +Methods: + +- client.email_security.settings.block_senders.create(\*, account_id, \*\*params) -> BlockSenderCreateResponse +- client.email_security.settings.block_senders.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[BlockSenderListResponse] +- client.email_security.settings.block_senders.delete(pattern_id, \*, account_id) -> BlockSenderDeleteResponse +- client.email_security.settings.block_senders.edit(pattern_id, \*, account_id, \*\*params) -> BlockSenderEditResponse +- client.email_security.settings.block_senders.get(pattern_id, \*, account_id) -> BlockSenderGetResponse + +### Domains + +Types: + +```python +from cloudflare.types.email_security.settings import ( + DomainListResponse, + DomainDeleteResponse, + DomainBulkDeleteResponse, + DomainEditResponse, + DomainGetResponse, +) +``` + +Methods: + +- client.email_security.settings.domains.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DomainListResponse] +- client.email_security.settings.domains.delete(domain_id, \*, account_id) -> DomainDeleteResponse +- client.email_security.settings.domains.bulk_delete(\*, account_id) -> SyncSinglePage[DomainBulkDeleteResponse] +- client.email_security.settings.domains.edit(domain_id, \*, account_id, \*\*params) -> DomainEditResponse +- client.email_security.settings.domains.get(domain_id, \*, account_id) -> DomainGetResponse + +### ImpersonationRegistry + +Types: + +```python +from cloudflare.types.email_security.settings import ( + ImpersonationRegistryCreateResponse, + ImpersonationRegistryListResponse, + ImpersonationRegistryDeleteResponse, + ImpersonationRegistryEditResponse, + ImpersonationRegistryGetResponse, +) +``` + +Methods: + +- client.email_security.settings.impersonation_registry.create(\*, account_id, \*\*params) -> ImpersonationRegistryCreateResponse +- client.email_security.settings.impersonation_registry.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ImpersonationRegistryListResponse] +- client.email_security.settings.impersonation_registry.delete(display_name_id, \*, account_id) -> ImpersonationRegistryDeleteResponse +- client.email_security.settings.impersonation_registry.edit(display_name_id, \*, account_id, \*\*params) -> ImpersonationRegistryEditResponse +- client.email_security.settings.impersonation_registry.get(display_name_id, \*, account_id) -> ImpersonationRegistryGetResponse + +### TrustedDomains + +Types: + +```python +from cloudflare.types.email_security.settings import ( + TrustedDomainCreateResponse, + TrustedDomainListResponse, + TrustedDomainDeleteResponse, + TrustedDomainEditResponse, + TrustedDomainGetResponse, +) +``` + +Methods: + +- client.email_security.settings.trusted_domains.create(\*, account_id, \*\*params) -> TrustedDomainCreateResponse +- client.email_security.settings.trusted_domains.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TrustedDomainListResponse] +- client.email_security.settings.trusted_domains.delete(trusted_domain_id, \*, account_id) -> TrustedDomainDeleteResponse +- client.email_security.settings.trusted_domains.edit(trusted_domain_id, \*, account_id, \*\*params) -> TrustedDomainEditResponse +- client.email_security.settings.trusted_domains.get(trusted_domain_id, \*, account_id) -> TrustedDomainGetResponse + +## Submissions + +Types: + +```python +from cloudflare.types.email_security import SubmissionListResponse +``` + +Methods: + +- client.email_security.submissions.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SubmissionListResponse] + +# EmailRouting + +Types: + +```python +from cloudflare.types.email_routing import Settings +``` + +Methods: + +- client.email_routing.disable(\*, zone_id, \*\*params) -> Optional[Settings] +- client.email_routing.enable(\*, zone_id, \*\*params) -> Optional[Settings] +- client.email_routing.get(\*, zone_id) -> Optional[Settings] + ## DNS Types: @@ -1162,7 +1598,10 @@ from cloudflare.types.email_routing import DNSRecord, DNSGetResponse Methods: -- client.email_routing.dns.get(zone_identifier) -> Optional +- client.email_routing.dns.create(\*, zone_id, \*\*params) -> Optional[Settings] +- client.email_routing.dns.delete(\*, zone_id) -> SyncSinglePage[DNSRecord] +- client.email_routing.dns.edit(\*, zone_id, \*\*params) -> Optional[Settings] +- client.email_routing.dns.get(\*, zone_id, \*\*params) -> DNSGetResponse ## Rules @@ -1174,11 +1613,11 @@ from cloudflare.types.email_routing import Action, EmailRoutingRule, Matcher Methods: -- client.email_routing.rules.create(zone_identifier, \*\*params) -> Optional -- client.email_routing.rules.update(rule_identifier, \*, zone_identifier, \*\*params) -> Optional -- client.email_routing.rules.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[EmailRoutingRule] -- client.email_routing.rules.delete(rule_identifier, \*, zone_identifier) -> Optional -- client.email_routing.rules.get(rule_identifier, \*, zone_identifier) -> Optional +- client.email_routing.rules.create(\*, zone_id, \*\*params) -> Optional[EmailRoutingRule] +- client.email_routing.rules.update(rule_identifier, \*, zone_id, \*\*params) -> Optional[EmailRoutingRule] +- client.email_routing.rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[EmailRoutingRule] +- client.email_routing.rules.delete(rule_identifier, \*, zone_id) -> Optional[EmailRoutingRule] +- client.email_routing.rules.get(rule_identifier, \*, zone_id) -> Optional[EmailRoutingRule] ### CatchAlls @@ -1195,8 +1634,8 @@ from cloudflare.types.email_routing.rules import ( Methods: -- client.email_routing.rules.catch_alls.update(zone_identifier, \*\*params) -> Optional -- client.email_routing.rules.catch_alls.get(zone_identifier) -> Optional +- client.email_routing.rules.catch_alls.update(\*, zone_id, \*\*params) -> Optional[CatchAllUpdateResponse] +- client.email_routing.rules.catch_alls.get(\*, zone_id) -> Optional[CatchAllGetResponse] ## Addresses @@ -1208,26 +1647,28 @@ from cloudflare.types.email_routing import Address Methods: -- client.email_routing.addresses.create(account_identifier, \*\*params) -> Optional -- client.email_routing.addresses.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[Address] -- client.email_routing.addresses.delete(destination_address_identifier, \*, account_identifier) -> Optional -- client.email_routing.addresses.get(destination_address_identifier, \*, account_identifier) -> Optional +- client.email_routing.addresses.create(\*, account_id, \*\*params) -> Optional[Address] +- client.email_routing.addresses.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Address] +- client.email_routing.addresses.delete(destination_address_identifier, \*, account_id) -> Optional[Address] +- client.email_routing.addresses.get(destination_address_identifier, \*, account_id) -> Optional[Address] # Filters Types: ```python -from cloudflare.types.filters import FirewallFilter, FilterCreateResponse +from cloudflare.types.filters import FirewallFilter, FilterDeleteResponse, FilterBulkDeleteResponse ``` Methods: -- client.filters.create(zone_identifier, \*\*params) -> Optional -- client.filters.update(id, \*, zone_identifier, \*\*params) -> FirewallFilter -- client.filters.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[FirewallFilter] -- client.filters.delete(id, \*, zone_identifier) -> FirewallFilter -- client.filters.get(id, \*, zone_identifier) -> FirewallFilter +- client.filters.create(\*, zone_id, \*\*params) -> SyncSinglePage[FirewallFilter] +- client.filters.update(filter_id, \*, zone_id, \*\*params) -> FirewallFilter +- client.filters.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[FirewallFilter] +- client.filters.delete(filter_id, \*, zone_id) -> FilterDeleteResponse +- client.filters.bulk_delete(\*, zone_id, \*\*params) -> Optional[FilterBulkDeleteResponse] +- client.filters.bulk_update(\*, zone_id, \*\*params) -> SyncSinglePage[FirewallFilter] +- client.filters.get(filter_id, \*, zone_id) -> FirewallFilter # Firewall @@ -1248,34 +1689,31 @@ from cloudflare.types.firewall import ( Methods: -- client.firewall.lockdowns.create(zone_identifier, \*\*params) -> Lockdown -- client.firewall.lockdowns.update(id, \*, zone_identifier, \*\*params) -> Lockdown -- client.firewall.lockdowns.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[Lockdown] -- client.firewall.lockdowns.delete(id, \*, zone_identifier) -> Optional -- client.firewall.lockdowns.get(id, \*, zone_identifier) -> Lockdown +- client.firewall.lockdowns.create(\*, zone_id, \*\*params) -> Lockdown +- client.firewall.lockdowns.update(lock_downs_id, \*, zone_id, \*\*params) -> Lockdown +- client.firewall.lockdowns.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Lockdown] +- client.firewall.lockdowns.delete(lock_downs_id, \*, zone_id) -> Optional[LockdownDeleteResponse] +- client.firewall.lockdowns.get(lock_downs_id, \*, zone_id) -> Lockdown ## Rules Types: ```python -from cloudflare.types.firewall import ( - FirewallRule, - Product, - DeletedFilter, - RuleCreateResponse, - RuleEditResponse, -) +from cloudflare.types.firewall import DeletedFilter, FirewallRule, Product ``` Methods: -- client.firewall.rules.create(zone_identifier, \*\*params) -> Optional -- client.firewall.rules.update(id, \*, zone_identifier, \*\*params) -> FirewallRule -- client.firewall.rules.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[FirewallRule] -- client.firewall.rules.delete(id, \*, zone_identifier) -> FirewallRule -- client.firewall.rules.edit(id, \*, zone_identifier, \*\*params) -> Optional -- client.firewall.rules.get(zone_identifier, \*, path_id, \*\*params) -> FirewallRule +- client.firewall.rules.create(\*, zone_id, \*\*params) -> SyncSinglePage[FirewallRule] +- client.firewall.rules.update(rule_id, \*, zone_id, \*\*params) -> FirewallRule +- client.firewall.rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[FirewallRule] +- client.firewall.rules.delete(rule_id, \*, zone_id) -> FirewallRule +- client.firewall.rules.bulk_delete(\*, zone_id) -> SyncSinglePage[FirewallRule] +- client.firewall.rules.bulk_edit(\*, zone_id, \*\*params) -> SyncSinglePage[FirewallRule] +- client.firewall.rules.bulk_update(\*, zone_id, \*\*params) -> SyncSinglePage[FirewallRule] +- client.firewall.rules.edit(rule_id, \*, zone_id) -> SyncSinglePage[FirewallRule] +- client.firewall.rules.get(rule_id, \*, zone_id) -> FirewallRule ## AccessRules @@ -1298,11 +1736,11 @@ from cloudflare.types.firewall import ( Methods: -- client.firewall.access_rules.create(\*, account_id, zone_id, \*\*params) -> AccessRuleCreateResponse -- client.firewall.access_rules.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] -- client.firewall.access_rules.delete(identifier, \*, account_id, zone_id) -> Optional -- client.firewall.access_rules.edit(identifier, \*, account_id, zone_id, \*\*params) -> AccessRuleEditResponse -- client.firewall.access_rules.get(identifier, \*, account_id, zone_id) -> AccessRuleGetResponse +- client.firewall.access_rules.create(\*, account_id, zone_id, \*\*params) -> AccessRuleCreateResponse +- client.firewall.access_rules.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[AccessRuleListResponse] +- client.firewall.access_rules.delete(rule_id, \*, account_id, zone_id) -> Optional[AccessRuleDeleteResponse] +- client.firewall.access_rules.edit(rule_id, \*, account_id, zone_id, \*\*params) -> AccessRuleEditResponse +- client.firewall.access_rules.get(rule_id, \*, account_id, zone_id) -> AccessRuleGetResponse ## UARules @@ -1320,11 +1758,11 @@ from cloudflare.types.firewall import ( Methods: -- client.firewall.ua_rules.create(zone_identifier, \*\*params) -> UARuleCreateResponse -- client.firewall.ua_rules.update(id, \*, zone_identifier, \*\*params) -> UARuleUpdateResponse -- client.firewall.ua_rules.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[UARuleListResponse] -- client.firewall.ua_rules.delete(id, \*, zone_identifier) -> UARuleDeleteResponse -- client.firewall.ua_rules.get(id, \*, zone_identifier) -> UARuleGetResponse +- client.firewall.ua_rules.create(\*, zone_id, \*\*params) -> UARuleCreateResponse +- client.firewall.ua_rules.update(ua_rule_id, \*, zone_id, \*\*params) -> UARuleUpdateResponse +- client.firewall.ua_rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[UARuleListResponse] +- client.firewall.ua_rules.delete(ua_rule_id, \*, zone_id) -> UARuleDeleteResponse +- client.firewall.ua_rules.get(ua_rule_id, \*, zone_id) -> UARuleGetResponse ## WAF @@ -1344,24 +1782,24 @@ from cloudflare.types.firewall.waf import ( Methods: -- client.firewall.waf.overrides.create(zone_identifier, \*\*params) -> Override -- client.firewall.waf.overrides.update(id, \*, zone_identifier, \*\*params) -> Override -- client.firewall.waf.overrides.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[Override] -- client.firewall.waf.overrides.delete(id, \*, zone_identifier) -> Optional -- client.firewall.waf.overrides.get(id, \*, zone_identifier) -> Override +- client.firewall.waf.overrides.create(\*, zone_id, \*\*params) -> Override +- client.firewall.waf.overrides.update(overrides_id, \*, zone_id, \*\*params) -> Override +- client.firewall.waf.overrides.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Override] +- client.firewall.waf.overrides.delete(overrides_id, \*, zone_id) -> Optional[OverrideDeleteResponse] +- client.firewall.waf.overrides.get(overrides_id, \*, zone_id) -> Override ### Packages Types: ```python -from cloudflare.types.firewall.waf import PackageListResponse, PackageGetResponse +from cloudflare.types.firewall.waf import PackageGetResponse ``` Methods: -- client.firewall.waf.packages.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[PackageListResponse] -- client.firewall.waf.packages.get(identifier, \*, zone_identifier) -> PackageGetResponse +- client.firewall.waf.packages.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] +- client.firewall.waf.packages.get(package_id, \*, zone_id) -> PackageGetResponse #### Groups @@ -1416,7 +1854,7 @@ Methods: - client.healthchecks.create(\*, zone_id, \*\*params) -> Healthcheck - client.healthchecks.update(healthcheck_id, \*, zone_id, \*\*params) -> Healthcheck -- client.healthchecks.list(\*, zone_id, \*\*params) -> SyncSinglePage[Healthcheck] +- client.healthchecks.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Healthcheck] - client.healthchecks.delete(healthcheck_id, \*, zone_id) -> HealthcheckDeleteResponse - client.healthchecks.edit(healthcheck_id, \*, zone_id, \*\*params) -> Healthcheck - client.healthchecks.get(healthcheck_id, \*, zone_id) -> Healthcheck @@ -1449,11 +1887,11 @@ from cloudflare.types.keyless_certificates import ( Methods: -- client.keyless_certificates.create(\*, zone_id, \*\*params) -> Optional +- client.keyless_certificates.create(\*, zone_id, \*\*params) -> Optional[KeylessCertificate] - client.keyless_certificates.list(\*, zone_id) -> SyncSinglePage[KeylessCertificate] -- client.keyless_certificates.delete(keyless_certificate_id, \*, zone_id) -> Optional -- client.keyless_certificates.edit(keyless_certificate_id, \*, zone_id, \*\*params) -> Optional -- client.keyless_certificates.get(keyless_certificate_id, \*, zone_id) -> Optional +- client.keyless_certificates.delete(keyless_certificate_id, \*, zone_id) -> Optional[KeylessCertificateDeleteResponse] +- client.keyless_certificates.edit(keyless_certificate_id, \*, zone_id, \*\*params) -> Optional[KeylessCertificate] +- client.keyless_certificates.get(keyless_certificate_id, \*, zone_id) -> Optional[KeylessCertificate] # Logpush @@ -1461,40 +1899,28 @@ Methods: ### Fields -Types: - -```python -from cloudflare.types.logpush.datasets import FieldGetResponse -``` - Methods: -- client.logpush.datasets.fields.get(dataset_id, \*, account_id, zone_id) -> object +- client.logpush.datasets.fields.get(dataset_id, \*, account_id, zone_id) -> object ### Jobs -Types: - -```python -from cloudflare.types.logpush.datasets import JobGetResponse -``` - Methods: -- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> Optional +- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> SyncSinglePage[Optional[LogpushJob]] ## Edge Types: ```python -from cloudflare.types.logpush import InstantLogpushJob, EdgeGetResponse +from cloudflare.types.logpush import InstantLogpushJob ``` Methods: -- client.logpush.edge.create(\*, zone_id, \*\*params) -> Optional -- client.logpush.edge.get(\*, zone_id) -> Optional +- client.logpush.edge.create(\*, zone_id, \*\*params) -> Optional[InstantLogpushJob] +- client.logpush.edge.get(\*, zone_id) -> SyncSinglePage[Optional[InstantLogpushJob]] ## Jobs @@ -1506,11 +1932,11 @@ from cloudflare.types.logpush import LogpushJob, OutputOptions, JobDeleteRespons Methods: -- client.logpush.jobs.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.logpush.jobs.update(job_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.logpush.jobs.list(\*, account_id, zone_id) -> SyncSinglePage[Optional] -- client.logpush.jobs.delete(job_id, \*, account_id, zone_id) -> object -- client.logpush.jobs.get(job_id, \*, account_id, zone_id) -> Optional +- client.logpush.jobs.create(\*, account_id, zone_id, \*\*params) -> Optional[LogpushJob] +- client.logpush.jobs.update(job_id, \*, account_id, zone_id, \*\*params) -> Optional[LogpushJob] +- client.logpush.jobs.list(\*, account_id, zone_id) -> SyncSinglePage[Optional[LogpushJob]] +- client.logpush.jobs.delete(job_id, \*, account_id, zone_id) -> Optional[JobDeleteResponse] +- client.logpush.jobs.get(job_id, \*, account_id, zone_id) -> Optional[LogpushJob] ## Ownership @@ -1522,21 +1948,26 @@ from cloudflare.types.logpush import OwnershipValidation, OwnershipCreateRespons Methods: -- client.logpush.ownership.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.logpush.ownership.validate(\*, account_id, zone_id, \*\*params) -> Optional +- client.logpush.ownership.create(\*, account_id, zone_id, \*\*params) -> Optional[OwnershipCreateResponse] +- client.logpush.ownership.validate(\*, account_id, zone_id, \*\*params) -> Optional[OwnershipValidation] ## Validate Types: ```python -from cloudflare.types.logpush import ValidateDestinationResponse, ValidateOriginResponse +from cloudflare.types.logpush import ( + ValidateDestinationResponse, + ValidateDestinationExistsResponse, + ValidateOriginResponse, +) ``` Methods: -- client.logpush.validate.destination(\*, account_id, zone_id, \*\*params) -> Optional -- client.logpush.validate.origin(\*, account_id, zone_id, \*\*params) -> Optional +- client.logpush.validate.destination(\*, account_id, zone_id, \*\*params) -> Optional[ValidateDestinationResponse] +- client.logpush.validate.destination_exists(\*, account_id, zone_id, \*\*params) -> Optional[ValidateDestinationExistsResponse] +- client.logpush.validate.origin(\*, account_id, zone_id, \*\*params) -> Optional[ValidateOriginResponse] # Logs @@ -1552,8 +1983,8 @@ from cloudflare.types.logs.control import RetentionCreateResponse, RetentionGetR Methods: -- client.logs.control.retention.create(zone_identifier, \*\*params) -> RetentionCreateResponse -- client.logs.control.retention.get(zone_identifier) -> RetentionGetResponse +- client.logs.control.retention.create(\*, zone_id, \*\*params) -> Optional[RetentionCreateResponse] +- client.logs.control.retention.get(\*, zone_id) -> Optional[RetentionGetResponse] ### Cmb @@ -1562,14 +1993,14 @@ Methods: Types: ```python -from cloudflare.types.logs.control.cmb import CmbConfig, ConfigDeleteResponse +from cloudflare.types.logs.control.cmb import CmbConfig ``` Methods: -- client.logs.control.cmb.config.create(\*, account_id, \*\*params) -> Optional -- client.logs.control.cmb.config.delete(\*, account_id) -> object -- client.logs.control.cmb.config.get(\*, account_id) -> Optional +- client.logs.control.cmb.config.create(\*, account_id, \*\*params) -> Optional[CmbConfig] +- client.logs.control.cmb.config.delete(\*, account_id) -> object +- client.logs.control.cmb.config.get(\*, account_id) -> Optional[CmbConfig] ## RayID @@ -1581,7 +2012,7 @@ from cloudflare.types.logs import RayIDGetResponse Methods: -- client.logs.rayid.get(ray_identifier, \*, zone_identifier, \*\*params) -> RayIDGetResponse +- client.logs.rayid.get(rayid, \*, zone_id, \*\*params) -> RayIDGetResponse ## Received @@ -1593,7 +2024,7 @@ from cloudflare.types.logs import ReceivedGetResponse Methods: -- client.logs.received.get(zone_identifier, \*\*params) -> ReceivedGetResponse +- client.logs.received.get(\*, zone_id, \*\*params) -> ReceivedGetResponse ### Fields @@ -1605,7 +2036,7 @@ from cloudflare.types.logs.received import FieldGetResponse Methods: -- client.logs.received.fields.get(zone_identifier) -> FieldGetResponse +- client.logs.received.fields.get(\*, zone_id) -> FieldGetResponse # OriginTLSClientAuth @@ -1613,8 +2044,8 @@ Types: ```python from cloudflare.types.origin_tls_client_auth import ( - ZoneAuthenticatedOriginPull, OriginTLSClientAuthCreateResponse, + OriginTLSClientAuthListResponse, OriginTLSClientAuthDeleteResponse, OriginTLSClientAuthGetResponse, ) @@ -1622,10 +2053,31 @@ from cloudflare.types.origin_tls_client_auth import ( Methods: -- client.origin_tls_client_auth.create(\*, zone_id, \*\*params) -> Optional -- client.origin_tls_client_auth.list(\*, zone_id) -> SyncSinglePage[ZoneAuthenticatedOriginPull] -- client.origin_tls_client_auth.delete(certificate_id, \*, zone_id) -> Optional -- client.origin_tls_client_auth.get(certificate_id, \*, zone_id) -> Optional +- client.origin_tls_client_auth.create(\*, zone_id, \*\*params) -> Optional[OriginTLSClientAuthCreateResponse] +- client.origin_tls_client_auth.list(\*, zone_id) -> SyncSinglePage[OriginTLSClientAuthListResponse] +- client.origin_tls_client_auth.delete(certificate_id, \*, zone_id) -> Optional[OriginTLSClientAuthDeleteResponse] +- client.origin_tls_client_auth.get(certificate_id, \*, zone_id) -> Optional[OriginTLSClientAuthGetResponse] + +## ZoneCertificates + +Types: + +```python +from cloudflare.types.origin_tls_client_auth import ( + ZoneAuthenticatedOriginPull, + ZoneCertificateCreateResponse, + ZoneCertificateListResponse, + ZoneCertificateDeleteResponse, + ZoneCertificateGetResponse, +) +``` + +Methods: + +- client.origin_tls_client_auth.zone_certificates.create(\*, zone_id, \*\*params) -> Optional[ZoneCertificateCreateResponse] +- client.origin_tls_client_auth.zone_certificates.list(\*, zone_id) -> SyncSinglePage[ZoneCertificateListResponse] +- client.origin_tls_client_auth.zone_certificates.delete(certificate_id, \*, zone_id) -> Optional[ZoneCertificateDeleteResponse] +- client.origin_tls_client_auth.zone_certificates.get(certificate_id, \*, zone_id) -> Optional[ZoneCertificateGetResponse] ## Hostnames @@ -1637,28 +2089,29 @@ from cloudflare.types.origin_tls_client_auth import AuthenticatedOriginPull, Hos Methods: -- client.origin_tls_client_auth.hostnames.update(\*, zone_id, \*\*params) -> Optional -- client.origin_tls_client_auth.hostnames.get(hostname, \*, zone_id) -> Optional +- client.origin_tls_client_auth.hostnames.update(\*, zone_id, \*\*params) -> SyncSinglePage[HostnameUpdateResponse] +- client.origin_tls_client_auth.hostnames.get(hostname, \*, zone_id) -> Optional[AuthenticatedOriginPull] -### Certificates +## HostnameCertificates Types: ```python -from cloudflare.types.origin_tls_client_auth.hostnames import ( +from cloudflare.types.origin_tls_client_auth import ( Certificate, - CertificateCreateResponse, - CertificateDeleteResponse, - CertificateGetResponse, + HostnameCertificateCreateResponse, + HostnameCertificateListResponse, + HostnameCertificateDeleteResponse, + HostnameCertificateGetResponse, ) ``` Methods: -- client.origin_tls_client_auth.hostnames.certificates.create(\*, zone_id, \*\*params) -> Optional -- client.origin_tls_client_auth.hostnames.certificates.list(\*, zone_id) -> SyncSinglePage[AuthenticatedOriginPull] -- client.origin_tls_client_auth.hostnames.certificates.delete(certificate_id, \*, zone_id) -> Optional -- client.origin_tls_client_auth.hostnames.certificates.get(certificate_id, \*, zone_id) -> Optional +- client.origin_tls_client_auth.hostname_certificates.create(\*, zone_id, \*\*params) -> Optional[HostnameCertificateCreateResponse] +- client.origin_tls_client_auth.hostname_certificates.list(\*, zone_id) -> SyncSinglePage[HostnameCertificateListResponse] +- client.origin_tls_client_auth.hostname_certificates.delete(certificate_id, \*, zone_id) -> Optional[HostnameCertificateDeleteResponse] +- client.origin_tls_client_auth.hostname_certificates.get(certificate_id, \*, zone_id) -> Optional[HostnameCertificateGetResponse] ## Settings @@ -1670,213 +2123,71 @@ from cloudflare.types.origin_tls_client_auth import SettingUpdateResponse, Setti Methods: -- client.origin_tls_client_auth.settings.update(\*, zone_id, \*\*params) -> Optional -- client.origin_tls_client_auth.settings.get(\*, zone_id) -> Optional +- client.origin_tls_client_auth.settings.update(\*, zone_id, \*\*params) -> Optional[SettingUpdateResponse] +- client.origin_tls_client_auth.settings.get(\*, zone_id) -> Optional[SettingGetResponse] -# Pagerules +# PageRules Types: ```python -from cloudflare.types.pagerules import ( +from cloudflare.types.page_rules import ( PageRule, - Route, Target, - PageruleCreateResponse, - PageruleUpdateResponse, - PageruleListResponse, - PageruleDeleteResponse, - PageruleEditResponse, - PageruleGetResponse, + PageRuleListResponse, + PageRuleDeleteResponse, ) ``` Methods: -- client.pagerules.create(\*, zone_id, \*\*params) -> PageruleCreateResponse -- client.pagerules.update(pagerule_id, \*, zone_id, \*\*params) -> PageruleUpdateResponse -- client.pagerules.list(\*, zone_id, \*\*params) -> PageruleListResponse -- client.pagerules.delete(pagerule_id, \*, zone_id) -> Optional -- client.pagerules.edit(pagerule_id, \*, zone_id, \*\*params) -> PageruleEditResponse -- client.pagerules.get(pagerule_id, \*, zone_id) -> PageruleGetResponse +- client.page_rules.create(\*, zone_id, \*\*params) -> Optional[PageRule] +- client.page_rules.update(pagerule_id, \*, zone_id, \*\*params) -> Optional[PageRule] +- client.page_rules.list(\*, zone_id, \*\*params) -> Optional[PageRuleListResponse] +- client.page_rules.delete(pagerule_id, \*, zone_id) -> Optional[PageRuleDeleteResponse] +- client.page_rules.edit(pagerule_id, \*, zone_id, \*\*params) -> Optional[PageRule] +- client.page_rules.get(pagerule_id, \*, zone_id) -> Optional[PageRule] -## Settings +# RateLimits Types: ```python -from cloudflare.types.pagerules import SettingListResponse +from cloudflare.types.rate_limits import Action, RateLimit, RateLimitDeleteResponse ``` Methods: -- client.pagerules.settings.list(\*, zone_id) -> SettingListResponse +- client.rate_limits.create(\*, zone_id, \*\*params) -> RateLimit +- client.rate_limits.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[RateLimit] +- client.rate_limits.delete(rate_limit_id, \*, zone_id) -> RateLimitDeleteResponse +- client.rate_limits.edit(rate_limit_id, \*, zone_id, \*\*params) -> RateLimit +- client.rate_limits.get(rate_limit_id, \*, zone_id) -> RateLimit -# RateLimits +# WaitingRooms Types: ```python -from cloudflare.types.rate_limits import ( - Action, - Methods, - RateLimit, - RateLimitCreateResponse, - RateLimitDeleteResponse, - RateLimitEditResponse, - RateLimitGetResponse, +from cloudflare.types.waiting_rooms import ( + AdditionalRoutes, + CookieAttributes, + Query, + WaitingRoom, + WaitingRoomDeleteResponse, ) ``` Methods: -- client.rate_limits.create(zone_identifier, \*\*params) -> RateLimitCreateResponse -- client.rate_limits.list(zone_identifier, \*\*params) -> SyncV4PagePaginationArray[RateLimit] -- client.rate_limits.delete(id, \*, zone_identifier) -> RateLimitDeleteResponse -- client.rate_limits.edit(id, \*, zone_identifier, \*\*params) -> RateLimitEditResponse -- client.rate_limits.get(id, \*, zone_identifier) -> RateLimitGetResponse +- client.waiting_rooms.create(\*, zone_id, \*\*params) -> WaitingRoom +- client.waiting_rooms.update(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom +- client.waiting_rooms.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[WaitingRoom] +- client.waiting_rooms.delete(waiting_room_id, \*, zone_id) -> WaitingRoomDeleteResponse +- client.waiting_rooms.edit(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom +- client.waiting_rooms.get(waiting_room_id, \*, zone_id) -> WaitingRoom -# SecondaryDNS - -## ForceAXFR - -Types: - -```python -from cloudflare.types.secondary_dns import ForceAXFR -``` - -Methods: - -- client.secondary_dns.force_axfr.create(\*, zone_id, \*\*params) -> str - -## Incoming - -Types: - -```python -from cloudflare.types.secondary_dns import ( - Incoming, - IncomingCreateResponse, - IncomingUpdateResponse, - IncomingDeleteResponse, - IncomingGetResponse, -) -``` - -Methods: - -- client.secondary_dns.incoming.create(\*, zone_id, \*\*params) -> Optional -- client.secondary_dns.incoming.update(\*, zone_id, \*\*params) -> Optional -- client.secondary_dns.incoming.delete(\*, zone_id) -> Optional -- client.secondary_dns.incoming.get(\*, zone_id) -> Optional - -## Outgoing - -Types: - -```python -from cloudflare.types.secondary_dns import ( - DisableTransfer, - EnableTransfer, - Outgoing, - OutgoingStatus, - OutgoingCreateResponse, - OutgoingUpdateResponse, - OutgoingDeleteResponse, - OutgoingForceNotifyResponse, - OutgoingGetResponse, -) -``` - -Methods: - -- client.secondary_dns.outgoing.create(\*, zone_id, \*\*params) -> Optional -- client.secondary_dns.outgoing.update(\*, zone_id, \*\*params) -> Optional -- client.secondary_dns.outgoing.delete(\*, zone_id) -> Optional -- client.secondary_dns.outgoing.disable(\*, zone_id, \*\*params) -> str -- client.secondary_dns.outgoing.enable(\*, zone_id, \*\*params) -> str -- client.secondary_dns.outgoing.force_notify(\*, zone_id, \*\*params) -> str -- client.secondary_dns.outgoing.get(\*, zone_id) -> Optional - -### Status - -Methods: - -- client.secondary_dns.outgoing.status.get(\*, zone_id) -> str - -## ACLs - -Types: - -```python -from cloudflare.types.secondary_dns import ACL, ACLDeleteResponse -``` - -Methods: - -- client.secondary_dns.acls.create(\*, account_id, \*\*params) -> Optional -- client.secondary_dns.acls.update(acl_id, \*, account_id, \*\*params) -> Optional -- client.secondary_dns.acls.list(\*, account_id) -> SyncSinglePage[ACL] -- client.secondary_dns.acls.delete(acl_id, \*, account_id) -> Optional -- client.secondary_dns.acls.get(acl_id, \*, account_id) -> Optional - -## Peers - -Types: - -```python -from cloudflare.types.secondary_dns import Peer, PeerDeleteResponse -``` - -Methods: - -- client.secondary_dns.peers.create(\*, account_id, \*\*params) -> Optional -- client.secondary_dns.peers.update(peer_id, \*, account_id, \*\*params) -> Optional -- client.secondary_dns.peers.list(\*, account_id) -> SyncSinglePage[Peer] -- client.secondary_dns.peers.delete(peer_id, \*, account_id) -> Optional -- client.secondary_dns.peers.get(peer_id, \*, account_id) -> Optional - -## TSIGs - -Types: - -```python -from cloudflare.types.secondary_dns import TSIG, TSIGDeleteResponse -``` - -Methods: - -- client.secondary_dns.tsigs.create(\*, account_id, \*\*params) -> Optional -- client.secondary_dns.tsigs.update(tsig_id, \*, account_id, \*\*params) -> Optional -- client.secondary_dns.tsigs.list(\*, account_id) -> SyncSinglePage[TSIG] -- client.secondary_dns.tsigs.delete(tsig_id, \*, account_id) -> Optional -- client.secondary_dns.tsigs.get(tsig_id, \*, account_id) -> Optional - -# WaitingRooms - -Types: - -```python -from cloudflare.types.waiting_rooms import ( - AdditionalRoutes, - CookieAttributes, - Query, - WaitingRoom, - WaitingRoomDeleteResponse, -) -``` - -Methods: - -- client.waiting_rooms.create(\*, zone_id, \*\*params) -> WaitingRoom -- client.waiting_rooms.update(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom -- client.waiting_rooms.list(\*, zone_id, \*\*params) -> SyncSinglePage[WaitingRoom] -- client.waiting_rooms.delete(waiting_room_id, \*, zone_id) -> WaitingRoomDeleteResponse -- client.waiting_rooms.edit(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom -- client.waiting_rooms.get(waiting_room_id, \*, zone_id) -> WaitingRoom - -## Page +## Page Types: @@ -1900,7 +2211,7 @@ Methods: - client.waiting_rooms.events.create(waiting_room_id, \*, zone_id, \*\*params) -> Event - client.waiting_rooms.events.update(event_id, \*, zone_id, waiting_room_id, \*\*params) -> Event -- client.waiting_rooms.events.list(waiting_room_id, \*, zone_id, \*\*params) -> SyncSinglePage[Event] +- client.waiting_rooms.events.list(waiting_room_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Event] - client.waiting_rooms.events.delete(event_id, \*, zone_id, waiting_room_id) -> EventDeleteResponse - client.waiting_rooms.events.edit(event_id, \*, zone_id, waiting_room_id, \*\*params) -> Event - client.waiting_rooms.events.get(event_id, \*, zone_id, waiting_room_id) -> Event @@ -1922,22 +2233,16 @@ Methods: Types: ```python -from cloudflare.types.waiting_rooms import ( - WaitingRoomRule, - RuleCreateResponse, - RuleUpdateResponse, - RuleDeleteResponse, - RuleEditResponse, -) +from cloudflare.types.waiting_rooms import WaitingRoomRule ``` Methods: -- client.waiting_rooms.rules.create(waiting_room_id, \*, zone_id, \*\*params) -> Optional -- client.waiting_rooms.rules.update(waiting_room_id, \*, zone_id, \*\*params) -> Optional -- client.waiting_rooms.rules.list(waiting_room_id, \*, zone_id) -> SyncSinglePage[WaitingRoomRule] -- client.waiting_rooms.rules.delete(rule_id, \*, zone_id, waiting_room_id) -> Optional -- client.waiting_rooms.rules.edit(rule_id, \*, zone_id, waiting_room_id, \*\*params) -> Optional +- client.waiting_rooms.rules.create(waiting_room_id, \*, zone_id, \*\*params) -> SyncSinglePage[WaitingRoomRule] +- client.waiting_rooms.rules.update(waiting_room_id, \*, zone_id, \*\*params) -> SyncSinglePage[WaitingRoomRule] +- client.waiting_rooms.rules.delete(rule_id, \*, zone_id, waiting_room_id) -> SyncSinglePage[WaitingRoomRule] +- client.waiting_rooms.rules.edit(rule_id, \*, zone_id, waiting_room_id, \*\*params) -> SyncSinglePage[WaitingRoomRule] +- client.waiting_rooms.rules.get(waiting_room_id, \*, zone_id) -> SyncSinglePage[WaitingRoomRule] ## Statuses @@ -1982,11 +2287,11 @@ from cloudflare.types.web3 import Hostname, HostnameDeleteResponse Methods: -- client.web3.hostnames.create(zone_identifier, \*\*params) -> Hostname -- client.web3.hostnames.list(zone_identifier) -> SyncSinglePage[Hostname] -- 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.create(\*, zone_id, \*\*params) -> Hostname +- client.web3.hostnames.list(\*, zone_id) -> SyncSinglePage[Hostname] +- client.web3.hostnames.delete(identifier, \*, zone_id) -> Optional[HostnameDeleteResponse] +- client.web3.hostnames.edit(identifier, \*, zone_id, \*\*params) -> Hostname +- client.web3.hostnames.get(identifier, \*, zone_id) -> Hostname ### IPFSUniversalPaths @@ -2000,8 +2305,8 @@ from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList 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_id, \*\*params) -> ContentList +- client.web3.hostnames.ipfs_universal_paths.content_lists.get(identifier, \*, zone_id) -> ContentList ##### Entries @@ -2019,87 +2324,157 @@ from cloudflare.types.web3.hostnames.ipfs_universal_paths.content_lists import ( Methods: -- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.create(identifier, \*, zone_identifier, \*\*params) -> EntryCreateResponse -- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.update(content_list_entry_identifier, \*, zone_identifier, identifier, \*\*params) -> EntryUpdateResponse -- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.list(identifier, \*, zone_identifier) -> Optional -- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.delete(content_list_entry_identifier, \*, zone_identifier, identifier) -> Optional -- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.get(content_list_entry_identifier, \*, zone_identifier, identifier) -> EntryGetResponse +- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.create(identifier, \*, zone_id, \*\*params) -> EntryCreateResponse +- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.update(content_list_entry_identifier, \*, zone_id, identifier, \*\*params) -> EntryUpdateResponse +- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.list(identifier, \*, zone_id) -> Optional[EntryListResponse] +- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.delete(content_list_entry_identifier, \*, zone_id, identifier) -> Optional[EntryDeleteResponse] +- client.web3.hostnames.ipfs_universal_paths.content_lists.entries.get(content_list_entry_identifier, \*, zone_id, identifier) -> EntryGetResponse # Workers Types: +```python +from cloudflare.types.workers import MigrationStep, SingleStepMigration, WorkerMetadata +``` + +## Beta + +### Workers + +Types: + +```python +from cloudflare.types.workers.beta import Worker, WorkerDeleteResponse +``` + +Methods: + +- client.workers.beta.workers.create(\*, account_id, \*\*params) -> Worker +- client.workers.beta.workers.update(worker_id, \*, account_id, \*\*params) -> Worker +- client.workers.beta.workers.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Worker] +- client.workers.beta.workers.delete(worker_id, \*, account_id) -> WorkerDeleteResponse +- client.workers.beta.workers.edit(worker_id, \*, account_id, \*\*params) -> Worker +- client.workers.beta.workers.get(worker_id, \*, account_id) -> Worker + +#### Versions + +Types: + +```python +from cloudflare.types.workers.beta.workers import Version, VersionDeleteResponse +``` + +Methods: + +- client.workers.beta.workers.versions.create(worker_id, \*, account_id, \*\*params) -> Version +- client.workers.beta.workers.versions.list(worker_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[Version] +- client.workers.beta.workers.versions.delete(version_id, \*, account_id, worker_id) -> VersionDeleteResponse +- client.workers.beta.workers.versions.get(version_id, \*, account_id, worker_id, \*\*params) -> Version + +## Routes + +Types: + ```python from cloudflare.types.workers import ( - Binding, - D1Binding, - DispatchNamespaceBinding, - DurableObjectBinding, - KVNamespaceBinding, - MigrationStep, - MTLSCERTBinding, - PlacementConfiguration, - R2Binding, - ServiceBinding, - SingleStepMigration, - SteppedMigration, - WorkerMetadata, + RouteCreateResponse, + RouteUpdateResponse, + RouteListResponse, + RouteDeleteResponse, + RouteGetResponse, ) ``` -## AI +Methods: + +- client.workers.routes.create(\*, zone_id, \*\*params) -> RouteCreateResponse +- client.workers.routes.update(route_id, \*, zone_id, \*\*params) -> RouteUpdateResponse +- client.workers.routes.list(\*, zone_id) -> SyncSinglePage[RouteListResponse] +- client.workers.routes.delete(route_id, \*, zone_id) -> RouteDeleteResponse +- client.workers.routes.get(route_id, \*, zone_id) -> RouteGetResponse + +## Assets + +### Upload + +Types: + +```python +from cloudflare.types.workers.assets import UploadCreateResponse +``` + +Methods: + +- client.workers.assets.upload.create(\*, account_id, \*\*params) -> Optional[UploadCreateResponse] + +## Scripts Types: ```python -from cloudflare.types.workers import AIRunResponse +from cloudflare.types.workers import ( + Script, + ScriptSetting, + ScriptUpdateResponse, + ScriptListResponse, + ScriptGetResponse, + ScriptSearchResponse, +) ``` Methods: -- client.workers.ai.run(model_name, \*, account_id, \*\*params) -> Optional +- client.workers.scripts.update(script_name, \*, account_id, \*\*params) -> ScriptUpdateResponse +- client.workers.scripts.list(\*, account_id, \*\*params) -> SyncSinglePage[ScriptListResponse] +- client.workers.scripts.delete(script_name, \*, account_id, \*\*params) -> object +- client.workers.scripts.get(script_name, \*, account_id) -> str +- client.workers.scripts.search(\*, account_id, \*\*params) -> ScriptSearchResponse -### Models +### Assets -#### Schema +#### Upload Types: ```python -from cloudflare.types.workers.ai.models import SchemaGetResponse +from cloudflare.types.workers.scripts.assets import UploadCreateResponse ``` Methods: -- client.workers.ai.models.schema.get(\*, account_id, \*\*params) -> object +- client.workers.scripts.assets.upload.create(script_name, \*, account_id, \*\*params) -> Optional[UploadCreateResponse] -## Scripts +### Subdomain Types: ```python -from cloudflare.types.workers import Script, ScriptSetting +from cloudflare.types.workers.scripts import ( + SubdomainCreateResponse, + SubdomainDeleteResponse, + SubdomainGetResponse, +) ``` Methods: -- client.workers.scripts.update(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.list(\*, account_id) -> SyncSinglePage[Script] -- client.workers.scripts.delete(script_name, \*, account_id, \*\*params) -> None -- client.workers.scripts.get(script_name, \*, account_id) -> BinaryAPIResponse +- client.workers.scripts.subdomain.create(script_name, \*, account_id, \*\*params) -> SubdomainCreateResponse +- client.workers.scripts.subdomain.delete(script_name, \*, account_id) -> SubdomainDeleteResponse +- client.workers.scripts.subdomain.get(script_name, \*, account_id) -> SubdomainGetResponse ### Schedules Types: ```python -from cloudflare.types.workers.scripts import Schedule, ScheduleUpdateResponse, ScheduleGetResponse +from cloudflare.types.workers.scripts import ScheduleUpdateResponse, ScheduleGetResponse ``` Methods: -- client.workers.scripts.schedules.update(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.schedules.get(script_name, \*, account_id) -> Optional +- client.workers.scripts.schedules.update(script_name, \*, account_id, \*\*params) -> ScheduleUpdateResponse +- client.workers.scripts.schedules.get(script_name, \*, account_id) -> ScheduleGetResponse ### Tail @@ -2116,23 +2491,23 @@ from cloudflare.types.workers.scripts import ( Methods: -- client.workers.scripts.tail.create(script_name, \*, account_id, \*\*params) -> Optional +- client.workers.scripts.tail.create(script_name, \*, account_id, \*\*params) -> TailCreateResponse - client.workers.scripts.tail.delete(id, \*, account_id, script_name) -> TailDeleteResponse -- client.workers.scripts.tail.get(script_name, \*, account_id) -> Optional +- client.workers.scripts.tail.get(script_name, \*, account_id) -> TailGetResponse ### Content Methods: -- client.workers.scripts.content.update(script_name, \*, account_id, \*\*params) -> Optional +- client.workers.scripts.content.update(script_name, \*, account_id, \*\*params) -> Script - client.workers.scripts.content.get(script_name, \*, account_id) -> BinaryAPIResponse ### Settings Methods: -- client.workers.scripts.settings.edit(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.settings.get(script_name, \*, account_id) -> Optional +- client.workers.scripts.settings.edit(script_name, \*, account_id, \*\*params) -> ScriptSetting +- client.workers.scripts.settings.get(script_name, \*, account_id) -> ScriptSetting ### Deployments @@ -2141,15 +2516,17 @@ Types: ```python from cloudflare.types.workers.scripts import ( Deployment, - DeploymentCreateResponse, - DeploymentGetResponse, + DeploymentListResponse, + DeploymentDeleteResponse, ) ``` Methods: -- client.workers.scripts.deployments.create(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.deployments.get(script_name, \*, account_id) -> Optional +- client.workers.scripts.deployments.create(script_name, \*, account_id, \*\*params) -> Deployment +- client.workers.scripts.deployments.list(script_name, \*, account_id) -> DeploymentListResponse +- client.workers.scripts.deployments.delete(deployment_id, \*, account_id, script_name) -> DeploymentDeleteResponse +- client.workers.scripts.deployments.get(deployment_id, \*, account_id, script_name) -> Deployment ### Versions @@ -2165,9 +2542,44 @@ from cloudflare.types.workers.scripts import ( Methods: -- client.workers.scripts.versions.create(script_name, \*, account_id, \*\*params) -> Optional +- client.workers.scripts.versions.create(script_name, \*, account_id, \*\*params) -> VersionCreateResponse - client.workers.scripts.versions.list(script_name, \*, account_id, \*\*params) -> SyncV4PagePagination[VersionListResponse] -- client.workers.scripts.versions.get(version_id, \*, account_id, script_name) -> Optional +- client.workers.scripts.versions.get(version_id, \*, account_id, script_name) -> VersionGetResponse + +### Secrets + +Types: + +```python +from cloudflare.types.workers.scripts import ( + SecretUpdateResponse, + SecretListResponse, + SecretGetResponse, +) +``` + +Methods: + +- client.workers.scripts.secrets.update(script_name, \*, account_id, \*\*params) -> Optional[SecretUpdateResponse] +- client.workers.scripts.secrets.list(script_name, \*, account_id) -> SyncSinglePage[SecretListResponse] +- client.workers.scripts.secrets.delete(secret_name, \*, account_id, script_name, \*\*params) -> object +- client.workers.scripts.secrets.get(secret_name, \*, account_id, script_name, \*\*params) -> Optional[SecretGetResponse] + +### ScriptAndVersionSettings + +Types: + +```python +from cloudflare.types.workers.scripts import ( + ScriptAndVersionSettingEditResponse, + ScriptAndVersionSettingGetResponse, +) +``` + +Methods: + +- client.workers.scripts.script_and_version_settings.edit(script_name, \*, account_id, \*\*params) -> ScriptAndVersionSettingEditResponse +- client.workers.scripts.script_and_version_settings.get(script_name, \*, account_id) -> ScriptAndVersionSettingGetResponse ## AccountSettings @@ -2179,8 +2591,8 @@ from cloudflare.types.workers import AccountSettingUpdateResponse, AccountSettin Methods: -- client.workers.account_settings.update(\*, account_id, \*\*params) -> Optional -- client.workers.account_settings.get(\*, account_id) -> Optional +- client.workers.account_settings.update(\*, account_id, \*\*params) -> AccountSettingUpdateResponse +- client.workers.account_settings.get(\*, account_id) -> AccountSettingGetResponse ## Domains @@ -2192,10 +2604,10 @@ from cloudflare.types.workers import Domain Methods: -- client.workers.domains.update(\*, account_id, \*\*params) -> Optional +- client.workers.domains.update(\*, account_id, \*\*params) -> Optional[Domain] - client.workers.domains.list(\*, account_id, \*\*params) -> SyncSinglePage[Domain] - client.workers.domains.delete(domain_id, \*, account_id) -> None -- client.workers.domains.get(domain_id, \*, account_id) -> Optional +- client.workers.domains.get(domain_id, \*, account_id) -> Optional[Domain] ## Subdomains @@ -2207,63 +2619,82 @@ from cloudflare.types.workers import SubdomainUpdateResponse, SubdomainGetRespon Methods: -- client.workers.subdomains.update(\*, account_id, \*\*params) -> Optional -- client.workers.subdomains.get(\*, account_id) -> Optional +- client.workers.subdomains.update(\*, account_id, \*\*params) -> SubdomainUpdateResponse +- client.workers.subdomains.delete(\*, account_id) -> None +- client.workers.subdomains.get(\*, account_id) -> SubdomainGetResponse -# KV +## Observability -## Namespaces +### Telemetry Types: ```python -from cloudflare.types.kv import Namespace, NamespaceUpdateResponse, NamespaceDeleteResponse +from cloudflare.types.workers.observability import ( + TelemetryKeysResponse, + TelemetryQueryResponse, + TelemetryValuesResponse, +) ``` Methods: -- client.kv.namespaces.create(\*, account_id, \*\*params) -> Optional -- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> Optional -- client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] -- client.kv.namespaces.delete(namespace_id, \*, account_id) -> Optional -- client.kv.namespaces.get(namespace_id, \*, account_id) -> Optional +- client.workers.observability.telemetry.keys(\*, account_id, \*\*params) -> SyncSinglePage[TelemetryKeysResponse] +- client.workers.observability.telemetry.query(\*, account_id, \*\*params) -> TelemetryQueryResponse +- client.workers.observability.telemetry.values(\*, account_id, \*\*params) -> SyncSinglePage[TelemetryValuesResponse] + +# KV -### Bulk +## Namespaces Types: ```python -from cloudflare.types.kv.namespaces import BulkUpdateResponse, BulkDeleteResponse +from cloudflare.types.kv import ( + Namespace, + NamespaceDeleteResponse, + NamespaceBulkDeleteResponse, + NamespaceBulkGetResponse, + NamespaceBulkUpdateResponse, +) ``` Methods: -- client.kv.namespaces.bulk.update(namespace_id, \*, account_id, \*\*params) -> Optional -- client.kv.namespaces.bulk.delete(namespace_id, \*, account_id) -> Optional +- client.kv.namespaces.create(\*, account_id, \*\*params) -> Optional[Namespace] +- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> Namespace +- client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] +- client.kv.namespaces.delete(namespace_id, \*, account_id) -> Optional[NamespaceDeleteResponse] +- client.kv.namespaces.bulk_delete(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceBulkDeleteResponse] +- client.kv.namespaces.bulk_get(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceBulkGetResponse] +- client.kv.namespaces.bulk_update(namespace_id, \*, account_id, \*\*params) -> Optional[NamespaceBulkUpdateResponse] +- client.kv.namespaces.get(namespace_id, \*, account_id) -> Optional[Namespace] ### Keys Types: ```python -from cloudflare.types.kv.namespaces import Key +from cloudflare.types.kv.namespaces import ( + Key, + KeyBulkDeleteResponse, + KeyBulkGetResponse, + KeyBulkUpdateResponse, +) ``` Methods: - client.kv.namespaces.keys.list(namespace_id, \*, account_id, \*\*params) -> SyncCursorLimitPagination[Key] +- client.kv.namespaces.keys.bulk_delete(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkDeleteResponse] +- client.kv.namespaces.keys.bulk_get(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkGetResponse] +- client.kv.namespaces.keys.bulk_update(namespace_id, \*, account_id, \*\*params) -> Optional[KeyBulkUpdateResponse] ### Metadata -Types: - -```python -from cloudflare.types.kv.namespaces import MetadataGetResponse -``` - Methods: -- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> Optional +- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> object ### Values @@ -2275,8 +2706,8 @@ from cloudflare.types.kv.namespaces import ValueUpdateResponse, ValueDeleteRespo Methods: -- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> Optional -- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> Optional +- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> Optional[ValueUpdateResponse] +- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> Optional[ValueDeleteResponse] - client.kv.namespaces.values.get(key_name, \*, account_id, namespace_id) -> BinaryAPIResponse # DurableObjects @@ -2291,7 +2722,7 @@ from cloudflare.types.durable_objects import Namespace Methods: -- client.durable_objects.namespaces.list(\*, account_id) -> SyncSinglePage[Namespace] +- client.durable_objects.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] ### Objects @@ -2303,57 +2734,95 @@ from cloudflare.types.durable_objects.namespaces import DurableObject Methods: -- client.durable_objects.namespaces.objects.list(id, \*, account_id, \*\*params) -> SyncCursorLimitPagination[DurableObject] +- client.durable_objects.namespaces.objects.list(id, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[DurableObject] # Queues Types: ```python -from cloudflare.types.queues import Queue, QueueCreated, QueueUpdated, QueueDeleteResponse +from cloudflare.types.queues import Queue, QueueDeleteResponse ``` Methods: -- client.queues.create(\*, account_id, \*\*params) -> Optional -- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional +- client.queues.create(\*, account_id, \*\*params) -> Optional[Queue] +- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional[Queue] - client.queues.list(\*, account_id) -> SyncSinglePage[Queue] -- client.queues.delete(queue_id, \*, account_id) -> Optional -- client.queues.get(queue_id, \*, account_id) -> Optional +- client.queues.delete(queue_id, \*, account_id) -> QueueDeleteResponse +- client.queues.edit(queue_id, \*, account_id, \*\*params) -> Optional[Queue] +- client.queues.get(queue_id, \*, account_id) -> Optional[Queue] -## Consumers +## Messages Types: ```python from cloudflare.types.queues import ( - Consumer, - ConsumerCreateResponse, - ConsumerUpdateResponse, - ConsumerDeleteResponse, - ConsumerGetResponse, + MessageAckResponse, + MessageBulkPushResponse, + MessagePullResponse, + MessagePushResponse, ) ``` Methods: -- client.queues.consumers.create(queue_id, \*, account_id, \*\*params) -> Optional -- client.queues.consumers.update(consumer_id, \*, account_id, queue_id, \*\*params) -> Optional -- client.queues.consumers.delete(consumer_id, \*, account_id, queue_id) -> Optional -- client.queues.consumers.get(queue_id, \*, account_id) -> Optional +- client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional[MessageAckResponse] +- client.queues.messages.bulk_push(queue_id, \*, account_id, \*\*params) -> MessageBulkPushResponse +- client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> Optional[MessagePullResponse] +- client.queues.messages.push(queue_id, \*, account_id, \*\*params) -> MessagePushResponse -## Messages +## Purge + +Types: + +```python +from cloudflare.types.queues import PurgeStatusResponse +``` + +Methods: + +- client.queues.purge.start(queue_id, \*, account_id, \*\*params) -> Optional[Queue] +- client.queues.purge.status(queue_id, \*, account_id) -> Optional[PurgeStatusResponse] + +## Consumers + +Types: + +```python +from cloudflare.types.queues import Consumer, ConsumerDeleteResponse +``` + +Methods: + +- client.queues.consumers.create(queue_id, \*, account_id, \*\*params) -> Optional[Consumer] +- client.queues.consumers.update(consumer_id, \*, account_id, queue_id, \*\*params) -> Optional[Consumer] +- client.queues.consumers.list(queue_id, \*, account_id) -> SyncSinglePage[Consumer] +- client.queues.consumers.delete(consumer_id, \*, account_id, queue_id) -> ConsumerDeleteResponse +- client.queues.consumers.get(consumer_id, \*, account_id, queue_id) -> Optional[Consumer] + +## Subscriptions Types: ```python -from cloudflare.types.queues import MessageAckResponse, MessagePullResponse +from cloudflare.types.queues import ( + SubscriptionCreateResponse, + SubscriptionUpdateResponse, + SubscriptionListResponse, + SubscriptionDeleteResponse, + SubscriptionGetResponse, +) ``` Methods: -- client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional -- client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> Optional +- client.queues.subscriptions.create(\*, account_id, \*\*params) -> Optional[SubscriptionCreateResponse] +- client.queues.subscriptions.update(subscription_id, \*, account_id, \*\*params) -> Optional[SubscriptionUpdateResponse] +- client.queues.subscriptions.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SubscriptionListResponse] +- client.queues.subscriptions.delete(subscription_id, \*, account_id) -> Optional[SubscriptionDeleteResponse] +- client.queues.subscriptions.get(subscription_id, \*, account_id) -> Optional[SubscriptionGetResponse] # APIGateway @@ -2362,12 +2831,12 @@ Methods: Types: ```python -from cloudflare.types.api_gateway import Configuration, ConfigurationUpdateResponse +from cloudflare.types.api_gateway import Configuration ``` Methods: -- client.api_gateway.configurations.update(\*, zone_id, \*\*params) -> ConfigurationUpdateResponse +- client.api_gateway.configurations.update(\*, zone_id, \*\*params) -> Configuration - client.api_gateway.configurations.get(\*, zone_id, \*\*params) -> Configuration ## Discovery @@ -2387,12 +2856,13 @@ Methods: Types: ```python -from cloudflare.types.api_gateway.discovery import OperationEditResponse +from cloudflare.types.api_gateway.discovery import OperationBulkEditResponse, OperationEditResponse ``` Methods: - client.api_gateway.discovery.operations.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[DiscoveryOperation] +- client.api_gateway.discovery.operations.bulk_edit(\*, zone_id, \*\*params) -> OperationBulkEditResponse - client.api_gateway.discovery.operations.edit(operation_id, \*, zone_id, \*\*params) -> OperationEditResponse ## Operations @@ -2405,15 +2875,19 @@ from cloudflare.types.api_gateway import ( OperationCreateResponse, OperationListResponse, OperationDeleteResponse, + OperationBulkCreateResponse, + OperationBulkDeleteResponse, OperationGetResponse, ) ``` Methods: -- client.api_gateway.operations.create(\*, zone_id, \*\*params) -> OperationCreateResponse +- client.api_gateway.operations.create(\*, zone_id, \*\*params) -> OperationCreateResponse - client.api_gateway.operations.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] - client.api_gateway.operations.delete(operation_id, \*, zone_id) -> OperationDeleteResponse +- client.api_gateway.operations.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[OperationBulkCreateResponse] +- client.api_gateway.operations.bulk_delete(\*, zone_id) -> OperationBulkDeleteResponse - client.api_gateway.operations.get(operation_id, \*, zone_id, \*\*params) -> OperationGetResponse ### SchemaValidation @@ -2469,19 +2943,19 @@ Types: ```python from cloudflare.types.api_gateway import ( Message, - PublicSchema, - SchemaUpload, + OldPublicSchema, + UserSchemaCreateResponse, UserSchemaDeleteResponse, ) ``` Methods: -- client.api_gateway.user_schemas.create(\*, zone_id, \*\*params) -> SchemaUpload -- client.api_gateway.user_schemas.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[PublicSchema] -- client.api_gateway.user_schemas.delete(schema_id, \*, zone_id) -> Optional -- client.api_gateway.user_schemas.edit(schema_id, \*, zone_id, \*\*params) -> PublicSchema -- client.api_gateway.user_schemas.get(schema_id, \*, zone_id, \*\*params) -> PublicSchema +- client.api_gateway.user_schemas.create(\*, zone_id, \*\*params) -> UserSchemaCreateResponse +- client.api_gateway.user_schemas.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OldPublicSchema] +- client.api_gateway.user_schemas.delete(schema_id, \*, zone_id) -> UserSchemaDeleteResponse +- client.api_gateway.user_schemas.edit(schema_id, \*, zone_id, \*\*params) -> OldPublicSchema +- client.api_gateway.user_schemas.get(schema_id, \*, zone_id, \*\*params) -> OldPublicSchema ### Operations @@ -2495,22 +2969,48 @@ Methods: - client.api_gateway.user_schemas.operations.list(schema_id, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] -# ManagedHeaders +### Hosts + +Types: + +```python +from cloudflare.types.api_gateway.user_schemas import HostListResponse +``` + +Methods: + +- client.api_gateway.user_schemas.hosts.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[HostListResponse] + +## ExpressionTemplate + +### Fallthrough + +Types: + +```python +from cloudflare.types.api_gateway.expression_template import FallthroughCreateResponse +``` + +Methods: + +- client.api_gateway.expression_template.fallthrough.create(\*, zone_id, \*\*params) -> FallthroughCreateResponse + +# ManagedTransforms Types: ```python -from cloudflare.types.managed_headers import ( - RequestModel, - ManagedHeaderListResponse, - ManagedHeaderEditResponse, +from cloudflare.types.managed_transforms import ( + ManagedTransformListResponse, + ManagedTransformEditResponse, ) ``` Methods: -- client.managed_headers.list(\*, zone_id) -> ManagedHeaderListResponse -- client.managed_headers.edit(\*, zone_id, \*\*params) -> ManagedHeaderEditResponse +- client.managed_transforms.list(\*, zone_id) -> ManagedTransformListResponse +- client.managed_transforms.delete(\*, zone_id) -> None +- client.managed_transforms.edit(\*, zone_id, \*\*params) -> ManagedTransformEditResponse # PageShield @@ -2522,8 +3022,8 @@ from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse Methods: -- client.page_shield.update(\*, zone_id, \*\*params) -> Optional -- client.page_shield.get(\*, zone_id) -> Optional +- client.page_shield.update(\*, zone_id, \*\*params) -> Optional[PageShieldUpdateResponse] +- client.page_shield.get(\*, zone_id) -> Optional[Setting] ## Policies @@ -2541,11 +3041,11 @@ from cloudflare.types.page_shield import ( Methods: -- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Optional -- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Optional +- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Optional[PolicyCreateResponse] +- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Optional[PolicyUpdateResponse] - client.page_shield.policies.list(\*, zone_id) -> SyncSinglePage[PolicyListResponse] - client.page_shield.policies.delete(policy_id, \*, zone_id) -> None -- client.page_shield.policies.get(policy_id, \*, zone_id) -> Optional +- client.page_shield.policies.get(policy_id, \*, zone_id) -> Optional[PolicyGetResponse] ## Connections @@ -2558,7 +3058,7 @@ from cloudflare.types.page_shield import Connection Methods: - client.page_shield.connections.list(\*, zone_id, \*\*params) -> SyncSinglePage[Connection] -- client.page_shield.connections.get(connection_id, \*, zone_id) -> Optional +- client.page_shield.connections.get(connection_id, \*, zone_id) -> Optional[Connection] ## Scripts @@ -2571,7 +3071,7 @@ from cloudflare.types.page_shield import Script, ScriptGetResponse Methods: - client.page_shield.scripts.list(\*, zone_id, \*\*params) -> SyncSinglePage[Script] -- client.page_shield.scripts.get(script_id, \*, zone_id) -> Optional +- client.page_shield.scripts.get(script_id, \*, zone_id) -> Optional[ScriptGetResponse] ## Cookies @@ -2584,7 +3084,7 @@ from cloudflare.types.page_shield import CookieListResponse, CookieGetResponse Methods: - client.page_shield.cookies.list(\*, zone_id, \*\*params) -> SyncSinglePage[CookieListResponse] -- client.page_shield.cookies.get(cookie_id, \*, zone_id) -> Optional +- client.page_shield.cookies.get(cookie_id, \*, zone_id) -> Optional[CookieGetResponse] # Rulesets @@ -2604,11 +3104,11 @@ from cloudflare.types.rulesets import ( Methods: -- client.rulesets.create(\*, account_id, zone_id, \*\*params) -> RulesetCreateResponse -- client.rulesets.update(ruleset_id, \*, account_id, zone_id, \*\*params) -> RulesetUpdateResponse -- client.rulesets.list(\*, account_id, zone_id) -> SyncSinglePage[RulesetListResponse] -- client.rulesets.delete(ruleset_id, \*, account_id, zone_id) -> None -- client.rulesets.get(ruleset_id, \*, account_id, zone_id) -> RulesetGetResponse +- client.rulesets.create(\*, account_id, zone_id, \*\*params) -> RulesetCreateResponse +- client.rulesets.update(ruleset_id, \*, account_id, zone_id, \*\*params) -> RulesetUpdateResponse +- client.rulesets.list(\*, account_id, zone_id, \*\*params) -> SyncCursorPagination[RulesetListResponse] +- client.rulesets.delete(ruleset_id, \*, account_id, zone_id) -> None +- client.rulesets.get(ruleset_id, \*, account_id, zone_id) -> RulesetGetResponse ## Phases @@ -2620,8 +3120,8 @@ from cloudflare.types.rulesets import PhaseUpdateResponse, PhaseGetResponse Methods: -- client.rulesets.phases.update(ruleset_phase, \*, account_id, zone_id, \*\*params) -> PhaseUpdateResponse -- client.rulesets.phases.get(ruleset_phase, \*, account_id, zone_id) -> PhaseGetResponse +- client.rulesets.phases.update(ruleset_phase, \*, account_id, zone_id, \*\*params) -> PhaseUpdateResponse +- client.rulesets.phases.get(ruleset_phase, \*, account_id, zone_id) -> PhaseGetResponse ### Versions @@ -2633,8 +3133,8 @@ from cloudflare.types.rulesets.phases import VersionListResponse, VersionGetResp Methods: -- client.rulesets.phases.versions.list(ruleset_phase, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] -- client.rulesets.phases.versions.get(ruleset_version, \*, ruleset_phase, account_id, zone_id) -> VersionGetResponse +- client.rulesets.phases.versions.list(ruleset_phase, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] +- client.rulesets.phases.versions.get(ruleset_version, \*, ruleset_phase, account_id, zone_id) -> VersionGetResponse ## Rules @@ -2643,16 +3143,16 @@ Types: ```python from cloudflare.types.rulesets import ( BlockRule, - ChallengeRule, CompressResponseRule, + DDoSDynamicRule, ExecuteRule, - JSChallengeRule, + ForceConnectionCloseRule, + LogCustomFieldRule, LogRule, Logging, ManagedChallengeRule, RedirectRule, RewriteRule, - RewriteURIPart, RouteRule, RulesetRule, ScoreRule, @@ -2668,9 +3168,9 @@ from cloudflare.types.rulesets import ( Methods: -- client.rulesets.rules.create(ruleset_id, \*, account_id, zone_id, \*\*params) -> RuleCreateResponse -- client.rulesets.rules.delete(rule_id, \*, ruleset_id, account_id, zone_id) -> RuleDeleteResponse -- client.rulesets.rules.edit(rule_id, \*, ruleset_id, account_id, zone_id, \*\*params) -> RuleEditResponse +- client.rulesets.rules.create(ruleset_id, \*, account_id, zone_id, \*\*params) -> RuleCreateResponse +- client.rulesets.rules.delete(rule_id, \*, ruleset_id, account_id, zone_id) -> RuleDeleteResponse +- client.rulesets.rules.edit(rule_id, \*, ruleset_id, account_id, zone_id, \*\*params) -> RuleEditResponse ## Versions @@ -2682,21 +3182,9 @@ from cloudflare.types.rulesets import VersionListResponse, VersionGetResponse Methods: -- client.rulesets.versions.list(ruleset_id, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] -- client.rulesets.versions.delete(ruleset_version, \*, ruleset_id, account_id, zone_id) -> None -- client.rulesets.versions.get(ruleset_version, \*, ruleset_id, account_id, zone_id) -> VersionGetResponse - -### ByTag - -Types: - -```python -from cloudflare.types.rulesets.versions import ByTagGetResponse -``` - -Methods: - -- client.rulesets.versions.by_tag.get(rule_tag, \*, account_id, ruleset_id, ruleset_version) -> ByTagGetResponse +- client.rulesets.versions.list(ruleset_id, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] +- client.rulesets.versions.delete(ruleset_version, \*, ruleset_id, account_id, zone_id) -> None +- client.rulesets.versions.get(ruleset_version, \*, ruleset_id, account_id, zone_id) -> VersionGetResponse # URLNormalization @@ -2712,6 +3200,7 @@ from cloudflare.types.url_normalization import ( Methods: - client.url_normalization.update(\*, zone_id, \*\*params) -> URLNormalizationUpdateResponse +- client.url_normalization.delete(\*, zone_id) -> None - client.url_normalization.get(\*, zone_id) -> URLNormalizationGetResponse # Spectrum @@ -2736,7 +3225,7 @@ from cloudflare.types.spectrum.analytics.aggregates import CurrentGetResponse Methods: -- client.spectrum.analytics.aggregates.currents.get(zone, \*\*params) -> CurrentGetResponse +- client.spectrum.analytics.aggregates.currents.get(\*, zone_id, \*\*params) -> Optional[CurrentGetResponse] ### Events @@ -2756,7 +3245,7 @@ from cloudflare.types.spectrum.analytics.events import BytimeGetResponse Methods: -- client.spectrum.analytics.events.bytimes.get(zone, \*\*params) -> Optional +- client.spectrum.analytics.events.bytimes.get(\*, zone_id, \*\*params) -> Optional[BytimeGetResponse] #### Summaries @@ -2768,7 +3257,7 @@ from cloudflare.types.spectrum.analytics.events import SummaryGetResponse Methods: -- client.spectrum.analytics.events.summaries.get(zone, \*\*params) -> Optional +- client.spectrum.analytics.events.summaries.get(\*, zone_id, \*\*params) -> Optional[SummaryGetResponse] ## Apps @@ -2786,11 +3275,11 @@ from cloudflare.types.spectrum import ( Methods: -- client.spectrum.apps.create(zone, \*\*params) -> Optional -- client.spectrum.apps.update(app_id, \*, zone, \*\*params) -> Optional -- client.spectrum.apps.list(zone, \*\*params) -> SyncV4PagePaginationArray[object] -- client.spectrum.apps.delete(app_id, \*, zone) -> Optional -- client.spectrum.apps.get(app_id, \*, zone) -> AppGetResponse +- client.spectrum.apps.create(\*, zone_id, \*\*params) -> Optional[AppCreateResponse] +- client.spectrum.apps.update(app_id, \*, zone_id, \*\*params) -> Optional[AppUpdateResponse] +- client.spectrum.apps.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[AppListResponse] +- client.spectrum.apps.delete(app_id, \*, zone_id) -> Optional[AppDeleteResponse] +- client.spectrum.apps.get(app_id, \*, zone_id) -> Optional[AppGetResponse] # Addressing @@ -2810,11 +3299,11 @@ from cloudflare.types.addressing import ( Methods: -- client.addressing.regional_hostnames.create(\*, zone_id, \*\*params) -> Optional +- client.addressing.regional_hostnames.create(\*, zone_id, \*\*params) -> Optional[RegionalHostnameCreateResponse] - client.addressing.regional_hostnames.list(\*, zone_id) -> SyncSinglePage[RegionalHostnameListResponse] - client.addressing.regional_hostnames.delete(hostname, \*, zone_id) -> RegionalHostnameDeleteResponse -- client.addressing.regional_hostnames.edit(hostname, \*, zone_id, \*\*params) -> Optional -- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional +- client.addressing.regional_hostnames.edit(hostname, \*, zone_id, \*\*params) -> Optional[RegionalHostnameEditResponse] +- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional[RegionalHostnameGetResponse] ### Regions @@ -2856,11 +3345,11 @@ from cloudflare.types.addressing import ( Methods: -- client.addressing.address_maps.create(\*, account_id, \*\*params) -> Optional +- client.addressing.address_maps.create(\*, account_id, \*\*params) -> Optional[AddressMapCreateResponse] - client.addressing.address_maps.list(\*, account_id) -> SyncSinglePage[AddressMap] -- client.addressing.address_maps.delete(address_map_id, \*, account_id) -> Optional -- client.addressing.address_maps.edit(address_map_id, \*, account_id, \*\*params) -> Optional -- client.addressing.address_maps.get(address_map_id, \*, account_id) -> Optional +- client.addressing.address_maps.delete(address_map_id, \*, account_id) -> AddressMapDeleteResponse +- client.addressing.address_maps.edit(address_map_id, \*, account_id, \*\*params) -> Optional[AddressMap] +- client.addressing.address_maps.get(address_map_id, \*, account_id) -> Optional[AddressMapGetResponse] ### Accounts @@ -2872,8 +3361,8 @@ from cloudflare.types.addressing.address_maps import AccountUpdateResponse, Acco Methods: -- client.addressing.address_maps.accounts.update(address_map_id, \*, account_id, \*\*params) -> Optional -- client.addressing.address_maps.accounts.delete(address_map_id, \*, account_id) -> Optional +- client.addressing.address_maps.accounts.update(address_map_id, \*, account_id, \*\*params) -> AccountUpdateResponse +- client.addressing.address_maps.accounts.delete(address_map_id, \*, account_id) -> AccountDeleteResponse ### IPs @@ -2885,8 +3374,8 @@ from cloudflare.types.addressing.address_maps import IPUpdateResponse, IPDeleteR Methods: -- client.addressing.address_maps.ips.update(ip_address, \*, account_id, address_map_id, \*\*params) -> Optional -- client.addressing.address_maps.ips.delete(ip_address, \*, account_id, address_map_id) -> Optional +- client.addressing.address_maps.ips.update(ip_address, \*, account_id, address_map_id, \*\*params) -> IPUpdateResponse +- client.addressing.address_maps.ips.delete(ip_address, \*, account_id, address_map_id) -> IPDeleteResponse ### Zones @@ -2898,8 +3387,8 @@ from cloudflare.types.addressing.address_maps import ZoneUpdateResponse, ZoneDel Methods: -- client.addressing.address_maps.zones.update(address_map_id, \*, zone_id, account_id, \*\*params) -> Optional -- client.addressing.address_maps.zones.delete(address_map_id, \*, zone_id, account_id) -> Optional +- client.addressing.address_maps.zones.update(address_map_id, \*, zone_id, account_id, \*\*params) -> ZoneUpdateResponse +- client.addressing.address_maps.zones.delete(address_map_id, \*, zone_id, account_id) -> ZoneDeleteResponse ## LOADocuments @@ -2911,15 +3400,10 @@ from cloudflare.types.addressing import LOADocumentCreateResponse Methods: -- client.addressing.loa_documents.create(\*, account_id, \*\*params) -> Optional +- client.addressing.loa_documents.create(\*, account_id, \*\*params) -> Optional[LOADocumentCreateResponse] +- client.addressing.loa_documents.get(loa_document_id, \*, account_id) -> BinaryAPIResponse -### Downloads - -Methods: - -- client.addressing.loa_documents.downloads.get(loa_document_id, \*, account_id) -> BinaryAPIResponse - -## Prefixes +## Prefixes Types: @@ -2929,55 +3413,57 @@ from cloudflare.types.addressing import Prefix, PrefixDeleteResponse Methods: -- client.addressing.prefixes.create(\*, account_id, \*\*params) -> Optional +- client.addressing.prefixes.create(\*, account_id, \*\*params) -> Optional[Prefix] - client.addressing.prefixes.list(\*, account_id) -> SyncSinglePage[Prefix] -- client.addressing.prefixes.delete(prefix_id, \*, account_id) -> Optional -- client.addressing.prefixes.edit(prefix_id, \*, account_id, \*\*params) -> Optional -- client.addressing.prefixes.get(prefix_id, \*, account_id) -> Optional +- client.addressing.prefixes.delete(prefix_id, \*, account_id) -> PrefixDeleteResponse +- client.addressing.prefixes.edit(prefix_id, \*, account_id, \*\*params) -> Optional[Prefix] +- client.addressing.prefixes.get(prefix_id, \*, account_id) -> Optional[Prefix] -### BGP - -#### Bindings +### ServiceBindings Types: ```python -from cloudflare.types.addressing.prefixes.bgp import ServiceBinding, BindingDeleteResponse +from cloudflare.types.addressing.prefixes import ServiceBinding, ServiceBindingDeleteResponse ``` Methods: -- client.addressing.prefixes.bgp.bindings.create(prefix_id, \*, account_id, \*\*params) -> Optional -- client.addressing.prefixes.bgp.bindings.list(prefix_id, \*, account_id) -> SyncSinglePage[ServiceBinding] -- client.addressing.prefixes.bgp.bindings.delete(binding_id, \*, account_id, prefix_id) -> BindingDeleteResponse -- client.addressing.prefixes.bgp.bindings.get(binding_id, \*, account_id, prefix_id) -> Optional +- client.addressing.prefixes.service_bindings.create(prefix_id, \*, account_id, \*\*params) -> Optional[ServiceBinding] +- client.addressing.prefixes.service_bindings.list(prefix_id, \*, account_id) -> SyncSinglePage[ServiceBinding] +- client.addressing.prefixes.service_bindings.delete(binding_id, \*, account_id, prefix_id) -> ServiceBindingDeleteResponse +- client.addressing.prefixes.service_bindings.get(binding_id, \*, account_id, prefix_id) -> Optional[ServiceBinding] -#### Prefixes +### BGPPrefixes Types: ```python -from cloudflare.types.addressing.prefixes.bgp import BGPPrefix +from cloudflare.types.addressing.prefixes import BGPPrefix ``` Methods: -- client.addressing.prefixes.bgp.prefixes.list(prefix_id, \*, account_id) -> SyncSinglePage[BGPPrefix] -- client.addressing.prefixes.bgp.prefixes.edit(bgp_prefix_id, \*, account_id, prefix_id, \*\*params) -> Optional -- client.addressing.prefixes.bgp.prefixes.get(bgp_prefix_id, \*, account_id, prefix_id) -> Optional +- client.addressing.prefixes.bgp_prefixes.create(prefix_id, \*, account_id, \*\*params) -> Optional[BGPPrefix] +- client.addressing.prefixes.bgp_prefixes.list(prefix_id, \*, account_id) -> SyncSinglePage[BGPPrefix] +- client.addressing.prefixes.bgp_prefixes.edit(bgp_prefix_id, \*, account_id, prefix_id, \*\*params) -> Optional[BGPPrefix] +- client.addressing.prefixes.bgp_prefixes.get(bgp_prefix_id, \*, account_id, prefix_id) -> Optional[BGPPrefix] -#### Statuses +### AdvertisementStatus Types: ```python -from cloudflare.types.addressing.prefixes.bgp import StatusEditResponse, StatusGetResponse +from cloudflare.types.addressing.prefixes import ( + AdvertisementStatusEditResponse, + AdvertisementStatusGetResponse, +) ``` Methods: -- client.addressing.prefixes.bgp.statuses.edit(prefix_id, \*, account_id, \*\*params) -> Optional -- client.addressing.prefixes.bgp.statuses.get(prefix_id, \*, account_id) -> Optional +- client.addressing.prefixes.advertisement_status.edit(prefix_id, \*, account_id, \*\*params) -> Optional[AdvertisementStatusEditResponse] +- client.addressing.prefixes.advertisement_status.get(prefix_id, \*, account_id) -> Optional[AdvertisementStatusGetResponse] ### Delegations @@ -2989,9 +3475,9 @@ from cloudflare.types.addressing.prefixes import Delegations, DelegationDeleteRe Methods: -- client.addressing.prefixes.delegations.create(prefix_id, \*, account_id, \*\*params) -> Optional +- client.addressing.prefixes.delegations.create(prefix_id, \*, account_id, \*\*params) -> Optional[Delegations] - client.addressing.prefixes.delegations.list(prefix_id, \*, account_id) -> SyncSinglePage[Delegations] -- client.addressing.prefixes.delegations.delete(delegation_id, \*, account_id, prefix_id) -> Optional +- client.addressing.prefixes.delegations.delete(delegation_id, \*, account_id, prefix_id) -> Optional[DelegationDeleteResponse] # AuditLogs @@ -3011,7 +3497,7 @@ from cloudflare.types.billing import ProfileGetResponse Methods: -- client.billing.profiles.get(account_identifier) -> ProfileGetResponse +- client.billing.profiles.get(\*, account_id) -> ProfileGetResponse # BrandProtection @@ -3020,17 +3506,63 @@ Types: ```python from cloudflare.types.brand_protection import ( Info, - RuleMatch, - ScanStatus, Submit, - URLInfoModelResults, + BrandProtectionSubmitResponse, + BrandProtectionURLInfoResponse, ) ``` Methods: -- client.brand_protection.submit(\*, account_id, \*\*params) -> Optional -- client.brand_protection.url_info(\*, account_id, \*\*params) -> Optional +- client.brand_protection.submit(\*, account_id) -> BrandProtectionSubmitResponse +- client.brand_protection.url_info(\*, account_id) -> SyncSinglePage[BrandProtectionURLInfoResponse] + +## Queries + +Methods: + +- client.brand_protection.queries.create(\*, account_id, \*\*params) -> None +- client.brand_protection.queries.delete(\*, account_id, \*\*params) -> None +- client.brand_protection.queries.bulk(\*, account_id, \*\*params) -> None + +## Matches + +Types: + +```python +from cloudflare.types.brand_protection import MatchDownloadResponse, MatchGetResponse +``` + +Methods: + +- client.brand_protection.matches.download(\*, account_id, \*\*params) -> MatchDownloadResponse +- client.brand_protection.matches.get(\*, account_id, \*\*params) -> MatchGetResponse + +## Logos + +Types: + +```python +from cloudflare.types.brand_protection import LogoCreateResponse +``` + +Methods: + +- client.brand_protection.logos.create(\*, account_id, \*\*params) -> LogoCreateResponse +- client.brand_protection.logos.delete(logo_id, \*, account_id) -> None + +## LogoMatches + +Types: + +```python +from cloudflare.types.brand_protection import LogoMatchDownloadResponse, LogoMatchGetResponse +``` + +Methods: + +- client.brand_protection.logo_matches.download(\*, account_id, \*\*params) -> LogoMatchDownloadResponse +- client.brand_protection.logo_matches.get(\*, account_id, \*\*params) -> LogoMatchGetResponse # Diagnostics @@ -3039,12 +3571,35 @@ Methods: Types: ```python -from cloudflare.types.diagnostics import Traceroute, TracerouteCreateResponse +from cloudflare.types.diagnostics import Traceroute +``` + +Methods: + +- client.diagnostics.traceroutes.create(\*, account_id, \*\*params) -> SyncSinglePage[Traceroute] + +## EndpointHealthchecks + +Types: + +```python +from cloudflare.types.diagnostics import ( + EndpointHealthcheck, + EndpointHealthcheckCreateResponse, + EndpointHealthcheckUpdateResponse, + EndpointHealthcheckListResponse, + EndpointHealthcheckDeleteResponse, + EndpointHealthcheckGetResponse, +) ``` Methods: -- client.diagnostics.traceroutes.create(\*, account_id, \*\*params) -> Optional +- client.diagnostics.endpoint_healthchecks.create(\*, account_id, \*\*params) -> Optional[EndpointHealthcheckCreateResponse] +- client.diagnostics.endpoint_healthchecks.update(id, \*, account_id, \*\*params) -> Optional[EndpointHealthcheckUpdateResponse] +- client.diagnostics.endpoint_healthchecks.list(\*, account_id) -> Optional[EndpointHealthcheckListResponse] +- client.diagnostics.endpoint_healthchecks.delete(id, \*, account_id) -> EndpointHealthcheckDeleteResponse +- client.diagnostics.endpoint_healthchecks.get(id, \*, account_id) -> Optional[EndpointHealthcheckGetResponse] # Images @@ -3148,7 +3703,7 @@ Methods: Methods: -- client.intel.asn.get(asn, \*, account_id) -> Optional +- client.intel.asn.get(asn, \*, account_id) -> Optional[ASN] ### Subnets @@ -3167,12 +3722,12 @@ Methods: Types: ```python -from cloudflare.types.intel import DNS, DNSListResponse +from cloudflare.types.intel import DNS ``` Methods: -- client.intel.dns.list(\*, account_id, \*\*params) -> SyncV4PagePagination[DNSListResponse] +- client.intel.dns.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[DNS]] ## Domains @@ -3184,7 +3739,7 @@ from cloudflare.types.intel import Domain Methods: -- client.intel.domains.get(\*, account_id, \*\*params) -> Optional +- client.intel.domains.get(\*, account_id, \*\*params) -> Optional[Domain] ### Bulks @@ -3196,7 +3751,7 @@ from cloudflare.types.intel.domains import BulkGetResponse Methods: -- client.intel.domains.bulks.get(\*, account_id, \*\*params) -> Optional +- client.intel.domains.bulks.get(\*, account_id, \*\*params) -> Optional[BulkGetResponse] ## DomainHistory @@ -3208,7 +3763,7 @@ from cloudflare.types.intel import DomainHistory, DomainHistoryGetResponse Methods: -- client.intel.domain_history.get(\*, account_id, \*\*params) -> Optional +- client.intel.domain_history.get(\*, account_id, \*\*params) -> Optional[DomainHistoryGetResponse] ## IPs @@ -3220,20 +3775,16 @@ from cloudflare.types.intel import IP, IPGetResponse Methods: -- client.intel.ips.get(\*, account_id, \*\*params) -> Optional +- client.intel.ips.get(\*, account_id, \*\*params) -> Optional[IPGetResponse] ## IPLists Types: ```python -from cloudflare.types.intel import IPList, IPListGetResponse +from cloudflare.types.intel import IPList ``` -Methods: - -- client.intel.ip_lists.get(\*, account_id) -> Optional - ## Miscategorizations Types: @@ -3244,7 +3795,7 @@ from cloudflare.types.intel import MiscategorizationCreateResponse Methods: -- client.intel.miscategorizations.create(\*, account_id, \*\*params) -> Optional +- client.intel.miscategorizations.create(\*, account_id, \*\*params) -> MiscategorizationCreateResponse ## Whois @@ -3256,7 +3807,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional[WhoisGetResponse] ## IndicatorFeeds @@ -3274,11 +3825,11 @@ from cloudflare.types.intel import ( Methods: -- client.intel.indicator_feeds.create(\*, account_id, \*\*params) -> Optional -- client.intel.indicator_feeds.update(feed_id, \*, account_id, \*\*params) -> Optional +- client.intel.indicator_feeds.create(\*, account_id, \*\*params) -> Optional[IndicatorFeedCreateResponse] +- client.intel.indicator_feeds.update(feed_id, \*, account_id, \*\*params) -> Optional[IndicatorFeedUpdateResponse] - client.intel.indicator_feeds.list(\*, account_id) -> SyncSinglePage[IndicatorFeedListResponse] - client.intel.indicator_feeds.data(feed_id, \*, account_id) -> str -- client.intel.indicator_feeds.get(feed_id, \*, account_id) -> Optional +- client.intel.indicator_feeds.get(feed_id, \*, account_id) -> Optional[IndicatorFeedGetResponse] ### Snapshots @@ -3290,7 +3841,7 @@ from cloudflare.types.intel.indicator_feeds import SnapshotUpdateResponse Methods: -- client.intel.indicator_feeds.snapshots.update(feed_id, \*, account_id, \*\*params) -> Optional +- client.intel.indicator_feeds.snapshots.update(feed_id, \*, account_id, \*\*params) -> Optional[SnapshotUpdateResponse] ### Permissions @@ -3306,9 +3857,9 @@ from cloudflare.types.intel.indicator_feeds import ( Methods: -- client.intel.indicator_feeds.permissions.create(\*, account_id, \*\*params) -> Optional -- client.intel.indicator_feeds.permissions.list(\*, account_id) -> Optional -- client.intel.indicator_feeds.permissions.delete(\*, account_id, \*\*params) -> Optional +- client.intel.indicator_feeds.permissions.create(\*, account_id, \*\*params) -> Optional[PermissionCreateResponse] +- client.intel.indicator_feeds.permissions.list(\*, account_id) -> Optional[PermissionListResponse] +- client.intel.indicator_feeds.permissions.delete(\*, account_id, \*\*params) -> Optional[PermissionDeleteResponse] ## Sinkholes @@ -3334,7 +3885,7 @@ from cloudflare.types.intel.attack_surface_report import IssueTypeGetResponse Methods: -- client.intel.attack_surface_report.issue_types.get(\*, account_id) -> Optional +- client.intel.attack_surface_report.issue_types.get(\*, account_id) -> SyncSinglePage[IssueTypeGetResponse] ### Issues @@ -3354,11 +3905,11 @@ from cloudflare.types.intel.attack_surface_report import ( Methods: -- client.intel.attack_surface_report.issues.list(\*, account_id, \*\*params) -> SyncV4PagePagination[IssueListResponse] -- client.intel.attack*surface_report.issues.class*(\*, account_id, \*\*params) -> Optional -- client.intel.attack_surface_report.issues.dismiss(issue_id, \*, account_id, \*\*params) -> Optional -- client.intel.attack_surface_report.issues.severity(\*, account_id, \*\*params) -> Optional -- client.intel.attack_surface_report.issues.type(\*, account_id, \*\*params) -> Optional +- client.intel.attack_surface_report.issues.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[IssueListResponse]] +- client.intel.attack*surface_report.issues.class*(\*, account_id, \*\*params) -> Optional[IssueClassResponse] +- client.intel.attack_surface_report.issues.dismiss(issue_id, \*, account_id, \*\*params) -> IssueDismissResponse +- client.intel.attack_surface_report.issues.severity(\*, account_id, \*\*params) -> Optional[IssueSeverityResponse] +- client.intel.attack_surface_report.issues.type(\*, account_id, \*\*params) -> Optional[IssueTypeResponse] # MagicTransit @@ -3378,15 +3929,17 @@ from cloudflare.types.magic_transit import ( AppUpdateResponse, AppListResponse, AppDeleteResponse, + AppEditResponse, ) ``` Methods: -- client.magic_transit.apps.create(\*, account_id, \*\*params) -> Optional -- client.magic_transit.apps.update(account_app_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.apps.create(\*, account_id, \*\*params) -> Optional[AppCreateResponse] +- client.magic_transit.apps.update(account_app_id, \*, account_id, \*\*params) -> Optional[AppUpdateResponse] - client.magic_transit.apps.list(\*, account_id) -> SyncSinglePage[AppListResponse] -- client.magic_transit.apps.delete(account_app_id, \*, account_id) -> Optional +- client.magic_transit.apps.delete(account_app_id, \*, account_id) -> Optional[AppDeleteResponse] +- client.magic_transit.apps.edit(account_app_id, \*, account_id, \*\*params) -> Optional[AppEditResponse] ## CfInterconnects @@ -3396,6 +3949,7 @@ Types: from cloudflare.types.magic_transit import ( CfInterconnectUpdateResponse, CfInterconnectListResponse, + CfInterconnectBulkUpdateResponse, CfInterconnectGetResponse, ) ``` @@ -3404,6 +3958,7 @@ Methods: - client.magic_transit.cf_interconnects.update(cf_interconnect_id, \*, account_id, \*\*params) -> CfInterconnectUpdateResponse - client.magic_transit.cf_interconnects.list(\*, account_id) -> CfInterconnectListResponse +- client.magic_transit.cf_interconnects.bulk_update(\*, account_id, \*\*params) -> CfInterconnectBulkUpdateResponse - client.magic_transit.cf_interconnects.get(cf_interconnect_id, \*, account_id) -> CfInterconnectGetResponse ## GRETunnels @@ -3416,6 +3971,7 @@ from cloudflare.types.magic_transit import ( GRETunnelUpdateResponse, GRETunnelListResponse, GRETunnelDeleteResponse, + GRETunnelBulkUpdateResponse, GRETunnelGetResponse, ) ``` @@ -3426,6 +3982,7 @@ Methods: - client.magic_transit.gre_tunnels.update(gre_tunnel_id, \*, account_id, \*\*params) -> GRETunnelUpdateResponse - client.magic_transit.gre_tunnels.list(\*, account_id) -> GRETunnelListResponse - client.magic_transit.gre_tunnels.delete(gre_tunnel_id, \*, account_id) -> GRETunnelDeleteResponse +- client.magic_transit.gre_tunnels.bulk_update(\*, account_id, \*\*params) -> GRETunnelBulkUpdateResponse - client.magic_transit.gre_tunnels.get(gre_tunnel_id, \*, account_id) -> GRETunnelGetResponse ## IPSECTunnels @@ -3439,6 +3996,7 @@ from cloudflare.types.magic_transit import ( IPSECTunnelUpdateResponse, IPSECTunnelListResponse, IPSECTunnelDeleteResponse, + IPSECTunnelBulkUpdateResponse, IPSECTunnelGetResponse, IPSECTunnelPSKGenerateResponse, ) @@ -3450,6 +4008,7 @@ Methods: - client.magic_transit.ipsec_tunnels.update(ipsec_tunnel_id, \*, account_id, \*\*params) -> IPSECTunnelUpdateResponse - client.magic_transit.ipsec_tunnels.list(\*, account_id) -> IPSECTunnelListResponse - client.magic_transit.ipsec_tunnels.delete(ipsec_tunnel_id, \*, account_id) -> IPSECTunnelDeleteResponse +- client.magic_transit.ipsec_tunnels.bulk_update(\*, account_id, \*\*params) -> IPSECTunnelBulkUpdateResponse - client.magic_transit.ipsec_tunnels.get(ipsec_tunnel_id, \*, account_id) -> IPSECTunnelGetResponse - client.magic_transit.ipsec_tunnels.psk_generate(ipsec_tunnel_id, \*, account_id, \*\*params) -> IPSECTunnelPSKGenerateResponse @@ -3464,6 +4023,7 @@ from cloudflare.types.magic_transit import ( RouteUpdateResponse, RouteListResponse, RouteDeleteResponse, + RouteBulkUpdateResponse, RouteEmptyResponse, RouteGetResponse, ) @@ -3475,6 +4035,7 @@ Methods: - client.magic_transit.routes.update(route_id, \*, account_id, \*\*params) -> RouteUpdateResponse - client.magic_transit.routes.list(\*, account_id) -> RouteListResponse - client.magic_transit.routes.delete(route_id, \*, account_id) -> RouteDeleteResponse +- client.magic_transit.routes.bulk_update(\*, account_id, \*\*params) -> RouteBulkUpdateResponse - client.magic_transit.routes.empty(\*, account_id) -> RouteEmptyResponse - client.magic_transit.routes.get(route_id, \*, account_id) -> RouteGetResponse @@ -3524,13 +4085,12 @@ from cloudflare.types.magic_transit.sites import ( LANStaticAddressing, Nat, RoutedSubnet, - LANCreateResponse, ) ``` Methods: -- client.magic_transit.sites.lans.create(site_id, \*, account_id, \*\*params) -> LANCreateResponse +- client.magic_transit.sites.lans.create(site_id, \*, account_id, \*\*params) -> SyncSinglePage[LAN] - client.magic_transit.sites.lans.update(lan_id, \*, account_id, site_id, \*\*params) -> LAN - client.magic_transit.sites.lans.list(site_id, \*, account_id) -> SyncSinglePage[LAN] - client.magic_transit.sites.lans.delete(lan_id, \*, account_id, site_id) -> LAN @@ -3542,12 +4102,12 @@ Methods: Types: ```python -from cloudflare.types.magic_transit.sites import WAN, WANStaticAddressing, WANCreateResponse +from cloudflare.types.magic_transit.sites import WAN, WANStaticAddressing ``` Methods: -- client.magic_transit.sites.wans.create(site_id, \*, account_id, \*\*params) -> WANCreateResponse +- client.magic_transit.sites.wans.create(site_id, \*, account_id, \*\*params) -> SyncSinglePage[WAN] - client.magic_transit.sites.wans.update(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.list(site_id, \*, account_id) -> SyncSinglePage[WAN] - client.magic_transit.sites.wans.delete(wan_id, \*, account_id, site_id) -> WAN @@ -3560,8 +4120,10 @@ Types: ```python from cloudflare.types.magic_transit import ( + ConnectorCreateResponse, ConnectorUpdateResponse, ConnectorListResponse, + ConnectorDeleteResponse, ConnectorEditResponse, ConnectorGetResponse, ) @@ -3569,495 +4131,748 @@ from cloudflare.types.magic_transit import ( Methods: -- client.magic_transit.connectors.update(connector_id, \*, account_id, \*\*params) -> ConnectorUpdateResponse -- client.magic_transit.connectors.list(\*, account_id) -> SyncSinglePage[ConnectorListResponse] -- client.magic_transit.connectors.edit(connector_id, \*, account_id, \*\*params) -> ConnectorEditResponse -- client.magic_transit.connectors.get(connector_id, \*, account_id) -> ConnectorGetResponse - -# MagicNetworkMonitoring +- client.magic_transit.connectors.create(\*, account_id, \*\*params) -> ConnectorCreateResponse +- client.magic_transit.connectors.update(connector_id, \*, account_id, \*\*params) -> ConnectorUpdateResponse +- client.magic_transit.connectors.list(\*, account_id) -> SyncSinglePage[ConnectorListResponse] +- client.magic_transit.connectors.delete(connector_id, \*, account_id) -> ConnectorDeleteResponse +- client.magic_transit.connectors.edit(connector_id, \*, account_id, \*\*params) -> ConnectorEditResponse +- client.magic_transit.connectors.get(connector_id, \*, account_id) -> ConnectorGetResponse -## Configs +### Events Types: ```python -from cloudflare.types.magic_network_monitoring import Configuration +from cloudflare.types.magic_transit.connectors import EventListResponse, EventGetResponse ``` Methods: -- client.magic_network_monitoring.configs.create(\*, account_id, \*\*params) -> Configuration -- client.magic_network_monitoring.configs.update(\*, account_id, \*\*params) -> Configuration -- client.magic_network_monitoring.configs.delete(\*, account_id) -> Configuration -- client.magic_network_monitoring.configs.edit(\*, account_id, \*\*params) -> Configuration -- client.magic_network_monitoring.configs.get(\*, account_id) -> Configuration +- client.magic_transit.connectors.events.list(connector_id, \*, account_id, \*\*params) -> EventListResponse +- client.magic_transit.connectors.events.get(event_n, \*, account_id, connector_id, event_t) -> EventGetResponse -### Full +#### Latest + +Types: + +```python +from cloudflare.types.magic_transit.connectors.events import LatestListResponse +``` Methods: -- client.magic_network_monitoring.configs.full.get(\*, account_id) -> Configuration +- client.magic_transit.connectors.events.latest.list(connector_id, \*, account_id) -> LatestListResponse -## Rules +### Snapshots Types: ```python -from cloudflare.types.magic_network_monitoring import MagicNetworkMonitoringRule +from cloudflare.types.magic_transit.connectors import SnapshotListResponse, SnapshotGetResponse ``` Methods: -- client.magic_network_monitoring.rules.create(\*, account_id, \*\*params) -> Optional -- client.magic_network_monitoring.rules.update(\*, account_id, \*\*params) -> Optional -- client.magic_network_monitoring.rules.list(\*, account_id) -> SyncSinglePage[Optional] -- client.magic_network_monitoring.rules.delete(rule_id, \*, account_id) -> Optional -- client.magic_network_monitoring.rules.edit(rule_id, \*, account_id, \*\*params) -> Optional -- client.magic_network_monitoring.rules.get(rule_id, \*, account_id) -> Optional +- client.magic_transit.connectors.snapshots.list(connector_id, \*, account_id, \*\*params) -> SnapshotListResponse +- client.magic_transit.connectors.snapshots.get(snapshot_t, \*, account_id, connector_id) -> SnapshotGetResponse -### Advertisements +#### Latest Types: ```python -from cloudflare.types.magic_network_monitoring.rules import Advertisement +from cloudflare.types.magic_transit.connectors.snapshots import LatestListResponse ``` Methods: -- client.magic_network_monitoring.rules.advertisements.edit(rule_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.connectors.snapshots.latest.list(connector_id, \*, account_id) -> LatestListResponse -# MTLSCertificates +## PCAPs Types: ```python -from cloudflare.types.mtls_certificates import MTLSCertificate, MTLSCertificateCreateResponse +from cloudflare.types.magic_transit import ( + PCAP, + PCAPFilter, + PCAPCreateResponse, + PCAPListResponse, + PCAPGetResponse, +) ``` Methods: -- client.mtls_certificates.create(\*, account_id, \*\*params) -> Optional -- client.mtls_certificates.list(\*, account_id) -> SyncSinglePage[MTLSCertificate] -- client.mtls_certificates.delete(mtls_certificate_id, \*, account_id) -> Optional -- client.mtls_certificates.get(mtls_certificate_id, \*, account_id) -> Optional +- client.magic_transit.pcaps.create(\*, account_id, \*\*params) -> PCAPCreateResponse +- client.magic_transit.pcaps.list(\*, account_id) -> SyncSinglePage[PCAPListResponse] +- client.magic_transit.pcaps.get(pcap_id, \*, account_id) -> PCAPGetResponse +- client.magic_transit.pcaps.stop(pcap_id, \*, account_id) -> None -## Associations +### Ownership Types: ```python -from cloudflare.types.mtls_certificates import CertificateAsssociation, AssociationGetResponse +from cloudflare.types.magic_transit.pcaps import Ownership ``` Methods: -- client.mtls_certificates.associations.get(mtls_certificate_id, \*, account_id) -> Optional +- client.magic_transit.pcaps.ownership.create(\*, account_id, \*\*params) -> Ownership +- client.magic_transit.pcaps.ownership.delete(ownership_id, \*, account_id) -> None +- client.magic_transit.pcaps.ownership.get(\*, account_id) -> SyncSinglePage[Ownership] +- client.magic_transit.pcaps.ownership.validate(\*, account_id, \*\*params) -> Ownership -# Pages +### Download -## Projects +Methods: + +- client.magic_transit.pcaps.download.get(pcap_id, \*, account_id) -> BinaryAPIResponse + +# MagicNetworkMonitoring + +## VPCFlows + +### Tokens Types: ```python -from cloudflare.types.pages import ( - Deployment, - Project, - Stage, - ProjectCreateResponse, - ProjectDeleteResponse, - ProjectEditResponse, - ProjectPurgeBuildCacheResponse, -) +from cloudflare.types.magic_network_monitoring.vpc_flows import TokenCreateResponse ``` Methods: -- client.pages.projects.create(\*, account_id, \*\*params) -> ProjectCreateResponse -- client.pages.projects.list(\*, account_id) -> SyncSinglePage[Deployment] -- client.pages.projects.delete(project_name, \*, account_id) -> object -- client.pages.projects.edit(project_name, \*, account_id, \*\*params) -> ProjectEditResponse -- client.pages.projects.get(project_name, \*, account_id) -> Project -- client.pages.projects.purge_build_cache(project_name, \*, account_id) -> object +- client.magic_network_monitoring.vpc_flows.tokens.create(\*, account_id) -> str -### Deployments +## Configs Types: ```python -from cloudflare.types.pages.projects import DeploymentDeleteResponse +from cloudflare.types.magic_network_monitoring import Configuration ``` Methods: -- client.pages.projects.deployments.create(project_name, \*, account_id, \*\*params) -> Deployment -- client.pages.projects.deployments.list(project_name, \*, account_id, \*\*params) -> SyncSinglePage[Deployment] -- client.pages.projects.deployments.delete(deployment_id, \*, account_id, project_name) -> object -- client.pages.projects.deployments.get(deployment_id, \*, account_id, project_name) -> Deployment -- client.pages.projects.deployments.retry(deployment_id, \*, account_id, project_name, \*\*params) -> Deployment -- client.pages.projects.deployments.rollback(deployment_id, \*, account_id, project_name, \*\*params) -> Deployment +- client.magic_network_monitoring.configs.create(\*, account_id, \*\*params) -> Configuration +- client.magic_network_monitoring.configs.update(\*, account_id, \*\*params) -> Configuration +- client.magic_network_monitoring.configs.delete(\*, account_id) -> Configuration +- client.magic_network_monitoring.configs.edit(\*, account_id, \*\*params) -> Configuration +- client.magic_network_monitoring.configs.get(\*, account_id) -> Configuration -#### History +### Full -##### Logs +Methods: + +- client.magic_network_monitoring.configs.full.get(\*, account_id) -> Configuration + +## Rules Types: ```python -from cloudflare.types.pages.projects.deployments.history import LogGetResponse +from cloudflare.types.magic_network_monitoring import MagicNetworkMonitoringRule ``` Methods: -- client.pages.projects.deployments.history.logs.get(deployment_id, \*, account_id, project_name) -> LogGetResponse +- client.magic_network_monitoring.rules.create(\*, account_id, \*\*params) -> Optional[MagicNetworkMonitoringRule] +- client.magic_network_monitoring.rules.update(\*, account_id, \*\*params) -> Optional[MagicNetworkMonitoringRule] +- client.magic_network_monitoring.rules.list(\*, account_id) -> SyncSinglePage[Optional[MagicNetworkMonitoringRule]] +- client.magic_network_monitoring.rules.delete(rule_id, \*, account_id) -> Optional[MagicNetworkMonitoringRule] +- client.magic_network_monitoring.rules.edit(rule_id, \*, account_id, \*\*params) -> Optional[MagicNetworkMonitoringRule] +- client.magic_network_monitoring.rules.get(rule_id, \*, account_id) -> Optional[MagicNetworkMonitoringRule] -### Domains +### Advertisements Types: ```python -from cloudflare.types.pages.projects import ( - DomainCreateResponse, - DomainListResponse, - DomainDeleteResponse, - DomainEditResponse, - DomainGetResponse, -) +from cloudflare.types.magic_network_monitoring.rules import Advertisement ``` Methods: -- client.pages.projects.domains.create(project_name, \*, account_id, \*\*params) -> Optional -- client.pages.projects.domains.list(project_name, \*, account_id) -> SyncSinglePage[object] -- client.pages.projects.domains.delete(domain_name, \*, account_id, project_name) -> object -- client.pages.projects.domains.edit(domain_name, \*, account_id, project_name, \*\*params) -> Optional -- client.pages.projects.domains.get(domain_name, \*, account_id, project_name) -> Optional +- client.magic_network_monitoring.rules.advertisements.edit(rule_id, \*, account_id, \*\*params) -> Optional[Advertisement] + +# MagicCloudNetworking -# PCAPs +## CatalogSyncs Types: ```python -from cloudflare.types.pcaps import ( - PCAP, - PCAPFilter, - PCAPCreateResponse, - PCAPListResponse, - PCAPGetResponse, +from cloudflare.types.magic_cloud_networking import ( + CatalogSyncCreateResponse, + CatalogSyncUpdateResponse, + CatalogSyncListResponse, + CatalogSyncDeleteResponse, + CatalogSyncEditResponse, + CatalogSyncGetResponse, + CatalogSyncRefreshResponse, ) ``` Methods: -- client.pcaps.create(\*, account_id, \*\*params) -> PCAPCreateResponse -- client.pcaps.list(\*, account_id) -> SyncSinglePage[PCAPListResponse] -- client.pcaps.get(pcap_id, \*, account_id) -> PCAPGetResponse +- client.magic_cloud_networking.catalog_syncs.create(\*, account_id, \*\*params) -> CatalogSyncCreateResponse +- client.magic_cloud_networking.catalog_syncs.update(sync_id, \*, account_id, \*\*params) -> CatalogSyncUpdateResponse +- client.magic_cloud_networking.catalog_syncs.list(\*, account_id) -> SyncSinglePage[CatalogSyncListResponse] +- client.magic_cloud_networking.catalog_syncs.delete(sync_id, \*, account_id, \*\*params) -> CatalogSyncDeleteResponse +- client.magic_cloud_networking.catalog_syncs.edit(sync_id, \*, account_id, \*\*params) -> CatalogSyncEditResponse +- client.magic_cloud_networking.catalog_syncs.get(sync_id, \*, account_id) -> CatalogSyncGetResponse +- client.magic_cloud_networking.catalog_syncs.refresh(sync_id, \*, account_id) -> str -## Ownership +### PrebuiltPolicies Types: ```python -from cloudflare.types.pcaps import Ownership, OwnershipGetResponse +from cloudflare.types.magic_cloud_networking.catalog_syncs import PrebuiltPolicyListResponse ``` Methods: -- client.pcaps.ownership.create(\*, account_id, \*\*params) -> Ownership -- client.pcaps.ownership.delete(ownership_id, \*, account_id) -> None -- client.pcaps.ownership.get(\*, account_id) -> Optional -- client.pcaps.ownership.validate(\*, account_id, \*\*params) -> Ownership +- client.magic_cloud_networking.catalog_syncs.prebuilt_policies.list(\*, account_id, \*\*params) -> SyncSinglePage[PrebuiltPolicyListResponse] -## Download +## OnRamps -Methods: +Types: + +```python +from cloudflare.types.magic_cloud_networking import ( + OnRampCreateResponse, + OnRampUpdateResponse, + OnRampListResponse, + OnRampDeleteResponse, + OnRampApplyResponse, + OnRampEditResponse, + OnRampGetResponse, + OnRampPlanResponse, +) +``` -- client.pcaps.download.get(pcap_id, \*, account_id) -> BinaryAPIResponse +Methods: -# Registrar +- client.magic_cloud_networking.on_ramps.create(\*, account_id, \*\*params) -> OnRampCreateResponse +- client.magic_cloud_networking.on_ramps.update(onramp_id, \*, account_id, \*\*params) -> OnRampUpdateResponse +- client.magic_cloud_networking.on_ramps.list(\*, account_id, \*\*params) -> SyncSinglePage[OnRampListResponse] +- client.magic_cloud_networking.on_ramps.delete(onramp_id, \*, account_id, \*\*params) -> OnRampDeleteResponse +- client.magic_cloud_networking.on_ramps.apply(onramp_id, \*, account_id) -> OnRampApplyResponse +- client.magic_cloud_networking.on_ramps.edit(onramp_id, \*, account_id, \*\*params) -> OnRampEditResponse +- client.magic_cloud_networking.on_ramps.export(onramp_id, \*, account_id) -> BinaryAPIResponse +- client.magic_cloud_networking.on_ramps.get(onramp_id, \*, account_id, \*\*params) -> OnRampGetResponse +- client.magic_cloud_networking.on_ramps.plan(onramp_id, \*, account_id) -> OnRampPlanResponse -## Domains +### AddressSpaces Types: ```python -from cloudflare.types.registrar import Domain, DomainUpdateResponse, DomainGetResponse +from cloudflare.types.magic_cloud_networking.on_ramps import ( + AddressSpaceUpdateResponse, + AddressSpaceListResponse, + AddressSpaceEditResponse, +) ``` Methods: -- client.registrar.domains.update(domain_name, \*, account_id, \*\*params) -> Optional -- client.registrar.domains.list(\*, account_id) -> SyncSinglePage[Domain] -- client.registrar.domains.get(domain_name, \*, account_id) -> Optional - -# RequestTracers +- client.magic_cloud_networking.on_ramps.address_spaces.update(\*, account_id, \*\*params) -> AddressSpaceUpdateResponse +- client.magic_cloud_networking.on_ramps.address_spaces.list(\*, account_id) -> AddressSpaceListResponse +- client.magic_cloud_networking.on_ramps.address_spaces.edit(\*, account_id, \*\*params) -> AddressSpaceEditResponse -## Traces +## CloudIntegrations Types: ```python -from cloudflare.types.request_tracers import Trace, TraceItem, TraceCreateResponse +from cloudflare.types.magic_cloud_networking import ( + CloudIntegrationCreateResponse, + CloudIntegrationUpdateResponse, + CloudIntegrationListResponse, + CloudIntegrationDeleteResponse, + CloudIntegrationDiscoverResponse, + CloudIntegrationDiscoverAllResponse, + CloudIntegrationEditResponse, + CloudIntegrationGetResponse, + CloudIntegrationInitialSetupResponse, +) ``` Methods: -- client.request_tracers.traces.create(\*, account_id, \*\*params) -> Optional +- client.magic_cloud_networking.cloud_integrations.create(\*, account_id, \*\*params) -> CloudIntegrationCreateResponse +- client.magic_cloud_networking.cloud_integrations.update(provider_id, \*, account_id, \*\*params) -> CloudIntegrationUpdateResponse +- client.magic_cloud_networking.cloud_integrations.list(\*, account_id, \*\*params) -> SyncSinglePage[CloudIntegrationListResponse] +- client.magic_cloud_networking.cloud_integrations.delete(provider_id, \*, account_id) -> CloudIntegrationDeleteResponse +- client.magic_cloud_networking.cloud_integrations.discover(provider_id, \*, account_id, \*\*params) -> CloudIntegrationDiscoverResponse +- client.magic_cloud_networking.cloud_integrations.discover_all(\*, account_id) -> CloudIntegrationDiscoverAllResponse +- client.magic_cloud_networking.cloud_integrations.edit(provider_id, \*, account_id, \*\*params) -> CloudIntegrationEditResponse +- client.magic_cloud_networking.cloud_integrations.get(provider_id, \*, account_id, \*\*params) -> CloudIntegrationGetResponse +- client.magic_cloud_networking.cloud_integrations.initial_setup(provider_id, \*, account_id) -> CloudIntegrationInitialSetupResponse -# Rules - -## Lists +## Resources Types: ```python -from cloudflare.types.rules import Hostname, ListsList, Redirect, ListDeleteResponse +from cloudflare.types.magic_cloud_networking import ( + ResourceListResponse, + ResourceGetResponse, + ResourcePolicyPreviewResponse, +) ``` Methods: -- client.rules.lists.create(\*, account_id, \*\*params) -> Optional -- client.rules.lists.update(list_id, \*, account_id, \*\*params) -> Optional -- client.rules.lists.list(\*, account_id) -> SyncSinglePage[ListsList] -- client.rules.lists.delete(list_id, \*, account_id) -> Optional -- client.rules.lists.get(list_id, \*, account_id) -> Optional +- client.magic_cloud_networking.resources.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceListResponse] +- client.magic_cloud_networking.resources.export(\*, account_id, \*\*params) -> BinaryAPIResponse +- client.magic_cloud_networking.resources.get(resource_id, \*, account_id, \*\*params) -> ResourceGetResponse +- client.magic_cloud_networking.resources.policy_preview(\*, account_id, \*\*params) -> str -### BulkOperations +# NetworkInterconnects + +## CNIs Types: ```python -from cloudflare.types.rules.lists import OperationStatus, BulkOperationGetResponse +from cloudflare.types.network_interconnects import ( + CNICreateResponse, + CNIUpdateResponse, + CNIListResponse, + CNIGetResponse, +) ``` Methods: -- client.rules.lists.bulk_operations.get(operation_id, \*, account_identifier) -> Optional +- client.network_interconnects.cnis.create(\*, account_id, \*\*params) -> CNICreateResponse +- client.network_interconnects.cnis.update(cni, \*, account_id, \*\*params) -> CNIUpdateResponse +- client.network_interconnects.cnis.list(\*, account_id, \*\*params) -> CNIListResponse +- client.network_interconnects.cnis.delete(cni, \*, account_id) -> None +- client.network_interconnects.cnis.get(cni, \*, account_id) -> CNIGetResponse -### Items +## Interconnects Types: ```python -from cloudflare.types.rules.lists import ( - ListCursor, - ListItem, - ItemCreateResponse, - ItemUpdateResponse, - ItemListResponse, - ItemDeleteResponse, - ItemGetResponse, +from cloudflare.types.network_interconnects import ( + InterconnectCreateResponse, + InterconnectListResponse, + InterconnectGetResponse, + InterconnectStatusResponse, ) ``` Methods: -- client.rules.lists.items.create(list_id, \*, account_id, \*\*params) -> Optional -- client.rules.lists.items.update(list_id, \*, account_id, \*\*params) -> Optional -- client.rules.lists.items.list(list_id, \*, account_id, \*\*params) -> SyncCursorPagination[object] -- client.rules.lists.items.delete(list_id, \*, account_id) -> Optional -- client.rules.lists.items.get(item_id, \*, account_identifier, list_id) -> Optional - -# Storage +- client.network_interconnects.interconnects.create(\*, account_id, \*\*params) -> InterconnectCreateResponse +- client.network_interconnects.interconnects.list(\*, account_id, \*\*params) -> InterconnectListResponse +- client.network_interconnects.interconnects.delete(icon, \*, account_id) -> None +- client.network_interconnects.interconnects.get(icon, \*, account_id) -> InterconnectGetResponse +- client.network_interconnects.interconnects.loa(icon, \*, account_id) -> None +- client.network_interconnects.interconnects.status(icon, \*, account_id) -> InterconnectStatusResponse -## Analytics +## Settings Types: ```python -from cloudflare.types.storage import Components, Schema +from cloudflare.types.network_interconnects import SettingUpdateResponse, SettingGetResponse ``` Methods: -- client.storage.analytics.list(\*, account_id, \*\*params) -> Optional -- client.storage.analytics.stored(\*, account_id, \*\*params) -> Optional +- client.network_interconnects.settings.update(\*, account_id, \*\*params) -> SettingUpdateResponse +- client.network_interconnects.settings.get(\*, account_id) -> SettingGetResponse -# Stream +## Slots Types: ```python -from cloudflare.types.stream import AllowedOrigins, Video +from cloudflare.types.network_interconnects import SlotListResponse, SlotGetResponse ``` Methods: -- client.stream.create(\*, account_id, \*\*params) -> None -- client.stream.list(\*, account_id, \*\*params) -> SyncSinglePage[Video] -- client.stream.delete(identifier, \*, account_id) -> None -- client.stream.get(identifier, \*, account_id) -> Optional +- client.network_interconnects.slots.list(\*, account_id, \*\*params) -> SlotListResponse +- client.network_interconnects.slots.get(slot, \*, account_id) -> SlotGetResponse -## AudioTracks +# MTLSCertificates Types: ```python -from cloudflare.types.stream import Audio, AudioTrackDeleteResponse, AudioTrackGetResponse +from cloudflare.types.mtls_certificates import MTLSCertificate, MTLSCertificateCreateResponse ``` Methods: -- client.stream.audio_tracks.delete(audio_identifier, \*, account_id, identifier) -> Optional -- client.stream.audio_tracks.copy(identifier, \*, account_id, \*\*params) -> Optional -- client.stream.audio_tracks.edit(audio_identifier, \*, account_id, identifier, \*\*params) -> Optional -- client.stream.audio_tracks.get(identifier, \*, account_id) -> Optional +- client.mtls_certificates.create(\*, account_id, \*\*params) -> Optional[MTLSCertificateCreateResponse] +- client.mtls_certificates.list(\*, account_id) -> SyncSinglePage[MTLSCertificate] +- client.mtls_certificates.delete(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] +- client.mtls_certificates.get(mtls_certificate_id, \*, account_id) -> Optional[MTLSCertificate] -## Videos +## Associations Types: ```python -from cloudflare.types.stream import VideoStorageUsageResponse +from cloudflare.types.mtls_certificates import CertificateAsssociation ``` Methods: -- client.stream.videos.storage_usage(\*, account_id, \*\*params) -> Optional +- client.mtls_certificates.associations.get(mtls_certificate_id, \*, account_id) -> SyncSinglePage[CertificateAsssociation] -## Clip +# Pages + +## Projects Types: ```python -from cloudflare.types.stream import Clip +from cloudflare.types.pages import Deployment, Project, Stage ``` Methods: -- client.stream.clip.create(\*, account_id, \*\*params) -> Optional +- client.pages.projects.create(\*, account_id, \*\*params) -> Project +- client.pages.projects.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Project] +- client.pages.projects.delete(project_name, \*, account_id) -> object +- client.pages.projects.edit(project_name, \*, account_id, \*\*params) -> Project +- client.pages.projects.get(project_name, \*, account_id) -> Project +- client.pages.projects.purge_build_cache(project_name, \*, account_id) -> object -## Copy +### Deployments Methods: -- client.stream.copy.create(\*, account_id, \*\*params) -> Optional +- client.pages.projects.deployments.create(project_name, \*, account_id, \*\*params) -> Deployment +- client.pages.projects.deployments.list(project_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[Deployment] +- client.pages.projects.deployments.delete(deployment_id, \*, account_id, project_name) -> object +- client.pages.projects.deployments.get(deployment_id, \*, account_id, project_name) -> Deployment +- client.pages.projects.deployments.retry(deployment_id, \*, account_id, project_name) -> Deployment +- client.pages.projects.deployments.rollback(deployment_id, \*, account_id, project_name) -> Deployment -## DirectUpload +#### History + +##### Logs Types: ```python -from cloudflare.types.stream import DirectUploadCreateResponse +from cloudflare.types.pages.projects.deployments.history import LogGetResponse ``` Methods: -- client.stream.direct_upload.create(\*, account_id, \*\*params) -> Optional +- client.pages.projects.deployments.history.logs.get(deployment_id, \*, account_id, project_name) -> LogGetResponse -## Keys +### Domains Types: ```python -from cloudflare.types.stream import Keys, KeyDeleteResponse, KeyGetResponse +from cloudflare.types.pages.projects import ( + DomainCreateResponse, + DomainListResponse, + DomainEditResponse, + DomainGetResponse, +) ``` Methods: -- client.stream.keys.create(\*, account_id, \*\*params) -> Optional -- client.stream.keys.delete(identifier, \*, account_id) -> Optional -- client.stream.keys.get(\*, account_id) -> Optional +- client.pages.projects.domains.create(project_name, \*, account_id, \*\*params) -> DomainCreateResponse +- client.pages.projects.domains.list(project_name, \*, account_id) -> SyncSinglePage[DomainListResponse] +- client.pages.projects.domains.delete(domain_name, \*, account_id, project_name) -> object +- client.pages.projects.domains.edit(domain_name, \*, account_id, project_name) -> DomainEditResponse +- client.pages.projects.domains.get(domain_name, \*, account_id, project_name) -> DomainGetResponse -## LiveInputs +# Registrar + +## Domains Types: ```python -from cloudflare.types.stream import LiveInput, LiveInputListResponse +from cloudflare.types.registrar import Domain ``` Methods: -- client.stream.live_inputs.create(\*, account_id, \*\*params) -> Optional -- client.stream.live_inputs.update(live_input_identifier, \*, account_id, \*\*params) -> Optional -- client.stream.live_inputs.list(\*, account_id, \*\*params) -> Optional -- client.stream.live_inputs.delete(live_input_identifier, \*, account_id) -> None -- client.stream.live_inputs.get(live_input_identifier, \*, account_id) -> Optional +- client.registrar.domains.update(domain_name, \*, account_id, \*\*params) -> object +- client.registrar.domains.list(\*, account_id) -> SyncSinglePage[Domain] +- client.registrar.domains.get(domain_name, \*, account_id) -> object -### Outputs +# RequestTracers + +## Traces Types: ```python -from cloudflare.types.stream.live_inputs import Output +from cloudflare.types.request_tracers import Trace, TraceItem, TraceCreateResponse ``` Methods: -- client.stream.live_inputs.outputs.create(live_input_identifier, \*, account_id, \*\*params) -> Optional -- client.stream.live_inputs.outputs.update(output_identifier, \*, account_id, live_input_identifier, \*\*params) -> Optional -- client.stream.live_inputs.outputs.list(live_input_identifier, \*, account_id) -> SyncSinglePage[Output] -- client.stream.live_inputs.outputs.delete(output_identifier, \*, account_id, live_input_identifier) -> None +- client.request_tracers.traces.create(\*, account_id, \*\*params) -> Optional[TraceCreateResponse] -## Watermarks +# Rules + +## Lists Types: ```python -from cloudflare.types.stream import Watermark, WatermarkDeleteResponse +from cloudflare.types.rules import ( + Hostname, + ListsList, + Redirect, + ListCreateResponse, + ListUpdateResponse, + ListDeleteResponse, + ListGetResponse, +) ``` Methods: -- client.stream.watermarks.create(\*, account_id, \*\*params) -> Optional -- client.stream.watermarks.list(\*, account_id) -> SyncSinglePage[Watermark] -- client.stream.watermarks.delete(identifier, \*, account_id) -> Optional -- client.stream.watermarks.get(identifier, \*, account_id) -> Optional +- client.rules.lists.create(\*, account_id, \*\*params) -> ListCreateResponse +- client.rules.lists.update(list_id, \*, account_id, \*\*params) -> ListUpdateResponse +- client.rules.lists.list(\*, account_id) -> SyncSinglePage[ListsList] +- client.rules.lists.delete(list_id, \*, account_id) -> ListDeleteResponse +- client.rules.lists.get(list_id, \*, account_id) -> ListGetResponse -## Webhooks +### BulkOperations Types: ```python -from cloudflare.types.stream import WebhookUpdateResponse, WebhookDeleteResponse, WebhookGetResponse +from cloudflare.types.rules.lists import BulkOperationGetResponse ``` Methods: -- client.stream.webhooks.update(\*, account_id, \*\*params) -> Optional -- client.stream.webhooks.delete(\*, account_id) -> Optional -- client.stream.webhooks.get(\*, account_id) -> Optional +- client.rules.lists.bulk_operations.get(operation_id, \*, account_id) -> BulkOperationGetResponse -## Captions +### Items Types: ```python -from cloudflare.types.stream import Caption, CaptionGetResponse +from cloudflare.types.rules.lists import ( + ListCursor, + ListItem, + ItemCreateResponse, + ItemUpdateResponse, + ItemListResponse, + ItemDeleteResponse, + ItemGetResponse, +) ``` Methods: -- client.stream.captions.get(identifier, \*, account_id) -> Optional +- client.rules.lists.items.create(list_id, \*, account_id, \*\*params) -> ItemCreateResponse +- client.rules.lists.items.update(list_id, \*, account_id, \*\*params) -> ItemUpdateResponse +- client.rules.lists.items.list(list_id, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[ItemListResponse] +- client.rules.lists.items.delete(list_id, \*, account_id, \*\*params) -> ItemDeleteResponse +- client.rules.lists.items.get(item_id, \*, account_id, list_id) -> ItemGetResponse -### Language +# Stream Types: ```python -from cloudflare.types.stream.captions import LanguageDeleteResponse +from cloudflare.types.stream import AllowedOrigins, Video ``` Methods: -- client.stream.captions.language.create(language, \*, account_id, identifier) -> Optional -- client.stream.captions.language.update(language, \*, account_id, identifier, \*\*params) -> Optional -- client.stream.captions.language.delete(language, \*, account_id, identifier) -> str -- client.stream.captions.language.get(language, \*, account_id, identifier) -> Optional +- client.stream.create(\*, account_id, \*\*params) -> None +- client.stream.list(\*, account_id, \*\*params) -> SyncSinglePage[Video] +- client.stream.delete(identifier, \*, account_id) -> None +- client.stream.edit(identifier, \*, account_id, \*\*params) -> Optional[Video] +- client.stream.get(identifier, \*, account_id) -> Optional[Video] -#### Vtt +## AudioTracks Types: ```python -from cloudflare.types.stream.captions.language import VttGetResponse +from cloudflare.types.stream import Audio, AudioTrackDeleteResponse ``` Methods: -- client.stream.captions.language.vtt.get(language, \*, account_id, identifier) -> str +- client.stream.audio_tracks.delete(audio_identifier, \*, account_id, identifier) -> str +- client.stream.audio_tracks.copy(identifier, \*, account_id, \*\*params) -> Optional[Audio] +- client.stream.audio_tracks.edit(audio_identifier, \*, account_id, identifier, \*\*params) -> Optional[Audio] +- client.stream.audio_tracks.get(identifier, \*, account_id) -> SyncSinglePage[Audio] + +## Videos + +Types: + +```python +from cloudflare.types.stream import VideoStorageUsageResponse +``` + +Methods: + +- client.stream.videos.storage_usage(\*, account_id, \*\*params) -> Optional[VideoStorageUsageResponse] + +## Clip + +Types: + +```python +from cloudflare.types.stream import Clip +``` + +Methods: + +- client.stream.clip.create(\*, account_id, \*\*params) -> Optional[Clip] + +## Copy + +Methods: + +- client.stream.copy.create(\*, account_id, \*\*params) -> Optional[Video] + +## DirectUpload + +Types: + +```python +from cloudflare.types.stream import DirectUploadCreateResponse +``` + +Methods: + +- client.stream.direct_upload.create(\*, account_id, \*\*params) -> Optional[DirectUploadCreateResponse] + +## Keys + +Types: + +```python +from cloudflare.types.stream import Keys, KeyDeleteResponse, KeyGetResponse +``` + +Methods: + +- client.stream.keys.create(\*, account_id, \*\*params) -> Optional[Keys] +- client.stream.keys.delete(identifier, \*, account_id) -> str +- client.stream.keys.get(\*, account_id) -> SyncSinglePage[KeyGetResponse] + +## LiveInputs + +Types: + +```python +from cloudflare.types.stream import LiveInput, LiveInputListResponse +``` + +Methods: + +- client.stream.live_inputs.create(\*, account_id, \*\*params) -> Optional[LiveInput] +- client.stream.live_inputs.update(live_input_identifier, \*, account_id, \*\*params) -> Optional[LiveInput] +- client.stream.live_inputs.list(\*, account_id, \*\*params) -> Optional[LiveInputListResponse] +- client.stream.live_inputs.delete(live_input_identifier, \*, account_id) -> None +- client.stream.live_inputs.get(live_input_identifier, \*, account_id) -> Optional[LiveInput] + +### Outputs + +Types: + +```python +from cloudflare.types.stream.live_inputs import Output +``` + +Methods: + +- client.stream.live_inputs.outputs.create(live_input_identifier, \*, account_id, \*\*params) -> Optional[Output] +- client.stream.live_inputs.outputs.update(output_identifier, \*, account_id, live_input_identifier, \*\*params) -> Optional[Output] +- client.stream.live_inputs.outputs.list(live_input_identifier, \*, account_id) -> SyncSinglePage[Output] +- client.stream.live_inputs.outputs.delete(output_identifier, \*, account_id, live_input_identifier) -> None + +## Watermarks + +Types: + +```python +from cloudflare.types.stream import Watermark, WatermarkDeleteResponse +``` + +Methods: + +- client.stream.watermarks.create(\*, account_id, \*\*params) -> Optional[Watermark] +- client.stream.watermarks.list(\*, account_id) -> SyncSinglePage[Watermark] +- client.stream.watermarks.delete(identifier, \*, account_id) -> str +- client.stream.watermarks.get(identifier, \*, account_id) -> Optional[Watermark] + +## Webhooks + +Types: + +```python +from cloudflare.types.stream import WebhookDeleteResponse +``` + +Methods: + +- client.stream.webhooks.update(\*, account_id, \*\*params) -> object +- client.stream.webhooks.delete(\*, account_id) -> str +- client.stream.webhooks.get(\*, account_id) -> object + +## Captions + +Types: + +```python +from cloudflare.types.stream import Caption +``` + +Methods: + +- client.stream.captions.get(identifier, \*, account_id) -> SyncSinglePage[Caption] + +### Language + +Types: + +```python +from cloudflare.types.stream.captions import LanguageDeleteResponse +``` + +Methods: + +- client.stream.captions.language.create(language, \*, account_id, identifier) -> Optional[Caption] +- client.stream.captions.language.update(language, \*, account_id, identifier, \*\*params) -> Optional[Caption] +- client.stream.captions.language.delete(language, \*, account_id, identifier) -> str +- client.stream.captions.language.get(language, \*, account_id, identifier) -> Optional[Caption] + +#### Vtt + +Types: + +```python +from cloudflare.types.stream.captions.language import VttGetResponse +``` + +Methods: + +- client.stream.captions.language.vtt.get(language, \*, account_id, identifier) -> str ## Downloads @@ -4073,9 +4888,9 @@ from cloudflare.types.stream import ( Methods: -- client.stream.downloads.create(identifier, \*, account_id, \*\*params) -> Optional -- client.stream.downloads.delete(identifier, \*, account_id) -> Optional -- client.stream.downloads.get(identifier, \*, account_id) -> Optional +- client.stream.downloads.create(identifier, \*, account_id, \*\*params) -> Optional[DownloadCreateResponse] +- client.stream.downloads.delete(identifier, \*, account_id) -> str +- client.stream.downloads.get(identifier, \*, account_id) -> Optional[DownloadGetResponse] ## Embed @@ -4099,7 +4914,7 @@ from cloudflare.types.stream import TokenCreateResponse Methods: -- client.stream.token.create(identifier, \*, account_id, \*\*params) -> Optional +- client.stream.token.create(identifier, \*, account_id, \*\*params) -> Optional[TokenCreateResponse] # Alerting @@ -4113,7 +4928,7 @@ from cloudflare.types.alerting import AvailableAlertListResponse Methods: -- client.alerting.available_alerts.list(\*, account_id) -> Optional +- client.alerting.available_alerts.list(\*, account_id) -> Optional[AvailableAlertListResponse] ## Destinations @@ -4127,7 +4942,7 @@ from cloudflare.types.alerting.destinations import EligibleGetResponse Methods: -- client.alerting.destinations.eligible.get(\*, account_id) -> Optional +- client.alerting.destinations.eligible.get(\*, account_id) -> Optional[EligibleGetResponse] ### Pagerduty @@ -4138,17 +4953,16 @@ from cloudflare.types.alerting.destinations import ( Pagerduty, PagerdutyCreateResponse, PagerdutyDeleteResponse, - PagerdutyGetResponse, PagerdutyLinkResponse, ) ``` Methods: -- client.alerting.destinations.pagerduty.create(\*, account_id) -> Optional +- client.alerting.destinations.pagerduty.create(\*, account_id) -> Optional[PagerdutyCreateResponse] - client.alerting.destinations.pagerduty.delete(\*, account_id) -> PagerdutyDeleteResponse -- client.alerting.destinations.pagerduty.get(\*, account_id) -> Optional -- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> Optional +- client.alerting.destinations.pagerduty.get(\*, account_id) -> SyncSinglePage[Pagerduty] +- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> Optional[PagerdutyLinkResponse] ### Webhooks @@ -4165,11 +4979,11 @@ from cloudflare.types.alerting.destinations import ( Methods: -- client.alerting.destinations.webhooks.create(\*, account_id, \*\*params) -> Optional -- client.alerting.destinations.webhooks.update(webhook_id, \*, account_id, \*\*params) -> Optional +- client.alerting.destinations.webhooks.create(\*, account_id, \*\*params) -> Optional[WebhookCreateResponse] +- client.alerting.destinations.webhooks.update(webhook_id, \*, account_id, \*\*params) -> Optional[WebhookUpdateResponse] - client.alerting.destinations.webhooks.list(\*, account_id) -> SyncSinglePage[Webhooks] - client.alerting.destinations.webhooks.delete(webhook_id, \*, account_id) -> WebhookDeleteResponse -- client.alerting.destinations.webhooks.get(webhook_id, \*, account_id) -> Optional +- client.alerting.destinations.webhooks.get(webhook_id, \*, account_id) -> Optional[Webhooks] ## History @@ -4200,11 +5014,33 @@ from cloudflare.types.alerting import ( Methods: -- client.alerting.policies.create(\*, account_id, \*\*params) -> Optional -- client.alerting.policies.update(policy_id, \*, account_id, \*\*params) -> Optional +- client.alerting.policies.create(\*, account_id, \*\*params) -> Optional[PolicyCreateResponse] +- client.alerting.policies.update(policy_id, \*, account_id, \*\*params) -> Optional[PolicyUpdateResponse] - client.alerting.policies.list(\*, account_id) -> SyncSinglePage[Policy] - client.alerting.policies.delete(policy_id, \*, account_id) -> PolicyDeleteResponse -- client.alerting.policies.get(policy_id, \*, account_id) -> Optional +- client.alerting.policies.get(policy_id, \*, account_id) -> Optional[Policy] + +## Silences + +Types: + +```python +from cloudflare.types.alerting import ( + SilenceCreateResponse, + SilenceUpdateResponse, + SilenceListResponse, + SilenceDeleteResponse, + SilenceGetResponse, +) +``` + +Methods: + +- client.alerting.silences.create(\*, account_id, \*\*params) -> SilenceCreateResponse +- client.alerting.silences.update(\*, account_id, \*\*params) -> SyncSinglePage[SilenceUpdateResponse] +- client.alerting.silences.list(\*, account_id) -> SyncSinglePage[SilenceListResponse] +- client.alerting.silences.delete(silence_id, \*, account_id) -> SilenceDeleteResponse +- client.alerting.silences.get(silence_id, \*, account_id) -> Optional[SilenceGetResponse] # D1 @@ -4221,3131 +5057,6055 @@ Types: ```python from cloudflare.types.d1 import ( QueryResult, - DatabaseCreateResponse, DatabaseListResponse, - DatabaseDeleteResponse, - DatabaseQueryResponse, + DatabaseExportResponse, + DatabaseImportResponse, DatabaseRawResponse, ) ``` Methods: -- client.d1.database.create(\*, account_id, \*\*params) -> DatabaseCreateResponse -- client.d1.database.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DatabaseListResponse] -- client.d1.database.delete(database_id, \*, account_id) -> DatabaseDeleteResponse -- client.d1.database.get(database_id, \*, account_id) -> D1 -- client.d1.database.query(database_id, \*, account_id, \*\*params) -> DatabaseQueryResponse -- client.d1.database.raw(database_id, \*, account_id, \*\*params) -> DatabaseRawResponse - -# R2 +- client.d1.database.create(\*, account_id, \*\*params) -> D1 +- client.d1.database.update(database_id, \*, account_id, \*\*params) -> D1 +- client.d1.database.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DatabaseListResponse] +- client.d1.database.delete(database_id, \*, account_id) -> object +- client.d1.database.edit(database_id, \*, account_id, \*\*params) -> D1 +- client.d1.database.export(database_id, \*, account_id, \*\*params) -> DatabaseExportResponse +- client.d1.database.get(database_id, \*, account_id) -> D1 +- client.d1.database.import\_(database_id, \*, account_id, \*\*params) -> DatabaseImportResponse +- client.d1.database.query(database_id, \*, account_id, \*\*params) -> SyncSinglePage[QueryResult] +- client.d1.database.raw(database_id, \*, account_id, \*\*params) -> SyncSinglePage[DatabaseRawResponse] -## Buckets +### TimeTravel Types: ```python -from cloudflare.types.r2 import Bucket, BucketDeleteResponse +from cloudflare.types.d1.database import TimeTravelGetBookmarkResponse, TimeTravelRestoreResponse ``` Methods: -- client.r2.buckets.create(\*, account_id, \*\*params) -> Bucket -- client.r2.buckets.list(\*, account_id, \*\*params) -> SyncCursorPagination[Bucket] -- client.r2.buckets.delete(bucket_name, \*, account_id) -> object -- client.r2.buckets.get(bucket_name, \*, account_id) -> Bucket +- client.d1.database.time_travel.get_bookmark(database_id, \*, account_id, \*\*params) -> TimeTravelGetBookmarkResponse +- client.d1.database.time_travel.restore(database_id, \*, account_id, \*\*params) -> TimeTravelRestoreResponse -## Sippy +# R2 + +## Buckets Types: ```python -from cloudflare.types.r2 import Provider, Sippy, SippyDeleteResponse +from cloudflare.types.r2 import Bucket, BucketListResponse ``` Methods: -- client.r2.sippy.update(bucket_name, \*, account_id, \*\*params) -> Sippy -- client.r2.sippy.delete(bucket_name, \*, account_id) -> SippyDeleteResponse -- client.r2.sippy.get(bucket_name, \*, account_id) -> Sippy +- client.r2.buckets.create(\*, account_id, \*\*params) -> Bucket +- client.r2.buckets.list(\*, account_id, \*\*params) -> BucketListResponse +- client.r2.buckets.delete(bucket_name, \*, account_id) -> object +- client.r2.buckets.edit(bucket_name, \*, account_id) -> Bucket +- client.r2.buckets.get(bucket_name, \*, account_id) -> Bucket -## TemporaryCredentials +### Lifecycle Types: ```python -from cloudflare.types.r2 import TemporaryCredential, TemporaryCredentialCreateResponse +from cloudflare.types.r2.buckets import LifecycleGetResponse ``` Methods: -- client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse +- client.r2.buckets.lifecycle.update(bucket_name, \*, account_id, \*\*params) -> object +- client.r2.buckets.lifecycle.get(bucket_name, \*, account_id) -> LifecycleGetResponse -# WARPConnector +### CORS Types: ```python -from cloudflare.types.warp_connector import ( - WARPConnectorCreateResponse, - WARPConnectorListResponse, - WARPConnectorDeleteResponse, - WARPConnectorEditResponse, - WARPConnectorGetResponse, - WARPConnectorTokenResponse, -) +from cloudflare.types.r2.buckets import CORSGetResponse ``` Methods: -- client.warp_connector.create(\*, account_id, \*\*params) -> WARPConnectorCreateResponse -- client.warp_connector.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[WARPConnectorListResponse] -- client.warp_connector.delete(tunnel_id, \*, account_id) -> WARPConnectorDeleteResponse -- client.warp_connector.edit(tunnel_id, \*, account_id, \*\*params) -> WARPConnectorEditResponse -- client.warp_connector.get(tunnel_id, \*, account_id) -> WARPConnectorGetResponse -- client.warp_connector.token(tunnel_id, \*, account_id) -> WARPConnectorTokenResponse +- client.r2.buckets.cors.update(bucket_name, \*, account_id, \*\*params) -> object +- client.r2.buckets.cors.delete(bucket_name, \*, account_id) -> object +- client.r2.buckets.cors.get(bucket_name, \*, account_id) -> CORSGetResponse -# WorkersForPlatforms - -## Dispatch +### Domains -### Namespaces +#### Custom Types: ```python -from cloudflare.types.workers_for_platforms.dispatch import ( - NamespaceCreateResponse, - NamespaceListResponse, - NamespaceDeleteResponse, - NamespaceGetResponse, +from cloudflare.types.r2.buckets.domains import ( + CustomCreateResponse, + CustomUpdateResponse, + CustomListResponse, + CustomDeleteResponse, + CustomGetResponse, ) ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.create(\*, account_id, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.list(\*, account_id) -> SyncSinglePage[NamespaceListResponse] -- client.workers_for_platforms.dispatch.namespaces.delete(dispatch_namespace, \*, account_id) -> object -- client.workers_for_platforms.dispatch.namespaces.get(dispatch_namespace, \*, account_id) -> Optional +- client.r2.buckets.domains.custom.create(bucket_name, \*, account_id, \*\*params) -> CustomCreateResponse +- client.r2.buckets.domains.custom.update(domain, \*, account_id, bucket_name, \*\*params) -> CustomUpdateResponse +- client.r2.buckets.domains.custom.list(bucket_name, \*, account_id) -> CustomListResponse +- client.r2.buckets.domains.custom.delete(domain, \*, account_id, bucket_name) -> CustomDeleteResponse +- client.r2.buckets.domains.custom.get(domain, \*, account_id, bucket_name) -> CustomGetResponse -#### Scripts +#### Managed Types: ```python -from cloudflare.types.workers_for_platforms.dispatch.namespaces import Script +from cloudflare.types.r2.buckets.domains import ManagedUpdateResponse, ManagedListResponse ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.scripts.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.scripts.delete(script_name, \*, account_id, dispatch_namespace, \*\*params) -> None -- client.workers_for_platforms.dispatch.namespaces.scripts.get(script_name, \*, account_id, dispatch_namespace) -> Optional - -##### Content - -Methods: - -- client.workers_for_platforms.dispatch.namespaces.scripts.content.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.scripts.content.get(script_name, \*, account_id, dispatch_namespace) -> BinaryAPIResponse +- client.r2.buckets.domains.managed.update(bucket_name, \*, account_id, \*\*params) -> ManagedUpdateResponse +- client.r2.buckets.domains.managed.list(bucket_name, \*, account_id) -> ManagedListResponse -##### Settings +### EventNotifications Types: ```python -from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( - SettingEditResponse, - SettingGetResponse, -) +from cloudflare.types.r2.buckets import EventNotificationListResponse, EventNotificationGetResponse ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.scripts.settings.edit(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.scripts.settings.get(script_name, \*, account_id, dispatch_namespace) -> Optional +- client.r2.buckets.event_notifications.update(queue_id, \*, account_id, bucket_name, \*\*params) -> object +- client.r2.buckets.event_notifications.list(bucket_name, \*, account_id) -> EventNotificationListResponse +- client.r2.buckets.event_notifications.delete(queue_id, \*, account_id, bucket_name) -> object +- client.r2.buckets.event_notifications.get(queue_id, \*, account_id, bucket_name) -> EventNotificationGetResponse -##### Bindings +### Locks Types: ```python -from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import BindingGetResponse +from cloudflare.types.r2.buckets import LockGetResponse ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.scripts.bindings.get(script_name, \*, account_id, dispatch_namespace) -> Optional +- client.r2.buckets.locks.update(bucket_name, \*, account_id, \*\*params) -> object +- client.r2.buckets.locks.get(bucket_name, \*, account_id) -> LockGetResponse -##### Secrets +### Metrics Types: ```python -from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( - SecretUpdateResponse, - SecretListResponse, -) +from cloudflare.types.r2.buckets import MetricListResponse ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.list(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[SecretListResponse] +- client.r2.buckets.metrics.list(\*, account_id) -> MetricListResponse -##### Tags +### Sippy Types: ```python -from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( - TagUpdateResponse, - TagListResponse, - TagDeleteResponse, -) +from cloudflare.types.r2.buckets import Provider, Sippy, SippyDeleteResponse ``` Methods: -- client.workers_for_platforms.dispatch.namespaces.scripts.tags.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional -- client.workers_for_platforms.dispatch.namespaces.scripts.tags.list(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[TagListResponse] -- client.workers_for_platforms.dispatch.namespaces.scripts.tags.delete(tag, \*, account_id, dispatch_namespace, script_name) -> object - -# ZeroTrust +- client.r2.buckets.sippy.update(bucket_name, \*, account_id, \*\*params) -> Sippy +- client.r2.buckets.sippy.delete(bucket_name, \*, account_id) -> SippyDeleteResponse +- client.r2.buckets.sippy.get(bucket_name, \*, account_id) -> Sippy -## Devices +## TemporaryCredentials Types: ```python -from cloudflare.types.zero_trust import Device, DeviceGetResponse +from cloudflare.types.r2 import TemporaryCredential, TemporaryCredentialCreateResponse ``` Methods: -- client.zero_trust.devices.list(\*, account_id) -> SyncSinglePage[Device] -- client.zero_trust.devices.get(device_id, \*, account_id) -> DeviceGetResponse +- client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse -### DEXTests +## SuperSlurper + +### Jobs Types: ```python -from cloudflare.types.zero_trust.devices import ( - DEXTest, - SchemaData, - SchemaHTTP, - DEXTestDeleteResponse, +from cloudflare.types.r2.super_slurper import ( + JobCreateResponse, + JobListResponse, + JobAbortResponse, + JobAbortAllResponse, + JobGetResponse, + JobPauseResponse, + JobProgressResponse, + JobResumeResponse, ) ``` Methods: -- client.zero_trust.devices.dex_tests.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.dex_tests.update(dex_test_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.dex_tests.list(\*, account_id) -> SyncSinglePage[SchemaHTTP] -- client.zero_trust.devices.dex_tests.delete(dex_test_id, \*, account_id) -> Optional -- client.zero_trust.devices.dex_tests.get(dex_test_id, \*, account_id) -> Optional +- client.r2.super_slurper.jobs.create(\*, account_id, \*\*params) -> Optional[JobCreateResponse] +- client.r2.super_slurper.jobs.list(\*, account_id, \*\*params) -> SyncSinglePage[JobListResponse] +- client.r2.super_slurper.jobs.abort(job_id, \*, account_id) -> str +- client.r2.super_slurper.jobs.abort_all(\*, account_id) -> str +- client.r2.super_slurper.jobs.get(job_id, \*, account_id) -> Optional[JobGetResponse] +- client.r2.super_slurper.jobs.pause(job_id, \*, account_id) -> str +- client.r2.super_slurper.jobs.progress(job_id, \*, account_id) -> Optional[JobProgressResponse] +- client.r2.super_slurper.jobs.resume(job_id, \*, account_id) -> str -### Networks +#### Logs Types: ```python -from cloudflare.types.zero_trust.devices import DeviceNetwork, NetworkDeleteResponse +from cloudflare.types.r2.super_slurper.jobs import LogListResponse ``` Methods: -- client.zero_trust.devices.networks.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.networks.update(network_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.networks.list(\*, account_id) -> SyncSinglePage[DeviceNetwork] -- client.zero_trust.devices.networks.delete(network_id, \*, account_id) -> Optional -- client.zero_trust.devices.networks.get(network_id, \*, account_id) -> Optional +- client.r2.super_slurper.jobs.logs.list(job_id, \*, account_id, \*\*params) -> SyncSinglePage[LogListResponse] -### Policies +### ConnectivityPrecheck Types: ```python -from cloudflare.types.zero_trust.devices import SettingsPolicy, PolicyDeleteResponse +from cloudflare.types.r2.super_slurper import ( + ConnectivityPrecheckSourceResponse, + ConnectivityPrecheckTargetResponse, +) ``` Methods: -- client.zero_trust.devices.policies.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.list(\*, account_id) -> SyncSinglePage[SettingsPolicy] -- client.zero_trust.devices.policies.delete(policy_id, \*, account_id) -> Optional -- client.zero_trust.devices.policies.edit(policy_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.get(policy_id, \*, account_id) -> Optional +- client.r2.super_slurper.connectivity_precheck.source(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckSourceResponse] +- client.r2.super_slurper.connectivity_precheck.target(\*, account_id, \*\*params) -> Optional[ConnectivityPrecheckTargetResponse] -#### DefaultPolicy +# R2DataCatalog Types: ```python -from cloudflare.types.zero_trust.devices.policies import DefaultPolicyGetResponse +from cloudflare.types.r2_data_catalog import ( + R2DataCatalogListResponse, + R2DataCatalogEnableResponse, + R2DataCatalogGetResponse, +) ``` Methods: -- client.zero_trust.devices.policies.default_policy.get(\*, account_id) -> Optional +- client.r2_data_catalog.list(\*, account_id) -> Optional[R2DataCatalogListResponse] +- client.r2_data_catalog.disable(bucket_name, \*, account_id) -> None +- client.r2_data_catalog.enable(bucket_name, \*, account_id) -> Optional[R2DataCatalogEnableResponse] +- client.r2_data_catalog.get(bucket_name, \*, account_id) -> Optional[R2DataCatalogGetResponse] -#### Excludes +## MaintenanceConfigs Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - SplitTunnelExclude, - ExcludeUpdateResponse, - ExcludeGetResponse, +from cloudflare.types.r2_data_catalog import ( + MaintenanceConfigUpdateResponse, + MaintenanceConfigGetResponse, ) ``` Methods: -- client.zero_trust.devices.policies.excludes.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.excludes.list(\*, account_id) -> SyncSinglePage[SplitTunnelExclude] -- client.zero_trust.devices.policies.excludes.get(policy_id, \*, account_id) -> Optional +- client.r2_data_catalog.maintenance_configs.update(bucket_name, \*, account_id, \*\*params) -> Optional[MaintenanceConfigUpdateResponse] +- client.r2_data_catalog.maintenance_configs.get(bucket_name, \*, account_id) -> Optional[MaintenanceConfigGetResponse] + +## Credentials + +Methods: + +- client.r2_data_catalog.credentials.create(bucket_name, \*, account_id, \*\*params) -> object -#### FallbackDomains +## Namespaces Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - FallbackDomain, - FallbackDomainPolicy, - FallbackDomainUpdateResponse, - FallbackDomainGetResponse, -) +from cloudflare.types.r2_data_catalog import NamespaceListResponse ``` Methods: -- client.zero_trust.devices.policies.fallback_domains.update(policy_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.fallback_domains.list(\*, account_id) -> SyncSinglePage[FallbackDomain] -- client.zero_trust.devices.policies.fallback_domains.get(policy_id, \*, account_id) -> Optional +- client.r2_data_catalog.namespaces.list(bucket_name, \*, account_id, \*\*params) -> Optional[NamespaceListResponse] -#### Includes +### Tables Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - SplitTunnelInclude, - IncludeUpdateResponse, - IncludeGetResponse, -) +from cloudflare.types.r2_data_catalog.namespaces import TableListResponse ``` Methods: -- client.zero_trust.devices.policies.includes.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.includes.list(\*, account_id) -> SyncSinglePage[SplitTunnelInclude] -- client.zero_trust.devices.policies.includes.get(policy_id, \*, account_id) -> Optional +- client.r2_data_catalog.namespaces.tables.list(namespace, \*, account_id, bucket_name, \*\*params) -> Optional[TableListResponse] -### Posture +#### MaintenanceConfigs Types: ```python -from cloudflare.types.zero_trust.devices import ( - CarbonblackInput, - ClientCertificateInput, - CrowdstrikeInput, - DeviceInput, - DeviceMatch, - DevicePostureRule, - DiskEncryptionInput, - DomainJoinedInput, - FileInput, - FirewallInput, - IntuneInput, - KolideInput, - OSVersionInput, - SentineloneInput, - SentineloneS2sInput, - TaniumInput, - UniqueClientIDInput, - WorkspaceOneInput, - PostureDeleteResponse, +from cloudflare.types.r2_data_catalog.namespaces.tables import ( + MaintenanceConfigUpdateResponse, + MaintenanceConfigGetResponse, ) ``` Methods: -- client.zero_trust.devices.posture.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.posture.update(rule_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.posture.list(\*, account_id) -> SyncSinglePage[DevicePostureRule] -- client.zero_trust.devices.posture.delete(rule_id, \*, account_id) -> Optional -- client.zero_trust.devices.posture.get(rule_id, \*, account_id) -> Optional +- client.r2_data_catalog.namespaces.tables.maintenance_configs.update(table_name, \*, account_id, bucket_name, namespace, \*\*params) -> Optional[MaintenanceConfigUpdateResponse] +- client.r2_data_catalog.namespaces.tables.maintenance_configs.get(table_name, \*, account_id, bucket_name, namespace) -> Optional[MaintenanceConfigGetResponse] -#### Integrations +# WorkersForPlatforms + +## Dispatch + +### Namespaces Types: ```python -from cloudflare.types.zero_trust.devices.posture import Integration, IntegrationDeleteResponse +from cloudflare.types.workers_for_platforms.dispatch import ( + NamespaceCreateResponse, + NamespaceListResponse, + NamespaceGetResponse, +) +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.create(\*, account_id, \*\*params) -> Optional[NamespaceCreateResponse] +- client.workers_for_platforms.dispatch.namespaces.list(\*, account_id) -> SyncSinglePage[NamespaceListResponse] +- client.workers_for_platforms.dispatch.namespaces.delete(dispatch_namespace, \*, account_id) -> object +- client.workers_for_platforms.dispatch.namespaces.get(dispatch_namespace, \*, account_id) -> Optional[NamespaceGetResponse] + +#### Scripts + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces import Script, ScriptUpdateResponse +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> ScriptUpdateResponse +- client.workers_for_platforms.dispatch.namespaces.scripts.delete(script_name, \*, account_id, dispatch_namespace, \*\*params) -> object +- client.workers_for_platforms.dispatch.namespaces.scripts.get(script_name, \*, account_id, dispatch_namespace) -> Script + +##### AssetUpload + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( + AssetUploadCreateResponse, +) +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.asset_upload.create(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional[AssetUploadCreateResponse] + +##### Content + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.content.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Script +- client.workers_for_platforms.dispatch.namespaces.scripts.content.get(script_name, \*, account_id, dispatch_namespace) -> BinaryAPIResponse + +##### Settings + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( + SettingEditResponse, + SettingGetResponse, +) +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.settings.edit(script_name, \*, account_id, dispatch_namespace, \*\*params) -> Optional[SettingEditResponse] +- client.workers_for_platforms.dispatch.namespaces.scripts.settings.get(script_name, \*, account_id, dispatch_namespace) -> Optional[SettingGetResponse] + +##### Bindings + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import BindingGetResponse +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.bindings.get(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[BindingGetResponse] + +##### Secrets + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( + SecretUpdateResponse, + SecretListResponse, + SecretGetResponse, +) +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> SecretUpdateResponse +- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.list(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[SecretListResponse] +- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.delete(secret_name, \*, account_id, dispatch_namespace, script_name, \*\*params) -> object +- client.workers_for_platforms.dispatch.namespaces.scripts.secrets.get(secret_name, \*, account_id, dispatch_namespace, script_name, \*\*params) -> SecretGetResponse + +##### Tags + +Types: + +```python +from cloudflare.types.workers_for_platforms.dispatch.namespaces.scripts import ( + TagUpdateResponse, + TagListResponse, +) +``` + +Methods: + +- client.workers_for_platforms.dispatch.namespaces.scripts.tags.update(script_name, \*, account_id, dispatch_namespace, \*\*params) -> SyncSinglePage[TagUpdateResponse] +- client.workers_for_platforms.dispatch.namespaces.scripts.tags.list(script_name, \*, account_id, dispatch_namespace) -> SyncSinglePage[TagListResponse] +- client.workers_for_platforms.dispatch.namespaces.scripts.tags.delete(tag, \*, account_id, dispatch_namespace, script_name) -> object + +# ZeroTrust + +## Devices + +Types: + +```python +from cloudflare.types.zero_trust import Device, DeviceGetResponse +``` + +Methods: + +- client.zero_trust.devices.list(\*, account_id) -> SyncSinglePage[Device] +- client.zero_trust.devices.get(device_id, \*, account_id) -> Optional[DeviceGetResponse] + +### Devices + +Types: + +```python +from cloudflare.types.zero_trust.devices import DeviceListResponse, DeviceGetResponse +``` + +Methods: + +- client.zero*trust.devices.devices.list(\*, account_id, \*\*params) -> SyncCursorPagination[DeviceListResponse] +- client.zero*trust.devices.devices.delete(device_id, \*, account_id) -> object +- client.zero*trust.devices.devices.get(device_id, \*, account_id, \*\*params) -> DeviceGetResponse +- client.zero*trust.devices.devices.revoke(device_id, \*, account_id) -> object + +### Resilience + +#### GlobalWARPOverride + +Types: + +```python +from cloudflare.types.zero_trust.devices.resilience import ( + GlobalWARPOverrideCreateResponse, + GlobalWARPOverrideGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.resilience.global_warp_override.create(\*, account_id, \*\*params) -> Optional[GlobalWARPOverrideCreateResponse] +- client.zero_trust.devices.resilience.global_warp_override.get(\*, account_id) -> Optional[GlobalWARPOverrideGetResponse] + +### Registrations + +Types: + +```python +from cloudflare.types.zero_trust.devices import RegistrationListResponse, RegistrationGetResponse +``` + +Methods: + +- client.zero_trust.devices.registrations.list(\*, account_id, \*\*params) -> SyncCursorPagination[RegistrationListResponse] +- client.zero_trust.devices.registrations.delete(registration_id, \*, account_id) -> object +- client.zero_trust.devices.registrations.bulk_delete(\*, account_id, \*\*params) -> object +- client.zero_trust.devices.registrations.get(registration_id, \*, account_id, \*\*params) -> RegistrationGetResponse +- client.zero_trust.devices.registrations.revoke(\*, account_id, \*\*params) -> object +- client.zero_trust.devices.registrations.unrevoke(\*, account_id, \*\*params) -> object + +### DEXTests + +Types: + +```python +from cloudflare.types.zero_trust.devices import ( + SchemaData, + SchemaHTTP, + DEXTestCreateResponse, + DEXTestUpdateResponse, + DEXTestListResponse, + DEXTestDeleteResponse, + DEXTestGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.dex_tests.create(\*, account_id, \*\*params) -> Optional[DEXTestCreateResponse] +- client.zero_trust.devices.dex_tests.update(dex_test_id, \*, account_id, \*\*params) -> Optional[DEXTestUpdateResponse] +- client.zero_trust.devices.dex_tests.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DEXTestListResponse] +- client.zero_trust.devices.dex_tests.delete(dex_test_id, \*, account_id) -> Optional[DEXTestDeleteResponse] +- client.zero_trust.devices.dex_tests.get(dex_test_id, \*, account_id) -> Optional[DEXTestGetResponse] + +### Networks + +Types: + +```python +from cloudflare.types.zero_trust.devices import DeviceNetwork +``` + +Methods: + +- client.zero_trust.devices.networks.create(\*, account_id, \*\*params) -> Optional[DeviceNetwork] +- client.zero_trust.devices.networks.update(network_id, \*, account_id, \*\*params) -> Optional[DeviceNetwork] +- client.zero_trust.devices.networks.list(\*, account_id) -> SyncSinglePage[DeviceNetwork] +- client.zero_trust.devices.networks.delete(network_id, \*, account_id) -> SyncSinglePage[DeviceNetwork] +- client.zero_trust.devices.networks.get(network_id, \*, account_id) -> Optional[DeviceNetwork] + +### FleetStatus + +Types: + +```python +from cloudflare.types.zero_trust.devices import FleetStatusGetResponse +``` + +Methods: + +- client.zero_trust.devices.fleet_status.get(device_id, \*, account_id, \*\*params) -> FleetStatusGetResponse + +### Policies + +Types: + +```python +from cloudflare.types.zero_trust.devices import ( + DevicePolicyCertificates, + FallbackDomain, + FallbackDomainPolicy, + SettingsPolicy, + SplitTunnelExclude, + SplitTunnelInclude, +) +``` + +#### Default + +Types: + +```python +from cloudflare.types.zero_trust.devices.policies import DefaultEditResponse, DefaultGetResponse +``` + +Methods: + +- client.zero_trust.devices.policies.default.edit(\*, account_id, \*\*params) -> Optional[DefaultEditResponse] +- client.zero_trust.devices.policies.default.get(\*, account_id) -> Optional[DefaultGetResponse] + +##### Excludes + +Methods: + +- client.zero_trust.devices.policies.default.excludes.update(\*, account_id, \*\*params) -> SyncSinglePage[SplitTunnelExclude] +- client.zero_trust.devices.policies.default.excludes.get(\*, account_id) -> SyncSinglePage[SplitTunnelExclude] + +##### Includes + +Methods: + +- client.zero_trust.devices.policies.default.includes.update(\*, account_id, \*\*params) -> SyncSinglePage[SplitTunnelInclude] +- client.zero_trust.devices.policies.default.includes.get(\*, account_id) -> SyncSinglePage[SplitTunnelInclude] + +##### FallbackDomains + +Methods: + +- client.zero_trust.devices.policies.default.fallback_domains.update(\*, account_id, \*\*params) -> SyncSinglePage[FallbackDomain] +- client.zero_trust.devices.policies.default.fallback_domains.get(\*, account_id) -> SyncSinglePage[FallbackDomain] + +##### Certificates + +Methods: + +- client.zero_trust.devices.policies.default.certificates.edit(\*, zone_id, \*\*params) -> Optional[DevicePolicyCertificates] +- client.zero_trust.devices.policies.default.certificates.get(\*, zone_id) -> Optional[DevicePolicyCertificates] + +#### Custom + +Methods: + +- client.zero_trust.devices.policies.custom.create(\*, account_id, \*\*params) -> Optional[SettingsPolicy] +- client.zero_trust.devices.policies.custom.list(\*, account_id) -> SyncSinglePage[SettingsPolicy] +- client.zero_trust.devices.policies.custom.delete(policy_id, \*, account_id) -> SyncSinglePage[SettingsPolicy] +- client.zero_trust.devices.policies.custom.edit(policy_id, \*, account_id, \*\*params) -> Optional[SettingsPolicy] +- client.zero_trust.devices.policies.custom.get(policy_id, \*, account_id) -> Optional[SettingsPolicy] + +##### Excludes + +Methods: + +- client.zero_trust.devices.policies.custom.excludes.update(policy_id, \*, account_id, \*\*params) -> SyncSinglePage[SplitTunnelExclude] +- client.zero_trust.devices.policies.custom.excludes.get(policy_id, \*, account_id) -> SyncSinglePage[SplitTunnelExclude] + +##### Includes + +Methods: + +- client.zero_trust.devices.policies.custom.includes.update(policy_id, \*, account_id, \*\*params) -> SyncSinglePage[SplitTunnelInclude] +- client.zero_trust.devices.policies.custom.includes.get(policy_id, \*, account_id) -> SyncSinglePage[SplitTunnelInclude] + +##### FallbackDomains + +Methods: + +- client.zero_trust.devices.policies.custom.fallback_domains.update(policy_id, \*, account_id, \*\*params) -> SyncSinglePage[FallbackDomain] +- client.zero_trust.devices.policies.custom.fallback_domains.get(policy_id, \*, account_id) -> SyncSinglePage[FallbackDomain] + +### Posture + +Types: + +```python +from cloudflare.types.zero_trust.devices import ( + CarbonblackInput, + ClientCertificateInput, + CrowdstrikeInput, + DeviceInput, + DeviceMatch, + DevicePostureRule, + DiskEncryptionInput, + DomainJoinedInput, + FileInput, + FirewallInput, + IntuneInput, + KolideInput, + OSVersionInput, + SentineloneInput, + SentineloneS2sInput, + TaniumInput, + UniqueClientIDInput, + WorkspaceOneInput, + PostureDeleteResponse, +) +``` + +Methods: + +- client.zero_trust.devices.posture.create(\*, account_id, \*\*params) -> Optional[DevicePostureRule] +- client.zero_trust.devices.posture.update(rule_id, \*, account_id, \*\*params) -> Optional[DevicePostureRule] +- client.zero_trust.devices.posture.list(\*, account_id) -> SyncSinglePage[DevicePostureRule] +- client.zero_trust.devices.posture.delete(rule_id, \*, account_id) -> Optional[PostureDeleteResponse] +- client.zero_trust.devices.posture.get(rule_id, \*, account_id) -> Optional[DevicePostureRule] + +#### Integrations + +Types: + +```python +from cloudflare.types.zero_trust.devices.posture import Integration, IntegrationDeleteResponse +``` + +Methods: + +- client.zero_trust.devices.posture.integrations.create(\*, account_id, \*\*params) -> Optional[Integration] +- client.zero_trust.devices.posture.integrations.list(\*, account_id) -> SyncSinglePage[Integration] +- client.zero_trust.devices.posture.integrations.delete(integration_id, \*, account_id) -> Optional[IntegrationDeleteResponse] +- client.zero_trust.devices.posture.integrations.edit(integration_id, \*, account_id, \*\*params) -> Optional[Integration] +- client.zero_trust.devices.posture.integrations.get(integration_id, \*, account_id) -> Optional[Integration] + +### Revoke + +Types: + +```python +from cloudflare.types.zero_trust.devices import RevokeCreateResponse +``` + +Methods: + +- client.zero_trust.devices.revoke.create(\*, account_id, \*\*params) -> Optional[RevokeCreateResponse] + +### Settings + +Types: + +```python +from cloudflare.types.zero_trust.devices import DeviceSettings +``` + +Methods: + +- client.zero_trust.devices.settings.update(\*, account_id, \*\*params) -> Optional[DeviceSettings] +- client.zero_trust.devices.settings.delete(\*, account_id) -> Optional[DeviceSettings] +- client.zero_trust.devices.settings.edit(\*, account_id, \*\*params) -> Optional[DeviceSettings] +- client.zero_trust.devices.settings.get(\*, account_id) -> Optional[DeviceSettings] + +### Unrevoke + +Types: + +```python +from cloudflare.types.zero_trust.devices import UnrevokeCreateResponse +``` + +Methods: + +- client.zero_trust.devices.unrevoke.create(\*, account_id, \*\*params) -> Optional[UnrevokeCreateResponse] + +### OverrideCodes + +Types: + +```python +from cloudflare.types.zero_trust.devices import OverrideCodeGetResponse +``` + +Methods: + +- client.zero_trust.devices.override_codes.list(device_id, \*, account_id) -> SyncSinglePage[object] +- client.zero_trust.devices.override_codes.get(registration_id, \*, account_id) -> OverrideCodeGetResponse + +## IdentityProviders + +Types: + +```python +from cloudflare.types.zero_trust import ( + AzureAD, + GenericOAuthConfig, + IdentityProvider, + IdentityProviderSCIMConfig, + IdentityProviderType, + IdentityProviderListResponse, + IdentityProviderDeleteResponse, +) +``` + +Methods: + +- client.zero_trust.identity_providers.create(\*, account_id, zone_id, \*\*params) -> Optional[IdentityProvider] +- client.zero_trust.identity_providers.update(identity_provider_id, \*, account_id, zone_id, \*\*params) -> Optional[IdentityProvider] +- client.zero_trust.identity_providers.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[IdentityProviderListResponse] +- client.zero_trust.identity_providers.delete(identity_provider_id, \*, account_id, zone_id) -> Optional[IdentityProviderDeleteResponse] +- client.zero_trust.identity_providers.get(identity_provider_id, \*, account_id, zone_id) -> Optional[IdentityProvider] + +### SCIM + +#### Groups + +Methods: + +- client.zero_trust.identity_providers.scim.groups.list(identity_provider_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ZeroTrustGroup] + +#### Users + +Methods: + +- client.zero_trust.identity_providers.scim.users.list(identity_provider_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[AccessUser] + +## Organizations + +Types: + +```python +from cloudflare.types.zero_trust import LoginDesign, Organization, OrganizationRevokeUsersResponse +``` + +Methods: + +- client.zero_trust.organizations.create(\*, account_id, zone_id, \*\*params) -> Optional[Organization] +- client.zero_trust.organizations.update(\*, account_id, zone_id, \*\*params) -> Optional[Organization] +- client.zero_trust.organizations.list(\*, account_id, zone_id) -> Optional[Organization] +- client.zero_trust.organizations.revoke_users(\*, account_id, zone_id, \*\*params) -> Optional[OrganizationRevokeUsersResponse] + +### DOH + +Types: + +```python +from cloudflare.types.zero_trust.organizations import DOHUpdateResponse, DOHGetResponse +``` + +Methods: + +- client.zero_trust.organizations.doh.update(\*, account_id, \*\*params) -> Optional[DOHUpdateResponse] +- client.zero_trust.organizations.doh.get(\*, account_id) -> Optional[DOHGetResponse] + +## Seats + +Types: + +```python +from cloudflare.types.zero_trust import Seat +``` + +Methods: + +- client.zero_trust.seats.edit(\*, account_id, \*\*params) -> SyncSinglePage[Seat] + +## Access + +### AIControls + +#### Mcp + +##### Portals + +Types: + +```python +from cloudflare.types.zero_trust.access.ai_controls.mcp import ( + PortalCreateResponse, + PortalUpdateResponse, + PortalListResponse, + PortalDeleteResponse, + PortalReadResponse, +) +``` + +Methods: + +- client.zero_trust.access.ai_controls.mcp.portals.create(\*, account_id, \*\*params) -> PortalCreateResponse +- client.zero_trust.access.ai_controls.mcp.portals.update(id, \*, account_id, \*\*params) -> PortalUpdateResponse +- client.zero_trust.access.ai_controls.mcp.portals.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PortalListResponse] +- client.zero_trust.access.ai_controls.mcp.portals.delete(id, \*, account_id) -> PortalDeleteResponse +- client.zero_trust.access.ai_controls.mcp.portals.read(id, \*, account_id) -> PortalReadResponse + +##### Servers + +Types: + +```python +from cloudflare.types.zero_trust.access.ai_controls.mcp import ( + ServerCreateResponse, + ServerUpdateResponse, + ServerListResponse, + ServerDeleteResponse, + ServerReadResponse, +) +``` + +Methods: + +- client.zero_trust.access.ai_controls.mcp.servers.create(\*, account_id, \*\*params) -> ServerCreateResponse +- client.zero_trust.access.ai_controls.mcp.servers.update(id, \*, account_id, \*\*params) -> ServerUpdateResponse +- client.zero_trust.access.ai_controls.mcp.servers.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ServerListResponse] +- client.zero_trust.access.ai_controls.mcp.servers.delete(id, \*, account_id) -> ServerDeleteResponse +- client.zero_trust.access.ai_controls.mcp.servers.read(id, \*, account_id) -> ServerReadResponse +- client.zero_trust.access.ai_controls.mcp.servers.sync(id, \*, account_id) -> object + +### GatewayCA + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + GatewayCACreateResponse, + GatewayCAListResponse, + GatewayCADeleteResponse, +) +``` + +Methods: + +- client.zero_trust.access.gateway_ca.create(\*, account_id) -> Optional[GatewayCACreateResponse] +- client.zero_trust.access.gateway_ca.list(\*, account_id) -> SyncSinglePage[GatewayCAListResponse] +- client.zero_trust.access.gateway_ca.delete(certificate_id, \*, account_id) -> Optional[GatewayCADeleteResponse] + +### Infrastructure + +#### Targets + +Types: + +```python +from cloudflare.types.zero_trust.access.infrastructure import ( + TargetCreateResponse, + TargetUpdateResponse, + TargetListResponse, + TargetBulkUpdateResponse, + TargetGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.infrastructure.targets.create(\*, account_id, \*\*params) -> Optional[TargetCreateResponse] +- client.zero_trust.access.infrastructure.targets.update(target_id, \*, account_id, \*\*params) -> Optional[TargetUpdateResponse] +- client.zero_trust.access.infrastructure.targets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TargetListResponse] +- client.zero_trust.access.infrastructure.targets.delete(target_id, \*, account_id) -> None +- client.zero_trust.access.infrastructure.targets.bulk_delete(\*, account_id) -> None +- client.zero_trust.access.infrastructure.targets.bulk_delete_v2(\*, account_id, \*\*params) -> None +- client.zero_trust.access.infrastructure.targets.bulk_update(\*, account_id, \*\*params) -> SyncSinglePage[TargetBulkUpdateResponse] +- client.zero_trust.access.infrastructure.targets.get(target_id, \*, account_id) -> Optional[TargetGetResponse] + +### Applications + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + AllowedHeaders, + AllowedIdPs, + AllowedMethods, + AllowedOrigins, + AppID, + Application, + ApplicationPolicy, + ApplicationSCIMConfig, + ApplicationType, + CORSHeaders, + Decision, + OIDCSaaSApp, + SaaSAppNameIDFormat, + SAMLSaaSApp, + SCIMConfigAuthenticationHTTPBasic, + SCIMConfigAuthenticationOAuthBearerToken, + SCIMConfigAuthenticationOauth2, + SCIMConfigMapping, + SelfHostedDomains, + ApplicationCreateResponse, + ApplicationUpdateResponse, + ApplicationListResponse, + ApplicationDeleteResponse, + ApplicationGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.applications.create(\*, account_id, zone_id, \*\*params) -> Optional[ApplicationCreateResponse] +- client.zero_trust.access.applications.update(app_id, \*, account_id, zone_id, \*\*params) -> Optional[ApplicationUpdateResponse] +- client.zero_trust.access.applications.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[ApplicationListResponse] +- client.zero_trust.access.applications.delete(app_id, \*, account_id, zone_id) -> Optional[ApplicationDeleteResponse] +- client.zero_trust.access.applications.get(app_id, \*, account_id, zone_id) -> Optional[ApplicationGetResponse] +- client.zero_trust.access.applications.revoke_tokens(app_id, \*, account_id, zone_id) -> object + +#### CAs + +Types: + +```python +from cloudflare.types.zero_trust.access.applications import CA, CADeleteResponse +``` + +Methods: + +- client.zero_trust.access.applications.cas.create(app_id, \*, account_id, zone_id) -> Optional[CA] +- client.zero_trust.access.applications.cas.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[CA] +- client.zero_trust.access.applications.cas.delete(app_id, \*, account_id, zone_id) -> Optional[CADeleteResponse] +- client.zero_trust.access.applications.cas.get(app_id, \*, account_id, zone_id) -> Optional[CA] + +#### UserPolicyChecks + +Types: + +```python +from cloudflare.types.zero_trust.access.applications import ( + UserPolicyCheckGeo, + UserPolicyCheckListResponse, +) +``` + +Methods: + +- client.zero_trust.access.applications.user_policy_checks.list(app_id, \*, account_id, zone_id) -> Optional[UserPolicyCheckListResponse] + +#### Policies + +Types: + +```python +from cloudflare.types.zero_trust.access.applications import ( + AccessDevicePostureRule, + AccessRule, + AnyValidServiceTokenRule, + AuthenticationMethodRule, + AzureGroupRule, + CertificateRule, + CountryRule, + DomainRule, + EmailListRule, + EmailRule, + EveryoneRule, + ExternalEvaluationRule, + GitHubOrganizationRule, + GroupRule, + GSuiteGroupRule, + IPListRule, + IPRule, + OktaGroupRule, + SAMLGroupRule, + ServiceTokenRule, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyDeleteResponse, + PolicyGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.applications.policies.create(app_id, \*, account_id, zone_id, \*\*params) -> Optional[PolicyCreateResponse] +- client.zero_trust.access.applications.policies.update(policy_id, \*, app_id, account_id, zone_id, \*\*params) -> Optional[PolicyUpdateResponse] +- client.zero_trust.access.applications.policies.list(app_id, \*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[PolicyListResponse] +- client.zero_trust.access.applications.policies.delete(policy_id, \*, app_id, account_id, zone_id) -> Optional[PolicyDeleteResponse] +- client.zero_trust.access.applications.policies.get(policy_id, \*, app_id, account_id, zone_id) -> Optional[PolicyGetResponse] + +#### PolicyTests + +Types: + +```python +from cloudflare.types.zero_trust.access.applications import ( + PolicyTestCreateResponse, + PolicyTestGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.applications.policy_tests.create(\*, account_id, \*\*params) -> Optional[PolicyTestCreateResponse] +- client.zero_trust.access.applications.policy_tests.get(policy_test_id, \*, account_id) -> Optional[PolicyTestGetResponse] + +##### Users + +Types: + +```python +from cloudflare.types.zero_trust.access.applications.policy_tests import UserListResponse +``` + +Methods: + +- client.zero_trust.access.applications.policy_tests.users.list(policy_test_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[UserListResponse] + +#### Settings + +Types: + +```python +from cloudflare.types.zero_trust.access.applications import ( + SettingUpdateResponse, + SettingEditResponse, +) +``` + +Methods: + +- client.zero_trust.access.applications.settings.update(app_id, \*, account_id, zone_id, \*\*params) -> Optional[SettingUpdateResponse] +- client.zero_trust.access.applications.settings.edit(app_id, \*, account_id, zone_id, \*\*params) -> Optional[SettingEditResponse] + +### Certificates + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + AssociatedHostnames, + Certificate, + CertificateDeleteResponse, +) +``` + +Methods: + +- client.zero_trust.access.certificates.create(\*, account_id, zone_id, \*\*params) -> Optional[Certificate] +- client.zero_trust.access.certificates.update(certificate_id, \*, account_id, zone_id, \*\*params) -> Optional[Certificate] +- client.zero_trust.access.certificates.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[Certificate] +- client.zero_trust.access.certificates.delete(certificate_id, \*, account_id, zone_id) -> Optional[CertificateDeleteResponse] +- client.zero_trust.access.certificates.get(certificate_id, \*, account_id, zone_id) -> Optional[Certificate] + +#### Settings + +Types: + +```python +from cloudflare.types.zero_trust.access.certificates import CertificateSettings +``` + +Methods: + +- client.zero_trust.access.certificates.settings.update(\*, account_id, zone_id, \*\*params) -> SyncSinglePage[CertificateSettings] +- client.zero_trust.access.certificates.settings.get(\*, account_id, zone_id) -> SyncSinglePage[CertificateSettings] + +### Groups + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + ZeroTrustGroup, + GroupCreateResponse, + GroupUpdateResponse, + GroupListResponse, + GroupDeleteResponse, + GroupGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.groups.create(\*, account_id, zone_id, \*\*params) -> Optional[GroupCreateResponse] +- client.zero_trust.access.groups.update(group_id, \*, account_id, zone_id, \*\*params) -> Optional[GroupUpdateResponse] +- client.zero_trust.access.groups.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[GroupListResponse] +- client.zero_trust.access.groups.delete(group_id, \*, account_id, zone_id) -> Optional[GroupDeleteResponse] +- client.zero_trust.access.groups.get(group_id, \*, account_id, zone_id) -> Optional[GroupGetResponse] + +### ServiceTokens + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + ServiceToken, + ServiceTokenCreateResponse, + ServiceTokenRotateResponse, +) +``` + +Methods: + +- client.zero_trust.access.service_tokens.create(\*, account_id, zone_id, \*\*params) -> Optional[ServiceTokenCreateResponse] +- client.zero_trust.access.service_tokens.update(service_token_id, \*, account_id, zone_id, \*\*params) -> Optional[ServiceToken] +- client.zero_trust.access.service_tokens.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[ServiceToken] +- client.zero_trust.access.service_tokens.delete(service_token_id, \*, account_id, zone_id) -> Optional[ServiceToken] +- client.zero_trust.access.service_tokens.get(service_token_id, \*, account_id, zone_id) -> Optional[ServiceToken] +- client.zero_trust.access.service_tokens.refresh(service_token_id, \*, account_id) -> Optional[ServiceToken] +- client.zero_trust.access.service_tokens.rotate(service_token_id, \*, account_id, \*\*params) -> Optional[ServiceTokenRotateResponse] + +### Bookmarks + +Types: + +```python +from cloudflare.types.zero_trust.access import Bookmark, BookmarkDeleteResponse +``` + +Methods: + +- client.zero_trust.access.bookmarks.create(bookmark_id, \*, account_id, \*\*params) -> Optional[Bookmark] +- client.zero_trust.access.bookmarks.update(bookmark_id, \*, account_id, \*\*params) -> Optional[Bookmark] +- client.zero_trust.access.bookmarks.list(\*, account_id) -> SyncSinglePage[Bookmark] +- client.zero_trust.access.bookmarks.delete(bookmark_id, \*, account_id) -> Optional[BookmarkDeleteResponse] +- client.zero_trust.access.bookmarks.get(bookmark_id, \*, account_id) -> Optional[Bookmark] + +### Keys + +Types: + +```python +from cloudflare.types.zero_trust.access import KeyUpdateResponse, KeyGetResponse, KeyRotateResponse +``` + +Methods: + +- client.zero_trust.access.keys.update(\*, account_id, \*\*params) -> Optional[KeyUpdateResponse] +- client.zero_trust.access.keys.get(\*, account_id) -> Optional[KeyGetResponse] +- client.zero_trust.access.keys.rotate(\*, account_id) -> Optional[KeyRotateResponse] + +### Logs + +#### AccessRequests + +Types: + +```python +from cloudflare.types.zero_trust.access.logs import AccessRequestListResponse +``` + +Methods: + +- client.zero_trust.access.logs.access_requests.list(\*, account_id, \*\*params) -> Optional[AccessRequestListResponse] + +#### SCIM + +Types: + +```python +from cloudflare.types.zero_trust.access.logs import AccessRequest +``` + +##### Updates + +Types: + +```python +from cloudflare.types.zero_trust.access.logs.scim import UpdateListResponse +``` + +Methods: + +- client.zero_trust.access.logs.scim.updates.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[UpdateListResponse] + +### Users + +Types: + +```python +from cloudflare.types.zero_trust.access import AccessUser, UserListResponse +``` + +Methods: + +- client.zero_trust.access.users.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[UserListResponse] + +#### ActiveSessions + +Types: + +```python +from cloudflare.types.zero_trust.access.users import ( + ActiveSessionListResponse, + ActiveSessionGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.users.active_sessions.list(user_id, \*, account_id) -> SyncSinglePage[ActiveSessionListResponse] +- client.zero_trust.access.users.active_sessions.get(nonce, \*, account_id, user_id) -> Optional[ActiveSessionGetResponse] + +#### LastSeenIdentity + +Types: + +```python +from cloudflare.types.zero_trust.access.users import Identity +``` + +Methods: + +- client.zero_trust.access.users.last_seen_identity.get(user_id, \*, account_id) -> Optional[Identity] + +#### FailedLogins + +Types: + +```python +from cloudflare.types.zero_trust.access.users import FailedLoginListResponse +``` + +Methods: + +- client.zero_trust.access.users.failed_logins.list(user_id, \*, account_id) -> SyncSinglePage[FailedLoginListResponse] + +### CustomPages + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + CustomPage, + CustomPageWithoutHTML, + CustomPageDeleteResponse, +) +``` + +Methods: + +- client.zero_trust.access.custom_pages.create(\*, account_id, \*\*params) -> Optional[CustomPageWithoutHTML] +- client.zero_trust.access.custom_pages.update(custom_page_id, \*, account_id, \*\*params) -> Optional[CustomPageWithoutHTML] +- client.zero_trust.access.custom_pages.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[CustomPageWithoutHTML] +- client.zero_trust.access.custom_pages.delete(custom_page_id, \*, account_id) -> Optional[CustomPageDeleteResponse] +- client.zero_trust.access.custom_pages.get(custom_page_id, \*, account_id) -> Optional[CustomPage] + +### Tags + +Types: + +```python +from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse +``` + +Methods: + +- client.zero_trust.access.tags.create(\*, account_id, \*\*params) -> Optional[Tag] +- client.zero_trust.access.tags.update(tag_name, \*, account_id, \*\*params) -> Optional[Tag] +- client.zero_trust.access.tags.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Tag] +- client.zero_trust.access.tags.delete(tag_name, \*, account_id) -> Optional[TagDeleteResponse] +- client.zero_trust.access.tags.get(tag_name, \*, account_id) -> Optional[Tag] + +### Policies + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + ApprovalGroup, + Policy, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyDeleteResponse, + PolicyGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.policies.create(\*, account_id, \*\*params) -> Optional[PolicyCreateResponse] +- client.zero_trust.access.policies.update(policy_id, \*, account_id, \*\*params) -> Optional[PolicyUpdateResponse] +- client.zero_trust.access.policies.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PolicyListResponse] +- client.zero_trust.access.policies.delete(policy_id, \*, account_id) -> Optional[PolicyDeleteResponse] +- client.zero_trust.access.policies.get(policy_id, \*, account_id) -> Optional[PolicyGetResponse] + +## DEX + +Types: + +```python +from cloudflare.types.zero_trust import ( + DigitalExperienceMonitor, + NetworkPath, + NetworkPathResponse, + Percentiles, +) +``` + +### WARPChangeEvents + +Types: + +```python +from cloudflare.types.zero_trust.dex import WARPChangeEventGetResponse +``` + +Methods: + +- client.zero_trust.dex.warp_change_events.get(\*, account_id, \*\*params) -> Optional[WARPChangeEventGetResponse] + +### Commands + +Types: + +```python +from cloudflare.types.zero_trust.dex import CommandCreateResponse, CommandListResponse +``` + +Methods: + +- client.zero_trust.dex.commands.create(\*, account_id, \*\*params) -> Optional[CommandCreateResponse] +- client.zero_trust.dex.commands.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[CommandListResponse]] + +#### Devices + +Types: + +```python +from cloudflare.types.zero_trust.dex.commands import DeviceListResponse +``` + +Methods: + +- client.zero_trust.dex.commands.devices.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[DeviceListResponse]] + +#### Downloads + +Methods: + +- client.zero_trust.dex.commands.downloads.get(filename, \*, account_id, command_id) -> BinaryAPIResponse + +#### Quota + +Types: + +```python +from cloudflare.types.zero_trust.dex.commands import QuotaGetResponse +``` + +Methods: + +- client.zero_trust.dex.commands.quota.get(\*, account_id) -> Optional[QuotaGetResponse] + +### Colos + +Types: + +```python +from cloudflare.types.zero_trust.dex import ColoListResponse +``` + +Methods: + +- client.zero_trust.dex.colos.list(\*, account_id, \*\*params) -> SyncSinglePage[ColoListResponse] + +### FleetStatus + +Types: + +```python +from cloudflare.types.zero_trust.dex import ( + LiveStat, + FleetStatusLiveResponse, + FleetStatusOverTimeResponse, +) +``` + +Methods: + +- client.zero_trust.dex.fleet_status.live(\*, account_id, \*\*params) -> Optional[FleetStatusLiveResponse] +- client.zero_trust.dex.fleet_status.over_time(\*, account_id, \*\*params) -> Optional[FleetStatusOverTimeResponse] + +#### Devices + +Types: + +```python +from cloudflare.types.zero_trust.dex.fleet_status import DeviceListResponse +``` + +Methods: + +- client.zero_trust.dex.fleet_status.devices.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DeviceListResponse] + +### HTTPTests + +Types: + +```python +from cloudflare.types.zero_trust.dex import HTTPDetails +``` + +Methods: + +- client.zero_trust.dex.http_tests.get(test_id, \*, account_id, \*\*params) -> Optional[HTTPDetails] + +#### Percentiles + +Types: + +```python +from cloudflare.types.zero_trust.dex.http_tests import HTTPDetailsPercentiles, TestStatOverTime +``` + +Methods: + +- client.zero_trust.dex.http_tests.percentiles.get(test_id, \*, account_id, \*\*params) -> Optional[HTTPDetailsPercentiles] + +### Tests + +Types: + +```python +from cloudflare.types.zero_trust.dex import AggregateTimePeriod, Tests +``` + +Methods: + +- client.zero_trust.dex.tests.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[Tests]] + +#### UniqueDevices + +Types: + +```python +from cloudflare.types.zero_trust.dex.tests import UniqueDevices +``` + +Methods: + +- client.zero_trust.dex.tests.unique_devices.list(\*, account_id, \*\*params) -> Optional[UniqueDevices] + +### TracerouteTestResults + +#### NetworkPath + +Types: + +```python +from cloudflare.types.zero_trust.dex.traceroute_test_results import NetworkPathGetResponse +``` + +Methods: + +- client.zero_trust.dex.traceroute_test_results.network_path.get(test_result_id, \*, account_id) -> Optional[NetworkPathGetResponse] + +### TracerouteTests + +Types: + +```python +from cloudflare.types.zero_trust.dex import Traceroute, TracerouteTestPercentilesResponse +``` + +Methods: + +- client.zero_trust.dex.traceroute_tests.get(test_id, \*, account_id, \*\*params) -> Optional[Traceroute] +- client.zero_trust.dex.traceroute_tests.network_path(test_id, \*, account_id, \*\*params) -> Optional[NetworkPathResponse] +- client.zero_trust.dex.traceroute_tests.percentiles(test_id, \*, account_id, \*\*params) -> Optional[TracerouteTestPercentilesResponse] + +## Tunnels + +Types: + +```python +from cloudflare.types.zero_trust import Connection, TunnelListResponse +``` + +Methods: + +- client.zero_trust.tunnels.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TunnelListResponse] + +### Cloudflared + +Methods: + +- client.zero_trust.tunnels.cloudflared.create(\*, account_id, \*\*params) -> CloudflareTunnel +- client.zero_trust.tunnels.cloudflared.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[CloudflareTunnel] +- client.zero_trust.tunnels.cloudflared.delete(tunnel_id, \*, account_id) -> CloudflareTunnel +- client.zero_trust.tunnels.cloudflared.edit(tunnel_id, \*, account_id, \*\*params) -> CloudflareTunnel +- client.zero_trust.tunnels.cloudflared.get(tunnel_id, \*, account_id) -> CloudflareTunnel + +#### Configurations + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.cloudflared import ( + ConfigurationUpdateResponse, + ConfigurationGetResponse, +) +``` + +Methods: + +- client.zero_trust.tunnels.cloudflared.configurations.update(tunnel_id, \*, account_id, \*\*params) -> Optional[ConfigurationUpdateResponse] +- client.zero_trust.tunnels.cloudflared.configurations.get(tunnel_id, \*, account_id) -> Optional[ConfigurationGetResponse] + +#### Connections + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.cloudflared import Client +``` + +Methods: + +- client.zero_trust.tunnels.cloudflared.connections.delete(tunnel_id, \*, account_id, \*\*params) -> object +- client.zero_trust.tunnels.cloudflared.connections.get(tunnel_id, \*, account_id) -> SyncSinglePage[Client] + +#### Token + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.cloudflared import TokenGetResponse +``` + +Methods: + +- client.zero_trust.tunnels.cloudflared.token.get(tunnel_id, \*, account_id) -> str + +#### Connectors + +Methods: + +- client.zero_trust.tunnels.cloudflared.connectors.get(connector_id, \*, account_id, tunnel_id) -> Client + +#### Management + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.cloudflared import ManagementCreateResponse +``` + +Methods: + +- client.zero_trust.tunnels.cloudflared.management.create(tunnel_id, \*, account_id, \*\*params) -> str + +### WARPConnector + +Types: + +```python +from cloudflare.types.zero_trust.tunnels import ( + WARPConnectorCreateResponse, + WARPConnectorListResponse, + WARPConnectorDeleteResponse, + WARPConnectorEditResponse, + WARPConnectorGetResponse, +) +``` + +Methods: + +- client.zero_trust.tunnels.warp_connector.create(\*, account_id, \*\*params) -> WARPConnectorCreateResponse +- client.zero_trust.tunnels.warp_connector.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[WARPConnectorListResponse] +- client.zero_trust.tunnels.warp_connector.delete(tunnel_id, \*, account_id) -> WARPConnectorDeleteResponse +- client.zero_trust.tunnels.warp_connector.edit(tunnel_id, \*, account_id, \*\*params) -> WARPConnectorEditResponse +- client.zero_trust.tunnels.warp_connector.get(tunnel_id, \*, account_id) -> WARPConnectorGetResponse + +#### Token + +Types: + +```python +from cloudflare.types.zero_trust.tunnels.warp_connector import TokenGetResponse +``` + +Methods: + +- client.zero_trust.tunnels.warp_connector.token.get(tunnel_id, \*, account_id) -> str + +## ConnectivitySettings + +Types: + +```python +from cloudflare.types.zero_trust import ( + ConnectivitySettingEditResponse, + ConnectivitySettingGetResponse, +) +``` + +Methods: + +- client.zero_trust.connectivity_settings.edit(\*, account_id, \*\*params) -> ConnectivitySettingEditResponse +- client.zero_trust.connectivity_settings.get(\*, account_id) -> ConnectivitySettingGetResponse + +## DLP + +### Datasets + +Types: + +```python +from cloudflare.types.zero_trust.dlp import ( + Dataset, + DatasetArray, + DatasetCreation, + DatasetCreateResponse, + DatasetUpdateResponse, + DatasetGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.datasets.create(\*, account_id, \*\*params) -> Optional[DatasetCreateResponse] +- client.zero_trust.dlp.datasets.update(dataset_id, \*, account_id, \*\*params) -> Optional[DatasetUpdateResponse] +- client.zero_trust.dlp.datasets.list(\*, account_id) -> SyncSinglePage[Dataset] +- client.zero_trust.dlp.datasets.delete(dataset_id, \*, account_id) -> None +- client.zero_trust.dlp.datasets.get(dataset_id, \*, account_id) -> Optional[DatasetGetResponse] + +#### Upload + +Types: + +```python +from cloudflare.types.zero_trust.dlp.datasets import ( + NewVersion, + UploadCreateResponse, + UploadEditResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.datasets.upload.create(dataset_id, \*, account_id) -> Optional[UploadCreateResponse] +- client.zero_trust.dlp.datasets.upload.edit(version, dataset, \*, account_id, dataset_id, \*\*params) -> Optional[UploadEditResponse] + +#### Versions + +Types: + +```python +from cloudflare.types.zero_trust.dlp.datasets import VersionCreateResponse +``` + +Methods: + +- client.zero_trust.dlp.datasets.versions.create(version, \*, account_id, dataset_id, \*\*params) -> SyncSinglePage[VersionCreateResponse] + +##### Entries + +Types: + +```python +from cloudflare.types.zero_trust.dlp.datasets.versions import EntryCreateResponse +``` + +Methods: + +- client.zero_trust.dlp.datasets.versions.entries.create(entry_id, dataset_version_entry, \*, account_id, dataset_id, version, \*\*params) -> Optional[EntryCreateResponse] + +### Patterns + +Types: + +```python +from cloudflare.types.zero_trust.dlp import PatternValidateResponse +``` + +Methods: + +- client.zero_trust.dlp.patterns.validate(\*, account_id, \*\*params) -> Optional[PatternValidateResponse] + +### PayloadLogs + +Types: + +```python +from cloudflare.types.zero_trust.dlp import PayloadLogUpdateResponse, PayloadLogGetResponse +``` + +Methods: + +- client.zero_trust.dlp.payload_logs.update(\*, account_id, \*\*params) -> Optional[PayloadLogUpdateResponse] +- client.zero_trust.dlp.payload_logs.get(\*, account_id) -> Optional[PayloadLogGetResponse] + +### Email + +#### AccountMapping + +Types: + +```python +from cloudflare.types.zero_trust.dlp.email import ( + AccountMappingCreateResponse, + AccountMappingGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.email.account_mapping.create(\*, account_id, \*\*params) -> Optional[AccountMappingCreateResponse] +- client.zero_trust.dlp.email.account_mapping.get(\*, account_id) -> Optional[AccountMappingGetResponse] + +#### Rules + +Types: + +```python +from cloudflare.types.zero_trust.dlp.email import ( + RuleCreateResponse, + RuleUpdateResponse, + RuleListResponse, + RuleDeleteResponse, + RuleBulkEditResponse, + RuleGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.email.rules.create(\*, account_id, \*\*params) -> Optional[RuleCreateResponse] +- client.zero_trust.dlp.email.rules.update(rule_id, \*, account_id, \*\*params) -> Optional[RuleUpdateResponse] +- client.zero_trust.dlp.email.rules.list(\*, account_id) -> SyncSinglePage[RuleListResponse] +- client.zero_trust.dlp.email.rules.delete(rule_id, \*, account_id) -> Optional[RuleDeleteResponse] +- client.zero_trust.dlp.email.rules.bulk_edit(\*, account_id, \*\*params) -> Optional[RuleBulkEditResponse] +- client.zero_trust.dlp.email.rules.get(rule_id, \*, account_id) -> Optional[RuleGetResponse] + +### Profiles + +Types: + +```python +from cloudflare.types.zero_trust.dlp import ( + ContextAwareness, + Profile, + SkipConfiguration, + ProfileGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[Profile] +- client.zero_trust.dlp.profiles.get(profile_id, \*, account_id) -> Optional[ProfileGetResponse] + +#### Custom + +Types: + +```python +from cloudflare.types.zero_trust.dlp.profiles import ( + CustomProfile, + Pattern, + CustomCreateResponse, + CustomUpdateResponse, + CustomGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.profiles.custom.create(\*, account_id, \*\*params) -> Optional[CustomCreateResponse] +- client.zero_trust.dlp.profiles.custom.update(profile_id, \*, account_id, \*\*params) -> Optional[CustomUpdateResponse] +- client.zero_trust.dlp.profiles.custom.delete(profile_id, \*, account_id) -> object +- client.zero_trust.dlp.profiles.custom.get(profile_id, \*, account_id) -> Optional[CustomGetResponse] + +#### Predefined + +Types: + +```python +from cloudflare.types.zero_trust.dlp.profiles import ( + PredefinedProfile, + PredefinedUpdateResponse, + PredefinedGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.profiles.predefined.update(profile_id, \*, account_id, \*\*params) -> Optional[PredefinedUpdateResponse] +- client.zero_trust.dlp.profiles.predefined.delete(profile_id, \*, account_id) -> object +- client.zero_trust.dlp.profiles.predefined.get(profile_id, \*, account_id) -> Optional[PredefinedGetResponse] + +### Limits + +Types: + +```python +from cloudflare.types.zero_trust.dlp import LimitListResponse +``` + +Methods: + +- client.zero_trust.dlp.limits.list(\*, account_id) -> Optional[LimitListResponse] + +### Entries + +Types: + +```python +from cloudflare.types.zero_trust.dlp import ( + EntryCreateResponse, + EntryUpdateResponse, + EntryListResponse, + EntryGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.entries.create(\*, account_id, \*\*params) -> Optional[EntryCreateResponse] +- client.zero_trust.dlp.entries.update(entry_id, \*, account_id, \*\*params) -> Optional[EntryUpdateResponse] +- client.zero_trust.dlp.entries.list(\*, account_id) -> SyncSinglePage[EntryListResponse] +- client.zero_trust.dlp.entries.delete(entry_id, \*, account_id) -> object +- client.zero_trust.dlp.entries.get(entry_id, \*, account_id) -> Optional[EntryGetResponse] + +#### Custom + +Types: + +```python +from cloudflare.types.zero_trust.dlp.entries import ( + CustomCreateResponse, + CustomUpdateResponse, + CustomListResponse, + CustomGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.entries.custom.create(\*, account_id, \*\*params) -> Optional[CustomCreateResponse] +- client.zero_trust.dlp.entries.custom.update(entry_id, \*, account_id, \*\*params) -> Optional[CustomUpdateResponse] +- client.zero_trust.dlp.entries.custom.list(\*, account_id) -> SyncSinglePage[CustomListResponse] +- client.zero_trust.dlp.entries.custom.delete(entry_id, \*, account_id) -> object +- client.zero_trust.dlp.entries.custom.get(entry_id, \*, account_id) -> Optional[CustomGetResponse] + +#### Predefined + +Types: + +```python +from cloudflare.types.zero_trust.dlp.entries import ( + PredefinedCreateResponse, + PredefinedUpdateResponse, + PredefinedListResponse, + PredefinedGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.entries.predefined.create(\*, account_id, \*\*params) -> Optional[PredefinedCreateResponse] +- client.zero_trust.dlp.entries.predefined.update(entry_id, \*, account_id, \*\*params) -> Optional[PredefinedUpdateResponse] +- client.zero_trust.dlp.entries.predefined.list(\*, account_id) -> SyncSinglePage[PredefinedListResponse] +- client.zero_trust.dlp.entries.predefined.delete(entry_id, \*, account_id) -> object +- client.zero_trust.dlp.entries.predefined.get(entry_id, \*, account_id) -> Optional[PredefinedGetResponse] + +#### Integration + +Types: + +```python +from cloudflare.types.zero_trust.dlp.entries import ( + IntegrationCreateResponse, + IntegrationUpdateResponse, + IntegrationListResponse, + IntegrationGetResponse, +) +``` + +Methods: + +- client.zero_trust.dlp.entries.integration.create(\*, account_id, \*\*params) -> Optional[IntegrationCreateResponse] +- client.zero_trust.dlp.entries.integration.update(entry_id, \*, account_id, \*\*params) -> Optional[IntegrationUpdateResponse] +- client.zero_trust.dlp.entries.integration.list(\*, account_id) -> SyncSinglePage[IntegrationListResponse] +- client.zero_trust.dlp.entries.integration.delete(entry_id, \*, account_id) -> object +- client.zero_trust.dlp.entries.integration.get(entry_id, \*, account_id) -> Optional[IntegrationGetResponse] + +## Gateway + +Types: + +```python +from cloudflare.types.zero_trust import GatewayCreateResponse, GatewayListResponse +``` + +Methods: + +- client.zero_trust.gateway.create(\*, account_id) -> Optional[GatewayCreateResponse] +- client.zero_trust.gateway.list(\*, account_id) -> Optional[GatewayListResponse] + +### AuditSSHSettings + +Types: + +```python +from cloudflare.types.zero_trust.gateway import GatewaySettings +``` + +Methods: + +- client.zero_trust.gateway.audit_ssh_settings.update(\*, account_id, \*\*params) -> Optional[GatewaySettings] +- client.zero_trust.gateway.audit_ssh_settings.get(\*, account_id) -> Optional[GatewaySettings] +- client.zero_trust.gateway.audit_ssh_settings.rotate_seed(\*, account_id) -> Optional[GatewaySettings] + +### Categories + +Types: + +```python +from cloudflare.types.zero_trust.gateway import Category +``` + +Methods: + +- client.zero_trust.gateway.categories.list(\*, account_id) -> SyncSinglePage[Category] + +### AppTypes + +Types: + +```python +from cloudflare.types.zero_trust.gateway import AppType +``` + +Methods: + +- client.zero_trust.gateway.app_types.list(\*, account_id) -> SyncSinglePage[AppType] + +### Configurations + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + ActivityLogSettings, + AntiVirusSettings, + BlockPageSettings, + BodyScanningSettings, + BrowserIsolationSettings, + CustomCertificateSettings, + ExtendedEmailMatching, + FipsSettings, + GatewayConfigurationSettings, + NotificationSettings, + ProtocolDetection, + TLSSettings, + ConfigurationUpdateResponse, + ConfigurationEditResponse, + ConfigurationGetResponse, +) +``` + +Methods: + +- client.zero_trust.gateway.configurations.update(\*, account_id, \*\*params) -> Optional[ConfigurationUpdateResponse] +- client.zero_trust.gateway.configurations.edit(\*, account_id, \*\*params) -> Optional[ConfigurationEditResponse] +- client.zero_trust.gateway.configurations.get(\*, account_id) -> Optional[ConfigurationGetResponse] + +#### CustomCertificate + +Methods: + +- client.zero_trust.gateway.configurations.custom_certificate.get(\*, account_id) -> Optional[CustomCertificateSettings] + +### Lists + +Types: + +```python +from cloudflare.types.zero_trust.gateway import GatewayItem, GatewayList, ListCreateResponse +``` + +Methods: + +- client.zero_trust.gateway.lists.create(\*, account_id, \*\*params) -> Optional[ListCreateResponse] +- client.zero_trust.gateway.lists.update(list_id, \*, account_id, \*\*params) -> Optional[GatewayList] +- client.zero_trust.gateway.lists.list(\*, account_id, \*\*params) -> SyncSinglePage[GatewayList] +- client.zero_trust.gateway.lists.delete(list_id, \*, account_id) -> object +- client.zero_trust.gateway.lists.edit(list_id, \*, account_id, \*\*params) -> Optional[GatewayList] +- client.zero_trust.gateway.lists.get(list_id, \*, account_id) -> Optional[GatewayList] + +#### Items + +Types: + +```python +from cloudflare.types.zero_trust.gateway.lists import ItemListResponse +``` + +Methods: + +- client.zero_trust.gateway.lists.items.list(list_id, \*, account_id) -> SyncSinglePage[ItemListResponse] + +### Locations + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + DOHEndpoint, + DOTEndpoint, + Endpoint, + IPNetwork, + IPV4Endpoint, + IPV6Endpoint, + IPV6Network, + Location, +) +``` + +Methods: + +- client.zero_trust.gateway.locations.create(\*, account_id, \*\*params) -> Optional[Location] +- client.zero_trust.gateway.locations.update(location_id, \*, account_id, \*\*params) -> Optional[Location] +- client.zero_trust.gateway.locations.list(\*, account_id) -> SyncSinglePage[Location] +- client.zero_trust.gateway.locations.delete(location_id, \*, account_id) -> object +- client.zero_trust.gateway.locations.get(location_id, \*, account_id) -> Optional[Location] + +### Logging + +Types: + +```python +from cloudflare.types.zero_trust.gateway import LoggingSetting +``` + +Methods: + +- client.zero_trust.gateway.logging.update(\*, account_id, \*\*params) -> Optional[LoggingSetting] +- client.zero_trust.gateway.logging.get(\*, account_id) -> Optional[LoggingSetting] + +### ProxyEndpoints + +Types: + +```python +from cloudflare.types.zero_trust.gateway import GatewayIPs, ProxyEndpoint +``` + +Methods: + +- client.zero_trust.gateway.proxy_endpoints.create(\*, account_id, \*\*params) -> Optional[ProxyEndpoint] +- client.zero_trust.gateway.proxy_endpoints.list(\*, account_id) -> SyncSinglePage[ProxyEndpoint] +- client.zero_trust.gateway.proxy_endpoints.delete(proxy_endpoint_id, \*, account_id) -> object +- client.zero_trust.gateway.proxy_endpoints.edit(proxy_endpoint_id, \*, account_id, \*\*params) -> Optional[ProxyEndpoint] +- client.zero_trust.gateway.proxy_endpoints.get(proxy_endpoint_id, \*, account_id) -> Optional[ProxyEndpoint] + +### Rules + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + DNSResolverSettingsV4, + DNSResolverSettingsV6, + GatewayFilter, + GatewayRule, + RuleSetting, + Schedule, +) +``` + +Methods: + +- client.zero_trust.gateway.rules.create(\*, account_id, \*\*params) -> Optional[GatewayRule] +- client.zero_trust.gateway.rules.update(rule_id, \*, account_id, \*\*params) -> Optional[GatewayRule] +- client.zero_trust.gateway.rules.list(\*, account_id) -> SyncSinglePage[GatewayRule] +- client.zero_trust.gateway.rules.delete(rule_id, \*, account_id) -> object +- client.zero_trust.gateway.rules.get(rule_id, \*, account_id) -> Optional[GatewayRule] +- client.zero_trust.gateway.rules.list_tenant(\*, account_id) -> SyncSinglePage[GatewayRule] +- client.zero_trust.gateway.rules.reset_expiration(rule_id, \*, account_id) -> Optional[GatewayRule] + +### Certificates + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + CertificateCreateResponse, + CertificateListResponse, + CertificateDeleteResponse, + CertificateActivateResponse, + CertificateDeactivateResponse, + CertificateGetResponse, +) +``` + +Methods: + +- client.zero_trust.gateway.certificates.create(\*, account_id, \*\*params) -> Optional[CertificateCreateResponse] +- client.zero_trust.gateway.certificates.list(\*, account_id) -> SyncSinglePage[CertificateListResponse] +- client.zero_trust.gateway.certificates.delete(certificate_id, \*, account_id) -> Optional[CertificateDeleteResponse] +- client.zero_trust.gateway.certificates.activate(certificate_id, \*, account_id, \*\*params) -> Optional[CertificateActivateResponse] +- client.zero_trust.gateway.certificates.deactivate(certificate_id, \*, account_id, \*\*params) -> Optional[CertificateDeactivateResponse] +- client.zero_trust.gateway.certificates.get(certificate_id, \*, account_id) -> Optional[CertificateGetResponse] + +## Networks + +### Routes + +Types: + +```python +from cloudflare.types.zero_trust.networks import NetworkRoute, Route, Teamnet +``` + +Methods: + +- client.zero_trust.networks.routes.create(\*, account_id, \*\*params) -> Route +- client.zero_trust.networks.routes.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Teamnet] +- client.zero_trust.networks.routes.delete(route_id, \*, account_id) -> Route +- client.zero_trust.networks.routes.edit(route_id, \*, account_id, \*\*params) -> Route +- client.zero_trust.networks.routes.get(route_id, \*, account_id) -> Route + +#### IPs + +Methods: + +- client.zero_trust.networks.routes.ips.get(ip, \*, account_id, \*\*params) -> Teamnet + +#### Networks + +Methods: + +- client.zero_trust.networks.routes.networks.create(ip_network_encoded, \*, account_id, \*\*params) -> Route +- client.zero_trust.networks.routes.networks.delete(ip_network_encoded, \*, account_id, \*\*params) -> Route +- client.zero_trust.networks.routes.networks.edit(ip_network_encoded, \*, account_id) -> Route + +### VirtualNetworks + +Types: + +```python +from cloudflare.types.zero_trust.networks import VirtualNetwork +``` + +Methods: + +- client.zero_trust.networks.virtual_networks.create(\*, account_id, \*\*params) -> VirtualNetwork +- client.zero_trust.networks.virtual_networks.list(\*, account_id, \*\*params) -> SyncSinglePage[VirtualNetwork] +- client.zero_trust.networks.virtual_networks.delete(virtual_network_id, \*, account_id) -> VirtualNetwork +- client.zero_trust.networks.virtual_networks.edit(virtual_network_id, \*, account_id, \*\*params) -> VirtualNetwork +- client.zero_trust.networks.virtual_networks.get(virtual_network_id, \*, account_id) -> VirtualNetwork + +### Subnets + +Types: + +```python +from cloudflare.types.zero_trust.networks import SubnetListResponse +``` + +Methods: + +- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SubnetListResponse] + +#### CloudflareSource + +Types: + +```python +from cloudflare.types.zero_trust.networks.subnets import CloudflareSourceUpdateResponse +``` + +Methods: + +- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> CloudflareSourceUpdateResponse + +### HostnameRoutes + +Types: + +```python +from cloudflare.types.zero_trust.networks import HostnameRoute +``` + +Methods: + +- client.zero_trust.networks.hostname_routes.create(\*, account_id, \*\*params) -> HostnameRoute +- client.zero_trust.networks.hostname_routes.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[HostnameRoute] +- client.zero_trust.networks.hostname_routes.delete(hostname_route_id, \*, account_id) -> HostnameRoute +- client.zero_trust.networks.hostname_routes.edit(hostname_route_id, \*, account_id, \*\*params) -> HostnameRoute +- client.zero_trust.networks.hostname_routes.get(hostname_route_id, \*, account_id) -> HostnameRoute + +## RiskScoring + +Types: + +```python +from cloudflare.types.zero_trust import RiskScoringGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.get(user_id, \*, account_id) -> Optional[RiskScoringGetResponse] +- client.zero_trust.risk_scoring.reset(user_id, \*, account_id) -> object + +### Behaviours + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import BehaviourUpdateResponse, BehaviourGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.behaviours.update(\*, account_id, \*\*params) -> Optional[BehaviourUpdateResponse] +- client.zero_trust.risk_scoring.behaviours.get(\*, account_id) -> Optional[BehaviourGetResponse] + +### Summary + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import SummaryGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.summary.get(\*, account_id) -> Optional[SummaryGetResponse] + +### Integrations + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import ( + IntegrationCreateResponse, + IntegrationUpdateResponse, + IntegrationListResponse, + IntegrationGetResponse, +) +``` + +Methods: + +- client.zero_trust.risk_scoring.integrations.create(\*, account_id, \*\*params) -> Optional[IntegrationCreateResponse] +- client.zero_trust.risk_scoring.integrations.update(integration_id, \*, account_id, \*\*params) -> Optional[IntegrationUpdateResponse] +- client.zero_trust.risk_scoring.integrations.list(\*, account_id) -> SyncSinglePage[IntegrationListResponse] +- client.zero_trust.risk_scoring.integrations.delete(integration_id, \*, account_id) -> object +- client.zero_trust.risk_scoring.integrations.get(integration_id, \*, account_id) -> Optional[IntegrationGetResponse] + +#### References + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring.integrations import ReferenceGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.integrations.references.get(reference_id, \*, account_id) -> Optional[ReferenceGetResponse] + +# Turnstile + +## Widgets + +Types: + +```python +from cloudflare.types.turnstile import Widget, WidgetDomain, WidgetListResponse +``` + +Methods: + +- client.turnstile.widgets.create(\*, account_id, \*\*params) -> Optional[Widget] +- client.turnstile.widgets.update(sitekey, \*, account_id, \*\*params) -> Optional[Widget] +- client.turnstile.widgets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[WidgetListResponse] +- client.turnstile.widgets.delete(sitekey, \*, account_id) -> Optional[Widget] +- client.turnstile.widgets.get(sitekey, \*, account_id) -> Optional[Widget] +- client.turnstile.widgets.rotate_secret(sitekey, \*, account_id, \*\*params) -> Optional[Widget] + +# Connectivity + +## Directory + +### Services + +Types: + +```python +from cloudflare.types.connectivity.directory import ( + ServiceCreateResponse, + ServiceUpdateResponse, + ServiceListResponse, + ServiceGetResponse, +) +``` + +Methods: + +- client.connectivity.directory.services.create(\*, account_id, \*\*params) -> Optional[ServiceCreateResponse] +- client.connectivity.directory.services.update(service_id, \*, account_id, \*\*params) -> Optional[ServiceUpdateResponse] +- client.connectivity.directory.services.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ServiceListResponse] +- client.connectivity.directory.services.delete(service_id, \*, account_id) -> None +- client.connectivity.directory.services.get(service_id, \*, account_id) -> Optional[ServiceGetResponse] + +# Hyperdrive + +Types: + +```python +from cloudflare.types.hyperdrive import Configuration, Hyperdrive +``` + +## Configs + +Methods: + +- client.hyperdrive.configs.create(\*, account_id, \*\*params) -> Hyperdrive +- client.hyperdrive.configs.update(hyperdrive_id, \*, account_id, \*\*params) -> Hyperdrive +- client.hyperdrive.configs.list(\*, account_id) -> SyncSinglePage[Hyperdrive] +- client.hyperdrive.configs.delete(hyperdrive_id, \*, account_id) -> object +- client.hyperdrive.configs.edit(hyperdrive_id, \*, account_id, \*\*params) -> Hyperdrive +- client.hyperdrive.configs.get(hyperdrive_id, \*, account_id) -> Hyperdrive + +# RUM + +## SiteInfo + +Types: + +```python +from cloudflare.types.rum import Site, SiteInfoDeleteResponse +``` + +Methods: + +- client.rum.site_info.create(\*, account_id, \*\*params) -> Optional[Site] +- client.rum.site_info.update(site_id, \*, account_id, \*\*params) -> Optional[Site] +- client.rum.site_info.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Site] +- client.rum.site_info.delete(site_id, \*, account_id) -> Optional[SiteInfoDeleteResponse] +- client.rum.site_info.get(site_id, \*, account_id) -> Optional[Site] + +## Rules + +Types: + +```python +from cloudflare.types.rum import ( + RUMRule, + RuleListResponse, + RuleDeleteResponse, + RuleBulkCreateResponse, +) +``` + +Methods: + +- client.rum.rules.create(ruleset_id, \*, account_id, \*\*params) -> Optional[RUMRule] +- client.rum.rules.update(rule_id, \*, account_id, ruleset_id, \*\*params) -> Optional[RUMRule] +- client.rum.rules.list(ruleset_id, \*, account_id) -> Optional[RuleListResponse] +- client.rum.rules.delete(rule_id, \*, account_id, ruleset_id) -> Optional[RuleDeleteResponse] +- client.rum.rules.bulk_create(ruleset_id, \*, account_id, \*\*params) -> Optional[RuleBulkCreateResponse] + +# Vectorize + +## Indexes + +Types: + +```python +from cloudflare.types.vectorize import ( + CreateIndex, + IndexDeleteVectorsByID, + IndexDimensionConfiguration, + IndexInsert, + IndexQuery, + IndexUpsert, + IndexDeleteResponse, + IndexDeleteByIDsResponse, + IndexInfoResponse, + IndexInsertResponse, + IndexListVectorsResponse, + IndexQueryResponse, + IndexUpsertResponse, +) +``` + +Methods: + +- client.vectorize.indexes.create(\*, account_id, \*\*params) -> Optional[CreateIndex] +- client.vectorize.indexes.list(\*, account_id) -> SyncSinglePage[CreateIndex] +- client.vectorize.indexes.delete(index_name, \*, account_id) -> Optional[IndexDeleteResponse] +- client.vectorize.indexes.delete_by_ids(index_name, \*, account_id, \*\*params) -> Optional[IndexDeleteByIDsResponse] +- client.vectorize.indexes.get(index_name, \*, account_id) -> Optional[CreateIndex] +- client.vectorize.indexes.get_by_ids(index_name, \*, account_id, \*\*params) -> object +- client.vectorize.indexes.info(index_name, \*, account_id) -> Optional[IndexInfoResponse] +- client.vectorize.indexes.insert(index_name, \*, account_id, \*\*params) -> Optional[IndexInsertResponse] +- client.vectorize.indexes.list_vectors(index_name, \*, account_id, \*\*params) -> Optional[IndexListVectorsResponse] +- client.vectorize.indexes.query(index_name, \*, account_id, \*\*params) -> Optional[IndexQueryResponse] +- client.vectorize.indexes.upsert(index_name, \*, account_id, \*\*params) -> Optional[IndexUpsertResponse] + +### MetadataIndex + +Types: + +```python +from cloudflare.types.vectorize.indexes import ( + MetadataIndexCreateResponse, + MetadataIndexListResponse, + MetadataIndexDeleteResponse, +) +``` + +Methods: + +- client.vectorize.indexes.metadata_index.create(index_name, \*, account_id, \*\*params) -> Optional[MetadataIndexCreateResponse] +- client.vectorize.indexes.metadata_index.list(index_name, \*, account_id) -> Optional[MetadataIndexListResponse] +- client.vectorize.indexes.metadata_index.delete(index_name, \*, account_id, \*\*params) -> Optional[MetadataIndexDeleteResponse] + +# URLScanner + +Types: + +```python +from cloudflare.types.url_scanner import URLScannerDomain, URLScannerTask +``` + +## Responses + +Types: + +```python +from cloudflare.types.url_scanner import ResponseGetResponse +``` + +Methods: + +- client.url_scanner.responses.get(response_id, \*, account_id) -> str + +## Scans + +Types: + +```python +from cloudflare.types.url_scanner import ( + ScanCreateResponse, + ScanListResponse, + ScanBulkCreateResponse, + ScanDOMResponse, + ScanGetResponse, + ScanHARResponse, +) +``` + +Methods: + +- client.url_scanner.scans.create(\*, account_id, \*\*params) -> ScanCreateResponse +- client.url_scanner.scans.list(\*, account_id, \*\*params) -> ScanListResponse +- client.url_scanner.scans.bulk_create(\*, account_id, \*\*params) -> ScanBulkCreateResponse +- client.url_scanner.scans.dom(scan_id, \*, account_id) -> str +- client.url_scanner.scans.get(scan_id, \*, account_id) -> ScanGetResponse +- client.url_scanner.scans.har(scan_id, \*, account_id) -> ScanHARResponse +- client.url_scanner.scans.screenshot(scan_id, \*, account_id, \*\*params) -> BinaryAPIResponse + +# Radar + +## AI + +### ToMarkdown + +Types: + +```python +from cloudflare.types.radar.ai import ToMarkdownCreateResponse +``` + +Methods: + +- client.radar.ai.to_markdown.create(\*, account_id, \*\*params) -> SyncSinglePage[ToMarkdownCreateResponse] + +### Inference + +Types: + +```python +from cloudflare.types.radar.ai import ( + InferenceSummaryV2Response, + InferenceTimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.ai.inference.summary_v2(dimension, \*\*params) -> InferenceSummaryV2Response +- client.radar.ai.inference.timeseries_groups_v2(dimension, \*\*params) -> InferenceTimeseriesGroupsV2Response + +#### Summary + +Types: + +```python +from cloudflare.types.radar.ai.inference import SummaryModelResponse, SummaryTaskResponse +``` + +Methods: + +- client.radar.ai.inference.summary.model(\*\*params) -> SummaryModelResponse +- client.radar.ai.inference.summary.task(\*\*params) -> SummaryTaskResponse + +#### TimeseriesGroups + +##### Summary + +Types: + +```python +from cloudflare.types.radar.ai.inference.timeseries_groups import ( + SummaryModelResponse, + SummaryTaskResponse, +) +``` + +Methods: + +- client.radar.ai.inference.timeseries_groups.summary.model(\*\*params) -> SummaryModelResponse +- client.radar.ai.inference.timeseries_groups.summary.task(\*\*params) -> SummaryTaskResponse + +### Bots + +Types: + +```python +from cloudflare.types.radar.ai import ( + BotSummaryV2Response, + BotTimeseriesResponse, + BotTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.ai.bots.summary_v2(dimension, \*\*params) -> BotSummaryV2Response +- client.radar.ai.bots.timeseries(\*\*params) -> BotTimeseriesResponse +- client.radar.ai.bots.timeseries_groups(dimension, \*\*params) -> BotTimeseriesGroupsResponse + +#### Summary + +Types: + +```python +from cloudflare.types.radar.ai.bots import SummaryUserAgentResponse +``` + +Methods: + +- client.radar.ai.bots.summary.user_agent(\*\*params) -> SummaryUserAgentResponse + +### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.ai import ( + TimeseriesGroupSummaryResponse, + TimeseriesGroupTimeseriesResponse, + TimeseriesGroupTimeseriesGroupsResponse, + TimeseriesGroupUserAgentResponse, +) +``` + +Methods: + +- client.radar.ai.timeseries_groups.summary(dimension, \*\*params) -> TimeseriesGroupSummaryResponse +- client.radar.ai.timeseries_groups.timeseries(\*\*params) -> TimeseriesGroupTimeseriesResponse +- client.radar.ai.timeseries_groups.timeseries_groups(dimension, \*\*params) -> TimeseriesGroupTimeseriesGroupsResponse +- client.radar.ai.timeseries_groups.user_agent(\*\*params) -> TimeseriesGroupUserAgentResponse + +## CT + +Types: + +```python +from cloudflare.types.radar import ( + CTSummaryResponse, + CTTimeseriesResponse, + CTTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.ct.summary(dimension, \*\*params) -> CTSummaryResponse +- client.radar.ct.timeseries(\*\*params) -> CTTimeseriesResponse +- client.radar.ct.timeseries_groups(dimension, \*\*params) -> CTTimeseriesGroupsResponse + +### Authorities + +Types: + +```python +from cloudflare.types.radar.ct import AuthorityListResponse, AuthorityGetResponse +``` + +Methods: + +- client.radar.ct.authorities.list(\*\*params) -> AuthorityListResponse +- client.radar.ct.authorities.get(ca_slug, \*\*params) -> AuthorityGetResponse + +### Logs + +Types: + +```python +from cloudflare.types.radar.ct import LogListResponse, LogGetResponse +``` + +Methods: + +- client.radar.ct.logs.list(\*\*params) -> LogListResponse +- client.radar.ct.logs.get(log_slug, \*\*params) -> LogGetResponse + +## Annotations + +Types: + +```python +from cloudflare.types.radar import AnnotationListResponse +``` + +Methods: + +- client.radar.annotations.list(\*\*params) -> AnnotationListResponse + +### Outages + +Types: + +```python +from cloudflare.types.radar.annotations import OutageGetResponse, OutageLocationsResponse +``` + +Methods: + +- client.radar.annotations.outages.get(\*\*params) -> OutageGetResponse +- client.radar.annotations.outages.locations(\*\*params) -> OutageLocationsResponse + +## BGP + +Types: + +```python +from cloudflare.types.radar import BGPTimeseriesResponse +``` + +Methods: + +- client.radar.bgp.timeseries(\*\*params) -> BGPTimeseriesResponse + +### Leaks + +#### Events + +Types: + +```python +from cloudflare.types.radar.bgp.leaks import EventListResponse +``` + +Methods: + +- client.radar.bgp.leaks.events.list(\*\*params) -> SyncV4PagePagination[EventListResponse] + +### Top + +Types: + +```python +from cloudflare.types.radar.bgp import TopPrefixesResponse +``` + +Methods: + +- client.radar.bgp.top.prefixes(\*\*params) -> TopPrefixesResponse + +#### Ases + +Types: + +```python +from cloudflare.types.radar.bgp.top import AseGetResponse, AsePrefixesResponse +``` + +Methods: + +- client.radar.bgp.top.ases.get(\*\*params) -> AseGetResponse +- client.radar.bgp.top.ases.prefixes(\*\*params) -> AsePrefixesResponse + +### Hijacks + +#### Events + +Types: + +```python +from cloudflare.types.radar.bgp.hijacks import EventListResponse +``` + +Methods: + +- client.radar.bgp.hijacks.events.list(\*\*params) -> SyncV4PagePagination[EventListResponse] + +### Routes + +Types: + +```python +from cloudflare.types.radar.bgp import ( + RouteAsesResponse, + RouteMoasResponse, + RoutePfx2asResponse, + RouteRealtimeResponse, + RouteStatsResponse, +) +``` + +Methods: + +- client.radar.bgp.routes.ases(\*\*params) -> RouteAsesResponse +- client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse +- client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse +- client.radar.bgp.routes.realtime(\*\*params) -> RouteRealtimeResponse +- client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse + +### IPs + +Types: + +```python +from cloudflare.types.radar.bgp import IPTimeseriesResponse +``` + +Methods: + +- client.radar.bgp.ips.timeseries(\*\*params) -> IPTimeseriesResponse + +### RPKI + +#### ASPA + +Types: + +```python +from cloudflare.types.radar.bgp.rpki import ( + ASPAChangesResponse, + ASPASnapshotResponse, + ASPATimeseriesResponse, +) +``` + +Methods: + +- client.radar.bgp.rpki.aspa.changes(\*\*params) -> ASPAChangesResponse +- client.radar.bgp.rpki.aspa.snapshot(\*\*params) -> ASPASnapshotResponse +- client.radar.bgp.rpki.aspa.timeseries(\*\*params) -> ASPATimeseriesResponse + +## Bots + +Types: + +```python +from cloudflare.types.radar import ( + BotListResponse, + BotGetResponse, + BotSummaryResponse, + BotTimeseriesResponse, + BotTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.bots.list(\*\*params) -> BotListResponse +- client.radar.bots.get(bot_slug, \*\*params) -> BotGetResponse +- client.radar.bots.summary(dimension, \*\*params) -> BotSummaryResponse +- client.radar.bots.timeseries(\*\*params) -> BotTimeseriesResponse +- client.radar.bots.timeseries_groups(dimension, \*\*params) -> BotTimeseriesGroupsResponse + +### WebCrawlers + +Types: + +```python +from cloudflare.types.radar.bots import ( + WebCrawlerSummaryResponse, + WebCrawlerTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.bots.web_crawlers.summary(dimension, \*\*params) -> WebCrawlerSummaryResponse +- client.radar.bots.web_crawlers.timeseries_groups(dimension, \*\*params) -> WebCrawlerTimeseriesGroupsResponse + +## Datasets + +Types: + +```python +from cloudflare.types.radar import DatasetListResponse, DatasetDownloadResponse, DatasetGetResponse +``` + +Methods: + +- client.radar.datasets.list(\*\*params) -> DatasetListResponse +- client.radar.datasets.download(\*\*params) -> DatasetDownloadResponse +- client.radar.datasets.get(alias) -> str + +## DNS + +Types: + +```python +from cloudflare.types.radar import ( + DNSSummaryV2Response, + DNSTimeseriesResponse, + DNSTimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.dns.summary_v2(dimension, \*\*params) -> DNSSummaryV2Response +- client.radar.dns.timeseries(\*\*params) -> DNSTimeseriesResponse +- client.radar.dns.timeseries_groups_v2(dimension, \*\*params) -> DNSTimeseriesGroupsV2Response + +### Top + +Types: + +```python +from cloudflare.types.radar.dns import TopAsesResponse, TopLocationsResponse +``` + +Methods: + +- client.radar.dns.top.ases(\*\*params) -> TopAsesResponse +- client.radar.dns.top.locations(\*\*params) -> TopLocationsResponse + +### Summary + +Types: + +```python +from cloudflare.types.radar.dns import ( + SummaryCacheHitResponse, + SummaryDNSSECResponse, + SummaryDNSSECAwareResponse, + SummaryDNSSECE2EResponse, + SummaryIPVersionResponse, + SummaryMatchingAnswerResponse, + SummaryProtocolResponse, + SummaryQueryTypeResponse, + SummaryResponseCodeResponse, + SummaryResponseTTLResponse, +) +``` + +Methods: + +- client.radar.dns.summary.cache_hit(\*\*params) -> SummaryCacheHitResponse +- client.radar.dns.summary.dnssec(\*\*params) -> SummaryDNSSECResponse +- client.radar.dns.summary.dnssec_aware(\*\*params) -> SummaryDNSSECAwareResponse +- client.radar.dns.summary.dnssec_e2e(\*\*params) -> SummaryDNSSECE2EResponse +- client.radar.dns.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.dns.summary.matching_answer(\*\*params) -> SummaryMatchingAnswerResponse +- client.radar.dns.summary.protocol(\*\*params) -> SummaryProtocolResponse +- client.radar.dns.summary.query_type(\*\*params) -> SummaryQueryTypeResponse +- client.radar.dns.summary.response_code(\*\*params) -> SummaryResponseCodeResponse +- client.radar.dns.summary.response_ttl(\*\*params) -> SummaryResponseTTLResponse + +### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.dns import ( + TimeseriesGroupCacheHitResponse, + TimeseriesGroupDNSSECResponse, + TimeseriesGroupDNSSECAwareResponse, + TimeseriesGroupDNSSECE2EResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupMatchingAnswerResponse, + TimeseriesGroupProtocolResponse, + TimeseriesGroupQueryTypeResponse, + TimeseriesGroupResponseCodeResponse, + TimeseriesGroupResponseTTLResponse, +) +``` + +Methods: + +- client.radar.dns.timeseries_groups.cache_hit(\*\*params) -> TimeseriesGroupCacheHitResponse +- client.radar.dns.timeseries_groups.dnssec(\*\*params) -> TimeseriesGroupDNSSECResponse +- client.radar.dns.timeseries_groups.dnssec_aware(\*\*params) -> TimeseriesGroupDNSSECAwareResponse +- client.radar.dns.timeseries_groups.dnssec_e2e(\*\*params) -> TimeseriesGroupDNSSECE2EResponse +- client.radar.dns.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.dns.timeseries_groups.matching_answer(\*\*params) -> TimeseriesGroupMatchingAnswerResponse +- client.radar.dns.timeseries_groups.protocol(\*\*params) -> TimeseriesGroupProtocolResponse +- client.radar.dns.timeseries_groups.query_type(\*\*params) -> TimeseriesGroupQueryTypeResponse +- client.radar.dns.timeseries_groups.response_code(\*\*params) -> TimeseriesGroupResponseCodeResponse +- client.radar.dns.timeseries_groups.response_ttl(\*\*params) -> TimeseriesGroupResponseTTLResponse + +## NetFlows + +Types: + +```python +from cloudflare.types.radar import ( + NetFlowsSummaryResponse, + NetFlowsSummaryV2Response, + NetFlowsTimeseriesResponse, + NetFlowsTimeseriesGroupsResponse, +) +``` + +Methods: + +- client.radar.netflows.summary(\*\*params) -> NetFlowsSummaryResponse +- client.radar.netflows.summary_v2(dimension, \*\*params) -> NetFlowsSummaryV2Response +- client.radar.netflows.timeseries(\*\*params) -> NetFlowsTimeseriesResponse +- client.radar.netflows.timeseries_groups(dimension, \*\*params) -> NetFlowsTimeseriesGroupsResponse + +### Top + +Types: + +```python +from cloudflare.types.radar.netflows import TopAsesResponse, TopLocationsResponse +``` + +Methods: + +- client.radar.netflows.top.ases(\*\*params) -> TopAsesResponse +- client.radar.netflows.top.locations(\*\*params) -> TopLocationsResponse + +## Search + +Types: + +```python +from cloudflare.types.radar import SearchGlobalResponse +``` + +Methods: + +- client.radar.search.global\_(\*\*params) -> SearchGlobalResponse + +## VerifiedBots + +### Top + +Types: + +```python +from cloudflare.types.radar.verified_bots import TopBotsResponse, TopCategoriesResponse +``` + +Methods: + +- client.radar.verified_bots.top.bots(\*\*params) -> TopBotsResponse +- client.radar.verified_bots.top.categories(\*\*params) -> TopCategoriesResponse + +## AS112 + +Types: + +```python +from cloudflare.types.radar import ( + AS112SummaryV2Response, + AS112TimeseriesResponse, + AS112TimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.as112.summary_v2(dimension, \*\*params) -> AS112SummaryV2Response +- client.radar.as112.timeseries(\*\*params) -> AS112TimeseriesResponse +- client.radar.as112.timeseries_groups_v2(dimension, \*\*params) -> AS112TimeseriesGroupsV2Response + +### Summary + +Types: + +```python +from cloudflare.types.radar.as112 import ( + SummaryDNSSECResponse, + SummaryEdnsResponse, + SummaryIPVersionResponse, + SummaryProtocolResponse, + SummaryQueryTypeResponse, + SummaryResponseCodesResponse, +) +``` + +Methods: + +- client.radar.as112.summary.dnssec(\*\*params) -> SummaryDNSSECResponse +- client.radar.as112.summary.edns(\*\*params) -> SummaryEdnsResponse +- client.radar.as112.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.as112.summary.protocol(\*\*params) -> SummaryProtocolResponse +- client.radar.as112.summary.query_type(\*\*params) -> SummaryQueryTypeResponse +- client.radar.as112.summary.response_codes(\*\*params) -> SummaryResponseCodesResponse + +### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.as112 import ( + TimeseriesGroupDNSSECResponse, + TimeseriesGroupEdnsResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupProtocolResponse, + TimeseriesGroupQueryTypeResponse, + TimeseriesGroupResponseCodesResponse, +) ``` Methods: -- client.zero_trust.devices.posture.integrations.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.posture.integrations.list(\*, account_id) -> SyncSinglePage[Integration] -- client.zero_trust.devices.posture.integrations.delete(integration_id, \*, account_id) -> IntegrationDeleteResponse -- client.zero_trust.devices.posture.integrations.edit(integration_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.posture.integrations.get(integration_id, \*, account_id) -> Optional +- client.radar.as112.timeseries_groups.dnssec(\*\*params) -> TimeseriesGroupDNSSECResponse +- client.radar.as112.timeseries_groups.edns(\*\*params) -> TimeseriesGroupEdnsResponse +- client.radar.as112.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.as112.timeseries_groups.protocol(\*\*params) -> TimeseriesGroupProtocolResponse +- client.radar.as112.timeseries_groups.query_type(\*\*params) -> TimeseriesGroupQueryTypeResponse +- client.radar.as112.timeseries_groups.response_codes(\*\*params) -> TimeseriesGroupResponseCodesResponse -### Revoke +### Top Types: ```python -from cloudflare.types.zero_trust.devices import RevokeCreateResponse +from cloudflare.types.radar.as112 import ( + TopDNSSECResponse, + TopEdnsResponse, + TopIPVersionResponse, + TopLocationsResponse, +) ``` Methods: -- client.zero_trust.devices.revoke.create(\*, account_id, \*\*params) -> RevokeCreateResponse +- client.radar.as112.top.dnssec(dnssec, \*\*params) -> TopDNSSECResponse +- client.radar.as112.top.edns(edns, \*\*params) -> TopEdnsResponse +- client.radar.as112.top.ip_version(ip_version, \*\*params) -> TopIPVersionResponse +- client.radar.as112.top.locations(\*\*params) -> TopLocationsResponse -### Settings +## Email Types: ```python -from cloudflare.types.zero_trust.devices import DeviceSettings +from cloudflare.types.radar import RadarEmailSeries, RadarEmailSummary +``` + +### Routing + +Types: + +```python +from cloudflare.types.radar.email import RoutingSummaryV2Response, RoutingTimeseriesGroupsV2Response ``` Methods: -- client.zero_trust.devices.settings.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.settings.list(\*, account_id) -> Optional +- client.radar.email.routing.summary_v2(dimension, \*\*params) -> RoutingSummaryV2Response +- client.radar.email.routing.timeseries_groups_v2(dimension, \*\*params) -> RoutingTimeseriesGroupsV2Response -### Unrevoke +#### Summary Types: ```python -from cloudflare.types.zero_trust.devices import UnrevokeCreateResponse +from cloudflare.types.radar.email.routing import ( + SummaryARCResponse, + SummaryDKIMResponse, + SummaryDMARCResponse, + SummaryEncryptedResponse, + SummaryIPVersionResponse, + SummarySPFResponse, +) ``` Methods: -- client.zero_trust.devices.unrevoke.create(\*, account_id, \*\*params) -> UnrevokeCreateResponse +- client.radar.email.routing.summary.arc(\*\*params) -> SummaryARCResponse +- client.radar.email.routing.summary.dkim(\*\*params) -> SummaryDKIMResponse +- client.radar.email.routing.summary.dmarc(\*\*params) -> SummaryDMARCResponse +- client.radar.email.routing.summary.encrypted(\*\*params) -> SummaryEncryptedResponse +- client.radar.email.routing.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.email.routing.summary.spf(\*\*params) -> SummarySPFResponse -### OverrideCodes +#### TimeseriesGroups Types: ```python -from cloudflare.types.zero_trust.devices import OverrideCodeListResponse +from cloudflare.types.radar.email.routing import ( + TimeseriesGroupARCResponse, + TimeseriesGroupDKIMResponse, + TimeseriesGroupDMARCResponse, + TimeseriesGroupEncryptedResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupSPFResponse, +) ``` Methods: -- client.zero_trust.devices.override_codes.list(device_id, \*, account_id) -> Optional +- client.radar.email.routing.timeseries_groups.arc(\*\*params) -> TimeseriesGroupARCResponse +- client.radar.email.routing.timeseries_groups.dkim(\*\*params) -> TimeseriesGroupDKIMResponse +- client.radar.email.routing.timeseries_groups.dmarc(\*\*params) -> TimeseriesGroupDMARCResponse +- client.radar.email.routing.timeseries_groups.encrypted(\*\*params) -> TimeseriesGroupEncryptedResponse +- client.radar.email.routing.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.email.routing.timeseries_groups.spf(\*\*params) -> TimeseriesGroupSPFResponse -## IdentityProviders +### Security Types: ```python -from cloudflare.types.zero_trust import ( - AzureAD, - GenericOAuthConfig, - IdentityProvider, - IdentityProviderType, - SCIMConfig, - IdentityProviderListResponse, - IdentityProviderDeleteResponse, +from cloudflare.types.radar.email import ( + SecuritySummaryV2Response, + SecurityTimeseriesGroupsV2Response, ) ``` Methods: -- client.zero_trust.identity_providers.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.identity_providers.update(identity_provider_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.identity_providers.list(\*, account_id, zone_id) -> SyncSinglePage[IdentityProviderListResponse] -- client.zero_trust.identity_providers.delete(identity_provider_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.identity_providers.get(identity_provider_id, \*, account_id, zone_id) -> Optional +- client.radar.email.security.summary_v2(dimension, \*\*params) -> SecuritySummaryV2Response +- client.radar.email.security.timeseries_groups_v2(dimension, \*\*params) -> SecurityTimeseriesGroupsV2Response -## Organizations +#### Top + +##### TLDs Types: ```python -from cloudflare.types.zero_trust import LoginDesign, Organization, OrganizationRevokeUsersResponse +from cloudflare.types.radar.email.security.top import TLDGetResponse +``` + +Methods: + +- client.radar.email.security.top.tlds.get(\*\*params) -> TLDGetResponse + +###### Malicious + +Types: + +```python +from cloudflare.types.radar.email.security.top.tlds import MaliciousGetResponse +``` + +Methods: + +- client.radar.email.security.top.tlds.malicious.get(malicious, \*\*params) -> MaliciousGetResponse + +###### Spam + +Types: + +```python +from cloudflare.types.radar.email.security.top.tlds import SpamGetResponse +``` + +Methods: + +- client.radar.email.security.top.tlds.spam.get(spam, \*\*params) -> SpamGetResponse + +###### Spoof + +Types: + +```python +from cloudflare.types.radar.email.security.top.tlds import SpoofGetResponse +``` + +Methods: + +- client.radar.email.security.top.tlds.spoof.get(spoof, \*\*params) -> SpoofGetResponse + +#### Summary + +Types: + +```python +from cloudflare.types.radar.email.security import ( + SummaryARCResponse, + SummaryDKIMResponse, + SummaryDMARCResponse, + SummaryMaliciousResponse, + SummarySpamResponse, + SummarySPFResponse, + SummarySpoofResponse, + SummaryThreatCategoryResponse, + SummaryTLSVersionResponse, +) +``` + +Methods: + +- client.radar.email.security.summary.arc(\*\*params) -> SummaryARCResponse +- client.radar.email.security.summary.dkim(\*\*params) -> SummaryDKIMResponse +- client.radar.email.security.summary.dmarc(\*\*params) -> SummaryDMARCResponse +- client.radar.email.security.summary.malicious(\*\*params) -> SummaryMaliciousResponse +- client.radar.email.security.summary.spam(\*\*params) -> SummarySpamResponse +- client.radar.email.security.summary.spf(\*\*params) -> SummarySPFResponse +- client.radar.email.security.summary.spoof(\*\*params) -> SummarySpoofResponse +- client.radar.email.security.summary.threat_category(\*\*params) -> SummaryThreatCategoryResponse +- client.radar.email.security.summary.tls_version(\*\*params) -> SummaryTLSVersionResponse + +#### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.email.security import ( + TimeseriesGroupARCResponse, + TimeseriesGroupDKIMResponse, + TimeseriesGroupDMARCResponse, + TimeseriesGroupMaliciousResponse, + TimeseriesGroupSpamResponse, + TimeseriesGroupSPFResponse, + TimeseriesGroupSpoofResponse, + TimeseriesGroupThreatCategoryResponse, + TimeseriesGroupTLSVersionResponse, +) +``` + +Methods: + +- client.radar.email.security.timeseries_groups.arc(\*\*params) -> TimeseriesGroupARCResponse +- client.radar.email.security.timeseries_groups.dkim(\*\*params) -> TimeseriesGroupDKIMResponse +- client.radar.email.security.timeseries_groups.dmarc(\*\*params) -> TimeseriesGroupDMARCResponse +- client.radar.email.security.timeseries_groups.malicious(\*\*params) -> TimeseriesGroupMaliciousResponse +- client.radar.email.security.timeseries_groups.spam(\*\*params) -> TimeseriesGroupSpamResponse +- client.radar.email.security.timeseries_groups.spf(\*\*params) -> TimeseriesGroupSPFResponse +- client.radar.email.security.timeseries_groups.spoof(\*\*params) -> TimeseriesGroupSpoofResponse +- client.radar.email.security.timeseries_groups.threat_category(\*\*params) -> TimeseriesGroupThreatCategoryResponse +- client.radar.email.security.timeseries_groups.tls_version(\*\*params) -> TimeseriesGroupTLSVersionResponse + +## Attacks + +### Layer3 + +Types: + +```python +from cloudflare.types.radar.attacks import ( + Layer3SummaryV2Response, + Layer3TimeseriesResponse, + Layer3TimeseriesGroupsV2Response, +) +``` + +Methods: + +- client.radar.attacks.layer3.summary_v2(dimension, \*\*params) -> Layer3SummaryV2Response +- client.radar.attacks.layer3.timeseries(\*\*params) -> Layer3TimeseriesResponse +- client.radar.attacks.layer3.timeseries_groups_v2(dimension, \*\*params) -> Layer3TimeseriesGroupsV2Response + +#### Summary + +Types: + +```python +from cloudflare.types.radar.attacks.layer3 import ( + SummaryBitrateResponse, + SummaryDurationResponse, + SummaryIndustryResponse, + SummaryIPVersionResponse, + SummaryProtocolResponse, + SummaryVectorResponse, + SummaryVerticalResponse, +) +``` + +Methods: + +- client.radar.attacks.layer3.summary.bitrate(\*\*params) -> SummaryBitrateResponse +- client.radar.attacks.layer3.summary.duration(\*\*params) -> SummaryDurationResponse +- client.radar.attacks.layer3.summary.industry(\*\*params) -> SummaryIndustryResponse +- client.radar.attacks.layer3.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.attacks.layer3.summary.protocol(\*\*params) -> SummaryProtocolResponse +- client.radar.attacks.layer3.summary.vector(\*\*params) -> SummaryVectorResponse +- client.radar.attacks.layer3.summary.vertical(\*\*params) -> SummaryVerticalResponse + +#### TimeseriesGroups + +Types: + +```python +from cloudflare.types.radar.attacks.layer3 import ( + TimeseriesGroupBitrateResponse, + TimeseriesGroupDurationResponse, + TimeseriesGroupIndustryResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupProtocolResponse, + TimeseriesGroupVectorResponse, + TimeseriesGroupVerticalResponse, +) +``` + +Methods: + +- client.radar.attacks.layer3.timeseries_groups.bitrate(\*\*params) -> TimeseriesGroupBitrateResponse +- client.radar.attacks.layer3.timeseries_groups.duration(\*\*params) -> TimeseriesGroupDurationResponse +- client.radar.attacks.layer3.timeseries_groups.industry(\*\*params) -> TimeseriesGroupIndustryResponse +- client.radar.attacks.layer3.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.attacks.layer3.timeseries_groups.protocol(\*\*params) -> TimeseriesGroupProtocolResponse +- client.radar.attacks.layer3.timeseries_groups.vector(\*\*params) -> TimeseriesGroupVectorResponse +- client.radar.attacks.layer3.timeseries_groups.vertical(\*\*params) -> TimeseriesGroupVerticalResponse + +#### Top + +Types: + +```python +from cloudflare.types.radar.attacks.layer3 import ( + TopAttacksResponse, + TopIndustryResponse, + TopVerticalResponse, +) ``` Methods: -- client.zero_trust.organizations.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.organizations.update(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.organizations.list(\*, account_id, zone_id) -> Optional -- client.zero_trust.organizations.revoke_users(\*, account_id, zone_id, \*\*params) -> Optional +- client.radar.attacks.layer3.top.attacks(\*\*params) -> TopAttacksResponse +- client.radar.attacks.layer3.top.industry(\*\*params) -> TopIndustryResponse +- client.radar.attacks.layer3.top.vertical(\*\*params) -> TopVerticalResponse -## Seats +##### Locations Types: ```python -from cloudflare.types.zero_trust import Seat, SeatEditResponse +from cloudflare.types.radar.attacks.layer3.top import LocationOriginResponse, LocationTargetResponse ``` Methods: -- client.zero_trust.seats.edit(\*, account_id, \*\*params) -> Optional - -## Access - -Types: - -```python -from cloudflare.types.zero_trust import ( - AccessDevicePostureRule, - AccessRule, - AnyValidServiceTokenRule, - AuthenticationMethodRule, - AzureGroupRule, - CertificateRule, - CountryRule, - DomainRule, - EmailListRule, - EmailRule, - EveryoneRule, - ExternalEvaluationRule, - GitHubOrganizationRule, - GroupRule, - GSuiteGroupRule, - IPListRule, - IPRule, - OktaGroupRule, - SAMLGroupRule, - ServiceTokenRule, -) -``` +- client.radar.attacks.layer3.top.locations.origin(\*\*params) -> LocationOriginResponse +- client.radar.attacks.layer3.top.locations.target(\*\*params) -> LocationTargetResponse -### Applications +### Layer7 Types: ```python -from cloudflare.types.zero_trust.access import ( - AllowedHeaders, - AllowedIdPs, - AllowedMethods, - AllowedOrigins, - AppID, - Application, - ApplicationType, - CORSHeaders, - Decision, - SaaSAppNameFormat, - SaaSAppNameIDFormat, - SaaSAppSource, - SAMLSaaSApp, - SelfHostedDomains, - ApplicationCreateResponse, - ApplicationUpdateResponse, - ApplicationListResponse, - ApplicationDeleteResponse, - ApplicationGetResponse, - ApplicationRevokeTokensResponse, +from cloudflare.types.radar.attacks import ( + Layer7SummaryV2Response, + Layer7TimeseriesResponse, + Layer7TimeseriesGroupsV2Response, ) ``` Methods: -- client.zero_trust.access.applications.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.update(app_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.list(\*, account_id, zone_id) -> SyncSinglePage[ApplicationListResponse] -- client.zero_trust.access.applications.delete(app_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.get(app_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.revoke_tokens(app_id, \*, account_id, zone_id) -> object +- client.radar.attacks.layer7.summary_v2(dimension, \*\*params) -> Layer7SummaryV2Response +- client.radar.attacks.layer7.timeseries(\*\*params) -> Layer7TimeseriesResponse +- client.radar.attacks.layer7.timeseries_groups_v2(dimension, \*\*params) -> Layer7TimeseriesGroupsV2Response -#### CAs +#### Summary Types: ```python -from cloudflare.types.zero_trust.access.applications import ( - CA, - CACreateResponse, - CADeleteResponse, - CAGetResponse, +from cloudflare.types.radar.attacks.layer7 import ( + SummaryHTTPMethodResponse, + SummaryHTTPVersionResponse, + SummaryIndustryResponse, + SummaryIPVersionResponse, + SummaryManagedRulesResponse, + SummaryMitigationProductResponse, + SummaryVerticalResponse, ) ``` Methods: -- client.zero_trust.access.applications.cas.create(app_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.cas.list(\*, account_id, zone_id) -> SyncSinglePage[CA] -- client.zero_trust.access.applications.cas.delete(app_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.cas.get(app_id, \*, account_id, zone_id) -> Optional +- client.radar.attacks.layer7.summary.http_method(\*\*params) -> SummaryHTTPMethodResponse +- client.radar.attacks.layer7.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse +- client.radar.attacks.layer7.summary.industry(\*\*params) -> SummaryIndustryResponse +- client.radar.attacks.layer7.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.attacks.layer7.summary.managed_rules(\*\*params) -> SummaryManagedRulesResponse +- client.radar.attacks.layer7.summary.mitigation_product(\*\*params) -> SummaryMitigationProductResponse +- client.radar.attacks.layer7.summary.vertical(\*\*params) -> SummaryVerticalResponse -#### UserPolicyChecks +#### TimeseriesGroups Types: ```python -from cloudflare.types.zero_trust.access.applications import ( - UserPolicyCheckGeo, - UserPolicyCheckListResponse, +from cloudflare.types.radar.attacks.layer7 import ( + TimeseriesGroupHTTPMethodResponse, + TimeseriesGroupHTTPVersionResponse, + TimeseriesGroupIndustryResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupManagedRulesResponse, + TimeseriesGroupMitigationProductResponse, + TimeseriesGroupVerticalResponse, ) ``` Methods: -- client.zero_trust.access.applications.user_policy_checks.list(app_id, \*, account_id, zone_id) -> Optional +- client.radar.attacks.layer7.timeseries_groups.http_method(\*\*params) -> TimeseriesGroupHTTPMethodResponse +- client.radar.attacks.layer7.timeseries_groups.http_version(\*\*params) -> TimeseriesGroupHTTPVersionResponse +- client.radar.attacks.layer7.timeseries_groups.industry(\*\*params) -> TimeseriesGroupIndustryResponse +- client.radar.attacks.layer7.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.attacks.layer7.timeseries_groups.managed_rules(\*\*params) -> TimeseriesGroupManagedRulesResponse +- client.radar.attacks.layer7.timeseries_groups.mitigation_product(\*\*params) -> TimeseriesGroupMitigationProductResponse +- client.radar.attacks.layer7.timeseries_groups.vertical(\*\*params) -> TimeseriesGroupVerticalResponse -#### Policies +#### Top Types: ```python -from cloudflare.types.zero_trust.access.applications import ( - ApprovalGroup, - Policy, - PolicyCreateResponse, - PolicyUpdateResponse, - PolicyListResponse, - PolicyDeleteResponse, - PolicyGetResponse, +from cloudflare.types.radar.attacks.layer7 import ( + TopAttacksResponse, + TopIndustryResponse, + TopVerticalResponse, ) ``` Methods: -- client.zero_trust.access.applications.policies.create(app_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.update(policy_id, \*, app_id, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.list(app_id, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] -- client.zero_trust.access.applications.policies.delete(policy_id, \*, app_id, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.policies.get(policy_id, \*, app_id, account_id, zone_id) -> Optional +- client.radar.attacks.layer7.top.attacks(\*\*params) -> TopAttacksResponse +- client.radar.attacks.layer7.top.industry(\*\*params) -> TopIndustryResponse +- client.radar.attacks.layer7.top.vertical(\*\*params) -> TopVerticalResponse -### Certificates +##### Locations Types: ```python -from cloudflare.types.zero_trust.access import ( - AssociatedHostnames, - Certificate, - CertificateDeleteResponse, -) +from cloudflare.types.radar.attacks.layer7.top import LocationOriginResponse, LocationTargetResponse ``` Methods: -- client.zero_trust.access.certificates.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.certificates.update(certificate_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.certificates.list(\*, account_id, zone_id) -> SyncSinglePage[Certificate] -- client.zero_trust.access.certificates.delete(certificate_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.certificates.get(certificate_id, \*, account_id, zone_id) -> Optional +- client.radar.attacks.layer7.top.locations.origin(\*\*params) -> LocationOriginResponse +- client.radar.attacks.layer7.top.locations.target(\*\*params) -> LocationTargetResponse -#### Settings +##### Ases Types: ```python -from cloudflare.types.zero_trust.access.certificates import ( - CertificateSettings, - SettingUpdateResponse, - SettingGetResponse, -) +from cloudflare.types.radar.attacks.layer7.top import AseOriginResponse ``` Methods: -- client.zero_trust.access.certificates.settings.update(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.certificates.settings.get(\*, account_id, zone_id) -> Optional +- client.radar.attacks.layer7.top.ases.origin(\*\*params) -> AseOriginResponse -### Groups +## Entities Types: ```python -from cloudflare.types.zero_trust.access import ZeroTrustGroup, GroupDeleteResponse +from cloudflare.types.radar import EntityGetResponse ``` Methods: -- client.zero_trust.access.groups.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.groups.update(group_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.groups.list(\*, account_id, zone_id) -> SyncSinglePage[ZeroTrustGroup] -- client.zero_trust.access.groups.delete(group_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.groups.get(group_id, \*, account_id, zone_id) -> Optional +- client.radar.entities.get(\*\*params) -> EntityGetResponse -### ServiceTokens +### ASNs Types: ```python -from cloudflare.types.zero_trust.access import ( - ServiceToken, - ServiceTokenCreateResponse, - ServiceTokenRotateResponse, +from cloudflare.types.radar.entities import ( + ASNListResponse, + ASNAsSetResponse, + ASNGetResponse, + ASNIPResponse, + ASNRelResponse, ) ``` Methods: -- client.zero_trust.access.service_tokens.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.service_tokens.update(service_token_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.service_tokens.list(\*, account_id, zone_id) -> SyncSinglePage[ServiceToken] -- client.zero_trust.access.service_tokens.delete(service_token_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.service_tokens.get(service_token_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.service_tokens.refresh(service_token_id, \*, account_id) -> Optional -- client.zero_trust.access.service_tokens.rotate(service_token_id, \*, account_id) -> Optional +- client.radar.entities.asns.list(\*\*params) -> ASNListResponse +- client.radar.entities.asns.as_set(asn, \*\*params) -> ASNAsSetResponse +- client.radar.entities.asns.get(asn, \*\*params) -> ASNGetResponse +- client.radar.entities.asns.ip(\*\*params) -> ASNIPResponse +- client.radar.entities.asns.rel(asn, \*\*params) -> ASNRelResponse -### Bookmarks +### Locations Types: ```python -from cloudflare.types.zero_trust.access import Bookmark, BookmarkDeleteResponse +from cloudflare.types.radar.entities import LocationListResponse, LocationGetResponse ``` Methods: -- client.zero_trust.access.bookmarks.create(bookmark_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.access.bookmarks.update(bookmark_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.access.bookmarks.list(\*, account_id) -> SyncSinglePage[Bookmark] -- client.zero_trust.access.bookmarks.delete(bookmark_id, \*, account_id) -> Optional -- client.zero_trust.access.bookmarks.get(bookmark_id, \*, account_id) -> Optional +- client.radar.entities.locations.list(\*\*params) -> LocationListResponse +- client.radar.entities.locations.get(location, \*\*params) -> LocationGetResponse -### Keys +## Geolocations Types: ```python -from cloudflare.types.zero_trust.access import KeyUpdateResponse, KeyGetResponse, KeyRotateResponse +from cloudflare.types.radar import GeolocationListResponse, GeolocationGetResponse ``` Methods: -- client.zero_trust.access.keys.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.access.keys.get(\*, account_id) -> Optional -- client.zero_trust.access.keys.rotate(\*, account_id) -> Optional - -### Logs +- client.radar.geolocations.list(\*\*params) -> GeolocationListResponse +- client.radar.geolocations.get(geo_id, \*\*params) -> GeolocationGetResponse -#### AccessRequests +## HTTP Types: ```python -from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessRequestListResponse +from cloudflare.types.radar import ( + HTTPSummaryV2Response, + HTTPTimeseriesResponse, + HTTPTimeseriesGroupsV2Response, +) ``` Methods: -- client.zero_trust.access.logs.access_requests.list(\*, account_id, \*\*params) -> Optional +- client.radar.http.summary_v2(dimension, \*\*params) -> HTTPSummaryV2Response +- client.radar.http.timeseries(\*\*params) -> HTTPTimeseriesResponse +- client.radar.http.timeseries_groups_v2(dimension, \*\*params) -> HTTPTimeseriesGroupsV2Response -### Users +### Locations Types: ```python -from cloudflare.types.zero_trust.access import AccessUser +from cloudflare.types.radar.http import LocationGetResponse ``` Methods: -- client.zero_trust.access.users.list(\*, account_id) -> SyncSinglePage[AccessUser] +- client.radar.http.locations.get(\*\*params) -> LocationGetResponse -#### ActiveSessions +#### BotClass Types: ```python -from cloudflare.types.zero_trust.access.users import ( - ActiveSessionListResponse, - ActiveSessionGetResponse, -) +from cloudflare.types.radar.http.locations import BotClassGetResponse ``` Methods: -- client.zero_trust.access.users.active_sessions.list(user_id, \*, account_id) -> SyncSinglePage[ActiveSessionListResponse] -- client.zero_trust.access.users.active_sessions.get(nonce, \*, account_id, user_id) -> Optional +- client.radar.http.locations.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse -#### LastSeenIdentity +#### DeviceType Types: ```python -from cloudflare.types.zero_trust.access.users import Identity +from cloudflare.types.radar.http.locations import DeviceTypeGetResponse ``` Methods: -- client.zero_trust.access.users.last_seen_identity.get(user_id, \*, account_id) -> Optional +- client.radar.http.locations.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse -#### FailedLogins +#### HTTPProtocol Types: ```python -from cloudflare.types.zero_trust.access.users import FailedLoginListResponse +from cloudflare.types.radar.http.locations import HTTPProtocolGetResponse ``` Methods: -- client.zero_trust.access.users.failed_logins.list(user_id, \*, account_id) -> SyncSinglePage[FailedLoginListResponse] +- client.radar.http.locations.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse -### CustomPages +#### HTTPMethod Types: ```python -from cloudflare.types.zero_trust.access import ( - CustomPage, - CustomPageWithoutHTML, - CustomPageDeleteResponse, -) +from cloudflare.types.radar.http.locations import HTTPMethodGetResponse ``` Methods: -- client.zero_trust.access.custom_pages.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.access.custom_pages.update(custom_page_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.access.custom_pages.list(\*, account_id) -> SyncSinglePage[CustomPageWithoutHTML] -- client.zero_trust.access.custom_pages.delete(custom_page_id, \*, account_id) -> Optional -- client.zero_trust.access.custom_pages.get(custom_page_id, \*, account_id) -> Optional +- client.radar.http.locations.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse -### Tags +#### IPVersion Types: ```python -from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse +from cloudflare.types.radar.http.locations import IPVersionGetResponse ``` Methods: -- client.zero_trust.access.tags.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.access.tags.update(tag_name, \*, account_id, \*\*params) -> Optional -- client.zero_trust.access.tags.list(\*, account_id) -> SyncSinglePage[Tag] -- client.zero_trust.access.tags.delete(tag_name, \*, account_id) -> Optional -- client.zero_trust.access.tags.get(tag_name, \*, account_id) -> Optional +- client.radar.http.locations.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse -### Policies +#### OS Types: ```python -from cloudflare.types.zero_trust.access import ( - PolicyCreateResponse, - PolicyUpdateResponse, - PolicyListResponse, - PolicyDeleteResponse, - PolicyGetResponse, -) +from cloudflare.types.radar.http.locations import OSGetResponse ``` Methods: -- client.zero_trust.access.policies.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.access.policies.update(policy_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.access.policies.list(\*, account_id) -> SyncSinglePage[PolicyListResponse] -- client.zero_trust.access.policies.delete(policy_id, \*, account_id) -> Optional -- client.zero_trust.access.policies.get(policy_id, \*, account_id) -> Optional +- client.radar.http.locations.os.get(os, \*\*params) -> OSGetResponse -## DEX +#### TLSVersion Types: ```python -from cloudflare.types.zero_trust import ( - DeviceExperienceMonitor, - NetworkPath, - NetworkPathResponse, - Percentiles, -) +from cloudflare.types.radar.http.locations import TLSVersionGetResponse ``` -### Colos +Methods: + +- client.radar.http.locations.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse + +#### BrowserFamily Types: ```python -from cloudflare.types.zero_trust.dex import ColoListResponse +from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse ``` Methods: -- client.zero_trust.dex.colos.list(\*, account_id, \*\*params) -> SyncSinglePage[object] +- client.radar.http.locations.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse -### FleetStatus +### Ases Types: ```python -from cloudflare.types.zero_trust.dex import LiveStat, FleetStatusLiveResponse +from cloudflare.types.radar.http import AseGetResponse ``` Methods: -- client.zero_trust.dex.fleet_status.live(\*, account_id, \*\*params) -> Optional -- client.zero_trust.dex.fleet_status.over_time(\*, account_id, \*\*params) -> None +- client.radar.http.ases.get(\*\*params) -> AseGetResponse -#### Devices +#### BotClass Types: ```python -from cloudflare.types.zero_trust.dex.fleet_status import DeviceListResponse +from cloudflare.types.radar.http.ases import BotClassGetResponse ``` Methods: -- client.zero_trust.dex.fleet_status.devices.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DeviceListResponse] +- client.radar.http.ases.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse -### HTTPTests +#### DeviceType Types: ```python -from cloudflare.types.zero_trust.dex import HTTPDetails +from cloudflare.types.radar.http.ases import DeviceTypeGetResponse ``` Methods: -- client.zero_trust.dex.http_tests.get(test_id, \*, account_id, \*\*params) -> Optional +- client.radar.http.ases.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse -#### Percentiles +#### HTTPProtocol Types: ```python -from cloudflare.types.zero_trust.dex.http_tests import HTTPDetailsPercentiles, TestStatOverTime +from cloudflare.types.radar.http.ases import HTTPProtocolGetResponse ``` Methods: -- client.zero_trust.dex.http_tests.percentiles.get(test_id, \*, account_id, \*\*params) -> Optional +- client.radar.http.ases.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse -### Tests +#### HTTPMethod Types: ```python -from cloudflare.types.zero_trust.dex import AggregateTimePeriod, Tests, TestListResponse +from cloudflare.types.radar.http.ases import HTTPMethodGetResponse ``` Methods: -- client.zero_trust.dex.tests.list(\*, account_id, \*\*params) -> SyncV4PagePagination[TestListResponse] +- client.radar.http.ases.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse -#### UniqueDevices +#### IPVersion Types: ```python -from cloudflare.types.zero_trust.dex.tests import UniqueDevices +from cloudflare.types.radar.http.ases import IPVersionGetResponse ``` Methods: -- client.zero_trust.dex.tests.unique_devices.list(\*, account_id, \*\*params) -> Optional - -### TracerouteTestResults +- client.radar.http.ases.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse -#### NetworkPath +#### OS Types: ```python -from cloudflare.types.zero_trust.dex.traceroute_test_results import NetworkPathGetResponse +from cloudflare.types.radar.http.ases import OSGetResponse ``` Methods: -- client.zero_trust.dex.traceroute_test_results.network_path.get(test_result_id, \*, account_id) -> Optional +- client.radar.http.ases.os.get(os, \*\*params) -> OSGetResponse -### TracerouteTests +#### TLSVersion Types: ```python -from cloudflare.types.zero_trust.dex import Traceroute, TracerouteTestPercentilesResponse +from cloudflare.types.radar.http.ases import TLSVersionGetResponse ``` Methods: -- client.zero_trust.dex.traceroute_tests.get(test_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.dex.traceroute_tests.network_path(test_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.dex.traceroute_tests.percentiles(test_id, \*, account_id, \*\*params) -> Optional +- client.radar.http.ases.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse -## Tunnels +#### BrowserFamily Types: ```python -from cloudflare.types.zero_trust import ( - Connection, - TunnelCreateResponse, - TunnelListResponse, - TunnelDeleteResponse, - TunnelEditResponse, - TunnelGetResponse, -) +from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse ``` Methods: -- client.zero_trust.tunnels.create(\*, account_id, \*\*params) -> TunnelCreateResponse -- client.zero_trust.tunnels.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TunnelListResponse] -- client.zero_trust.tunnels.delete(tunnel_id, \*, account_id) -> TunnelDeleteResponse -- client.zero_trust.tunnels.edit(tunnel_id, \*, account_id, \*\*params) -> TunnelEditResponse -- client.zero_trust.tunnels.get(tunnel_id, \*, account_id) -> TunnelGetResponse +- client.radar.http.ases.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse -### Configurations +### Summary Types: ```python -from cloudflare.types.zero_trust.tunnels import ( - ConfigurationUpdateResponse, - ConfigurationGetResponse, +from cloudflare.types.radar.http import ( + SummaryBotClassResponse, + SummaryDeviceTypeResponse, + SummaryHTTPProtocolResponse, + SummaryHTTPVersionResponse, + SummaryIPVersionResponse, + SummaryOSResponse, + SummaryPostQuantumResponse, + SummaryTLSVersionResponse, ) ``` Methods: -- client.zero_trust.tunnels.configurations.update(tunnel_id, \*, account_id, \*\*params) -> ConfigurationUpdateResponse -- client.zero_trust.tunnels.configurations.get(tunnel_id, \*, account_id) -> ConfigurationGetResponse +- client.radar.http.summary.bot_class(\*\*params) -> SummaryBotClassResponse +- client.radar.http.summary.device_type(\*\*params) -> SummaryDeviceTypeResponse +- client.radar.http.summary.http_protocol(\*\*params) -> SummaryHTTPProtocolResponse +- client.radar.http.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse +- client.radar.http.summary.ip_version(\*\*params) -> SummaryIPVersionResponse +- client.radar.http.summary.os(\*\*params) -> SummaryOSResponse +- client.radar.http.summary.post_quantum(\*\*params) -> SummaryPostQuantumResponse +- client.radar.http.summary.tls_version(\*\*params) -> SummaryTLSVersionResponse -### Connections +### TimeseriesGroups Types: ```python -from cloudflare.types.zero_trust.tunnels import ( - Client, - ConnectionDeleteResponse, - ConnectionGetResponse, +from cloudflare.types.radar.http import ( + TimeseriesGroupBotClassResponse, + TimeseriesGroupBrowserResponse, + TimeseriesGroupBrowserFamilyResponse, + TimeseriesGroupDeviceTypeResponse, + TimeseriesGroupHTTPProtocolResponse, + TimeseriesGroupHTTPVersionResponse, + TimeseriesGroupIPVersionResponse, + TimeseriesGroupOSResponse, + TimeseriesGroupPostQuantumResponse, + TimeseriesGroupTLSVersionResponse, ) ``` Methods: -- client.zero_trust.tunnels.connections.delete(tunnel_id, \*, account_id) -> ConnectionDeleteResponse -- client.zero_trust.tunnels.connections.get(tunnel_id, \*, account_id) -> Optional +- client.radar.http.timeseries_groups.bot_class(\*\*params) -> TimeseriesGroupBotClassResponse +- client.radar.http.timeseries_groups.browser(\*\*params) -> TimeseriesGroupBrowserResponse +- client.radar.http.timeseries_groups.browser_family(\*\*params) -> TimeseriesGroupBrowserFamilyResponse +- client.radar.http.timeseries_groups.device_type(\*\*params) -> TimeseriesGroupDeviceTypeResponse +- client.radar.http.timeseries_groups.http_protocol(\*\*params) -> TimeseriesGroupHTTPProtocolResponse +- client.radar.http.timeseries_groups.http_version(\*\*params) -> TimeseriesGroupHTTPVersionResponse +- client.radar.http.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse +- client.radar.http.timeseries_groups.os(\*\*params) -> TimeseriesGroupOSResponse +- client.radar.http.timeseries_groups.post_quantum(\*\*params) -> TimeseriesGroupPostQuantumResponse +- client.radar.http.timeseries_groups.tls_version(\*\*params) -> TimeseriesGroupTLSVersionResponse -### Token +### Top Types: ```python -from cloudflare.types.zero_trust.tunnels import TokenGetResponse +from cloudflare.types.radar.http import TopBrowserResponse, TopBrowserFamilyResponse ``` Methods: -- client.zero_trust.tunnels.token.get(tunnel_id, \*, account_id) -> TokenGetResponse - -### Connectors - -Methods: +- client.radar.http.top.browser(\*\*params) -> TopBrowserResponse +- client.radar.http.top.browser_family(\*\*params) -> TopBrowserFamilyResponse -- client.zero_trust.tunnels.connectors.get(connector_id, \*, account_id, tunnel_id) -> Client +## Quality -### Management +### IQI Types: ```python -from cloudflare.types.zero_trust.tunnels import ManagementCreateResponse +from cloudflare.types.radar.quality import IQISummaryResponse, IQITimeseriesGroupsResponse ``` Methods: -- client.zero_trust.tunnels.management.create(tunnel_id, \*, account_id, \*\*params) -> ManagementCreateResponse +- client.radar.quality.iqi.summary(\*\*params) -> IQISummaryResponse +- client.radar.quality.iqi.timeseries_groups(\*\*params) -> IQITimeseriesGroupsResponse -## ConnectivitySettings +### Speed Types: ```python -from cloudflare.types.zero_trust import ( - ConnectivitySettingEditResponse, - ConnectivitySettingGetResponse, -) +from cloudflare.types.radar.quality import SpeedHistogramResponse, SpeedSummaryResponse ``` Methods: -- client.zero_trust.connectivity_settings.edit(\*, account_id, \*\*params) -> ConnectivitySettingEditResponse -- client.zero_trust.connectivity_settings.get(\*, account_id) -> ConnectivitySettingGetResponse - -## DLP +- client.radar.quality.speed.histogram(\*\*params) -> SpeedHistogramResponse +- client.radar.quality.speed.summary(\*\*params) -> SpeedSummaryResponse -### Datasets +#### Top Types: ```python -from cloudflare.types.zero_trust.dlp import Dataset, DatasetArray, DatasetCreation +from cloudflare.types.radar.quality.speed import TopAsesResponse, TopLocationsResponse ``` Methods: -- client.zero_trust.dlp.datasets.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.dlp.datasets.update(dataset_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.dlp.datasets.list(\*, account_id) -> SyncSinglePage[Dataset] -- client.zero_trust.dlp.datasets.delete(dataset_id, \*, account_id) -> None -- client.zero_trust.dlp.datasets.get(dataset_id, \*, account_id) -> Optional +- client.radar.quality.speed.top.ases(\*\*params) -> TopAsesResponse +- client.radar.quality.speed.top.locations(\*\*params) -> TopLocationsResponse -#### Upload +## Ranking Types: ```python -from cloudflare.types.zero_trust.dlp.datasets import NewVersion +from cloudflare.types.radar import RankingTimeseriesGroupsResponse, RankingTopResponse ``` Methods: -- client.zero_trust.dlp.datasets.upload.create(dataset_id, \*, account_id) -> Optional -- client.zero_trust.dlp.datasets.upload.edit(version, \*, account_id, dataset_id, \*\*params) -> Optional - -### Patterns - -Methods: - -- client.zero_trust.dlp.patterns.validate(\*, account_id, \*\*params) -> Optional +- client.radar.ranking.timeseries_groups(\*\*params) -> RankingTimeseriesGroupsResponse +- client.radar.ranking.top(\*\*params) -> RankingTopResponse -### PayloadLogs +### Domain Types: ```python -from cloudflare.types.zero_trust.dlp import PayloadLogUpdateResponse, PayloadLogGetResponse +from cloudflare.types.radar.ranking import DomainGetResponse ``` Methods: -- client.zero_trust.dlp.payload_logs.update(\*, account_id, \*\*params) -> PayloadLogUpdateResponse -- client.zero_trust.dlp.payload_logs.get(\*, account_id) -> PayloadLogGetResponse +- client.radar.ranking.domain.get(domain, \*\*params) -> DomainGetResponse -### Profiles +### InternetServices Types: ```python -from cloudflare.types.zero_trust.dlp import ( - ContextAwareness, - Profile, - SkipConfiguration, - ProfileGetResponse, +from cloudflare.types.radar.ranking import ( + InternetServiceCategoriesResponse, + InternetServiceTimeseriesGroupsResponse, + InternetServiceTopResponse, ) ``` Methods: -- client.zero_trust.dlp.profiles.list(\*, account_id) -> SyncSinglePage[Profile] -- client.zero_trust.dlp.profiles.get(profile_id, \*, account_id) -> ProfileGetResponse +- client.radar.ranking.internet_services.categories(\*\*params) -> InternetServiceCategoriesResponse +- client.radar.ranking.internet_services.timeseries_groups(\*\*params) -> InternetServiceTimeseriesGroupsResponse +- client.radar.ranking.internet_services.top(\*\*params) -> InternetServiceTopResponse -#### Custom +## TrafficAnomalies Types: ```python -from cloudflare.types.zero_trust.dlp.profiles import ( - CustomProfile, - Pattern, - CustomCreateResponse, - CustomDeleteResponse, -) +from cloudflare.types.radar import TrafficAnomalyGetResponse ``` Methods: -- client.zero_trust.dlp.profiles.custom.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.dlp.profiles.custom.update(profile_id, \*, account_id, \*\*params) -> CustomProfile -- client.zero_trust.dlp.profiles.custom.delete(profile_id, \*, account_id) -> CustomDeleteResponse -- client.zero_trust.dlp.profiles.custom.get(profile_id, \*, account_id) -> CustomProfile +- client.radar.traffic_anomalies.get(\*\*params) -> TrafficAnomalyGetResponse -#### Predefined +### Locations Types: ```python -from cloudflare.types.zero_trust.dlp.profiles import PredefinedProfile +from cloudflare.types.radar.traffic_anomalies import LocationGetResponse ``` Methods: -- client.zero_trust.dlp.profiles.predefined.update(profile_id, \*, account_id, \*\*params) -> PredefinedProfile -- client.zero_trust.dlp.profiles.predefined.get(profile_id, \*, account_id) -> PredefinedProfile +- client.radar.traffic_anomalies.locations.get(\*\*params) -> LocationGetResponse -## Gateway +## TCPResetsTimeouts Types: ```python -from cloudflare.types.zero_trust import GatewayCreateResponse, GatewayListResponse +from cloudflare.types.radar import ( + TCPResetsTimeoutSummaryResponse, + TCPResetsTimeoutTimeseriesGroupsResponse, +) ``` Methods: -- client.zero_trust.gateway.create(\*, account_id) -> Optional -- client.zero_trust.gateway.list(\*, account_id) -> Optional +- client.radar.tcp_resets_timeouts.summary(\*\*params) -> TCPResetsTimeoutSummaryResponse +- client.radar.tcp_resets_timeouts.timeseries_groups(\*\*params) -> TCPResetsTimeoutTimeseriesGroupsResponse + +## RobotsTXT -### AuditSSHSettings +### Top Types: ```python -from cloudflare.types.zero_trust.gateway import GatewaySettings +from cloudflare.types.radar.robots_txt import TopDomainCategoriesResponse ``` Methods: -- client.zero_trust.gateway.audit_ssh_settings.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.audit_ssh_settings.get(\*, account_id) -> Optional +- client.radar.robots_txt.top.domain_categories(\*\*params) -> TopDomainCategoriesResponse -### Categories +#### UserAgents Types: ```python -from cloudflare.types.zero_trust.gateway import Category +from cloudflare.types.radar.robots_txt.top import UserAgentDirectiveResponse ``` Methods: -- client.zero_trust.gateway.categories.list(\*, account_id) -> SyncSinglePage[Category] +- client.radar.robots_txt.top.user_agents.directive(\*\*params) -> UserAgentDirectiveResponse -### AppTypes +## LeakedCredentials Types: ```python -from cloudflare.types.zero_trust.gateway import AppType +from cloudflare.types.radar import ( + LeakedCredentialSummaryV2Response, + LeakedCredentialTimeseriesGroupsV2Response, +) ``` Methods: -- client.zero_trust.gateway.app_types.list(\*, account_id) -> SyncSinglePage[AppType] +- client.radar.leaked_credentials.summary_v2(dimension, \*\*params) -> LeakedCredentialSummaryV2Response +- client.radar.leaked_credentials.timeseries_groups_v2(dimension, \*\*params) -> LeakedCredentialTimeseriesGroupsV2Response -### Configurations +### Summary Types: ```python -from cloudflare.types.zero_trust.gateway import ( - ActivityLogSettings, - AntiVirusSettings, - BlockPageSettings, - BodyScanningSettings, - BrowserIsolationSettings, - CustomCertificateSettings, - ExtendedEmailMatching, - FipsSettings, - GatewayConfigurationSettings, - NotificationSettings, - ProtocolDetection, - TLSSettings, - ConfigurationUpdateResponse, - ConfigurationEditResponse, - ConfigurationGetResponse, +from cloudflare.types.radar.leaked_credentials import ( + SummaryBotClassResponse, + SummaryCompromisedResponse, ) ``` Methods: -- client.zero_trust.gateway.configurations.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.configurations.edit(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.configurations.get(\*, account_id) -> Optional +- client.radar.leaked_credentials.summary.bot_class(\*\*params) -> SummaryBotClassResponse +- client.radar.leaked_credentials.summary.compromised(\*\*params) -> SummaryCompromisedResponse -### Lists +### TimeseriesGroups Types: ```python -from cloudflare.types.zero_trust.gateway import ( - GatewayItem, - GatewayList, - ListCreateResponse, - ListDeleteResponse, +from cloudflare.types.radar.leaked_credentials import ( + TimeseriesGroupBotClassResponse, + TimeseriesGroupCompromisedResponse, ) ``` Methods: -- client.zero_trust.gateway.lists.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.lists.update(list_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.lists.list(\*, account_id, \*\*params) -> SyncSinglePage[GatewayList] -- client.zero_trust.gateway.lists.delete(list_id, \*, account_id) -> Optional -- client.zero_trust.gateway.lists.edit(list_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.lists.get(list_id, \*, account_id) -> Optional +- client.radar.leaked_credentials.timeseries_groups.bot_class(\*\*params) -> TimeseriesGroupBotClassResponse +- client.radar.leaked_credentials.timeseries_groups.compromised(\*\*params) -> TimeseriesGroupCompromisedResponse -#### Items +# BotManagement Types: ```python -from cloudflare.types.zero_trust.gateway.lists import ItemListResponse +from cloudflare.types.bot_management import ( + BotFightModeConfiguration, + SubscriptionConfiguration, + SuperBotFightModeDefinitelyConfiguration, + SuperBotFightModeLikelyConfiguration, + BotManagementUpdateResponse, + BotManagementGetResponse, +) ``` Methods: -- client.zero_trust.gateway.lists.items.list(list_id, \*, account_id) -> SyncSinglePage[ItemListResponse] +- client.bot_management.update(\*, zone_id, \*\*params) -> Optional[BotManagementUpdateResponse] +- client.bot_management.get(\*, zone_id) -> Optional[BotManagementGetResponse] -### Locations +# Fraud Types: ```python -from cloudflare.types.zero_trust.gateway import Location, LocationDeleteResponse +from cloudflare.types.fraud import FraudSettings ``` Methods: -- client.zero_trust.gateway.locations.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.locations.update(location_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.locations.list(\*, account_id) -> SyncSinglePage[Location] -- client.zero_trust.gateway.locations.delete(location_id, \*, account_id) -> Optional -- client.zero_trust.gateway.locations.get(location_id, \*, account_id) -> Optional +- client.fraud.update(\*, zone_id, \*\*params) -> Optional[FraudSettings] +- client.fraud.get(\*, zone_id) -> Optional[FraudSettings] -### Logging +# OriginPostQuantumEncryption Types: ```python -from cloudflare.types.zero_trust.gateway import LoggingSetting +from cloudflare.types.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionUpdateResponse, + OriginPostQuantumEncryptionGetResponse, +) ``` Methods: -- client.zero_trust.gateway.logging.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.logging.get(\*, account_id) -> Optional +- client.origin_post_quantum_encryption.update(\*, zone_id, \*\*params) -> Optional[OriginPostQuantumEncryptionUpdateResponse] +- client.origin_post_quantum_encryption.get(\*, zone_id) -> Optional[OriginPostQuantumEncryptionGetResponse] -### ProxyEndpoints +# Zaraz Types: ```python -from cloudflare.types.zero_trust.gateway import ( - GatewayIPs, - ProxyEndpoint, - ProxyEndpointDeleteResponse, - ProxyEndpointGetResponse, -) +from cloudflare.types.zaraz import ButtonTextTranslation, NeoEvent ``` Methods: -- client.zero_trust.gateway.proxy_endpoints.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.proxy_endpoints.list(\*, account_id) -> Optional -- client.zero_trust.gateway.proxy_endpoints.delete(proxy_endpoint_id, \*, account_id) -> Optional -- client.zero_trust.gateway.proxy_endpoints.edit(proxy_endpoint_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.proxy_endpoints.get(proxy_endpoint_id, \*, account_id) -> Optional +- client.zaraz.update(\*, zone_id, \*\*params) -> Workflow -### Rules +## Config Types: ```python -from cloudflare.types.zero_trust.gateway import ( - DNSResolverSettingsV4, - DNSResolverSettingsV6, - GatewayFilter, - GatewayRule, - RuleSetting, - Schedule, - RuleDeleteResponse, -) +from cloudflare.types.zaraz import Configuration ``` Methods: -- client.zero_trust.gateway.rules.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.rules.update(rule_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.rules.list(\*, account_id) -> SyncSinglePage[GatewayRule] -- client.zero_trust.gateway.rules.delete(rule_id, \*, account_id) -> Optional -- client.zero_trust.gateway.rules.get(rule_id, \*, account_id) -> Optional +- client.zaraz.config.update(\*, zone_id, \*\*params) -> Configuration +- client.zaraz.config.get(\*, zone_id) -> Configuration -### Certificates +## Default -Types: +Methods: -```python -from cloudflare.types.zero_trust.gateway import ( - CertificateCreateResponse, - CertificateListResponse, - CertificateDeleteResponse, - CertificateGetResponse, -) -``` +- client.zaraz.default.get(\*, zone_id) -> Configuration -Methods: +## Export -- client.zero_trust.gateway.certificates.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.certificates.list(\*, account_id) -> SyncSinglePage[CertificateListResponse] -- client.zero_trust.gateway.certificates.delete(certificate_id, \*, account_id) -> Optional -- client.zero_trust.gateway.certificates.get(certificate_id, \*, account_id) -> Optional +Methods: -## Networks +- client.zaraz.export.get(\*, zone_id) -> Configuration -### Routes +## History Types: ```python -from cloudflare.types.zero_trust.networks import NetworkRoute, Route, Teamnet +from cloudflare.types.zaraz import HistoryListResponse ``` Methods: -- client.zero_trust.networks.routes.create(\*, account_id, \*\*params) -> Route -- client.zero_trust.networks.routes.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Teamnet] -- client.zero_trust.networks.routes.delete(route_id, \*, account_id) -> Route -- client.zero_trust.networks.routes.edit(route_id, \*, account_id, \*\*params) -> Route - -#### IPs +- client.zaraz.history.update(\*, zone_id, \*\*params) -> Configuration +- client.zaraz.history.list(\*, zone_id, \*\*params) -> SyncSinglePage[HistoryListResponse] -Methods: +### Configs -- client.zero_trust.networks.routes.ips.get(ip, \*, account_id, \*\*params) -> Teamnet +Types: -#### Networks +```python +from cloudflare.types.zaraz.history import ConfigGetResponse +``` Methods: -- client.zero_trust.networks.routes.networks.create(ip_network_encoded, \*, account_id, \*\*params) -> Route -- client.zero_trust.networks.routes.networks.delete(ip_network_encoded, \*, account_id, \*\*params) -> Route -- client.zero_trust.networks.routes.networks.edit(ip_network_encoded, \*, account_id) -> Route +- client.zaraz.history.configs.get(\*, zone_id, \*\*params) -> ConfigGetResponse -### VirtualNetworks +## Publish Types: ```python -from cloudflare.types.zero_trust.networks import ( - VirtualNetwork, - VirtualNetworkCreateResponse, - VirtualNetworkDeleteResponse, - VirtualNetworkEditResponse, -) +from cloudflare.types.zaraz import PublishCreateResponse ``` Methods: -- client.zero_trust.networks.virtual_networks.create(\*, account_id, \*\*params) -> VirtualNetworkCreateResponse -- client.zero_trust.networks.virtual_networks.list(\*, account_id, \*\*params) -> SyncSinglePage[VirtualNetwork] -- client.zero_trust.networks.virtual_networks.delete(virtual_network_id, \*, account_id) -> VirtualNetworkDeleteResponse -- client.zero_trust.networks.virtual_networks.edit(virtual_network_id, \*, account_id, \*\*params) -> VirtualNetworkEditResponse +- client.zaraz.publish.create(\*, zone_id, \*\*params) -> str -## RiskScoring +## Workflow Types: ```python -from cloudflare.types.zero_trust import RiskScoringGetResponse, RiskScoringResetResponse +from cloudflare.types.zaraz import Workflow ``` Methods: -- client.zero_trust.risk_scoring.get(user_id, \*, account_identifier, \*\*params) -> RiskScoringGetResponse -- client.zero_trust.risk_scoring.reset(user_id, \*, account_identifier) -> RiskScoringResetResponse +- client.zaraz.workflow.get(\*, zone_id) -> Workflow -### Behaviours +# Speed Types: ```python -from cloudflare.types.zero_trust.risk_scoring import BehaviourUpdateResponse, BehaviourGetResponse +from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend ``` -Methods: - -- client.zero_trust.risk_scoring.behaviours.update(account_identifier, \*\*params) -> BehaviourUpdateResponse -- client.zero_trust.risk_scoring.behaviours.get(account_identifier) -> BehaviourGetResponse - -### Summary +## Schedule Types: ```python -from cloudflare.types.zero_trust.risk_scoring import SummaryGetResponse +from cloudflare.types.speed import Schedule, ScheduleCreateResponse, ScheduleDeleteResponse ``` Methods: -- client.zero_trust.risk_scoring.summary.get(account_identifier, \*\*params) -> SummaryGetResponse +- client.speed.schedule.create(url, \*, zone_id, \*\*params) -> Optional[ScheduleCreateResponse] +- client.speed.schedule.delete(url, \*, zone_id, \*\*params) -> Optional[ScheduleDeleteResponse] +- client.speed.schedule.get(url, \*, zone_id, \*\*params) -> Optional[Schedule] -### Integrations +## Availabilities Types: ```python -from cloudflare.types.zero_trust.risk_scoring import ( - IntegrationCreateResponse, - IntegrationUpdateResponse, - IntegrationListResponse, - IntegrationDeleteResponse, - IntegrationGetResponse, -) +from cloudflare.types.speed import Availability ``` Methods: -- client.zero_trust.risk_scoring.integrations.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.risk_scoring.integrations.update(integration_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.risk_scoring.integrations.list(\*, account_id) -> SyncSinglePage[IntegrationListResponse] -- client.zero_trust.risk_scoring.integrations.delete(integration_id, \*, account_id) -> object -- client.zero_trust.risk_scoring.integrations.get(integration_id, \*, account_id) -> Optional +- client.speed.availabilities.list(\*, zone_id) -> Optional[Availability] -#### References +## Pages Types: ```python -from cloudflare.types.zero_trust.risk_scoring.integrations import ReferenceGetResponse +from cloudflare.types.speed import PageListResponse ``` Methods: -- client.zero_trust.risk_scoring.integrations.references.get(reference_id, \*, account_id) -> Optional - -# Challenges +- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse] +- client.speed.pages.trend(url, \*, zone_id, \*\*params) -> Optional[Trend] -## Widgets +### Tests Types: ```python -from cloudflare.types.challenges import Widget, WidgetDomain, WidgetListResponse +from cloudflare.types.speed.pages import Test, TestDeleteResponse ``` Methods: -- client.challenges.widgets.create(\*, account_id, \*\*params) -> Optional -- client.challenges.widgets.update(sitekey, \*, account_id, \*\*params) -> Optional -- client.challenges.widgets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[WidgetListResponse] -- client.challenges.widgets.delete(sitekey, \*, account_id) -> Optional -- client.challenges.widgets.get(sitekey, \*, account_id) -> Optional -- client.challenges.widgets.rotate_secret(sitekey, \*, account_id, \*\*params) -> Optional - -# Hyperdrive - -Types: - -```python -from cloudflare.types.hyperdrive import Configuration, Hyperdrive -``` +- client.speed.pages.tests.create(url, \*, zone_id, \*\*params) -> Optional[Test] +- client.speed.pages.tests.list(url, \*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Test] +- client.speed.pages.tests.delete(url, \*, zone_id, \*\*params) -> Optional[TestDeleteResponse] +- client.speed.pages.tests.get(test_id, \*, zone_id, url) -> Optional[Test] -## Configs +# DCVDelegation Types: ```python -from cloudflare.types.hyperdrive import ConfigDeleteResponse +from cloudflare.types.dcv_delegation import DCVDelegationUUID ``` Methods: -- client.hyperdrive.configs.create(\*, account_id, \*\*params) -> Optional -- client.hyperdrive.configs.update(hyperdrive_id, \*, account_id, \*\*params) -> Optional -- client.hyperdrive.configs.list(\*, account_id) -> SyncSinglePage[Hyperdrive] -- client.hyperdrive.configs.delete(hyperdrive_id, \*, account_id) -> ConfigDeleteResponse -- client.hyperdrive.configs.edit(hyperdrive_id, \*, account_id, \*\*params) -> Optional -- client.hyperdrive.configs.get(hyperdrive_id, \*, account_id) -> Optional +- client.dcv_delegation.get(\*, zone_id) -> Optional[DCVDelegationUUID] -# RUM +# Hostnames -## SiteInfo +## Settings + +### TLS Types: ```python -from cloudflare.types.rum import Site, SiteInfoDeleteResponse +from cloudflare.types.hostnames.settings import ( + Setting, + SettingValue, + TLSDeleteResponse, + TLSGetResponse, +) ``` Methods: -- client.rum.site_info.create(\*, account_id, \*\*params) -> Optional -- client.rum.site_info.update(site_id, \*, account_id, \*\*params) -> Optional -- client.rum.site_info.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Site] -- client.rum.site_info.delete(site_id, \*, account_id) -> Optional -- client.rum.site_info.get(site_id, \*, account_id) -> Optional +- client.hostnames.settings.tls.update(hostname, \*, zone_id, setting_id, \*\*params) -> Optional[Setting] +- client.hostnames.settings.tls.delete(hostname, \*, zone_id, setting_id) -> Optional[TLSDeleteResponse] +- client.hostnames.settings.tls.get(setting_id, \*, zone_id) -> SyncSinglePage[TLSGetResponse] -## Rules +# Snippets Types: ```python -from cloudflare.types.rum import RUMRule, RuleListResponse, RuleDeleteResponse +from cloudflare.types.snippets import ( + SnippetUpdateResponse, + SnippetListResponse, + SnippetDeleteResponse, + SnippetGetResponse, +) ``` Methods: -- client.rum.rules.create(ruleset_id, \*, account_id, \*\*params) -> Optional -- client.rum.rules.update(rule_id, \*, account_id, ruleset_id, \*\*params) -> Optional -- client.rum.rules.list(ruleset_id, \*, account_id) -> Optional -- client.rum.rules.delete(rule_id, \*, account_id, ruleset_id) -> Optional +- client.snippets.update(snippet_name, \*, zone_id, \*\*params) -> SnippetUpdateResponse +- client.snippets.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[SnippetListResponse] +- client.snippets.delete(snippet_name, \*, zone_id) -> str +- client.snippets.get(snippet_name, \*, zone_id) -> SnippetGetResponse -# Vectorize +## Content -## Indexes +Methods: + +- client.snippets.content.get(snippet_name, \*, zone_id) -> BinaryAPIResponse + +## Rules Types: ```python -from cloudflare.types.vectorize import ( - CreateIndex, - IndexDeleteVectorsByID, - IndexDimensionConfiguration, - IndexInsert, - IndexQuery, - IndexUpsert, - IndexDeleteResponse, - IndexGetByIDsResponse, -) +from cloudflare.types.snippets import RuleUpdateResponse, RuleListResponse, RuleDeleteResponse ``` Methods: -- client.vectorize.indexes.create(\*, account_id, \*\*params) -> Optional -- client.vectorize.indexes.update(index_name, \*, account_id, \*\*params) -> Optional -- client.vectorize.indexes.list(\*, account_id) -> SyncSinglePage[CreateIndex] -- client.vectorize.indexes.delete(index_name, \*, account_id) -> IndexDeleteResponse -- client.vectorize.indexes.delete_by_ids(index_name, \*, account_id, \*\*params) -> Optional -- client.vectorize.indexes.get(index_name, \*, account_id) -> Optional -- client.vectorize.indexes.get_by_ids(index_name, \*, account_id, \*\*params) -> object -- client.vectorize.indexes.insert(index_name, \*, account_id, \*\*params) -> Optional -- client.vectorize.indexes.query(index_name, \*, account_id, \*\*params) -> Optional -- client.vectorize.indexes.upsert(index_name, \*, account_id, \*\*params) -> Optional +- client.snippets.rules.update(\*, zone_id, \*\*params) -> SyncSinglePage[RuleUpdateResponse] +- client.snippets.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] +- client.snippets.rules.delete(\*, zone_id) -> SyncSinglePage[RuleDeleteResponse] -# URLScanner +# RealtimeKit + +## Apps Types: ```python -from cloudflare.types.url_scanner import URLScannerScanResponse +from cloudflare.types.realtime_kit import AppGetResponse, AppPostResponse ``` Methods: -- client.url_scanner.scan(account_id, \*\*params) -> URLScannerScanResponse +- client.realtime_kit.apps.get(\*, account_id) -> AppGetResponse +- client.realtime_kit.apps.post(\*, account_id, \*\*params) -> AppPostResponse -## Scans +## Meetings Types: ```python -from cloudflare.types.url_scanner import ( - URLScannerDomain, - URLScannerTask, - ScanCreateResponse, - ScanGetResponse, - ScanHarResponse, +from cloudflare.types.realtime_kit import ( + MeetingCreateResponse, + MeetingAddParticipantResponse, + MeetingDeleteMeetingParticipantResponse, + MeetingEditParticipantResponse, + MeetingGetResponse, + MeetingGetMeetingByIDResponse, + MeetingGetMeetingParticipantResponse, + MeetingGetMeetingParticipantsResponse, + MeetingRefreshParticipantTokenResponse, + MeetingReplaceMeetingByIDResponse, + MeetingUpdateMeetingByIDResponse, ) ``` Methods: -- client.url_scanner.scans.create(account_id, \*\*params) -> ScanCreateResponse -- client.url_scanner.scans.get(scan_id, \*, account_id, \*\*params) -> ScanGetResponse -- client.url_scanner.scans.har(scan_id, \*, account_id) -> ScanHarResponse -- client.url_scanner.scans.screenshot(scan_id, \*, account_id, \*\*params) -> BinaryAPIResponse - -# Radar - -## Annotations +- client.realtime_kit.meetings.create(app_id, \*, account_id, \*\*params) -> MeetingCreateResponse +- client.realtime_kit.meetings.add_participant(meeting_id, \*, account_id, app_id, \*\*params) -> MeetingAddParticipantResponse +- client.realtime_kit.meetings.delete_meeting_participant(participant_id, \*, account_id, app_id, meeting_id) -> MeetingDeleteMeetingParticipantResponse +- client.realtime_kit.meetings.edit_participant(participant_id, \*, account_id, app_id, meeting_id, \*\*params) -> MeetingEditParticipantResponse +- client.realtime_kit.meetings.get(app_id, \*, account_id, \*\*params) -> MeetingGetResponse +- client.realtime_kit.meetings.get_meeting_by_id(meeting_id, \*, account_id, app_id, \*\*params) -> MeetingGetMeetingByIDResponse +- client.realtime_kit.meetings.get_meeting_participant(participant_id, \*, account_id, app_id, meeting_id) -> MeetingGetMeetingParticipantResponse +- client.realtime_kit.meetings.get_meeting_participants(meeting_id, \*, account_id, app_id, \*\*params) -> MeetingGetMeetingParticipantsResponse +- client.realtime_kit.meetings.refresh_participant_token(participant_id, \*, account_id, app_id, meeting_id) -> MeetingRefreshParticipantTokenResponse +- client.realtime_kit.meetings.replace_meeting_by_id(meeting_id, \*, account_id, app_id, \*\*params) -> MeetingReplaceMeetingByIDResponse +- client.realtime_kit.meetings.update_meeting_by_id(meeting_id, \*, account_id, app_id, \*\*params) -> MeetingUpdateMeetingByIDResponse -### Outages +## Presets Types: ```python -from cloudflare.types.radar.annotations import OutageGetResponse, OutageLocationsResponse +from cloudflare.types.realtime_kit import ( + PresetCreateResponse, + PresetUpdateResponse, + PresetDeleteResponse, + PresetGetResponse, + PresetGetPresetByIDResponse, +) ``` Methods: -- client.radar.annotations.outages.get(\*\*params) -> OutageGetResponse -- client.radar.annotations.outages.locations(\*\*params) -> OutageLocationsResponse +- client.realtime_kit.presets.create(app_id, \*, account_id, \*\*params) -> PresetCreateResponse +- client.realtime_kit.presets.update(preset_id, \*, account_id, app_id, \*\*params) -> PresetUpdateResponse +- client.realtime_kit.presets.delete(preset_id, \*, account_id, app_id) -> PresetDeleteResponse +- client.realtime_kit.presets.get(app_id, \*, account_id, \*\*params) -> PresetGetResponse +- client.realtime_kit.presets.get_preset_by_id(preset_id, \*, account_id, app_id) -> PresetGetPresetByIDResponse -## BGP +## Sessions Types: ```python -from cloudflare.types.radar import BGPTimeseriesResponse +from cloudflare.types.realtime_kit import ( + SessionGetParticipantDataFromPeerIDResponse, + SessionGetSessionChatResponse, + SessionGetSessionDetailsResponse, + SessionGetSessionParticipantDetailsResponse, + SessionGetSessionParticipantsResponse, + SessionGetSessionSummaryResponse, + SessionGetSessionTranscriptsResponse, + SessionGetSessionsResponse, +) ``` Methods: -- client.radar.bgp.timeseries(\*\*params) -> BGPTimeseriesResponse - -### Leaks +- client.realtime_kit.sessions.generate_summary_of_transcripts(session_id, \*, account_id, app_id) -> None +- client.realtime_kit.sessions.get_participant_data_from_peer_id(peer_id, \*, account_id, app_id, \*\*params) -> SessionGetParticipantDataFromPeerIDResponse +- client.realtime_kit.sessions.get_session_chat(session_id, \*, account_id, app_id) -> SessionGetSessionChatResponse +- client.realtime_kit.sessions.get_session_details(session_id, \*, account_id, app_id, \*\*params) -> SessionGetSessionDetailsResponse +- client.realtime_kit.sessions.get_session_participant_details(participant_id, \*, account_id, app_id, session_id, \*\*params) -> SessionGetSessionParticipantDetailsResponse +- client.realtime_kit.sessions.get_session_participants(session_id, \*, account_id, app_id, \*\*params) -> SessionGetSessionParticipantsResponse +- client.realtime_kit.sessions.get_session_summary(session_id, \*, account_id, app_id) -> SessionGetSessionSummaryResponse +- client.realtime_kit.sessions.get_session_transcripts(session_id, \*, account_id, app_id) -> SessionGetSessionTranscriptsResponse +- client.realtime_kit.sessions.get_sessions(app_id, \*, account_id, \*\*params) -> SessionGetSessionsResponse -#### Events +## Recordings Types: ```python -from cloudflare.types.radar.bgp.leaks import EventListResponse +from cloudflare.types.realtime_kit import ( + RecordingGetActiveRecordingsResponse, + RecordingGetOneRecordingResponse, + RecordingGetRecordingsResponse, + RecordingPauseResumeStopRecordingResponse, + RecordingStartRecordingsResponse, +) ``` Methods: -- client.radar.bgp.leaks.events.list(\*\*params) -> SyncV4PagePagination[EventListResponse] +- client.realtime_kit.recordings.get_active_recordings(meeting_id, \*, account_id, app_id) -> RecordingGetActiveRecordingsResponse +- client.realtime_kit.recordings.get_one_recording(recording_id, \*, account_id, app_id) -> RecordingGetOneRecordingResponse +- client.realtime_kit.recordings.get_recordings(app_id, \*, account_id, \*\*params) -> RecordingGetRecordingsResponse +- client.realtime_kit.recordings.pause_resume_stop_recording(recording_id, \*, account_id, app_id, \*\*params) -> RecordingPauseResumeStopRecordingResponse +- client.realtime_kit.recordings.start_recordings(app_id, \*, account_id, \*\*params) -> RecordingStartRecordingsResponse +- client.realtime_kit.recordings.start_track_recording(app_id, \*, account_id, \*\*params) -> None -### Top +## Webhooks Types: ```python -from cloudflare.types.radar.bgp import TopPrefixesResponse +from cloudflare.types.realtime_kit import ( + WebhookCreateWebhookResponse, + WebhookDeleteWebhookResponse, + WebhookEditWebhookResponse, + WebhookGetWebhookByIDResponse, + WebhookGetWebhooksResponse, + WebhookReplaceWebhookResponse, +) ``` Methods: -- client.radar.bgp.top.prefixes(\*\*params) -> TopPrefixesResponse +- client.realtime_kit.webhooks.create_webhook(app_id, \*, account_id, \*\*params) -> WebhookCreateWebhookResponse +- client.realtime_kit.webhooks.delete_webhook(webhook_id, \*, account_id, app_id) -> WebhookDeleteWebhookResponse +- client.realtime_kit.webhooks.edit_webhook(webhook_id, \*, account_id, app_id, \*\*params) -> WebhookEditWebhookResponse +- client.realtime_kit.webhooks.get_webhook_by_id(webhook_id, \*, account_id, app_id) -> WebhookGetWebhookByIDResponse +- client.realtime_kit.webhooks.get_webhooks(app_id, \*, account_id) -> WebhookGetWebhooksResponse +- client.realtime_kit.webhooks.replace_webhook(webhook_id, \*, account_id, app_id, \*\*params) -> WebhookReplaceWebhookResponse -#### Ases +## ActiveSession Types: ```python -from cloudflare.types.radar.bgp.top import AseGetResponse, AsePrefixesResponse +from cloudflare.types.realtime_kit import ( + ActiveSessionCreatePollResponse, + ActiveSessionGetActiveSessionResponse, + ActiveSessionKickAllParticipantsResponse, + ActiveSessionKickParticipantsResponse, +) ``` Methods: -- client.radar.bgp.top.ases.get(\*\*params) -> AseGetResponse -- client.radar.bgp.top.ases.prefixes(\*\*params) -> AsePrefixesResponse - -### Hijacks +- client.realtime_kit.active_session.create_poll(meeting_id, \*, account_id, app_id, \*\*params) -> ActiveSessionCreatePollResponse +- client.realtime_kit.active_session.get_active_session(meeting_id, \*, account_id, app_id) -> ActiveSessionGetActiveSessionResponse +- client.realtime_kit.active_session.kick_all_participants(meeting_id, \*, account_id, app_id) -> ActiveSessionKickAllParticipantsResponse +- client.realtime_kit.active_session.kick_participants(meeting_id, \*, account_id, app_id, \*\*params) -> ActiveSessionKickParticipantsResponse -#### Events +## Livestreams Types: ```python -from cloudflare.types.radar.bgp.hijacks import EventListResponse +from cloudflare.types.realtime_kit import ( + LivestreamCreateIndependentLivestreamResponse, + LivestreamGetActiveLivestreamsForLivestreamIDResponse, + LivestreamGetAllLivestreamsResponse, + LivestreamGetLivestreamAnalyticsCompleteResponse, + LivestreamGetLivestreamSessionDetailsForSessionIDResponse, + LivestreamGetLivestreamSessionForLivestreamIDResponse, + LivestreamGetMeetingActiveLivestreamsResponse, + LivestreamGetOrgAnalyticsResponse, + LivestreamStartLivestreamingAMeetingResponse, + LivestreamStopLivestreamingAMeetingResponse, +) ``` Methods: -- client.radar.bgp.hijacks.events.list(\*\*params) -> SyncV4PagePagination[EventListResponse] +- client.realtime_kit.livestreams.create_independent_livestream(app_id, \*, account_id, \*\*params) -> LivestreamCreateIndependentLivestreamResponse +- client.realtime_kit.livestreams.get_active_livestreams_for_livestream_id(livestream_id, \*, account_id, app_id) -> LivestreamGetActiveLivestreamsForLivestreamIDResponse +- client.realtime_kit.livestreams.get_all_livestreams(app_id, \*, account_id, \*\*params) -> LivestreamGetAllLivestreamsResponse +- client.realtime_kit.livestreams.get_livestream_analytics_complete(app_id, \*, account_id, \*\*params) -> LivestreamGetLivestreamAnalyticsCompleteResponse +- client.realtime_kit.livestreams.get_livestream_session_details_for_session_id(livestream_session_id, \*, account_id, app_id) -> LivestreamGetLivestreamSessionDetailsForSessionIDResponse +- client.realtime_kit.livestreams.get_livestream_session_for_livestream_id(livestream_id, \*, account_id, app_id, \*\*params) -> LivestreamGetLivestreamSessionForLivestreamIDResponse +- client.realtime_kit.livestreams.get_meeting_active_livestreams(meeting_id, \*, account_id, app_id) -> LivestreamGetMeetingActiveLivestreamsResponse +- client.realtime_kit.livestreams.get_org_analytics(app_id, \*, account_id, \*\*params) -> LivestreamGetOrgAnalyticsResponse +- client.realtime_kit.livestreams.start_livestreaming_a_meeting(meeting_id, \*, account_id, app_id, \*\*params) -> LivestreamStartLivestreamingAMeetingResponse +- client.realtime_kit.livestreams.stop_livestreaming_a_meeting(meeting_id, \*, account_id, app_id) -> LivestreamStopLivestreamingAMeetingResponse -### Routes +## Analytics Types: ```python -from cloudflare.types.radar.bgp import ( - RouteAsesResponse, - RouteMoasResponse, - RoutePfx2asResponse, - RouteStatsResponse, -) +from cloudflare.types.realtime_kit import AnalyticsGetOrgAnalyticsResponse ``` Methods: -- client.radar.bgp.routes.ases(\*\*params) -> RouteAsesResponse -- client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse -- client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse -- client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse +- client.realtime_kit.analytics.get_org_analytics(app_id, \*, account_id, \*\*params) -> AnalyticsGetOrgAnalyticsResponse -### IPs +# Calls + +## SFU Types: ```python -from cloudflare.types.radar.bgp import IPTimeseriesResponse +from cloudflare.types.calls import ( + SFUCreateResponse, + SFUUpdateResponse, + SFUListResponse, + SFUDeleteResponse, + SFUGetResponse, +) ``` Methods: -- client.radar.bgp.ips.timeseries(\*\*params) -> IPTimeseriesResponse +- client.calls.sfu.create(\*, account_id, \*\*params) -> Optional[SFUCreateResponse] +- client.calls.sfu.update(app_id, \*, account_id, \*\*params) -> Optional[SFUUpdateResponse] +- client.calls.sfu.list(\*, account_id) -> SyncSinglePage[SFUListResponse] +- client.calls.sfu.delete(app_id, \*, account_id) -> Optional[SFUDeleteResponse] +- client.calls.sfu.get(app_id, \*, account_id) -> Optional[SFUGetResponse] -## Datasets +## TURN Types: ```python -from cloudflare.types.radar import DatasetListResponse, DatasetDownloadResponse, DatasetGetResponse +from cloudflare.types.calls import ( + TURNCreateResponse, + TURNUpdateResponse, + TURNListResponse, + TURNDeleteResponse, + TURNGetResponse, +) ``` Methods: -- client.radar.datasets.list(\*\*params) -> DatasetListResponse -- client.radar.datasets.download(\*\*params) -> DatasetDownloadResponse -- client.radar.datasets.get(alias) -> str +- client.calls.turn.create(\*, account_id, \*\*params) -> Optional[TURNCreateResponse] +- client.calls.turn.update(key_id, \*, account_id, \*\*params) -> Optional[TURNUpdateResponse] +- client.calls.turn.list(\*, account_id) -> SyncSinglePage[TURNListResponse] +- client.calls.turn.delete(key_id, \*, account_id) -> Optional[TURNDeleteResponse] +- client.calls.turn.get(key_id, \*, account_id) -> Optional[TURNGetResponse] -## DNS +# CloudforceOne -### Top +## Scans + +### Results Types: ```python -from cloudflare.types.radar.dns import TopAsesResponse, TopLocationsResponse +from cloudflare.types.cloudforce_one.scans import ScanResult, ResultGetResponse ``` Methods: -- client.radar.dns.top.ases(\*\*params) -> TopAsesResponse -- client.radar.dns.top.locations(\*\*params) -> TopLocationsResponse +- client.cloudforce_one.scans.results.get(config_id, \*, account_id) -> ResultGetResponse -## Netflows +### Config Types: ```python -from cloudflare.types.radar import NetflowTimeseriesResponse +from cloudflare.types.cloudforce_one.scans import ( + ConfigCreateResponse, + ConfigListResponse, + ConfigEditResponse, +) ``` Methods: -- client.radar.netflows.timeseries(\*\*params) -> NetflowTimeseriesResponse +- client.cloudforce_one.scans.config.create(\*, account_id, \*\*params) -> Optional[ConfigCreateResponse] +- client.cloudforce_one.scans.config.list(\*, account_id) -> SyncSinglePage[ConfigListResponse] +- client.cloudforce_one.scans.config.delete(config_id, \*, account_id) -> object +- client.cloudforce_one.scans.config.edit(config_id, \*, account_id, \*\*params) -> Optional[ConfigEditResponse] -### Top +## BinaryStorage Types: ```python -from cloudflare.types.radar.netflows import TopAsesResponse, TopLocationsResponse +from cloudflare.types.cloudforce_one import BinaryStorageCreateResponse ``` Methods: -- client.radar.netflows.top.ases(\*\*params) -> TopAsesResponse -- client.radar.netflows.top.locations(\*\*params) -> TopLocationsResponse +- client.cloudforce_one.binary_storage.create(\*, account_id, \*\*params) -> BinaryStorageCreateResponse +- client.cloudforce_one.binary_storage.get(hash, \*, account_id) -> None -## Search +## Requests Types: ```python -from cloudflare.types.radar import SearchGlobalResponse +from cloudflare.types.cloudforce_one import ( + Item, + ListItem, + Quota, + RequestConstants, + RequestTypes, + RequestDeleteResponse, + RequestTypesResponse, +) ``` Methods: -- client.radar.search.global\_(\*\*params) -> SearchGlobalResponse - -## VerifiedBots +- client.cloudforce_one.requests.create(\*, account_id, \*\*params) -> Optional[Item] +- client.cloudforce_one.requests.update(request_id, \*, account_id, \*\*params) -> Optional[Item] +- client.cloudforce_one.requests.list(\*, account_id, \*\*params) -> SyncSinglePage[ListItem] +- client.cloudforce_one.requests.delete(request_id, \*, account_id) -> RequestDeleteResponse +- client.cloudforce_one.requests.constants(\*, account_id) -> Optional[RequestConstants] +- client.cloudforce_one.requests.get(request_id, \*, account_id) -> Optional[Item] +- client.cloudforce_one.requests.quota(\*, account_id) -> Optional[Quota] +- client.cloudforce_one.requests.types(\*, account_id) -> SyncSinglePage[RequestTypesResponse] -### Top +### Message Types: ```python -from cloudflare.types.radar.verified_bots import TopBotsResponse, TopCategoriesResponse +from cloudflare.types.cloudforce_one.requests import Message, MessageDeleteResponse ``` Methods: -- client.radar.verified_bots.top.bots(\*\*params) -> TopBotsResponse -- client.radar.verified_bots.top.categories(\*\*params) -> TopCategoriesResponse +- client.cloudforce_one.requests.message.create(request_id, \*, account_id, \*\*params) -> Optional[Message] +- client.cloudforce_one.requests.message.update(message_id, \*, account_id, request_id, \*\*params) -> Optional[Message] +- client.cloudforce_one.requests.message.delete(message_id, \*, account_id, request_id) -> MessageDeleteResponse +- client.cloudforce_one.requests.message.get(request_id, \*, account_id, \*\*params) -> SyncSinglePage[Message] -## AS112 +### Priority Types: ```python -from cloudflare.types.radar import AS112TimeseriesResponse +from cloudflare.types.cloudforce_one.requests import ( + Label, + Priority, + PriorityEdit, + PriorityDeleteResponse, +) ``` Methods: -- client.radar.as112.timeseries(\*\*params) -> AS112TimeseriesResponse +- client.cloudforce_one.requests.priority.create(\*, account_id, \*\*params) -> Optional[Priority] +- client.cloudforce_one.requests.priority.update(priority_id, \*, account_id, \*\*params) -> Optional[Item] +- client.cloudforce_one.requests.priority.delete(priority_id, \*, account_id) -> PriorityDeleteResponse +- client.cloudforce_one.requests.priority.get(priority_id, \*, account_id) -> Optional[Item] +- client.cloudforce_one.requests.priority.quota(\*, account_id) -> Optional[Quota] -### Summary +### Assets Types: ```python -from cloudflare.types.radar.as112 import ( - SummaryDNSSECResponse, - SummaryEdnsResponse, - SummaryIPVersionResponse, - SummaryProtocolResponse, - SummaryQueryTypeResponse, - SummaryResponseCodesResponse, +from cloudflare.types.cloudforce_one.requests import ( + AssetCreateResponse, + AssetUpdateResponse, + AssetDeleteResponse, + AssetGetResponse, ) ``` Methods: -- client.radar.as112.summary.dnssec(\*\*params) -> SummaryDNSSECResponse -- client.radar.as112.summary.edns(\*\*params) -> SummaryEdnsResponse -- client.radar.as112.summary.ip_version(\*\*params) -> SummaryIPVersionResponse -- client.radar.as112.summary.protocol(\*\*params) -> SummaryProtocolResponse -- client.radar.as112.summary.query_type(\*\*params) -> SummaryQueryTypeResponse -- client.radar.as112.summary.response_codes(\*\*params) -> SummaryResponseCodesResponse +- client.cloudforce_one.requests.assets.create(request_id, \*, account_id, \*\*params) -> SyncSinglePage[AssetCreateResponse] +- client.cloudforce_one.requests.assets.update(asset_id, \*, account_id, request_id, \*\*params) -> Optional[AssetUpdateResponse] +- client.cloudforce_one.requests.assets.delete(asset_id, \*, account_id, request_id) -> AssetDeleteResponse +- client.cloudforce_one.requests.assets.get(asset_id, \*, account_id, request_id) -> SyncSinglePage[AssetGetResponse] -### TimeseriesGroups +## ThreatEvents Types: ```python -from cloudflare.types.radar.as112 import ( - TimeseriesGroupDNSSECResponse, - TimeseriesGroupEdnsResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupProtocolResponse, - TimeseriesGroupQueryTypeResponse, - TimeseriesGroupResponseCodesResponse, +from cloudflare.types.cloudforce_one import ( + ThreatEventCreateResponse, + ThreatEventListResponse, + ThreatEventDeleteResponse, + ThreatEventBulkCreateResponse, + ThreatEventEditResponse, + ThreatEventGetResponse, ) ``` Methods: -- client.radar.as112.timeseries_groups.dnssec(\*\*params) -> TimeseriesGroupDNSSECResponse -- client.radar.as112.timeseries_groups.edns(\*\*params) -> TimeseriesGroupEdnsResponse -- client.radar.as112.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse -- client.radar.as112.timeseries_groups.protocol(\*\*params) -> TimeseriesGroupProtocolResponse -- client.radar.as112.timeseries_groups.query_type(\*\*params) -> TimeseriesGroupQueryTypeResponse -- client.radar.as112.timeseries_groups.response_codes(\*\*params) -> TimeseriesGroupResponseCodesResponse +- client.cloudforce_one.threat_events.create(\*, path_account_id, \*\*params) -> ThreatEventCreateResponse +- client.cloudforce_one.threat_events.list(\*, account_id, \*\*params) -> ThreatEventListResponse +- client.cloudforce_one.threat_events.delete(event_id, \*, account_id) -> ThreatEventDeleteResponse +- client.cloudforce_one.threat_events.bulk_create(\*, account_id, \*\*params) -> ThreatEventBulkCreateResponse +- client.cloudforce_one.threat_events.edit(event_id, \*, account_id, \*\*params) -> ThreatEventEditResponse +- client.cloudforce_one.threat_events.get(event_id, \*, account_id) -> ThreatEventGetResponse -### Top +### Attackers Types: ```python -from cloudflare.types.radar.as112 import ( - TopDNSSECResponse, - TopEdnsResponse, - TopIPVersionResponse, - TopLocationsResponse, -) +from cloudflare.types.cloudforce_one.threat_events import AttackerListResponse ``` Methods: -- client.radar.as112.top.dnssec(dnssec, \*\*params) -> TopDNSSECResponse -- client.radar.as112.top.edns(edns, \*\*params) -> TopEdnsResponse -- client.radar.as112.top.ip_version(ip_version, \*\*params) -> TopIPVersionResponse -- client.radar.as112.top.locations(\*\*params) -> TopLocationsResponse +- client.cloudforce_one.threat_events.attackers.list(\*, account_id, \*\*params) -> AttackerListResponse -## Email +### Categories Types: ```python -from cloudflare.types.radar import RadarEmailSeries, RadarEmailSummary +from cloudflare.types.cloudforce_one.threat_events import ( + CategoryCreateResponse, + CategoryListResponse, + CategoryDeleteResponse, + CategoryEditResponse, + CategoryGetResponse, +) ``` -### Routing +Methods: -#### Summary +- client.cloudforce_one.threat_events.categories.create(\*, account_id, \*\*params) -> CategoryCreateResponse +- client.cloudforce_one.threat_events.categories.list(\*, account_id, \*\*params) -> CategoryListResponse +- client.cloudforce_one.threat_events.categories.delete(category_id, \*, account_id) -> CategoryDeleteResponse +- client.cloudforce_one.threat_events.categories.edit(category_id, \*, account_id, \*\*params) -> CategoryEditResponse +- client.cloudforce_one.threat_events.categories.get(category_id, \*, account_id) -> CategoryGetResponse + +### Countries Types: ```python -from cloudflare.types.radar.email.routing import ( - SummaryARCResponse, - SummaryDKIMResponse, - SummaryDMARCResponse, - SummaryEncryptedResponse, - SummaryIPVersionResponse, - SummarySPFResponse, -) +from cloudflare.types.cloudforce_one.threat_events import CountryListResponse ``` Methods: -- client.radar.email.routing.summary.arc(\*\*params) -> SummaryARCResponse -- client.radar.email.routing.summary.dkim(\*\*params) -> SummaryDKIMResponse -- client.radar.email.routing.summary.dmarc(\*\*params) -> SummaryDMARCResponse -- client.radar.email.routing.summary.encrypted(\*\*params) -> SummaryEncryptedResponse -- client.radar.email.routing.summary.ip_version(\*\*params) -> SummaryIPVersionResponse -- client.radar.email.routing.summary.spf(\*\*params) -> SummarySPFResponse +- client.cloudforce_one.threat_events.countries.list(\*, account_id) -> CountryListResponse -#### TimeseriesGroups +### Datasets Types: ```python -from cloudflare.types.radar.email.routing import ( - TimeseriesGroupARCResponse, - TimeseriesGroupDKIMResponse, - TimeseriesGroupDMARCResponse, - TimeseriesGroupEncryptedResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupSPFResponse, +from cloudflare.types.cloudforce_one.threat_events import ( + DatasetCreateResponse, + DatasetListResponse, + DatasetEditResponse, + DatasetGetResponse, + DatasetRawResponse, ) ``` -Methods: - -- client.radar.email.routing.timeseries_groups.arc(\*\*params) -> TimeseriesGroupARCResponse -- client.radar.email.routing.timeseries_groups.dkim(\*\*params) -> TimeseriesGroupDKIMResponse -- client.radar.email.routing.timeseries_groups.dmarc(\*\*params) -> TimeseriesGroupDMARCResponse -- client.radar.email.routing.timeseries_groups.encrypted(\*\*params) -> TimeseriesGroupEncryptedResponse -- client.radar.email.routing.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse -- client.radar.email.routing.timeseries_groups.spf(\*\*params) -> TimeseriesGroupSPFResponse - -### Security +Methods: -#### Top +- client.cloudforce_one.threat_events.datasets.create(\*, account_id, \*\*params) -> DatasetCreateResponse +- client.cloudforce_one.threat_events.datasets.list(\*, account_id) -> DatasetListResponse +- client.cloudforce_one.threat_events.datasets.edit(dataset_id, \*, account_id, \*\*params) -> DatasetEditResponse +- client.cloudforce_one.threat_events.datasets.get(dataset_id, \*, account_id) -> DatasetGetResponse +- client.cloudforce_one.threat_events.datasets.raw(event_id, \*, account_id, dataset_id) -> DatasetRawResponse -##### Tlds +### IndicatorTypes Types: ```python -from cloudflare.types.radar.email.security.top import TldGetResponse +from cloudflare.types.cloudforce_one.threat_events import IndicatorTypeListResponse ``` Methods: -- client.radar.email.security.top.tlds.get(\*\*params) -> TldGetResponse +- client.cloudforce_one.threat_events.indicator_types.list(\*, account_id) -> IndicatorTypeListResponse -###### Malicious +### Raw Types: ```python -from cloudflare.types.radar.email.security.top.tlds import MaliciousGetResponse +from cloudflare.types.cloudforce_one.threat_events import RawEditResponse, RawGetResponse ``` Methods: -- client.radar.email.security.top.tlds.malicious.get(malicious, \*\*params) -> MaliciousGetResponse +- client.cloudforce_one.threat_events.raw.edit(raw_id, \*, account_id, event_id, \*\*params) -> RawEditResponse +- client.cloudforce_one.threat_events.raw.get(raw_id, \*, account_id, event_id) -> RawGetResponse -###### Spam +### Relate Types: ```python -from cloudflare.types.radar.email.security.top.tlds import SpamGetResponse +from cloudflare.types.cloudforce_one.threat_events import RelateDeleteResponse ``` Methods: -- client.radar.email.security.top.tlds.spam.get(spam, \*\*params) -> SpamGetResponse +- client.cloudforce_one.threat_events.relate.delete(event_id, \*, account_id) -> RelateDeleteResponse -###### Spoof +### Tags Types: ```python -from cloudflare.types.radar.email.security.top.tlds import SpoofGetResponse +from cloudflare.types.cloudforce_one.threat_events import TagCreateResponse ``` Methods: -- client.radar.email.security.top.tlds.spoof.get(spoof, \*\*params) -> SpoofGetResponse +- client.cloudforce_one.threat_events.tags.create(\*, account_id, \*\*params) -> TagCreateResponse -#### Summary +### EventTags Types: ```python -from cloudflare.types.radar.email.security import ( - SummaryARCResponse, - SummaryDKIMResponse, - SummaryDMARCResponse, - SummaryMaliciousResponse, - SummarySpamResponse, - SummarySPFResponse, - SummarySpoofResponse, - SummaryThreatCategoryResponse, - SummaryTLSVersionResponse, +from cloudflare.types.cloudforce_one.threat_events import ( + EventTagCreateResponse, + EventTagDeleteResponse, ) ``` Methods: -- client.radar.email.security.summary.arc(\*\*params) -> SummaryARCResponse -- client.radar.email.security.summary.dkim(\*\*params) -> SummaryDKIMResponse -- client.radar.email.security.summary.dmarc(\*\*params) -> SummaryDMARCResponse -- client.radar.email.security.summary.malicious(\*\*params) -> SummaryMaliciousResponse -- client.radar.email.security.summary.spam(\*\*params) -> SummarySpamResponse -- client.radar.email.security.summary.spf(\*\*params) -> SummarySPFResponse -- client.radar.email.security.summary.spoof(\*\*params) -> SummarySpoofResponse -- client.radar.email.security.summary.threat_category(\*\*params) -> SummaryThreatCategoryResponse -- client.radar.email.security.summary.tls_version(\*\*params) -> SummaryTLSVersionResponse +- client.cloudforce_one.threat_events.event_tags.create(event_id, \*, account_id, \*\*params) -> EventTagCreateResponse +- client.cloudforce_one.threat_events.event_tags.delete(event_id, \*, account_id) -> EventTagDeleteResponse -#### TimeseriesGroups +### TargetIndustries Types: ```python -from cloudflare.types.radar.email.security import ( - TimeseriesGroupARCResponse, - TimeseriesGroupDKIMResponse, - TimeseriesGroupDMARCResponse, - TimeseriesGroupMaliciousResponse, - TimeseriesGroupSpamResponse, - TimeseriesGroupSPFResponse, - TimeseriesGroupSpoofResponse, - TimeseriesGroupThreatCategoryResponse, - TimeseriesGroupTLSVersionResponse, -) +from cloudflare.types.cloudforce_one.threat_events import TargetIndustryListResponse ``` Methods: -- client.radar.email.security.timeseries_groups.arc(\*\*params) -> TimeseriesGroupARCResponse -- client.radar.email.security.timeseries_groups.dkim(\*\*params) -> TimeseriesGroupDKIMResponse -- client.radar.email.security.timeseries_groups.dmarc(\*\*params) -> TimeseriesGroupDMARCResponse -- client.radar.email.security.timeseries_groups.malicious(\*\*params) -> TimeseriesGroupMaliciousResponse -- client.radar.email.security.timeseries_groups.spam(\*\*params) -> TimeseriesGroupSpamResponse -- client.radar.email.security.timeseries_groups.spf(\*\*params) -> TimeseriesGroupSPFResponse -- client.radar.email.security.timeseries_groups.spoof(\*\*params) -> TimeseriesGroupSpoofResponse -- client.radar.email.security.timeseries_groups.threat_category(\*\*params) -> TimeseriesGroupThreatCategoryResponse -- client.radar.email.security.timeseries_groups.tls_version(\*\*params) -> TimeseriesGroupTLSVersionResponse - -## Attacks +- client.cloudforce_one.threat_events.target_industries.list(\*, account_id, \*\*params) -> TargetIndustryListResponse -### Layer3 +# AIGateway Types: ```python -from cloudflare.types.radar.attacks import Layer3TimeseriesResponse +from cloudflare.types.ai_gateway import ( + AIGatewayCreateResponse, + AIGatewayUpdateResponse, + AIGatewayListResponse, + AIGatewayDeleteResponse, + AIGatewayGetResponse, +) ``` Methods: -- client.radar.attacks.layer3.timeseries(\*\*params) -> Layer3TimeseriesResponse +- client.ai_gateway.create(\*, account_id, \*\*params) -> AIGatewayCreateResponse +- client.ai_gateway.update(id, \*, account_id, \*\*params) -> AIGatewayUpdateResponse +- client.ai_gateway.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AIGatewayListResponse] +- client.ai_gateway.delete(id, \*, account_id) -> AIGatewayDeleteResponse +- client.ai_gateway.get(id, \*, account_id) -> AIGatewayGetResponse -#### Summary +## EvaluationTypes Types: ```python -from cloudflare.types.radar.attacks.layer3 import ( - SummaryBitrateResponse, - SummaryDurationResponse, - SummaryGetResponse, - SummaryIPVersionResponse, - SummaryProtocolResponse, - SummaryVectorResponse, -) +from cloudflare.types.ai_gateway import EvaluationTypeListResponse ``` Methods: -- client.radar.attacks.layer3.summary.bitrate(\*\*params) -> SummaryBitrateResponse -- client.radar.attacks.layer3.summary.duration(\*\*params) -> SummaryDurationResponse -- client.radar.attacks.layer3.summary.get(\*\*params) -> SummaryGetResponse -- client.radar.attacks.layer3.summary.ip_version(\*\*params) -> SummaryIPVersionResponse -- client.radar.attacks.layer3.summary.protocol(\*\*params) -> SummaryProtocolResponse -- client.radar.attacks.layer3.summary.vector(\*\*params) -> SummaryVectorResponse +- client.ai_gateway.evaluation_types.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[EvaluationTypeListResponse] -#### TimeseriesGroups +## Logs Types: ```python -from cloudflare.types.radar.attacks.layer3 import ( - TimeseriesGroupBitrateResponse, - TimeseriesGroupDurationResponse, - TimeseriesGroupGetResponse, - TimeseriesGroupIndustryResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupProtocolResponse, - TimeseriesGroupVectorResponse, - TimeseriesGroupVerticalResponse, -) +from cloudflare.types.ai_gateway import LogListResponse, LogDeleteResponse, LogGetResponse ``` Methods: -- client.radar.attacks.layer3.timeseries_groups.bitrate(\*\*params) -> TimeseriesGroupBitrateResponse -- client.radar.attacks.layer3.timeseries_groups.duration(\*\*params) -> TimeseriesGroupDurationResponse -- client.radar.attacks.layer3.timeseries_groups.get(\*\*params) -> TimeseriesGroupGetResponse -- client.radar.attacks.layer3.timeseries_groups.industry(\*\*params) -> TimeseriesGroupIndustryResponse -- client.radar.attacks.layer3.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse -- client.radar.attacks.layer3.timeseries_groups.protocol(\*\*params) -> TimeseriesGroupProtocolResponse -- client.radar.attacks.layer3.timeseries_groups.vector(\*\*params) -> TimeseriesGroupVectorResponse -- client.radar.attacks.layer3.timeseries_groups.vertical(\*\*params) -> TimeseriesGroupVerticalResponse +- client.ai_gateway.logs.list(gateway_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse] +- client.ai_gateway.logs.delete(gateway_id, \*, account_id, \*\*params) -> LogDeleteResponse +- client.ai_gateway.logs.edit(id, \*, account_id, gateway_id, \*\*params) -> object +- client.ai_gateway.logs.get(id, \*, account_id, gateway_id) -> LogGetResponse +- client.ai_gateway.logs.request(id, \*, account_id, gateway_id) -> object +- client.ai_gateway.logs.response(id, \*, account_id, gateway_id) -> object -#### Top +## Datasets Types: ```python -from cloudflare.types.radar.attacks.layer3 import ( - TopAttacksResponse, - TopIndustryResponse, - TopVerticalResponse, +from cloudflare.types.ai_gateway import ( + DatasetCreateResponse, + DatasetUpdateResponse, + DatasetListResponse, + DatasetDeleteResponse, + DatasetGetResponse, ) ``` Methods: -- client.radar.attacks.layer3.top.attacks(\*\*params) -> TopAttacksResponse -- client.radar.attacks.layer3.top.industry(\*\*params) -> TopIndustryResponse -- client.radar.attacks.layer3.top.vertical(\*\*params) -> TopVerticalResponse +- client.ai_gateway.datasets.create(gateway_id, \*, account_id, \*\*params) -> DatasetCreateResponse +- client.ai_gateway.datasets.update(id, \*, account_id, gateway_id, \*\*params) -> DatasetUpdateResponse +- client.ai_gateway.datasets.list(gateway_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[DatasetListResponse] +- client.ai_gateway.datasets.delete(id, \*, account_id, gateway_id) -> DatasetDeleteResponse +- client.ai_gateway.datasets.get(id, \*, account_id, gateway_id) -> DatasetGetResponse -##### Locations +## Evaluations Types: ```python -from cloudflare.types.radar.attacks.layer3.top import LocationOriginResponse, LocationTargetResponse +from cloudflare.types.ai_gateway import ( + EvaluationCreateResponse, + EvaluationListResponse, + EvaluationDeleteResponse, + EvaluationGetResponse, +) ``` Methods: -- client.radar.attacks.layer3.top.locations.origin(\*\*params) -> LocationOriginResponse -- client.radar.attacks.layer3.top.locations.target(\*\*params) -> LocationTargetResponse +- client.ai_gateway.evaluations.create(gateway_id, \*, account_id, \*\*params) -> EvaluationCreateResponse +- client.ai_gateway.evaluations.list(gateway_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[EvaluationListResponse] +- client.ai_gateway.evaluations.delete(id, \*, account_id, gateway_id) -> EvaluationDeleteResponse +- client.ai_gateway.evaluations.get(id, \*, account_id, gateway_id) -> EvaluationGetResponse -### Layer7 +## DynamicRouting Types: ```python -from cloudflare.types.radar.attacks import Layer7TimeseriesResponse +from cloudflare.types.ai_gateway import ( + DynamicRoutingCreateResponse, + DynamicRoutingUpdateResponse, + DynamicRoutingListResponse, + DynamicRoutingDeleteResponse, + DynamicRoutingCreateDeploymentResponse, + DynamicRoutingCreateVersionResponse, + DynamicRoutingGetResponse, + DynamicRoutingGetVersionResponse, + DynamicRoutingListDeploymentsResponse, + DynamicRoutingListVersionsResponse, +) ``` Methods: -- client.radar.attacks.layer7.timeseries(\*\*params) -> Layer7TimeseriesResponse +- client.ai_gateway.dynamic_routing.create(gateway_id, \*, account_id, \*\*params) -> DynamicRoutingCreateResponse +- client.ai_gateway.dynamic_routing.update(id, \*, account_id, gateway_id, \*\*params) -> DynamicRoutingUpdateResponse +- client.ai_gateway.dynamic_routing.list(gateway_id, \*, account_id) -> DynamicRoutingListResponse +- client.ai_gateway.dynamic_routing.delete(id, \*, account_id, gateway_id) -> DynamicRoutingDeleteResponse +- client.ai_gateway.dynamic_routing.create_deployment(id, \*, account_id, gateway_id, \*\*params) -> DynamicRoutingCreateDeploymentResponse +- client.ai_gateway.dynamic_routing.create_version(id, \*, account_id, gateway_id, \*\*params) -> DynamicRoutingCreateVersionResponse +- client.ai_gateway.dynamic_routing.get(id, \*, account_id, gateway_id) -> DynamicRoutingGetResponse +- client.ai_gateway.dynamic_routing.get_version(version_id, \*, account_id, gateway_id, id) -> DynamicRoutingGetVersionResponse +- client.ai_gateway.dynamic_routing.list_deployments(id, \*, account_id, gateway_id) -> DynamicRoutingListDeploymentsResponse +- client.ai_gateway.dynamic_routing.list_versions(id, \*, account_id, gateway_id) -> DynamicRoutingListVersionsResponse -#### Summary +## ProviderConfigs Types: ```python -from cloudflare.types.radar.attacks.layer7 import ( - SummaryGetResponse, - SummaryHTTPMethodResponse, - SummaryHTTPVersionResponse, - SummaryIPVersionResponse, - SummaryManagedRulesResponse, - SummaryMitigationProductResponse, -) +from cloudflare.types.ai_gateway import ProviderConfigCreateResponse, ProviderConfigListResponse ``` Methods: -- client.radar.attacks.layer7.summary.get(\*\*params) -> SummaryGetResponse -- client.radar.attacks.layer7.summary.http_method(\*\*params) -> SummaryHTTPMethodResponse -- client.radar.attacks.layer7.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse -- client.radar.attacks.layer7.summary.ip_version(\*\*params) -> SummaryIPVersionResponse -- client.radar.attacks.layer7.summary.managed_rules(\*\*params) -> SummaryManagedRulesResponse -- client.radar.attacks.layer7.summary.mitigation_product(\*\*params) -> SummaryMitigationProductResponse +- client.ai_gateway.provider_configs.create(gateway_id, \*, account_id, \*\*params) -> ProviderConfigCreateResponse +- client.ai_gateway.provider_configs.list(gateway_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ProviderConfigListResponse] -#### TimeseriesGroups +## URLs Types: ```python -from cloudflare.types.radar.attacks.layer7 import ( - TimeseriesGroupGetResponse, - TimeseriesGroupHTTPMethodResponse, - TimeseriesGroupHTTPVersionResponse, - TimeseriesGroupIndustryResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupManagedRulesResponse, - TimeseriesGroupMitigationProductResponse, - TimeseriesGroupVerticalResponse, -) +from cloudflare.types.ai_gateway import URLGetResponse ``` Methods: -- client.radar.attacks.layer7.timeseries_groups.get(\*\*params) -> TimeseriesGroupGetResponse -- client.radar.attacks.layer7.timeseries_groups.http_method(\*\*params) -> TimeseriesGroupHTTPMethodResponse -- client.radar.attacks.layer7.timeseries_groups.http_version(\*\*params) -> TimeseriesGroupHTTPVersionResponse -- client.radar.attacks.layer7.timeseries_groups.industry(\*\*params) -> TimeseriesGroupIndustryResponse -- client.radar.attacks.layer7.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse -- client.radar.attacks.layer7.timeseries_groups.managed_rules(\*\*params) -> TimeseriesGroupManagedRulesResponse -- client.radar.attacks.layer7.timeseries_groups.mitigation_product(\*\*params) -> TimeseriesGroupMitigationProductResponse -- client.radar.attacks.layer7.timeseries_groups.vertical(\*\*params) -> TimeseriesGroupVerticalResponse +- client.ai_gateway.urls.get(provider, \*, account_id, gateway_id) -> str -#### Top +# IAM + +## PermissionGroups Types: ```python -from cloudflare.types.radar.attacks.layer7 import ( - TopAttacksResponse, - TopIndustryResponse, - TopVerticalResponse, -) +from cloudflare.types.iam import PermissionGroupListResponse, PermissionGroupGetResponse ``` Methods: -- client.radar.attacks.layer7.top.attacks(\*\*params) -> TopAttacksResponse -- client.radar.attacks.layer7.top.industry(\*\*params) -> TopIndustryResponse -- client.radar.attacks.layer7.top.vertical(\*\*params) -> TopVerticalResponse +- client.iam.permission_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PermissionGroupListResponse] +- client.iam.permission_groups.get(permission_group_id, \*, account_id) -> Optional[PermissionGroupGetResponse] -##### Locations +## ResourceGroups Types: ```python -from cloudflare.types.radar.attacks.layer7.top import LocationOriginResponse, LocationTargetResponse +from cloudflare.types.iam import ( + ResourceGroupCreateResponse, + ResourceGroupUpdateResponse, + ResourceGroupListResponse, + ResourceGroupDeleteResponse, + ResourceGroupGetResponse, +) ``` Methods: -- client.radar.attacks.layer7.top.locations.origin(\*\*params) -> LocationOriginResponse -- client.radar.attacks.layer7.top.locations.target(\*\*params) -> LocationTargetResponse +- client.iam.resource_groups.create(\*, account_id, \*\*params) -> Optional[ResourceGroupCreateResponse] +- client.iam.resource_groups.update(resource_group_id, \*, account_id, \*\*params) -> Optional[ResourceGroupUpdateResponse] +- client.iam.resource_groups.list(\*, account_id, \*\*params) -> SyncSinglePage[ResourceGroupListResponse] +- client.iam.resource_groups.delete(resource_group_id, \*, account_id) -> Optional[ResourceGroupDeleteResponse] +- client.iam.resource_groups.get(resource_group_id, \*, account_id) -> Optional[ResourceGroupGetResponse] -##### Ases +## UserGroups Types: ```python -from cloudflare.types.radar.attacks.layer7.top import AseOriginResponse +from cloudflare.types.iam import ( + UserGroupCreateResponse, + UserGroupUpdateResponse, + UserGroupListResponse, + UserGroupDeleteResponse, + UserGroupGetResponse, +) ``` Methods: -- client.radar.attacks.layer7.top.ases.origin(\*\*params) -> AseOriginResponse +- client.iam.user_groups.create(\*, account_id, \*\*params) -> Optional[UserGroupCreateResponse] +- client.iam.user_groups.update(user_group_id, \*, account_id, \*\*params) -> Optional[UserGroupUpdateResponse] +- client.iam.user_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[UserGroupListResponse] +- client.iam.user_groups.delete(user_group_id, \*, account_id) -> Optional[UserGroupDeleteResponse] +- client.iam.user_groups.get(user_group_id, \*, account_id) -> Optional[UserGroupGetResponse] -## Entities +### Members Types: ```python -from cloudflare.types.radar import EntityGetResponse +from cloudflare.types.iam.user_groups import ( + MemberCreateResponse, + MemberUpdateResponse, + MemberListResponse, + MemberDeleteResponse, +) ``` Methods: -- client.radar.entities.get(\*\*params) -> EntityGetResponse +- client.iam.user_groups.members.create(user_group_id, \*, account_id, \*\*params) -> Optional[MemberCreateResponse] +- client.iam.user_groups.members.update(user_group_id, \*, account_id, \*\*params) -> SyncSinglePage[MemberUpdateResponse] +- client.iam.user_groups.members.list(user_group_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] +- client.iam.user_groups.members.delete(member_id, \*, account_id, user_group_id) -> Optional[MemberDeleteResponse] -### ASNs +## SSO Types: ```python -from cloudflare.types.radar.entities import ( - ASNListResponse, - ASNGetResponse, - ASNIPResponse, - ASNRelResponse, +from cloudflare.types.iam import ( + SSOCreateResponse, + SSOUpdateResponse, + SSOListResponse, + SSODeleteResponse, + SSOBeginVerificationResponse, + SSOGetResponse, ) ``` Methods: -- client.radar.entities.asns.list(\*\*params) -> ASNListResponse -- client.radar.entities.asns.get(asn, \*\*params) -> ASNGetResponse -- client.radar.entities.asns.ip(\*\*params) -> ASNIPResponse -- client.radar.entities.asns.rel(asn, \*\*params) -> ASNRelResponse +- client.iam.sso.create(\*, account_id, \*\*params) -> Optional[SSOCreateResponse] +- client.iam.sso.update(sso_connector_id, \*, account_id, \*\*params) -> Optional[SSOUpdateResponse] +- client.iam.sso.list(\*, account_id) -> SyncSinglePage[SSOListResponse] +- client.iam.sso.delete(sso_connector_id, \*, account_id) -> Optional[SSODeleteResponse] +- client.iam.sso.begin_verification(sso_connector_id, \*, account_id) -> SSOBeginVerificationResponse +- client.iam.sso.get(sso_connector_id, \*, account_id) -> Optional[SSOGetResponse] -### Locations +# CloudConnector + +## Rules Types: ```python -from cloudflare.types.radar.entities import LocationListResponse, LocationGetResponse +from cloudflare.types.cloud_connector import RuleUpdateResponse, RuleListResponse ``` Methods: -- client.radar.entities.locations.list(\*\*params) -> LocationListResponse -- client.radar.entities.locations.get(location, \*\*params) -> LocationGetResponse +- client.cloud_connector.rules.update(\*, zone_id, \*\*params) -> SyncSinglePage[RuleUpdateResponse] +- client.cloud_connector.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] -## HTTP +# BotnetFeed + +## ASN Types: ```python -from cloudflare.types.radar import HTTPTimeseriesResponse +from cloudflare.types.botnet_feed import ASNDayReportResponse, ASNFullReportResponse ``` Methods: -- client.radar.http.timeseries(\*\*params) -> HTTPTimeseriesResponse +- client.botnet_feed.asn.day_report(asn_id, \*, account_id, \*\*params) -> Optional[ASNDayReportResponse] +- client.botnet_feed.asn.full_report(asn_id, \*, account_id) -> Optional[ASNFullReportResponse] -### Top +## Configs + +### ASN Types: ```python -from cloudflare.types.radar.http import Browser, TopBrowserFamiliesResponse, TopBrowsersResponse +from cloudflare.types.botnet_feed.configs import ASNDeleteResponse, ASNGetResponse ``` Methods: -- client.radar.http.top.browser_families(\*\*params) -> TopBrowserFamiliesResponse -- client.radar.http.top.browsers(\*\*params) -> TopBrowsersResponse +- client.botnet_feed.configs.asn.delete(asn_id, \*, account_id) -> Optional[ASNDeleteResponse] +- client.botnet_feed.configs.asn.get(\*, account_id) -> Optional[ASNGetResponse] -### Locations +# SecurityTXT Types: ```python -from cloudflare.types.radar.http import LocationGetResponse +from cloudflare.types.security_txt import ( + SecurityTXTUpdateResponse, + SecurityTXTDeleteResponse, + SecurityTXTGetResponse, +) ``` Methods: -- client.radar.http.locations.get(\*\*params) -> LocationGetResponse +- client.security_txt.update(\*, zone_id, \*\*params) -> SecurityTXTUpdateResponse +- client.security_txt.delete(\*, zone_id) -> SecurityTXTDeleteResponse +- client.security_txt.get(\*, zone_id) -> Optional[SecurityTXTGetResponse] -#### BotClass +# Workflows Types: ```python -from cloudflare.types.radar.http.locations import BotClassGetResponse +from cloudflare.types.workflows import ( + WorkflowUpdateResponse, + WorkflowListResponse, + WorkflowDeleteResponse, + WorkflowGetResponse, +) ``` Methods: -- client.radar.http.locations.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse +- client.workflows.update(workflow_name, \*, account_id, \*\*params) -> WorkflowUpdateResponse +- client.workflows.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[WorkflowListResponse] +- client.workflows.delete(workflow_name, \*, account_id) -> WorkflowDeleteResponse +- client.workflows.get(workflow_name, \*, account_id) -> WorkflowGetResponse -#### DeviceType +## Instances Types: ```python -from cloudflare.types.radar.http.locations import DeviceTypeGetResponse +from cloudflare.types.workflows import ( + InstanceCreateResponse, + InstanceListResponse, + InstanceBulkResponse, + InstanceGetResponse, +) ``` Methods: -- client.radar.http.locations.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse +- client.workflows.instances.create(workflow_name, \*, account_id, \*\*params) -> InstanceCreateResponse +- client.workflows.instances.list(workflow_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[InstanceListResponse] +- client.workflows.instances.bulk(workflow_name, \*, account_id, \*\*params) -> SyncSinglePage[InstanceBulkResponse] +- client.workflows.instances.get(instance_id, \*, account_id, workflow_name) -> InstanceGetResponse -#### HTTPProtocol +### Status Types: ```python -from cloudflare.types.radar.http.locations import HTTPProtocolGetResponse +from cloudflare.types.workflows.instances import StatusEditResponse ``` Methods: -- client.radar.http.locations.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse +- client.workflows.instances.status.edit(instance_id, \*, account_id, workflow_name, \*\*params) -> StatusEditResponse -#### HTTPMethod +### Events + +Methods: + +- client.workflows.instances.events.create(event_type, \*, account_id, workflow_name, instance_id, \*\*params) -> object + +## Versions Types: ```python -from cloudflare.types.radar.http.locations import HTTPMethodGetResponse +from cloudflare.types.workflows import VersionListResponse, VersionGetResponse ``` Methods: -- client.radar.http.locations.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse +- client.workflows.versions.list(workflow_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[VersionListResponse] +- client.workflows.versions.get(version_id, \*, account_id, workflow_name) -> VersionGetResponse -#### IPVersion +# ResourceSharing Types: ```python -from cloudflare.types.radar.http.locations import IPVersionGetResponse +from cloudflare.types.resource_sharing import ( + ResourceSharingCreateResponse, + ResourceSharingUpdateResponse, + ResourceSharingListResponse, + ResourceSharingDeleteResponse, + ResourceSharingGetResponse, +) ``` Methods: -- client.radar.http.locations.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse +- client.resource_sharing.create(\*, account_id, \*\*params) -> Optional[ResourceSharingCreateResponse] +- client.resource_sharing.update(share_id, \*, account_id, \*\*params) -> Optional[ResourceSharingUpdateResponse] +- client.resource_sharing.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceSharingListResponse] +- client.resource_sharing.delete(share_id, \*, account_id) -> Optional[ResourceSharingDeleteResponse] +- client.resource_sharing.get(share_id, \*, account_id, \*\*params) -> Optional[ResourceSharingGetResponse] -#### OS +## Recipients Types: ```python -from cloudflare.types.radar.http.locations import OSGetResponse +from cloudflare.types.resource_sharing import ( + RecipientCreateResponse, + RecipientListResponse, + RecipientDeleteResponse, + RecipientGetResponse, +) ``` Methods: -- client.radar.http.locations.os.get(os, \*\*params) -> OSGetResponse +- client.resource_sharing.recipients.create(share_id, \*, path_account_id, \*\*params) -> Optional[RecipientCreateResponse] +- client.resource_sharing.recipients.list(share_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[RecipientListResponse] +- client.resource_sharing.recipients.delete(recipient_id, \*, account_id, share_id) -> Optional[RecipientDeleteResponse] +- client.resource_sharing.recipients.get(recipient_id, \*, account_id, share_id, \*\*params) -> Optional[RecipientGetResponse] -#### TLSVersion +## Resources Types: ```python -from cloudflare.types.radar.http.locations import TLSVersionGetResponse +from cloudflare.types.resource_sharing import ( + ResourceCreateResponse, + ResourceUpdateResponse, + ResourceListResponse, + ResourceDeleteResponse, + ResourceGetResponse, +) ``` Methods: -- client.radar.http.locations.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse +- client.resource_sharing.resources.create(share_id, \*, account_id, \*\*params) -> Optional[ResourceCreateResponse] +- client.resource_sharing.resources.update(resource_id, \*, account_id, share_id, \*\*params) -> Optional[ResourceUpdateResponse] +- client.resource_sharing.resources.list(share_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceListResponse] +- client.resource_sharing.resources.delete(resource_id, \*, account_id, share_id) -> Optional[ResourceDeleteResponse] +- client.resource_sharing.resources.get(resource_id, \*, account_id, share_id) -> Optional[ResourceGetResponse] -#### BrowserFamily +# LeakedCredentialChecks Types: ```python -from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse +from cloudflare.types.leaked_credential_checks import ( + LeakedCredentialCheckCreateResponse, + LeakedCredentialCheckGetResponse, +) ``` Methods: -- client.radar.http.locations.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse +- client.leaked_credential_checks.create(\*, zone_id, \*\*params) -> LeakedCredentialCheckCreateResponse +- client.leaked_credential_checks.get(\*, zone_id) -> LeakedCredentialCheckGetResponse -### Ases +## Detections Types: ```python -from cloudflare.types.radar.http import AseGetResponse +from cloudflare.types.leaked_credential_checks import ( + DetectionCreateResponse, + DetectionUpdateResponse, + DetectionListResponse, + DetectionGetResponse, +) ``` Methods: -- client.radar.http.ases.get(\*\*params) -> AseGetResponse +- client.leaked_credential_checks.detections.create(\*, zone_id, \*\*params) -> DetectionCreateResponse +- client.leaked_credential_checks.detections.update(detection_id, \*, zone_id, \*\*params) -> DetectionUpdateResponse +- client.leaked_credential_checks.detections.list(\*, zone_id) -> SyncSinglePage[DetectionListResponse] +- client.leaked_credential_checks.detections.delete(detection_id, \*, zone_id) -> object +- client.leaked_credential_checks.detections.get(detection_id, \*, zone_id) -> DetectionGetResponse -#### BotClass +# ContentScanning Types: ```python -from cloudflare.types.radar.http.ases import BotClassGetResponse +from cloudflare.types.content_scanning import ( + ContentScanningCreateResponse, + ContentScanningUpdateResponse, + ContentScanningGetResponse, +) ``` Methods: -- client.radar.http.ases.bot_class.get(bot_class, \*\*params) -> BotClassGetResponse +- client.content_scanning.create(\*, zone_id, \*\*params) -> ContentScanningCreateResponse +- client.content_scanning.update(\*, zone_id, \*\*params) -> ContentScanningUpdateResponse +- client.content_scanning.disable(\*, zone_id) -> object +- client.content_scanning.enable(\*, zone_id) -> object +- client.content_scanning.get(\*, zone_id) -> ContentScanningGetResponse -#### DeviceType +## Payloads Types: ```python -from cloudflare.types.radar.http.ases import DeviceTypeGetResponse +from cloudflare.types.content_scanning import ( + PayloadCreateResponse, + PayloadListResponse, + PayloadDeleteResponse, +) ``` Methods: -- client.radar.http.ases.device_type.get(device_type, \*\*params) -> DeviceTypeGetResponse +- client.content_scanning.payloads.create(\*, zone_id, \*\*params) -> SyncSinglePage[PayloadCreateResponse] +- client.content_scanning.payloads.list(\*, zone_id) -> SyncSinglePage[PayloadListResponse] +- client.content_scanning.payloads.delete(expression_id, \*, zone_id) -> SyncSinglePage[PayloadDeleteResponse] -#### HTTPProtocol +## Settings Types: ```python -from cloudflare.types.radar.http.ases import HTTPProtocolGetResponse +from cloudflare.types.content_scanning import SettingGetResponse ``` Methods: -- client.radar.http.ases.http_protocol.get(http_protocol, \*\*params) -> HTTPProtocolGetResponse +- client.content_scanning.settings.get(\*, zone_id) -> SettingGetResponse -#### HTTPMethod +# AbuseReports Types: ```python -from cloudflare.types.radar.http.ases import HTTPMethodGetResponse +from cloudflare.types.abuse_reports import ( + AbuseReportCreateResponse, + AbuseReportListResponse, + AbuseReportGetResponse, +) ``` Methods: -- client.radar.http.ases.http_method.get(http_version, \*\*params) -> HTTPMethodGetResponse +- client.abuse_reports.create(report_param, \*, account_id, \*\*params) -> str +- client.abuse_reports.list(\*, account_id, \*\*params) -> SyncV4PagePagination[Optional[AbuseReportListResponse]] +- client.abuse_reports.get(report_param, \*, account_id) -> AbuseReportGetResponse -#### IPVersion +## Mitigations Types: ```python -from cloudflare.types.radar.http.ases import IPVersionGetResponse +from cloudflare.types.abuse_reports import MitigationListResponse, MitigationReviewResponse ``` Methods: -- client.radar.http.ases.ip_version.get(ip_version, \*\*params) -> IPVersionGetResponse +- client.abuse_reports.mitigations.list(report_id, \*, account_id, \*\*params) -> SyncV4PagePagination[Optional[MitigationListResponse]] +- client.abuse_reports.mitigations.review(report_id, \*, account_id, \*\*params) -> SyncSinglePage[MitigationReviewResponse] -#### OS +# AI Types: ```python -from cloudflare.types.radar.http.ases import OSGetResponse +from cloudflare.types.ai import AIRunResponse ``` Methods: -- client.radar.http.ases.os.get(os, \*\*params) -> OSGetResponse +- client.ai.run(model_name, \*, account_id, \*\*params) -> Optional[AIRunResponse] -#### TLSVersion +## Finetunes Types: ```python -from cloudflare.types.radar.http.ases import TLSVersionGetResponse +from cloudflare.types.ai import FinetuneCreateResponse, FinetuneListResponse ``` Methods: -- client.radar.http.ases.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse +- client.ai.finetunes.create(\*, account_id, \*\*params) -> FinetuneCreateResponse +- client.ai.finetunes.list(\*, account_id) -> FinetuneListResponse -#### BrowserFamily +### Assets Types: ```python -from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse +from cloudflare.types.ai.finetunes import AssetCreateResponse ``` Methods: -- client.radar.http.ases.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse +- client.ai.finetunes.assets.create(finetune_id, \*, account_id, \*\*params) -> AssetCreateResponse -### Summary +### Public Types: ```python -from cloudflare.types.radar.http import ( - SummaryBotClassResponse, - SummaryDeviceTypeResponse, - SummaryHTTPProtocolResponse, - SummaryHTTPVersionResponse, - SummaryIPVersionResponse, - SummaryOSResponse, - SummaryPostQuantumResponse, - SummaryTLSVersionResponse, -) +from cloudflare.types.ai.finetunes import PublicListResponse ``` Methods: -- client.radar.http.summary.bot_class(\*\*params) -> SummaryBotClassResponse -- client.radar.http.summary.device_type(\*\*params) -> SummaryDeviceTypeResponse -- client.radar.http.summary.http_protocol(\*\*params) -> SummaryHTTPProtocolResponse -- client.radar.http.summary.http_version(\*\*params) -> SummaryHTTPVersionResponse -- client.radar.http.summary.ip_version(\*\*params) -> SummaryIPVersionResponse -- client.radar.http.summary.os(\*\*params) -> SummaryOSResponse -- client.radar.http.summary.post_quantum(\*\*params) -> SummaryPostQuantumResponse -- client.radar.http.summary.tls_version(\*\*params) -> SummaryTLSVersionResponse +- client.ai.finetunes.public.list(\*, account_id, \*\*params) -> SyncSinglePage[PublicListResponse] -### TimeseriesGroups +## Authors -Types: +Methods: -```python -from cloudflare.types.radar.http import ( - TimeseriesGroupBotClassResponse, - TimeseriesGroupBrowserResponse, - TimeseriesGroupBrowserFamilyResponse, - TimeseriesGroupDeviceTypeResponse, - TimeseriesGroupHTTPProtocolResponse, - TimeseriesGroupHTTPVersionResponse, - TimeseriesGroupIPVersionResponse, - TimeseriesGroupOSResponse, - TimeseriesGroupPostQuantumResponse, - TimeseriesGroupTLSVersionResponse, -) -``` +- client.ai.authors.list(\*, account_id) -> SyncSinglePage[object] + +## Tasks Methods: -- client.radar.http.timeseries_groups.bot_class(\*\*params) -> TimeseriesGroupBotClassResponse -- client.radar.http.timeseries_groups.browser(\*\*params) -> TimeseriesGroupBrowserResponse -- client.radar.http.timeseries_groups.browser_family(\*\*params) -> TimeseriesGroupBrowserFamilyResponse -- client.radar.http.timeseries_groups.device_type(\*\*params) -> TimeseriesGroupDeviceTypeResponse -- client.radar.http.timeseries_groups.http_protocol(\*\*params) -> TimeseriesGroupHTTPProtocolResponse -- client.radar.http.timeseries_groups.http_version(\*\*params) -> TimeseriesGroupHTTPVersionResponse -- client.radar.http.timeseries_groups.ip_version(\*\*params) -> TimeseriesGroupIPVersionResponse -- client.radar.http.timeseries_groups.os(\*\*params) -> TimeseriesGroupOSResponse -- client.radar.http.timeseries_groups.post_quantum(\*\*params) -> TimeseriesGroupPostQuantumResponse -- client.radar.http.timeseries_groups.tls_version(\*\*params) -> TimeseriesGroupTLSVersionResponse +- client.ai.tasks.list(\*, account_id) -> SyncSinglePage[object] -## Quality +## Models -### IQI +Methods: -Types: +- client.ai.models.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] -```python -from cloudflare.types.radar.quality import IQISummaryResponse, IQITimeseriesGroupsResponse -``` +### Schema Methods: -- client.radar.quality.iqi.summary(\*\*params) -> IQISummaryResponse -- client.radar.quality.iqi.timeseries_groups(\*\*params) -> IQITimeseriesGroupsResponse +- client.ai.models.schema.get(\*, account_id, \*\*params) -> object -### Speed +## ToMarkdown Types: ```python -from cloudflare.types.radar.quality import SpeedHistogramResponse, SpeedSummaryResponse +from cloudflare.types.ai import ToMarkdownSupportedResponse, ToMarkdownTransformResponse ``` Methods: -- client.radar.quality.speed.histogram(\*\*params) -> SpeedHistogramResponse -- client.radar.quality.speed.summary(\*\*params) -> SpeedSummaryResponse +- client.ai.to_markdown.supported(\*, account_id) -> SyncSinglePage[ToMarkdownSupportedResponse] +- client.ai.to_markdown.transform(\*, account_id, \*\*params) -> SyncSinglePage[ToMarkdownTransformResponse] -#### Top +# AISearch + +## Instances Types: ```python -from cloudflare.types.radar.quality.speed import TopAsesResponse, TopLocationsResponse +from cloudflare.types.aisearch import ( + InstanceCreateResponse, + InstanceUpdateResponse, + InstanceListResponse, + InstanceDeleteResponse, + InstanceChatCompletionsResponse, + InstanceReadResponse, + InstanceSearchResponse, + InstanceStatsResponse, +) ``` Methods: -- client.radar.quality.speed.top.ases(\*\*params) -> TopAsesResponse -- client.radar.quality.speed.top.locations(\*\*params) -> TopLocationsResponse +- client.aisearch.instances.create(\*, account_id, \*\*params) -> InstanceCreateResponse +- client.aisearch.instances.update(id, \*, account_id, \*\*params) -> InstanceUpdateResponse +- client.aisearch.instances.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[InstanceListResponse] +- client.aisearch.instances.delete(id, \*, account_id) -> InstanceDeleteResponse +- client.aisearch.instances.chat_completions(id, \*, account_id, \*\*params) -> InstanceChatCompletionsResponse +- client.aisearch.instances.read(id, \*, account_id) -> InstanceReadResponse +- client.aisearch.instances.search(id, \*, account_id, \*\*params) -> InstanceSearchResponse +- client.aisearch.instances.stats(id, \*, account_id) -> InstanceStatsResponse -## Ranking +### Items Types: ```python -from cloudflare.types.radar import RankingTimeseriesGroupsResponse, RankingTopResponse +from cloudflare.types.aisearch.instances import ItemListResponse, ItemGetResponse ``` Methods: -- client.radar.ranking.timeseries_groups(\*\*params) -> RankingTimeseriesGroupsResponse -- client.radar.ranking.top(\*\*params) -> RankingTopResponse +- client.aisearch.instances.items.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ItemListResponse] +- client.aisearch.instances.items.get(item_id, \*, account_id, id) -> ItemGetResponse -### Domain +### Jobs Types: ```python -from cloudflare.types.radar.ranking import DomainGetResponse +from cloudflare.types.aisearch.instances import ( + JobCreateResponse, + JobListResponse, + JobGetResponse, + JobLogsResponse, +) ``` Methods: -- client.radar.ranking.domain.get(domain, \*\*params) -> DomainGetResponse +- client.aisearch.instances.jobs.create(id, \*, account_id) -> JobCreateResponse +- client.aisearch.instances.jobs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[JobListResponse] +- client.aisearch.instances.jobs.get(job_id, \*, account_id, id) -> JobGetResponse +- client.aisearch.instances.jobs.logs(job_id, \*, account_id, id, \*\*params) -> JobLogsResponse -## TrafficAnomalies +## Tokens Types: ```python -from cloudflare.types.radar import TrafficAnomalyGetResponse +from cloudflare.types.aisearch import ( + TokenCreateResponse, + TokenUpdateResponse, + TokenListResponse, + TokenDeleteResponse, + TokenReadResponse, +) ``` Methods: -- client.radar.traffic_anomalies.get(\*\*params) -> TrafficAnomalyGetResponse +- client.aisearch.tokens.create(\*, account_id, \*\*params) -> TokenCreateResponse +- client.aisearch.tokens.update(id, \*, account_id, \*\*params) -> TokenUpdateResponse +- client.aisearch.tokens.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[TokenListResponse] +- client.aisearch.tokens.delete(id, \*, account_id) -> TokenDeleteResponse +- client.aisearch.tokens.read(id, \*, account_id) -> TokenReadResponse -### Locations +# SecurityCenter + +## Insights Types: ```python -from cloudflare.types.radar.traffic_anomalies import LocationGetResponse +from cloudflare.types.security_center import InsightListResponse, InsightDismissResponse ``` Methods: -- client.radar.traffic_anomalies.locations.get(\*\*params) -> LocationGetResponse +- client.security_center.insights.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePagination[Optional[InsightListResponse]] +- client.security_center.insights.dismiss(issue_id, \*, account_id, zone_id, \*\*params) -> InsightDismissResponse -## TCPResetsTimeouts +### Class Types: ```python -from cloudflare.types.radar import ( - TCPResetsTimeoutSummaryResponse, - TCPResetsTimeoutTimeseriesGroupsResponse, -) +from cloudflare.types.security_center.insights import ClassGetResponse ``` Methods: -- client.radar.tcp_resets_timeouts.summary(\*\*params) -> TCPResetsTimeoutSummaryResponse -- client.radar.tcp_resets_timeouts.timeseries_groups(\*\*params) -> TCPResetsTimeoutTimeseriesGroupsResponse +- client.security*center.insights.class*.get(\*, account_id, zone_id, \*\*params) -> Optional[ClassGetResponse] -# BotManagement +### Severity Types: ```python -from cloudflare.types.bot_management import ( - BotFightModeConfiguration, - SubscriptionConfiguration, - SuperBotFightModeDefinitelyConfiguration, - SuperBotFightModeLikelyConfiguration, - BotManagementUpdateResponse, - BotManagementGetResponse, -) +from cloudflare.types.security_center.insights import SeverityGetResponse ``` Methods: -- client.bot_management.update(\*, zone_id, \*\*params) -> Optional -- client.bot_management.get(\*, zone_id) -> Optional +- client.security_center.insights.severity.get(\*, account_id, zone_id, \*\*params) -> Optional[SeverityGetResponse] -# OriginPostQuantumEncryption +### Type Types: ```python -from cloudflare.types.origin_post_quantum_encryption import ( - OriginPostQuantumEncryptionUpdateResponse, - OriginPostQuantumEncryptionGetResponse, -) +from cloudflare.types.security_center.insights import TypeGetResponse ``` Methods: -- client.origin_post_quantum_encryption.update(\*, zone_id, \*\*params) -> OriginPostQuantumEncryptionUpdateResponse -- client.origin_post_quantum_encryption.get(\*, zone_id) -> OriginPostQuantumEncryptionGetResponse +- client.security_center.insights.type.get(\*, account_id, zone_id, \*\*params) -> Optional[TypeGetResponse] -# Speed +# BrowserRendering + +## Content Types: ```python -from cloudflare.types.speed import LabeledRegion, LighthouseReport, Trend +from cloudflare.types.browser_rendering import ContentCreateResponse ``` -## Schedule +Methods: -Types: +- client.browser_rendering.content.create(\*, account_id, \*\*params) -> str -```python -from cloudflare.types.speed import Schedule, ScheduleCreateResponse, ScheduleDeleteResponse -``` +## PDF Methods: -- client.speed.schedule.create(url, \*, zone_id, \*\*params) -> Optional -- client.speed.schedule.delete(url, \*, zone_id, \*\*params) -> Optional -- client.speed.schedule.get(url, \*, zone_id, \*\*params) -> Optional +- client.browser_rendering.pdf.create(\*, account_id, \*\*params) -> BinaryAPIResponse -## Availabilities +## Scrape Types: ```python -from cloudflare.types.speed import Availability +from cloudflare.types.browser_rendering import ScrapeCreateResponse ``` Methods: -- client.speed.availabilities.list(\*, zone_id) -> Optional +- client.browser_rendering.scrape.create(\*, account_id, \*\*params) -> ScrapeCreateResponse -## Pages +## Screenshot Types: ```python -from cloudflare.types.speed import PageListResponse +from cloudflare.types.browser_rendering import ScreenshotCreateResponse ``` Methods: -- client.speed.pages.list(\*, zone_id) -> SyncSinglePage[PageListResponse] -- client.speed.pages.trend(url, \*, zone_id, \*\*params) -> Optional +- client.browser_rendering.screenshot.create(\*, account_id, \*\*params) -> ScreenshotCreateResponse -### Tests +## Snapshot Types: ```python -from cloudflare.types.speed.pages import Test, TestListResponse, TestDeleteResponse +from cloudflare.types.browser_rendering import SnapshotCreateResponse ``` Methods: -- client.speed.pages.tests.create(url, \*, zone_id, \*\*params) -> Optional -- client.speed.pages.tests.list(url, \*, zone_id, \*\*params) -> TestListResponse -- client.speed.pages.tests.delete(url, \*, zone_id, \*\*params) -> Optional -- client.speed.pages.tests.get(test_id, \*, zone_id, url) -> Optional +- client.browser_rendering.snapshot.create(\*, account_id, \*\*params) -> Optional[SnapshotCreateResponse] -# DCVDelegation +## Json Types: ```python -from cloudflare.types.dcv_delegation import DCVDelegationUUID +from cloudflare.types.browser_rendering import JsonCreateResponse ``` Methods: -- client.dcv_delegation.get(\*, zone_id) -> Optional - -# Hostnames - -## Settings +- client.browser_rendering.json.create(\*, account_id, \*\*params) -> JsonCreateResponse -### TLS +## Links Types: ```python -from cloudflare.types.hostnames.settings import ( - Setting, - SettingValue, - TLSDeleteResponse, - TLSGetResponse, -) +from cloudflare.types.browser_rendering import LinkCreateResponse ``` Methods: -- client.hostnames.settings.tls.update(hostname, \*, zone_id, setting_id, \*\*params) -> Optional -- client.hostnames.settings.tls.delete(hostname, \*, zone_id, setting_id) -> Optional -- client.hostnames.settings.tls.get(setting_id, \*, zone_id) -> Optional +- client.browser_rendering.links.create(\*, account_id, \*\*params) -> LinkCreateResponse -# Snippets +## Markdown Types: ```python -from cloudflare.types.snippets import Snippet, SnippetDeleteResponse +from cloudflare.types.browser_rendering import MarkdownCreateResponse ``` Methods: -- client.snippets.update(snippet_name, \*, zone_id, \*\*params) -> Optional -- client.snippets.list(\*, zone_id) -> SyncSinglePage[Snippet] -- client.snippets.delete(snippet_name, \*, zone_id) -> SnippetDeleteResponse -- client.snippets.get(snippet_name, \*, zone_id) -> Optional - -## Content - -Methods: - -- client.snippets.content.get(snippet_name, \*, zone_id) -> BinaryAPIResponse +- client.browser_rendering.markdown.create(\*, account_id, \*\*params) -> str -## Rules +# CustomPages Types: ```python -from cloudflare.types.snippets import RuleUpdateResponse, RuleListResponse +from cloudflare.types.custom_pages import ( + CustomPageUpdateResponse, + CustomPageListResponse, + CustomPageGetResponse, +) ``` Methods: -- client.snippets.rules.update(\*, zone_id, \*\*params) -> Optional -- client.snippets.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] +- client.custom_pages.update(identifier, \*, account_id, zone_id, \*\*params) -> Optional[CustomPageUpdateResponse] +- client.custom_pages.list(\*, account_id, zone_id) -> SyncSinglePage[CustomPageListResponse] +- client.custom_pages.get(identifier, \*, account_id, zone_id) -> Optional[CustomPageGetResponse] -# Calls +# SecretsStore + +## Stores Types: ```python -from cloudflare.types.calls import CallsApp, CallsAppWithSecret, CallListResponse +from cloudflare.types.secrets_store import ( + StoreCreateResponse, + StoreListResponse, + StoreDeleteResponse, +) ``` Methods: -- client.calls.create(\*, account_id, \*\*params) -> Optional -- client.calls.update(app_id, \*, account_id, \*\*params) -> Optional -- client.calls.list(\*, account_id) -> SyncSinglePage[CallListResponse] -- client.calls.delete(app_id, \*, account_id) -> Optional -- client.calls.get(app_id, \*, account_id) -> Optional - -## TURN +- client.secrets_store.stores.create(\*, account_id, \*\*params) -> SyncSinglePage[StoreCreateResponse] +- client.secrets_store.stores.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[StoreListResponse] +- client.secrets_store.stores.delete(store_id, \*, account_id) -> Optional[StoreDeleteResponse] -### Keys +### Secrets Types: ```python -from cloudflare.types.calls.turn import ( - KeyCreateResponse, - KeyUpdateResponse, - KeyListResponse, - KeyDeleteResponse, - KeyGetResponse, +from cloudflare.types.secrets_store.stores import ( + SecretCreateResponse, + SecretListResponse, + SecretDeleteResponse, + SecretBulkDeleteResponse, + SecretDuplicateResponse, + SecretEditResponse, + SecretGetResponse, ) ``` Methods: -- client.calls.turn.keys.create(\*, account_id, \*\*params) -> KeyCreateResponse -- client.calls.turn.keys.update(key_id, \*, account_id, \*\*params) -> str -- client.calls.turn.keys.list(\*, account_id) -> SyncSinglePage[KeyListResponse] -- client.calls.turn.keys.delete(key_id, \*, account_id) -> str -- client.calls.turn.keys.get(key_id, \*, account_id) -> str - -# CloudforceOne +- client.secrets_store.stores.secrets.create(store_id, \*, account_id, \*\*params) -> SyncSinglePage[SecretCreateResponse] +- client.secrets_store.stores.secrets.list(store_id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[SecretListResponse] +- client.secrets_store.stores.secrets.delete(secret_id, \*, account_id, store_id) -> Optional[SecretDeleteResponse] +- client.secrets_store.stores.secrets.bulk_delete(store_id, \*, account_id) -> SyncSinglePage[SecretBulkDeleteResponse] +- client.secrets_store.stores.secrets.duplicate(secret_id, \*, account_id, store_id, \*\*params) -> Optional[SecretDuplicateResponse] +- client.secrets_store.stores.secrets.edit(secret_id, \*, account_id, store_id, \*\*params) -> Optional[SecretEditResponse] +- client.secrets_store.stores.secrets.get(secret_id, \*, account_id, store_id) -> Optional[SecretGetResponse] -## Requests +## Quota Types: ```python -from cloudflare.types.cloudforce_one import ( - Item, - ListItem, - Quota, - RequestConstants, - RequestTypes, - RequestDeleteResponse, -) +from cloudflare.types.secrets_store import QuotaGetResponse ``` Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] -- client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.secrets_store.quota.get(\*, account_id) -> Optional[QuotaGetResponse] -### Message +# Pipelines Types: ```python -from cloudflare.types.cloudforce_one.requests import ( - Message, - MessageDeleteResponse, - MessageGetResponse, +from cloudflare.types.pipelines import ( + PipelineCreateResponse, + PipelineUpdateResponse, + PipelineListResponse, + PipelineCreateV1Response, + PipelineGetResponse, + PipelineGetV1Response, + PipelineListV1Response, + PipelineValidateSqlResponse, ) ``` Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.pipelines.create(\*, account_id, \*\*params) -> PipelineCreateResponse +- client.pipelines.update(pipeline_name, \*, account_id, \*\*params) -> PipelineUpdateResponse +- client.pipelines.list(\*, account_id, \*\*params) -> PipelineListResponse +- client.pipelines.delete(pipeline_name, \*, account_id) -> None +- client.pipelines.create_v1(\*, account_id, \*\*params) -> PipelineCreateV1Response +- client.pipelines.delete_v1(pipeline_id, \*, account_id) -> None +- client.pipelines.get(pipeline_name, \*, account_id) -> PipelineGetResponse +- client.pipelines.get_v1(pipeline_id, \*, account_id) -> PipelineGetV1Response +- client.pipelines.list_v1(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[PipelineListV1Response] +- client.pipelines.validate_sql(\*, account_id, \*\*params) -> PipelineValidateSqlResponse -### Priority +## Sinks Types: ```python -from cloudflare.types.cloudforce_one.requests import ( - Label, - Priority, - PriorityEdit, - PriorityDeleteResponse, -) +from cloudflare.types.pipelines import SinkCreateResponse, SinkListResponse, SinkGetResponse ``` Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional - -# EventNotifications +- client.pipelines.sinks.create(\*, account_id, \*\*params) -> SinkCreateResponse +- client.pipelines.sinks.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SinkListResponse] +- client.pipelines.sinks.delete(sink_id, \*, account_id, \*\*params) -> None +- client.pipelines.sinks.get(sink_id, \*, account_id) -> SinkGetResponse -## R2 - -### Configuration +## Streams Types: ```python -from cloudflare.types.event_notifications.r2 import ConfigurationGetResponse +from cloudflare.types.pipelines import ( + StreamCreateResponse, + StreamUpdateResponse, + StreamListResponse, + StreamGetResponse, +) ``` Methods: -- client.event_notifications.r2.configuration.get(bucket_name, \*, account_id) -> ConfigurationGetResponse +- client.pipelines.streams.create(\*, account_id, \*\*params) -> StreamCreateResponse +- client.pipelines.streams.update(stream_id, \*, account_id, \*\*params) -> StreamUpdateResponse +- client.pipelines.streams.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[StreamListResponse] +- client.pipelines.streams.delete(stream_id, \*, account_id, \*\*params) -> None +- client.pipelines.streams.get(stream_id, \*, account_id) -> StreamGetResponse -#### Queues +# SchemaValidation + +## Schemas Types: ```python -from cloudflare.types.event_notifications.r2.configuration import ( - QueueUpdateResponse, - QueueDeleteResponse, -) +from cloudflare.types.schema_validation import PublicSchema, SchemaDeleteResponse ``` Methods: -- client.event_notifications.r2.configuration.queues.update(queue_id, \*, account_id, bucket_name, \*\*params) -> QueueUpdateResponse -- client.event_notifications.r2.configuration.queues.delete(queue_id, \*, account_id, bucket_name) -> QueueDeleteResponse +- client.schema_validation.schemas.create(\*, zone_id, \*\*params) -> PublicSchema +- client.schema_validation.schemas.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[PublicSchema] +- client.schema_validation.schemas.delete(schema_id, \*, zone_id) -> SchemaDeleteResponse +- client.schema_validation.schemas.edit(schema_id, \*, zone_id, \*\*params) -> PublicSchema +- client.schema_validation.schemas.get(schema_id, \*, zone_id, \*\*params) -> PublicSchema -# AIGateway +## Settings Types: ```python -from cloudflare.types.ai_gateway import ( - AIGatewayCreateResponse, - AIGatewayUpdateResponse, - AIGatewayListResponse, - AIGatewayDeleteResponse, - AIGatewayGetResponse, +from cloudflare.types.schema_validation import ( + SettingUpdateResponse, + SettingEditResponse, + SettingGetResponse, ) ``` Methods: -- client.ai_gateway.create(\*, account_id, \*\*params) -> AIGatewayCreateResponse -- client.ai_gateway.update(id, \*, account_id, \*\*params) -> AIGatewayUpdateResponse -- client.ai_gateway.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AIGatewayListResponse] -- client.ai_gateway.delete(id, \*, account_id) -> AIGatewayDeleteResponse -- client.ai_gateway.get(id, \*, account_id) -> AIGatewayGetResponse +- client.schema_validation.settings.update(\*, zone_id, \*\*params) -> SettingUpdateResponse +- client.schema_validation.settings.edit(\*, zone_id, \*\*params) -> SettingEditResponse +- client.schema_validation.settings.get(\*, zone_id) -> SettingGetResponse -## Logs +### Operations Types: ```python -from cloudflare.types.ai_gateway import LogListResponse +from cloudflare.types.schema_validation.settings import ( + OperationUpdateResponse, + OperationListResponse, + OperationDeleteResponse, + OperationBulkEditResponse, + OperationGetResponse, +) ``` Methods: -- client.ai_gateway.logs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse] +- client.schema_validation.settings.operations.update(operation_id, \*, zone_id, \*\*params) -> OperationUpdateResponse +- client.schema_validation.settings.operations.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[OperationListResponse] +- client.schema_validation.settings.operations.delete(operation_id, \*, zone_id) -> OperationDeleteResponse +- client.schema_validation.settings.operations.bulk_edit(\*, zone_id, \*\*params) -> OperationBulkEditResponse +- client.schema_validation.settings.operations.get(operation_id, \*, zone_id) -> OperationGetResponse -# IAM +# TokenValidation -## PermissionGroups +## Configuration Types: ```python -from cloudflare.types.iam import PermissionGroupListResponse, PermissionGroupGetResponse +from cloudflare.types.token_validation import ( + TokenConfig, + ConfigurationDeleteResponse, + ConfigurationEditResponse, +) ``` Methods: -- client.iam.permission_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] -- client.iam.permission_groups.get(permission_group_id, \*, account_id) -> PermissionGroupGetResponse +- client.token_validation.configuration.create(\*, zone_id, \*\*params) -> TokenConfig +- client.token_validation.configuration.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[TokenConfig] +- client.token_validation.configuration.delete(config_id, \*, zone_id) -> ConfigurationDeleteResponse +- client.token_validation.configuration.edit(config_id, \*, zone_id, \*\*params) -> ConfigurationEditResponse +- client.token_validation.configuration.get(config_id, \*, zone_id) -> TokenConfig -## ResourceGroups +### Credentials Types: ```python -from cloudflare.types.iam import ( - ResourceGroupCreateResponse, - ResourceGroupUpdateResponse, - ResourceGroupListResponse, - ResourceGroupDeleteResponse, - ResourceGroupGetResponse, -) +from cloudflare.types.token_validation.configuration import CredentialUpdateResponse ``` Methods: -- client.iam.resource_groups.create(\*, account_id, \*\*params) -> ResourceGroupCreateResponse -- client.iam.resource_groups.update(resource_group_id, \*, account_id, \*\*params) -> ResourceGroupUpdateResponse -- client.iam.resource_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] -- client.iam.resource_groups.delete(resource_group_id, \*, account_id) -> Optional -- client.iam.resource_groups.get(resource_group_id, \*, account_id) -> ResourceGroupGetResponse - -# CloudConnector +- client.token_validation.configuration.credentials.update(config_id, \*, zone_id, \*\*params) -> CredentialUpdateResponse ## Rules Types: ```python -from cloudflare.types.cloud_connector import RuleUpdateResponse, RuleListResponse +from cloudflare.types.token_validation import TokenValidationRule ``` Methods: -- client.cloud_connector.rules.update(\*, zone_id, \*\*params) -> Optional -- client.cloud_connector.rules.list(\*, zone_id) -> SyncSinglePage[RuleListResponse] +- client.token_validation.rules.create(\*, zone_id, \*\*params) -> TokenValidationRule +- client.token_validation.rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[TokenValidationRule] +- client.token_validation.rules.delete(rule_id, \*, zone_id) -> object +- client.token_validation.rules.bulk_create(\*, zone_id, \*\*params) -> SyncSinglePage[TokenValidationRule] +- client.token_validation.rules.bulk_edit(\*, zone_id, \*\*params) -> SyncSinglePage[TokenValidationRule] +- client.token_validation.rules.edit(rule_id, \*, zone_id, \*\*params) -> TokenValidationRule +- client.token_validation.rules.get(rule_id, \*, zone_id) -> TokenValidationRule diff --git a/bin/check-release-environment b/bin/check-release-environment index b659e91535b..b845b0f4c96 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,7 +3,7 @@ errors=() if [ -z "${PYPI_TOKEN}" ]; then - errors+=("The CLOUDFLARE_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") + errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") fi lenErrors=${#errors[@]} diff --git a/bin/publish-pypi b/bin/publish-pypi index 05bfccbb71e..826054e9248 100644 --- a/bin/publish-pypi +++ b/bin/publish-pypi @@ -3,7 +3,4 @@ set -eux mkdir -p dist rye build --clean -# Patching importlib-metadata version until upstream library version is updated -# https://github.com/pypa/twine/issues/977#issuecomment-2189800841 -"$HOME/.rye/self/bin/python3" -m pip install 'importlib-metadata==7.2.1' rye publish --yes --token=$PYPI_TOKEN diff --git a/docs/v5-migration-guide.md b/docs/v5-migration-guide.md new file mode 100644 index 00000000000..3871fad358c --- /dev/null +++ b/docs/v5-migration-guide.md @@ -0,0 +1,2230 @@ +# Migration Guide: v4.3.1 → v5 + +This guide helps you migrate your code from v4.3.1 to v5 of the Cloudflare Python SDK. + +## Overview + +Version 5 introduces several breaking changes across multiple resources. This guide provides detailed migration instructions for each affected resource. + +**Important**: This is a beta release. APIs and types may change before the final v5.0.0 release. + +## Quick Reference + +Resources with breaking changes: + +- [Abuse Reports](#abuse-reports) +- [ACM Total TLS](#acm-total-tls) +- [API Gateway Configurations](#api-gateway-configurations) +- [Cloudforce One Threat Events](#cloudforce-one-threat-events) +- [D1 Database](#d1-database) +- [Intel Indicator Feeds](#intel-indicator-feeds) +- [Logpush Edge](#logpush-edge) +- [Origin TLS Client Auth Hostnames](#origin-tls-client-auth-hostnames) +- [Queues Consumers](#queues-consumers) +- [Radar BGP](#radar-bgp) +- [Rulesets Rules](#rulesets-rules) +- [Schema Validation Schemas](#schema-validation-schemas) +- [Snippets](#snippets) +- [Zero Trust DLP](#zero-trust-dlp) +- [Zero Trust Networks](#zero-trust-networks) + +--- + +## Abuse Reports + +**Resource**: `abusereports` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `create()` endpoint changed from `post /accounts/{account_id}/abuse-reports/{report_type}` to `post /accounts/{account_id}/abuse-reports/{report_param}` + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## ACM Total TLS + +**Resource**: `acm.totaltls` + +### Overview + +The ACM Total TLS resource has undergone a method restructuring in v5. The `create()` method has been removed and replaced with two new methods: `update()` and `edit()`, both of which perform similar functionality but with slightly different semantics. + +### Changes + +#### 1. Removed `create()` Method + +**What changed:** + +The `create()` method has been completely removed and replaced with `update()` and `edit()` methods. Both new methods use the same endpoint (`POST /zones/{zone_id}/acm/total_tls`) and similar parameters. + +**Before (v4.3.1):** + +```python +client.acm.total_tls.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, + certificate_authority="google" +) +``` + +**After (v5):** + +```python +# Option 1: Use update() +client.acm.total_tls.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, + certificate_authority="google" +) + +# Option 2: Use edit() +client.acm.total_tls.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, + certificate_authority="google" +) +``` + +**Actions Needed:** + +1. Replace all calls to `create()` with either `update()` or `edit()` +2. The parameters remain the same: `zone_id`, `enabled`, and optional `certificate_authority` +3. Update import statements if needed: + - Remove: `from cloudflare.types.acm.total_tls_create_response import TotalTLSCreateResponse` + - Add: `from cloudflare.types.acm.total_tls_update_response import TotalTLSUpdateResponse` + - Or: `from cloudflare.types.acm.total_tls_edit_response import TotalTLSEditResponse` + +--- + +#### 2. Updated Default Value Handling + +**What changed:** + +The optional parameter `certificate_authority` now uses the `Omit` type instead of `NotGiven`, and its default value changed from `NOT_GIVEN` to `omit`. + +**Before (v4.3.1):** + +```python +from cloudflare._types import NOT_GIVEN + +result = client.acm.total_tls.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, + certificate_authority=NOT_GIVEN # Old sentinel value +) +``` + +**After (v5):** + +```python +from cloudflare._types import omit + +result = client.acm.total_tls.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True, + certificate_authority=omit # New sentinel value +) +``` + +**Actions Needed:** + +1. If you explicitly used `NOT_GIVEN`, replace it with `omit` +2. Update imports from `NOT_GIVEN` to `omit` +3. If you relied on the default behavior (not passing the parameter), no changes are needed + +This is part of a broader SDK improvement to provide more precise type hints and better distinguish between omitted parameters and null values. + +--- + +#### 3. Response Type Changes + +**What changed:** + +The response type has changed from `TotalTLSCreateResponse` to either `TotalTLSUpdateResponse` or `TotalTLSEditResponse`. + +**Before (v4.3.1):** + +```python +from cloudflare.types.acm.total_tls_create_response import TotalTLSCreateResponse + +result: TotalTLSCreateResponse = client.acm.total_tls.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True +) +``` + +**After (v5):** + +```python +from cloudflare.types.acm.total_tls_update_response import TotalTLSUpdateResponse + +result: TotalTLSUpdateResponse = client.acm.total_tls.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + enabled=True +) +``` + +**Actions Needed:** + +1. Update type annotations in your code +2. Update import statements to use the new response types +3. The response structure remains the same, only the type name has changed + +Response types were renamed to match the new method names for consistency across the SDK. + +--- + +## API Gateway Configurations + +**Resource**: `apigateway.configurations` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `ConfigurationUpdateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Cloudforce One Threat Events + +**Resource**: `cloudforceone.threatevents` + +### Overview + +The Cloudforce One Threat Events resource has undergone significant changes in v5. The `insights` and `crons` sub-resources have been completely removed, and the `get()` method has been deprecated. Several method signatures have been updated to make previously required parameters optional and add support for new features like multiple indicators per event. + +### Changes + +#### 1. Removed `insights` Sub-Resource + +**What changed:** + +The entire `insights` sub-resource has been removed, including all associated methods (`create()`, `delete()`, `edit()`, `get()`) and their response types. + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +insights = client.cloudforce_one.threat_events.insights + +result = insights.create( + account_id="abc123", +) +``` + +**After (v5):** + +```python +# Use the 'insight' parameter when creating events: + +result = client.cloudforce_one.threat_events.create( + path_account_id="abc123", + category="malware", + date="2024-01-01T00:00:00Z", + event="event description", + raw={"key": "value"}, + tlp="green", + insight="your insight text here" # New parameter +) +``` + +**Actions Needed:** + +1. Replace all `insights` sub-resource calls with the main threat events API +2. Use the new `insight` parameter when creating or editing events +3. Update import statements to remove insight-related types: + - Remove: `InsightCreateResponse`, `InsightDeleteResponse`, `InsightEditResponse`, `InsightGetResponse` +4. Refactor code that accessed `client.cloudforce_one.threat_events.insights` to use the main API + +Insights functionality was consolidated into the main threat events resource to simplify the API structure and make it easier to attach insights directly to events. + +--- + +#### 2. Removed `crons` Sub-Resource + +**What changed:** + +The entire `crons` sub-resource has been completely removed from the threat events API. + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +crons = client.cloudforce_one.threat_events.crons +``` + +**After (v5):** + +```python + +``` + +**Actions Needed:** + +1. Remove all references to `client.cloudforce_one.threat_events.crons` +2. If you relied on cron functionality, contact Cloudflare support for alternative scheduling solutions +3. Consider using external scheduling mechanisms if needed + +The crons functionality was removed as part of the API restructuring. Scheduling operations should be handled outside the threat events API. + +--- + +#### 3. Parameter Changes in `create()` Method + +**What changed:** + +Several parameters in the `create()` method changed from required to optional, and new parameters were added. The `dataset_id` parameter now has different default behavior. + +**Before (v4.3.1):** + +```python +result = client.cloudforce_one.threat_events.create( + path_account_id="abc123", + attacker="attacker-name", # Required + attacker_country="US", # Required + category="malware", + date="2024-01-01T00:00:00Z", + event="event description", + indicator_type="ipv4", # Required + raw={"key": "value"}, + tlp="green", + dataset_id="dataset-123" # Must be specified +) +``` + +**After (v5):** + +```python +result = client.cloudforce_one.threat_events.create( + path_account_id="abc123", + category="malware", + date="2024-01-01T00:00:00Z", + event="event description", + raw={"key": "value"}, + tlp="green", + # Optional parameters: + attacker="attacker-name", # Now optional, can be None + attacker_country="US", # Now optional + indicator_type="ipv4", # Now optional + dataset_id="dataset-123", # Optional - uses default if omitted + indicator="192.168.1.1", # Single indicator (legacy) + indicators=[ # New: Multiple indicators support + {"type": "ipv4", "value": "192.168.1.1"}, + {"type": "domain", "value": "malicious.com"} + ], + insight="threat intelligence insight" # New parameter +) +``` + +**Actions Needed:** + +1. Update method calls - `attacker`, `attacker_country`, and `indicator_type` are now optional +2. If you want to omit the attacker, set it to `None` explicitly or use the `omit` sentinel +3. Consider using the new `indicators` array parameter for events with multiple indicators +4. If you were always specifying `dataset_id`, continue doing so; if not specified, events will be created in the default "Cloudforce One Threat Events" dataset +5. Add `insight` parameter when you want to attach insights to events + +The changes make the API more flexible by allowing events to be created without always specifying an attacker, and enable more complex scenarios like events with multiple indicators. The default dataset behavior simplifies usage for common cases. + +--- + +#### 4. Parameter Changes in `list()` Method + +**What changed:** + +The `list()` method now supports cursor-based pagination and STIX2 format export. The `dataset_id` parameter behavior changed. + +**Before (v4.3.1):** + +```python +from typing import List + +result = client.cloudforce_one.threat_events.list( + account_id="abc123", + dataset_id=["dataset-123"], # Required, as List[str] + page=1, + page_size=50 +) +``` + +**After (v5):** + +```python +from cloudflare._types import SequenceNotStr + +result = client.cloudforce_one.threat_events.list( + account_id="abc123", + dataset_id=["dataset-123"], # Optional, now SequenceNotStr[str] + cursor="cursor-token", # New: cursor-based pagination + format="json", # New: "json" or "stix2" + page=1, + page_size=50 +) +``` + +**Actions Needed:** + +1. The `dataset_id` parameter is now optional - omit it to list from the default dataset +2. Update type hints from `List[str]` to `SequenceNotStr[str]` if you have explicit type annotations +3. For large result sets (beyond 100,000 records), use the new `cursor` parameter for better performance: + ```python + # First request + result = client.cloudforce_one.threat_events.list( + account_id="abc123", + page_size=50 + ) + + # Get next page using cursor + next_cursor = result.result_info.cursor + result = client.cloudforce_one.threat_events.list( + account_id="abc123", + cursor=next_cursor, + page_size=50 + ) + ``` +4. Use `format="stix2"` if you need STIX2-formatted output + +Cursor-based pagination provides better performance and supports deep pagination beyond the 100,000 record limit of offset-based pagination. STIX2 format support enables better integration with threat intelligence platforms. + +--- + +#### 5. Deprecated `get()` Method + +**What changed:** + +The `get()` method is now deprecated and marked for removal in a future version. + +**Before (v4.3.1):** + +```python +result = client.cloudforce_one.threat_events.get( + event_id="event-123", + account_id="abc123" +) +``` + +**After (v5):** + +```python +result = client.cloudforce_one.threat_events.get( + event_id="event-123", + account_id="abc123" +) + +# Use the dataset-specific endpoint via the datasets sub-resource: +result = client.cloudforce_one.threat_events.datasets.events.get( + dataset_id="dataset-123", + event_id="event-123", + account_id="abc123" +) +``` + +**Actions Needed:** + +1. Migrate away from the deprecated `get()` method as soon as possible +2. Use the dataset-specific events endpoint: `/events/dataset/:dataset_id/events/:event_id` +3. Access this via the datasets sub-resource API (refer to datasets documentation) +4. Update your code to handle the new endpoint structure + +The new API structure requires dataset context for retrieving individual events, providing better data organization and access control. + +--- + +#### 6. Parameter Changes in `edit()` Method + +**What changed:** + +The `edit()` method now supports additional optional parameters including `created_at`, `dataset_id`, `insight`, and `raw`. + +**Before (v4.3.1):** + +```python +result = client.cloudforce_one.threat_events.edit( + event_id="event-123", + account_id="abc123", + attacker="new-attacker", + category="malware", + date="2024-01-01T00:00:00Z" +) +``` + +**After (v5):** + +```python +result = client.cloudforce_one.threat_events.edit( + event_id="event-123", + account_id="abc123", + attacker="new-attacker", # Can now be None + category="malware", + date="2024-01-01T00:00:00Z", + # New optional parameters: + created_at="2024-01-01T00:00:00Z", + dataset_id="dataset-123", + insight="updated insight", + raw={"updated": "data"} +) +``` + +**Actions Needed:** + +1. No changes required for existing code +2. Optionally use new parameters to update additional fields: + - Use `created_at` to set the creation timestamp + - Use `dataset_id` to move events between datasets + - Use `insight` to update or add insights + - Use `raw` to update raw event data +3. The `attacker` parameter can now be set to `None` to remove the attacker + +Additional parameters provide more comprehensive event editing capabilities and better align with the new event model that includes insights and dataset references. + +--- + +#### 7. Parameter Changes in `bulk_create()` Method + +**What changed:** + +The `bulk_create()` method now supports an optional `include_created_events` parameter. + +**Before (v4.3.1):** + +```python +result = client.cloudforce_one.threat_events.bulk_create( + account_id="abc123", + data=[ + {"category": "malware", "date": "2024-01-01T00:00:00Z", ...}, + {"category": "phishing", "date": "2024-01-02T00:00:00Z", ...} + ], + dataset_id="dataset-123" +) +``` + +**After (v5):** + +```python +result = client.cloudforce_one.threat_events.bulk_create( + account_id="abc123", + data=[ + {"category": "malware", "date": "2024-01-01T00:00:00Z", ...}, + {"category": "phishing", "date": "2024-01-02T00:00:00Z", ...} + ], + dataset_id="dataset-123", + include_created_events=True # New parameter +) + +``` + +**Actions Needed:** + +1. No changes required for existing code +2. Set `include_created_events=True` if you need to track which events were created and their locations: + ```python + result = client.cloudforce_one.threat_events.bulk_create( + account_id="abc123", + data=events_data, + dataset_id="dataset-123", + include_created_events=True + ) + + # Access created event details + for event in result.created_events: + print(f"Created event {event.uuid} on shard {event.shard_id}") + ``` + +The new parameter provides better tracking and debugging capabilities for bulk operations, allowing developers to verify which events were successfully created and where they're stored. + +--- + +## D1 Database + +**Resource**: `d1.database` + +### Overview + +The D1 Database resource has been **completely rewritten** in v5. While the new implementation provides all the same core functionality, the API surface has changed significantly. All methods that existed in v4.3.1 have been removed and replaced with new implementations that have different signatures, particularly around path structure and method organization. + +**IMPORTANT:** Despite methods having the same names (e.g., `create()`, `delete()`, etc.), the new implementation is **not** a drop-in replacement. The path parameter structure has changed, requiring code updates. + +### Changes + +#### 1. Complete Resource Reimplementation + +**What changed:** + +The entire D1 Database resource was regenerated from the updated OpenAPI specification. While method names remain similar, the internal implementation and some signatures have changed. + +**Impact:** +This affects all methods: `create()`, `update()`, `list()`, `delete()`, `edit()`, `export()`, `get()`, `params()`, `query()`, `raw()`, and `import_()`. + +--- + +#### 2. Changed Path Structure for `create()` Method + +**What changed:** + +The endpoint path and parameter structure for creating databases has changed. + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +result = client.d1.database.create( + account_id="abc123", + name="my-database", +) +``` + +**After (v5):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +result = client.d1.database.create( + account_id="abc123", + name="my-database", + jurisdiction="eu", # Optional + primary_location_hint="weur" # Optional +) +``` + +**Actions Needed:** + +1. Update the `create()` method call to use the new parameter structure +2. Use the optional `jurisdiction` parameter to restrict where the D1 database runs and stores data: + - Values: `"eu"` or `"fedramp"` +3. Use the optional `primary_location_hint` parameter to specify the region: + - Values: `"wnam"`, `"enam"`, `"weur"`, `"eeur"`, `"apac"`, `"oc"` +4. Note: If `jurisdiction` is specified, the `primary_location_hint` is ignored + +The new implementation provides explicit control over data residency and regional placement, which is important for compliance and performance requirements. + +--- + +#### 3. New `update()` Method with Different Purpose + +**What changed:** + +The `update()` method now specifically handles read replication configuration. + +**Before (v4.3.1):** + +```python +result = client.d1.database.update( +) +``` + +**After (v5):** + +```python +result = client.d1.database.update( + database_id="def456", + account_id="abc123", + read_replication={ + "enabled": True, + "regions": ["weur", "enam"] + } +) +``` + +**Actions Needed:** + +1. The `update()` method now requires a `database_id` as the first positional parameter +2. The method specifically handles read replication configuration +3. For other database updates, use the new `edit()` method (PATCH) instead +4. The `read_replication` parameter is required and must include: + - `enabled`: Boolean flag + - `regions`: Optional list of regions for read replicas + +The separation of `update()` (PUT - full updates) and `edit()` (PATCH - partial updates) follows RESTful conventions more closely and provides clearer semantics for different types of updates. + +--- + +#### 4. New `edit()` Method for Partial Updates + +**What changed:** + +A new `edit()` method was added for partial updates using HTTP PATCH. + +**Before (v4.3.1):** + +```python + +``` + +**After (v5):** + +```python +result = client.d1.database.edit( + database_id="def456", + account_id="abc123", + read_replication={ + "enabled": True + } +) +``` + +**Actions Needed:** + +1. Use `edit()` for partial updates where you want to modify specific fields +2. Use `update()` when you want to replace the entire configuration +3. Both methods currently support `read_replication` configuration +4. The `database_id` is required as the first positional parameter + +Having both `update()` and `edit()` methods provides flexibility for different update scenarios and follows standard REST API patterns. + +--- + +#### 5. Updated `list()` Method Return Type + +**What changed:** + +The `list()` method now returns a paginated response type instead of a simple list. + +**Before (v4.3.1):** + +```python +result = client.d1.database.list( + account_id="abc123" +) +``` + +**After (v5):** + +```python +from cloudflare.pagination import SyncV4PagePaginationArray + +result = client.d1.database.list( + account_id="abc123", + name="search-term", # Optional: filter by name + page=1, # Optional: page number + per_page=20 # Optional: items per page +) + +for database in result: + print(database.name) +``` + +**Actions Needed:** + +1. Update code that expects a simple list to handle pagination +2. Use the new optional parameters for filtering and pagination: + - `name`: Search for databases by name + - `page`: Specify page number (1-indexed) + - `per_page`: Set number of items per page +3. Iterate through the paginated results or convert to a list if needed: + ```python + all_databases = list(result) + ``` + +Pagination support allows efficient handling of large numbers of databases and follows the standard pattern used across the Cloudflare API. + +--- + +#### 6. Changed `delete()` Method Return Type + +**What changed:** + +The `delete()` method now returns a generic `object` type instead of a specific response type. + +**Before (v4.3.1):** + +```python +result = client.d1.database.delete( + database_id="def456", + account_id="abc123" +) +``` + +**After (v5):** + +```python +result = client.d1.database.delete( + database_id="def456", + account_id="abc123" +) +``` + +**Actions Needed:** + +1. Update type annotations to expect `object` instead of a specific response type +2. The method signature requires `database_id` as the first positional parameter +3. The operation still returns a confirmation, but without a specific type structure + +The generic return type simplifies the API and aligns with the actual API behavior. + +--- + +#### 7. Enhanced `export()` Method + +**What changed:** + +The `export()` method now has a clearer parameter structure with required and optional fields. + +**Before (v4.3.1):** + +```python +result = client.d1.database.export( +) +``` + +**After (v5):** + +```python +result = client.d1.database.export( + database_id="def456", + account_id="abc123", + output_format="polling", # Required: must be "polling" + current_bookmark="bookmark", # Optional: for polling in-progress export + dump_options={ # Optional: export configuration + "no_data": False, + "no_schema": False, + "tables": ["table1", "table2"] + } +) + +while result.status == "in_progress": + result = client.d1.database.export( + database_id="def456", + account_id="abc123", + output_format="polling", + current_bookmark=result.bookmark + ) + +if result.status == "complete": + download_url = result.url +``` + +**Actions Needed:** + +1. Always specify `output_format="polling"` (currently the only supported format) +2. Use the `current_bookmark` parameter to poll for export completion +3. Configure export options using `dump_options`: + - `no_data`: Set to `True` to export schema only + - `no_schema`: Set to `True` to export data only + - `tables`: List specific tables to export +4. Implement polling logic to wait for export completion +5. Note: Exports block the database, so continue polling to avoid automatic cancellation + +The new structure makes the async export process more explicit and provides better control over what gets exported. + +--- + +#### 8. Restructured `import_()` Method with Overloads + +**What changed:** + +The `import_()` method now uses overloaded signatures for different import actions. + +**Before (v4.3.1):** + +```python +result = client.d1.database.import_( +) +``` + +**After (v5):** + +```python + +result = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="init", + etag="md5-hash-of-file" +) +upload_url = result.upload_url + +result = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="ingest", + etag="md5-hash-of-file", + filename="uploaded-filename" +) + +result = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="poll", + current_bookmark="bookmark-from-ingest" +) +``` + +**Actions Needed:** + +1. Break your import logic into three stages: + + **Stage 1: Initialize** + ```python + import hashlib + + # Calculate MD5 hash + with open("database.sql", "rb") as f: + etag = hashlib.md5(f.read()).hexdigest() + + # Get upload URL + result = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="init", + etag=etag + ) + ``` + + **Stage 2: Upload and Ingest** + ```python + # Upload file to the URL (use requests or similar) + import requests + with open("database.sql", "rb") as f: + requests.put(result.upload_url, data=f) + + # Trigger import + result = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="ingest", + etag=etag, + filename="database.sql" + ) + bookmark = result.bookmark + ``` + + **Stage 3: Poll for Completion** + ```python + while True: + status = client.d1.database.import_( + database_id="def456", + account_id="abc123", + action="poll", + current_bookmark=bookmark + ) + if status.status == "complete": + break + time.sleep(5) + ``` + +2. Always calculate and provide the MD5 etag of your SQL file +3. Use the `current_bookmark` to track import progress +4. Note: Imports block the database for their duration + +The overloaded signatures make each import stage explicit and type-safe, reducing errors and making the multi-step process clearer. + +--- + +#### 9. Enhanced `query()` Method with Overloads + +**What changed:** + +The `query()` method now supports both single-query and batch-query modes via overloads. + +**Before (v4.3.1):** + +```python +result = client.d1.database.query( +) +``` + +**After (v5):** + +```python +from cloudflare.pagination import SyncSinglePage + +result = client.d1.database.query( + database_id="def456", + account_id="abc123", + sql="SELECT * FROM users WHERE id = ?", + params=["123"] # Optional: parameterized query +) + +result = client.d1.database.query( + database_id="def456", + account_id="abc123", + batch=[ + {"sql": "SELECT * FROM users", "params": []}, + {"sql": "SELECT * FROM posts", "params": []} + ] +) + +for query_result in result: + for row in query_result.results: + print(row) +``` + +**Actions Needed:** + +1. For single queries, use the `sql` parameter with optional `params`: + ```python + result = client.d1.database.query( + database_id="def456", + account_id="abc123", + sql="SELECT * FROM users WHERE active = ?", + params=["true"] + ) + ``` + +2. For batch queries, use the `batch` parameter: + ```python + result = client.d1.database.query( + database_id="def456", + account_id="abc123", + batch=[ + {"sql": "BEGIN TRANSACTION"}, + {"sql": "INSERT INTO users (name) VALUES (?)", "params": ["John"]}, + {"sql": "COMMIT"} + ] + ) + ``` + +3. The return type is now `SyncSinglePage[QueryResult]` for pagination support +4. Use parameterized queries (the `params` array) to prevent SQL injection +5. Multiple statements in a single SQL string (separated by semicolons) are also supported + +Overloads provide type safety for different query modes, and the batch mode enables efficient execution of multiple queries with transaction support. + +--- + +#### 10. Enhanced `raw()` Method with Overloads + +**What changed:** + +The `raw()` method now supports both single-query and batch-query modes, similar to `query()`, but returns results as arrays instead of objects for better performance. + +**Before (v4.3.1):** + +```python +result = client.d1.database.raw( +) +``` + +**After (v5):** + +```python +from cloudflare.pagination import SyncSinglePage + +result = client.d1.database.raw( + database_id="def456", + account_id="abc123", + sql="SELECT id, name, email FROM users", + params=[] +) + +for query_result in result: + for row in query_result.results: + # row = [1, "John", "john@example.com"] + user_id, name, email = row + print(f"{user_id}: {name} <{email}>") + +result = client.d1.database.raw( + database_id="def456", + account_id="abc123", + batch=[ + {"sql": "SELECT * FROM users"}, + {"sql": "SELECT * FROM posts"} + ] +) +``` + +**Actions Needed:** + +1. Use `raw()` instead of `query()` when you need better performance +2. Adapt your code to handle array results instead of object results: + + **Before (with query()):** + ```python + result = client.d1.database.query( + database_id="def456", + account_id="abc123", + sql="SELECT id, name FROM users" + ) + for row in result[0].results: + print(row.id, row.name) # Object access + ``` + + **After (with raw()):** + ```python + result = client.d1.database.raw( + database_id="def456", + account_id="abc123", + sql="SELECT id, name FROM users" + ) + for row in result[0].results: + print(row[0], row[1]) # Array access + # Or use tuple unpacking: + user_id, name = row + print(user_id, name) + ``` + +3. Use the `columns` field to map array indices to column names if needed: + ```python + query_result = list(result)[0] + columns = {name: idx for idx, name in enumerate(query_result.columns)} + + for row in query_result.results: + user_id = row[columns["id"]] + name = row[columns["name"]] + ``` + +4. Batch queries work the same way as in `query()` + +The `raw()` method provides a performance-optimized alternative to `query()` by returning results as arrays instead of objects, reducing memory overhead and serialization time for large result sets. + +--- + +#### 11. Removed `params()` Method + +**What changed:** + +The `params()` method has been completely removed with no direct replacement. + +**Before (v4.3.1):** + +```python +result = client.d1.database.params( +) +``` + +**After (v5):** + +```python +# Use query() or raw() methods with the params parameter instead + +result = client.d1.database.query( + database_id="def456", + account_id="abc123", + sql="SELECT * FROM users WHERE id = ?", + params=["123"] # Pass params here +) +``` + +**Actions Needed:** + +1. Remove all calls to `params()` +2. Use parameterized queries in `query()` or `raw()` methods: + ```python + # Instead of a separate params() call, pass params inline: + result = client.d1.database.query( + database_id="def456", + account_id="abc123", + sql="SELECT * FROM users WHERE active = ? AND role = ?", + params=["true", "admin"] + ) + ``` + +The functionality was consolidated into the query methods themselves, making parameterized queries more intuitive and eliminating an unnecessary separate method. + +--- + +#### 12. Type Changes: Response Types Removed and Replaced + +**What changed:** + +Several response types were removed and replaced with new ones. + +**Removed Types:** +- `DatabaseImportResponse` +- `DatabaseExportResponse` +- `DatabaseListResponse` +- `DatabaseRawResponse` +- `QueryResult` + +**Before (v4.3.1):** + +```python +from cloudflare.types.d1 import ( + DatabaseImportResponse, + DatabaseExportResponse, + DatabaseListResponse, + DatabaseRawResponse, + QueryResult +) +``` + +**After (v5):** + +```python +from cloudflare.types.d1.database_import_response import DatabaseImportResponse +from cloudflare.types.d1.database_export_response import DatabaseExportResponse +from cloudflare.types.d1.database_list_response import DatabaseListResponse +from cloudflare.types.d1.database_raw_response import DatabaseRawResponse +from cloudflare.types.d1.query_result import QueryResult +``` + +**Actions Needed:** + +1. Update import statements to use the new module paths if you import types directly +2. The types themselves may have internal structural changes - review your code that accesses response fields +3. Most code should work without changes if you don't rely on specific type annotations + +Types were regenerated from the updated OpenAPI spec to ensure accuracy and maintain consistency with the API. + +--- + +#### 13. Path Parameter Changes Across All Methods + +**What changed:** + +All methods now require explicit `database_id` where appropriate, moving from a potentially different parameter structure. + +**Before (v4.3.1):** + +```python +result = client.d1.database.get( + account_id="abc123", + database_id="def456" +) +``` + +**After (v5):** + +```python +result = client.d1.database.get( + database_id="def456", # First positional parameter + account_id="abc123" # Named parameter +) +``` + +**Actions Needed:** + +1. Review all D1 database method calls +2. Ensure `database_id` is passed as the first parameter (after `self`) for methods that operate on specific databases +3. Methods that operate on a specific database: + - `update(database_id, ...)` + - `delete(database_id, ...)` + - `edit(database_id, ...)` + - `export(database_id, ...)` + - `get(database_id, ...)` + - `import_(database_id, ...)` + - `query(database_id, ...)` + - `raw(database_id, ...)` + +4. Methods that operate at the account level: + - `create(account_id, ...)` - Creates a new database + - `list(account_id, ...)` - Lists all databases + +Consistent parameter ordering improves API usability and follows RESTful conventions where resource identifiers appear earlier in the method signature. + +--- + +## General Migration Strategy + +Given the extensive nature of changes to the D1 Database resource, we recommend the following migration approach: + +1. **Audit Your Code:** Identify all locations where you use `client.d1.database.*` methods + +2. **Update Method Calls:** Go through each method call and update according to the specific breaking changes documented above + +3. **Test Thoroughly:** The reimplementation means you should test all D1-related functionality, even if the method names haven't changed + +4. **Update Type Annotations:** If you use explicit type hints, update them to match the new response types + +5. **Handle Pagination:** Update code to handle paginated responses from `list()` and query methods + +6. **Review Error Handling:** Error responses may have changed; update your error handling code accordingly + +7. **Consider Using Raw Queries:** If performance is critical, evaluate switching from `query()` to `raw()` for read operations + +## Summary + +The D1 Database resource has been completely overhauled in v5. While this provides a more robust and feature-rich API, it requires careful migration. The key changes are: + +- All methods have new implementations with updated signatures +- Path parameters are now consistently ordered +- Query methods support both single and batch modes +- Pagination support for list operations +- Better type safety with overloaded method signatures +- Removed `params()` method in favor of inline parameterization +- New `edit()` method for partial updates +- Enhanced import/export workflows with explicit multi-step processes + +Plan for significant testing time when migrating D1 Database code to v5. + +--- + +## Intel Indicator Feeds + +**Resource**: `intel.indicatorfeeds` + +### Overview + +The Intel Indicator Feeds resource has undergone a structural change in v5 with the removal of the `downloads` sub-resource. The `get()` method that was previously available under the downloads sub-resource has been removed. The main indicator feeds functionality remains largely intact with minor parameter handling improvements. + +### Changes + +#### 1. Removed `downloads` Sub-Resource + +**What changed:** + +The entire `downloads` sub-resource has been completely removed, along with its `get()` method. + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +downloads = client.intel.indicator_feeds.downloads + +result = downloads.get( + feed_id=123, + account_id="abc123" +) +``` + +**After (v5):** + +```python +# Use the main data() method instead: + +data = client.intel.indicator_feeds.data( + feed_id=123, + account_id="abc123" +) +``` + +**Actions Needed:** + +1. Replace all references to `client.intel.indicator_feeds.downloads` with the main resource +2. Replace `downloads.get()` calls with `indicator_feeds.data()`: + + **Before:** + ```python + downloads = client.intel.indicator_feeds.downloads + result = downloads.get( + feed_id=123, + account_id="abc123" + ) + ``` + + **After:** + ```python + result = client.intel.indicator_feeds.data( + feed_id=123, + account_id="abc123" + ) + ``` + +3. Remove any imports related to the downloads sub-resource: + ```python + # Remove these imports + from cloudflare.resources.intel.indicator_feeds.downloads import ( + DownloadsResource, + AsyncDownloadsResource + ) + from cloudflare.types.intel.indicator_feeds.download_get_response import ( + DownloadGetResponse + ) + ``` + +4. Update type annotations if you were using `DownloadGetResponse`: + ```python + # The data() method returns str + result: str = client.intel.indicator_feeds.data( + feed_id=123, + account_id="abc123" + ) + ``` + +The downloads functionality was consolidated into the main indicator feeds resource through the `data()` method, simplifying the API structure and eliminating redundant resource nesting. + +--- + +#### 2. Updated Default Value Handling + +**What changed:** + +Optional parameters now use the `Omit` type instead of `NotGiven`, and default values changed from `NOT_GIVEN` to `omit`. + +**Before (v4.3.1):** + +```python +from cloudflare._types import NOT_GIVEN, NotGiven + +result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Feed", + description=NOT_GIVEN # Old sentinel value +) +``` + +**After (v5):** + +```python +from cloudflare._types import omit, Omit + +result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Feed", + description=omit # New sentinel value +) +``` + +**Actions Needed:** + +1. If you explicitly used `NOT_GIVEN`, replace it with `omit`: + ```python + # Before + from cloudflare._types import NOT_GIVEN + + result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Feed", + description=NOT_GIVEN + ) + + # After + from cloudflare._types import omit + + result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Feed", + description=omit + ) + ``` + +2. Update type hints from `NotGiven` to `Omit`: + ```python + # Before + from cloudflare._types import NotGiven + + def create_feed(name: str, description: str | NotGiven = NOT_GIVEN): + pass + + # After + from cloudflare._types import Omit, omit + + def create_feed(name: str, description: str | Omit = omit): + pass + ``` + +3. If you relied on the default behavior (not passing optional parameters), no changes are needed: + ```python + # This works in both versions + result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Feed" + ) + ``` + +The `Omit` type provides more precise type hints and better distinguishes between omitted parameters and explicit null values, improving type safety across the SDK. + +--- + +#### 3. Consistent Timeout Parameter Type + +**What changed:** + +The timeout parameter default value changed from `NOT_GIVEN` to `not_given` (note the lowercase). + +**Before (v4.3.1):** + +```python +from cloudflare._types import NOT_GIVEN + +result = client.intel.indicator_feeds.list( + account_id="abc123", + timeout=NOT_GIVEN +) +``` + +**After (v5):** + +```python +from cloudflare._types import not_given + +result = client.intel.indicator_feeds.list( + account_id="abc123", + timeout=not_given +) +``` + +**Actions Needed:** + +1. Replace `NOT_GIVEN` with `not_given` for timeout parameters: + ```python + from cloudflare._types import not_given + + # Explicitly set timeout + result = client.intel.indicator_feeds.list( + account_id="abc123", + timeout=30.0 # 30 seconds + ) + + # Or use default + result = client.intel.indicator_feeds.list( + account_id="abc123" + # timeout defaults to not_given + ) + ``` + +2. In practice, you rarely need to explicitly pass the sentinel value - just omit the parameter: + ```python + # Preferred approach + result = client.intel.indicator_feeds.list( + account_id="abc123" + ) + ``` + +The lowercase `not_given` is used consistently for timeout parameters across the SDK, while `omit` is used for business logic parameters, providing clearer semantic meaning. + +--- + +#### 4. Updated Method Signatures (Non-Breaking Changes) + +**What changed:** + +Several methods had their signatures updated to use the new `Omit` type, but the actual behavior remains the same. + +**Methods affected:** +- `create()` +- `update()` +- `list()` +- `data()` +- `get()` + +**Example - create() method:** +```python +# v4.3.1 signature: +def create( + self, + *, + account_id: str, + description: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + ... +) -> Optional[IndicatorFeedCreateResponse]: + +# v5 signature: +def create( + self, + *, + account_id: str, + description: str | Omit = omit, + name: str | Omit = omit, + ... +) -> Optional[IndicatorFeedCreateResponse]: +``` + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare +from cloudflare._types import NOT_GIVEN + +client = Cloudflare() +account_id = "abc123" + +feed = client.intel.indicator_feeds.create( + account_id=account_id, + name="My Threat Feed", + description="Threat intelligence feed" +) + +downloads = client.intel.indicator_feeds.downloads +data = downloads.get( + feed_id=feed.id, + account_id=account_id +) + +updated = client.intel.indicator_feeds.update( + feed_id=feed.id, + account_id=account_id, + name="Updated Feed Name", + description=NOT_GIVEN +) + +feeds = client.intel.indicator_feeds.list( + account_id=account_id +) +``` + +**After (v5):** + +```python +from cloudflare import Cloudflare +from cloudflare._types import omit + +client = Cloudflare() +account_id = "abc123" + +feed = client.intel.indicator_feeds.create( + account_id=account_id, + name="My Threat Feed", + description="Threat intelligence feed" +) + +# Get feed data (no longer uses downloads sub-resource) +data = client.intel.indicator_feeds.data( + feed_id=feed.id, + account_id=account_id +) + +updated = client.intel.indicator_feeds.update( + feed_id=feed.id, + account_id=account_id, + name="Updated Feed Name", + description=omit # Or simply omit the parameter +) + +# Or better: just omit optional parameters +updated = client.intel.indicator_feeds.update( + feed_id=feed.id, + account_id=account_id, + name="Updated Feed Name" +) + +feeds = client.intel.indicator_feeds.list( + account_id=account_id +) + +# Use new permissions sub-resource +permissions = client.intel.indicator_feeds.permissions.list( + account_id=account_id +) +``` + +**Actions Needed:** + +These changes are largely transparent if you're using the methods normally: + +```python +# This code works in both versions +result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Indicator Feed", + description="Feed description" +) + +# Optional parameters can be omitted +result = client.intel.indicator_feeds.create( + account_id="abc123", + name="My Indicator Feed" +) +``` + +If you have explicit type annotations: +```python +# Before +from cloudflare._types import NotGiven, NOT_GIVEN + +def create_feed( + name: str, + description: str | NotGiven = NOT_GIVEN +) -> None: + pass + +# After +from cloudflare._types import Omit, omit + +def create_feed( + name: str, + description: str | Omit = omit +) -> None: + pass +``` + +Consistent use of `Omit` across all methods improves type safety and provides better IDE support. + +--- + +## New Features in v5 + +While not breaking changes, the indicator feeds resource gained new functionality through the permissions sub-resource: + +--- + +## Logpush Edge + +**Resource**: `logpush.edge` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `get()` endpoint changed from `get /zones/{zone_id}/logpush/edge` to `get /zones/{zone_id}/logpush/edge/jobs` + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Origin TLS Client Auth Hostnames + +**Resource**: `origintlsclientauth.hostnames` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `create()` method removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 2. `delete()` method removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 3. `list()` method removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 4. `get()` endpoint changed from `get /zones/{zone_id}/origin_tls_client_auth/hostnames/certificates/{certificate_id}` to `get /zones/{zone_id}/origin_tls_client_auth/hostnames/{hostname}` + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 5. `Certificate` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 6. `CertificateCreateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 7. `CertificateDeleteResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 8. `CertificateGetResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 9. `CertificateListResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Queues Consumers + +**Resource**: `queues.consumers` + +### Overview + +The Queues Consumers resource has undergone a significant restructuring in v5. The primary breaking change is the modification of the `get()` method endpoint and the addition of a new `list()` method. This change better aligns with RESTful conventions by separating the concerns of listing all consumers from fetching a specific consumer. + +### Changes + +#### 1. Changed `get()` Method Endpoint and Signature + +**What changed:** + +The `get()` method endpoint changed from listing all consumers to fetching a specific consumer by ID. A new `list()` method was added to replace the old `get()` behavior. + +**Before (v4.3.1):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +consumers = client.queues.consumers.get( + queue_id="abc123", + account_id="def456" +) + +for consumer in consumers: + print(f"Consumer: {consumer.consumer_id}") +``` + +**After (v5):** + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +consumer = client.queues.consumers.get( + consumer_id="consumer-123", # New required parameter + account_id="def456", + queue_id="abc123" +) + +print(f"Consumer: {consumer.consumer_id}") +``` + +**Actions Needed:** + +1. **If you were listing all consumers**, replace `get()` with `list()`: + ```python + # Before + consumers = client.queues.consumers.get( + queue_id="abc123", + account_id="def456" + ) + + # After + consumers = client.queues.consumers.list( + queue_id="abc123", + account_id="def456" + ) + + # Both return an iterable of consumers + for consumer in consumers: + print(consumer.consumer_id) + ``` + +2. **If you were getting a specific consumer** (by filtering the list), use the new `get()` directly: + ```python + # Before (inefficient) + consumers = client.queues.consumers.get( + queue_id="abc123", + account_id="def456" + ) + consumer = next(c for c in consumers if c.consumer_id == "consumer-123") + + # After (efficient) + consumer = client.queues.consumers.get( + consumer_id="consumer-123", + account_id="def456", + queue_id="abc123" + ) + ``` + +3. **Update type annotations**: + ```python + # Before + from cloudflare.pagination import SyncSinglePage + from cloudflare.types.queues import Consumer + + consumers: SyncSinglePage[Consumer] = client.queues.consumers.get(...) + + # After - for list() + from cloudflare.pagination import SyncSinglePage + from cloudflare.types.queues import Consumer + + consumers: SyncSinglePage[Consumer] = client.queues.consumers.list(...) + + # After - for get() + from cloudflare.types.queues import Consumer + from typing import Optional + + consumer: Optional[Consumer] = client.queues.consumers.get(...) + ``` + +The change aligns with RESTful API conventions where: +- `GET /resource` returns a list of resources +- `GET /resource/{id}` returns a specific resource by ID + +The previous implementation had `get()` returning a list, which was semantically incorrect. Now: +- `list()` returns all consumers for a queue +- `get()` returns a specific consumer by ID + +--- + +#### 2. Added `list()` Method + +**What changed:** + +A new `list()` method was added to retrieve all consumers for a queue. + +**Before (v4.3.1):** + +```python +consumers = client.queues.consumers.get( + queue_id="abc123", + account_id="def456" +) +``` + +**After (v5):** + +```python +# Use list() to list consumers +consumers = client.queues.consumers.list( + queue_id="abc123", + account_id="def456" +) +``` + +**Actions Needed:** + +Simply replace `get()` calls with `list()` when you need all consumers: + +```python +from cloudflare import Cloudflare + +client = Cloudflare() + +# List all consumers for a queue +consumers = client.queues.consumers.list( + queue_id="abc123", + account_id="def456" +) + +# Iterate through consumers +for consumer in consumers: + print(f"Consumer ID: {consumer.consumer_id}") + print(f"Script: {consumer.script_name}") + print(f"Type: {consumer.type}") +``` + +The `list()` method name clearly indicates its purpose of listing multiple resources, improving API discoverability and consistency with other Cloudflare resources. + +--- + +#### 3. Updated Default Value Handling + +**What changed:** + +Optional parameters now use the `Omit` type instead of `NotGiven`, and default values changed from `NOT_GIVEN` to `omit`. + +**Before (v4.3.1):** + +```python +from cloudflare._types import NOT_GIVEN, NotGiven + +result = client.queues.consumers.create( + queue_id="abc123", + account_id="def456", + script_name="my-worker", + dead_letter_queue=NOT_GIVEN, + settings=NOT_GIVEN +) +``` + +**After (v5):** + +```python +from cloudflare._types import omit, Omit + +result = client.queues.consumers.create( + queue_id="abc123", + account_id="def456", + script_name="my-worker", + dead_letter_queue=omit, + settings=omit +) +``` + +**Actions Needed:** + +1. **Replace imports**: + ```python + # Before + from cloudflare._types import NOT_GIVEN, NotGiven + + # After + from cloudflare._types import omit, Omit + ``` + +2. **Replace sentinel values**: + ```python + # Before + result = client.queues.consumers.create( + queue_id="abc123", + account_id="def456", + dead_letter_queue=NOT_GIVEN + ) + + # After + result = client.queues.consumers.create( + queue_id="abc123", + account_id="def456", + dead_letter_queue=omit + ) + ``` + +3. **Update type hints**: + ```python + # Before + from cloudflare._types import NotGiven + + def create_consumer( + script_name: str, + settings: dict | NotGiven = NOT_GIVEN + ) -> None: + pass + + # After + from cloudflare._types import Omit, omit + + def create_consumer( + script_name: str, + settings: dict | Omit = omit + ) -> None: + pass + ``` + +4. **Preferred approach - omit optional parameters entirely**: + ```python + # Best practice: just don't pass optional parameters + result = client.queues.consumers.create( + queue_id="abc123", + account_id="def456", + script_name="my-worker" + # No need to explicitly pass omit for optional parameters + ) + ``` + +The `Omit` type provides better type safety and clearer semantics for distinguishing between omitted parameters and explicit null values. + +--- + +#### 4. Consistent Timeout Parameter Handling + +**What changed:** + +The timeout parameter default value changed from `NOT_GIVEN` to `not_given` (lowercase). + +**Before (v4.3.1):** + +```python +from cloudflare._types import NOT_GIVEN + +result = client.queues.consumers.list( + queue_id="abc123", + account_id="def456", + timeout=NOT_GIVEN +) +``` + +**After (v5):** + +```python +from cloudflare._types import not_given + +result = client.queues.consumers.list( + queue_id="abc123", + account_id="def456", + timeout=not_given +) +``` + +**Actions Needed:** + +In practice, you rarely need to explicitly pass the sentinel value: + +```python +# Specify a custom timeout +result = client.queues.consumers.list( + queue_id="abc123", + account_id="def456", + timeout=30.0 # 30 seconds +) + +# Or use default (preferred) +result = client.queues.consumers.list( + queue_id="abc123", + account_id="def456" + # timeout defaults to not_given +) +``` + +Consistent use of lowercase `not_given` for infrastructure parameters like timeout improves consistency across the SDK. + +--- + +## Non-Breaking Changes + +The following methods retain the same functionality with updated type signatures: + +--- + +## Radar BGP + +**Resource**: `radar.bgp` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `timeseries()` endpoint changed from `get /radar/bgp/ips/timeseries` to `get /radar/bgp/rpki/aspa/timeseries` + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 2. `IPTimeseriesResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Rulesets Rules + +**Resource**: `rulesets.rules` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `RewriteURIPart` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Schema Validation Schemas + +**Resource**: `schemavalidation.schemas` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `SchemaCreateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 2. `SchemaEditResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 3. `SchemaGetResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 4. `SchemaListResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Snippets + +**Resource**: `snippets` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `Snippet` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Zero Trust DLP + +**Resource**: `zerotrust.dlp` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `update()` endpoint changed from `put /accounts/{account_id}/dlp/entries/{entry_id}` to `put /accounts/{account_id}/dlp/entries/integration/{entry_id}` + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 2. `EntryCreateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 3. `EntryGetResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 4. `EntryListResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 5. `EntryUpdateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- + +## Zero Trust Networks + +**Resource**: `zerotrust.networks` + +### Overview + +This resource has breaking changes. + +### Changes + +#### 1. `update()` method removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +#### 2. `CloudflareSourceUpdateResponse` type removed + +**Actions Needed:** + +Review the changes above and update your code accordingly. + +--- diff --git a/examples/workers/ai/demo.py b/examples/ai/demo.py similarity index 93% rename from examples/workers/ai/demo.py rename to examples/ai/demo.py index 18a35dd46a2..8244662c683 100644 --- a/examples/workers/ai/demo.py +++ b/examples/ai/demo.py @@ -7,10 +7,9 @@ if account_id is None: sys.exit("CLOUDFLARE_ACCOUNT_ID is not defined") - client = Cloudflare() -t = client.workers.ai.run( +t = client.ai.run( "@cf/meta/m2m100-1.2b", account_id=account_id, text="I'll have an order of the moule frites", diff --git a/examples/dns/record.py b/examples/dns/record.py index 091442174c9..87b3d4fd17a 100644 --- a/examples/dns/record.py +++ b/examples/dns/record.py @@ -11,10 +11,16 @@ record = client.dns.records.create( zone_id=zone_id, - type='A', + type="A", name="www.mydns.com", content="198.51.100.1", - proxied=True + ttl=1, + proxied=True, ) +assert record is not None -# print(record) +# clean up after we're done +client.dns.records.delete( + zone_id=zone_id, + dns_record_id=record.id, +) diff --git a/examples/workers/script_upload.py b/examples/workers/script_upload.py new file mode 100644 index 00000000000..d7a1cf5823d --- /dev/null +++ b/examples/workers/script_upload.py @@ -0,0 +1,99 @@ +"""Workers Script Upload Example + +Generate an API token: +https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ +(Not Global API Key!) + +Find your account id: +https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/ + +Set these environment variables: +- CLOUDFLARE_API_TOKEN +- CLOUDFLARE_ACCOUNT_ID + + +### Workers for Platforms ### + +For uploading a User Worker to a dispatch namespace: +https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/ + +Change the entire "script = " line to the following: +"script = client.workers_for_platforms.dispatch.namespaces.scripts.update(" + +Then, define a "dispatch_namespace_name" variable and add a +"dispatch_namespace=dispatch_namespace_name" keyword argument to the "update" method. +""" + +import os + +from cloudflare import Cloudflare, APIStatusError + +API_TOKEN = os.environ.get("CLOUDFLARE_API_TOKEN") +if API_TOKEN is None: + raise RuntimeError("Please set envar CLOUDFLARE_API_TOKEN") + +ACCOUNT_ID = os.environ.get("CLOUDFLARE_ACCOUNT_ID") +if ACCOUNT_ID is None: + raise RuntimeError("Please set envar CLOUDFLARE_ACCOUNT_ID") + +client = Cloudflare(api_token=API_TOKEN) + + +def main() -> None: + """Workers Script Upload Example""" + + script_name = "my-hello-world-script" + script_file_name = f"{script_name}.mjs" + + # Workers Scripts prefer Module Syntax + # https://blog.cloudflare.com/workers-javascript-modules/ + script_content = """ + export default { + async fetch(request, env, ctx) { + return new Response(env.MESSAGE, { status: 200 }); + } + }; + """ + + try: + # https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/ + script = client.workers.scripts.update( + script_name, + account_id=ACCOUNT_ID, # type: ignore + # https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/ + metadata={ + "main_module": script_file_name, + "bindings": [ + { + "type": "plain_text", + "name": "MESSAGE", + "text": "Hello World!", + } + ], + }, + files=[ + # Add main_module file + # Note: Content-Type must be "application/javascript" or "text/javascript" + ( + script_file_name, + bytes(script_content, "utf-8"), + "application/javascript", + ), + # Can add other files, such as more modules or source maps + # ( + # source_map_file_name, + # bytes(source_map_content, "utf-8"), + # "application/source-map", + # ), + ], + ) + print("Script Upload success!") + print(script.to_json(indent=2)) + except APIStatusError as err: + print("Script Upload failure!") + print(f"Error code: {err.status_code}") + print(err) + + +if __name__ == "__main__": + main() diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index ec35df6ad25..00000000000 --- a/mypy.ini +++ /dev/null @@ -1,47 +0,0 @@ -[mypy] -pretty = True -show_error_codes = True - -# Exclude _files.py because mypy isn't smart enough to apply -# the correct type narrowing and as this is an internal module -# it's fine to just use Pyright. -exclude = ^(src/cloudflare/_files\.py|_dev/.*\.py|src/cloudflare/resources/zero_trust/identity_providers\.py|src/cloudflare/resources/zero_trust/access/applications/applications\.py|src/cloudflare/resources/workers/ai\.py|src/cloudflare/resources/magic_transit/apps\.py)$ - -strict_equality = True -implicit_reexport = True -check_untyped_defs = True -no_implicit_optional = True - -warn_return_any = True -warn_unreachable = True -warn_unused_configs = True - -# Turn these options off as it could cause conflicts -# with the Pyright options. -warn_unused_ignores = False -warn_redundant_casts = False - -disallow_any_generics = True -disallow_untyped_defs = True -disallow_untyped_calls = True -disallow_subclassing_any = True -disallow_incomplete_defs = True -disallow_untyped_decorators = True -cache_fine_grained = True - -# By default, mypy reports an error if you assign a value to the result -# of a function call that doesn't return anything. We do this in our test -# cases: -# ``` -# result = ... -# assert result is None -# ``` -# Changing this codegen to make mypy happy would increase complexity -# and would not be worth it. -disable_error_code = func-returns-value - -# https://github.com/python/mypy/issues/12162 -[mypy.overrides] -module = "black.files.*" -ignore_errors = true -ignore_missing_imports = true diff --git a/pyproject.toml b/pyproject.toml index a7dd71ade61..a5a2adb78ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,32 +1,32 @@ [project] name = "cloudflare" -version = "3.1.1" +version = "5.0.0-beta.1" description = "The official Python library for the cloudflare API" dynamic = ["readme"] license = "Apache-2.0" authors = [ { name = "Cloudflare", email = "api@cloudflare.com" }, ] -dependencies = [ - "httpx>=0.23.0, <0.28", - "pydantic>=1.9.0, <2.10", - "typing-extensions>=4.7, <5", - "anyio>=3.5.0, <5", - "distro>=1.7.0, <2", - "sniffio", - "cached-property; python_version < '3.8'", +dependencies = [ + "httpx>=0.23.0, <1", + "pydantic>=1.9.0, <3", + "typing-extensions>=4.10, <5", + "anyio>=3.5.0, <5", + "distro>=1.7.0, <2", + "sniffio", ] -requires-python = ">= 3.7" + +requires-python = ">= 3.9" classifiers = [ "Typing :: Typed", "Intended Audience :: Developers", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Operating System :: OS Independent", "Operating System :: POSIX", "Operating System :: MacOS", @@ -36,20 +36,19 @@ classifiers = [ "License :: OSI Approved :: Apache Software License" ] - - [project.urls] Homepage = "https://github.com/cloudflare/cloudflare-python" Repository = "https://github.com/cloudflare/cloudflare-python" - +[project.optional-dependencies] +aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"] [tool.rye] managed = true # version pins are in requirements-dev.lock dev-dependencies = [ - "pyright>=1.1.359", - "mypy", + "pyright==1.1.399", + "mypy==1.17", "respx", "pytest", "pytest-asyncio", @@ -59,7 +58,8 @@ dev-dependencies = [ "dirty-equals>=0.6.0", "importlib-metadata>=6.7.0", "rich>=13.7.1", - + "pytest-xdist>=3.6.1", + "griffe>=1", ] [tool.rye.scripts] @@ -67,18 +67,21 @@ format = { chain = [ "format:ruff", "format:docs", "fix:ruff", + # run formatting again to fix any inconsistencies when imports are stripped + "format:ruff", ]} -"format:black" = "black ." "format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md" "format:ruff" = "ruff format" -"format:isort" = "isort ." "lint" = { chain = [ "check:ruff", "typecheck", + "check:importable", ]} -"check:ruff" = "ruff ." -"fix:ruff" = "ruff --fix ." +"check:ruff" = "ruff check ." +"fix:ruff" = "ruff check --fix ." + +"check:importable" = "python -c 'import cloudflare'" typecheck = { chain = [ "typecheck:pyright", @@ -89,7 +92,7 @@ typecheck = { chain = [ "typecheck:mypy" = "mypy ." [build-system] -requires = ["hatchling", "hatch-fancy-pypi-readme"] +requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"] build-backend = "hatchling.build" [tool.hatch.build] @@ -126,15 +129,12 @@ path = "README.md" pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)' replacement = '[\1](https://github.com/cloudflare/cloudflare-python/tree/main/\g<2>)' -[tool.black] -line-length = 120 -target-version = ["py37"] - [tool.pytest.ini_options] testpaths = ["tests"] -addopts = "--tb=short" +addopts = "--tb=short -n auto" xfail_strict = true asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "session" filterwarnings = [ "error" ] @@ -144,25 +144,82 @@ filterwarnings = [ # there are a couple of flags that are still disabled by # default in strict mode as they are experimental and niche. typeCheckingMode = "strict" -pythonVersion = "3.7" +pythonVersion = "3.9" exclude = [ "_dev", ".venv", ".nox", + ".git", ] reportImplicitOverride = true +reportOverlappingOverload = false reportImportCycles = false reportPrivateUsage = false -reportOverlappingOverload = false + +[tool.mypy] +pretty = true +show_error_codes = true + +# Exclude _files.py because mypy isn't smart enough to apply +# the correct type narrowing and as this is an internal module +# it's fine to just use Pyright. +# +# We also exclude our `tests` as mypy doesn't always infer +# types correctly and Pyright will still catch any type errors. +exclude = ['src/cloudflare/_files.py', '_dev/.*.py', 'tests/.*', 'src/cloudflare/resources/zero_trust/identity_providers\.py', 'src/cloudflare/resources/zero_trust/access/applications/applications\.py', 'src/cloudflare/resources/workers/ai\.py', 'src/cloudflare/resources/magic_transit/apps\.py'] + +strict_equality = true +implicit_reexport = true +check_untyped_defs = true +no_implicit_optional = true + +warn_return_any = true +warn_unreachable = true +warn_unused_configs = true + +# Turn these options off as it could cause conflicts +# with the Pyright options. +warn_unused_ignores = false +warn_redundant_casts = false + +disallow_any_generics = true +disallow_untyped_defs = true +disallow_untyped_calls = true +disallow_subclassing_any = true +disallow_incomplete_defs = true +disallow_untyped_decorators = true +cache_fine_grained = true + +# By default, mypy reports an error if you assign a value to the result +# of a function call that doesn't return anything. We do this in our test +# cases: +# ``` +# result = ... +# assert result is None +# ``` +# Changing this codegen to make mypy happy would increase complexity +# and would not be worth it. +disable_error_code = "func-returns-value,overload-cannot-match" + +# https://github.com/python/mypy/issues/12162 +[[tool.mypy.overrides]] +module = "black.files.*" +ignore_errors = true +ignore_missing_imports = true [tool.ruff] line-length = 120 output-format = "grouped" -target-version = "py37" +target-version = "py38" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] select = [ # isort "I", @@ -170,6 +227,8 @@ select = [ "B", # remove unused imports "F401", + # check for missing future annotations + "FA102", # bare except statements "E722", # unused arguments @@ -178,7 +237,7 @@ select = [ "T201", "T203", # misuse of typing.TYPE_CHECKING - "TCH004", + "TC004", # import rules "TID251", ] @@ -191,10 +250,8 @@ unfixable = [ "T201", "T203", ] -ignore-init-module-imports = true -[tool.ruff.format] -docstring-code-format = true +extend-safe-fixes = ["FA102"] [tool.ruff.lint.flake8-tidy-imports.banned-api] "functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead" @@ -206,7 +263,7 @@ combine-as-imports = true extra-standard-library = ["typing_extensions"] known-first-party = ["cloudflare", "tests"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "bin/**.py" = ["T201", "T203"] "scripts/**.py" = ["T201", "T203"] "tests/**.py" = ["T201", "T203"] diff --git a/requirements-dev.lock b/requirements-dev.lock index d624bbeb64e..9fb207c1220 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -7,99 +7,146 @@ # all-features: true # with-sources: false # generate-hashes: false +# universal: false -e file:. -annotated-types==0.6.0 +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.13.2 + # via cloudflare + # via httpx-aiohttp +aiosignal==1.4.0 + # via aiohttp +annotated-types==0.7.0 # via pydantic -anyio==4.4.0 +anyio==4.12.0 # via cloudflare # via httpx -argcomplete==3.1.2 +argcomplete==3.6.3 # via nox -attrs==23.1.0 - # via pytest -certifi==2023.7.22 +async-timeout==5.0.1 + # via aiohttp +attrs==25.4.0 + # via aiohttp + # via nox +backports-asyncio-runner==1.2.0 + # via pytest-asyncio +certifi==2025.11.12 # via httpcore # via httpx -colorlog==6.7.0 +colorama==0.4.6 + # via griffe +colorlog==6.10.1 + # via nox +dependency-groups==1.3.1 # via nox -dirty-equals==0.6.0 -distlib==0.3.7 +dirty-equals==0.11 +distlib==0.4.0 # via virtualenv -distro==1.8.0 +distro==1.9.0 # via cloudflare -exceptiongroup==1.1.3 +exceptiongroup==1.3.1 # via anyio -filelock==3.12.4 + # via pytest +execnet==2.1.2 + # via pytest-xdist +filelock==3.19.1 # via virtualenv -h11==0.14.0 +frozenlist==1.8.0 + # via aiohttp + # via aiosignal +griffe==1.14.0 +h11==0.16.0 # via httpcore -httpcore==1.0.2 +httpcore==1.0.9 # via httpx -httpx==0.25.2 +httpx==0.28.1 # via cloudflare + # via httpx-aiohttp # via respx -idna==3.4 +httpx-aiohttp==0.1.9 + # via cloudflare +humanize==4.13.0 + # via nox +idna==3.11 # via anyio # via httpx -importlib-metadata==7.0.0 -iniconfig==2.0.0 + # via yarl +importlib-metadata==8.7.0 +iniconfig==2.1.0 # via pytest markdown-it-py==3.0.0 # via rich mdurl==0.1.2 # via markdown-it-py -mypy==1.10.1 -mypy-extensions==1.0.0 +multidict==6.7.0 + # via aiohttp + # via yarl +mypy==1.17.0 +mypy-extensions==1.1.0 # via mypy -nodeenv==1.8.0 +nodeenv==1.9.1 # via pyright -nox==2023.4.22 -packaging==23.2 +nox==2025.11.12 +packaging==25.0 + # via dependency-groups # via nox # via pytest -platformdirs==3.11.0 +pathspec==0.12.1 + # via mypy +platformdirs==4.4.0 # via virtualenv -pluggy==1.3.0 +pluggy==1.6.0 # via pytest -py==1.11.0 - # via pytest -pydantic==2.7.1 +propcache==0.4.1 + # via aiohttp + # via yarl +pydantic==2.12.5 # via cloudflare -pydantic-core==2.18.2 +pydantic-core==2.41.5 # via pydantic -pygments==2.18.0 +pygments==2.19.2 + # via pytest # via rich -pyright==1.1.364 -pytest==7.1.1 +pyright==1.1.399 +pytest==8.4.2 # via pytest-asyncio -pytest-asyncio==0.21.1 -python-dateutil==2.8.2 + # via pytest-xdist +pytest-asyncio==1.2.0 +pytest-xdist==3.8.0 +python-dateutil==2.9.0.post0 # via time-machine -pytz==2023.3.post1 - # via dirty-equals -respx==0.20.2 -rich==13.7.1 -ruff==0.1.9 -setuptools==68.2.2 - # via nodeenv -six==1.16.0 +respx==0.22.0 +rich==14.2.0 +ruff==0.14.7 +six==1.17.0 # via python-dateutil -sniffio==1.3.0 - # via anyio +sniffio==1.3.1 # via cloudflare - # via httpx -time-machine==2.9.0 -tomli==2.0.1 +time-machine==2.19.0 +tomli==2.3.0 + # via dependency-groups # via mypy + # via nox # via pytest -typing-extensions==4.8.0 +typing-extensions==4.15.0 + # via aiosignal # via anyio # via cloudflare + # via exceptiongroup + # via multidict # via mypy # via pydantic # via pydantic-core -virtualenv==20.24.5 + # via pyright + # via pytest-asyncio + # via typing-inspection + # via virtualenv +typing-inspection==0.4.2 + # via pydantic +virtualenv==20.35.4 # via nox -zipp==3.17.0 +yarl==1.22.0 + # via aiohttp +zipp==3.23.0 # via importlib-metadata diff --git a/requirements.lock b/requirements.lock index a0d34229e70..c948e87d644 100644 --- a/requirements.lock +++ b/requirements.lock @@ -7,39 +7,70 @@ # all-features: true # with-sources: false # generate-hashes: false +# universal: false -e file:. -annotated-types==0.6.0 +aiohappyeyeballs==2.6.1 + # via aiohttp +aiohttp==3.13.2 + # via cloudflare + # via httpx-aiohttp +aiosignal==1.4.0 + # via aiohttp +annotated-types==0.7.0 # via pydantic -anyio==4.4.0 +anyio==4.12.0 # via cloudflare # via httpx -certifi==2023.7.22 +async-timeout==5.0.1 + # via aiohttp +attrs==25.4.0 + # via aiohttp +certifi==2025.11.12 # via httpcore # via httpx -distro==1.8.0 +distro==1.9.0 # via cloudflare -exceptiongroup==1.1.3 +exceptiongroup==1.3.1 # via anyio -h11==0.14.0 +frozenlist==1.8.0 + # via aiohttp + # via aiosignal +h11==0.16.0 # via httpcore -httpcore==1.0.2 +httpcore==1.0.9 # via httpx -httpx==0.25.2 +httpx==0.28.1 + # via cloudflare + # via httpx-aiohttp +httpx-aiohttp==0.1.9 # via cloudflare -idna==3.4 +idna==3.11 # via anyio # via httpx -pydantic==2.7.1 + # via yarl +multidict==6.7.0 + # via aiohttp + # via yarl +propcache==0.4.1 + # via aiohttp + # via yarl +pydantic==2.12.5 # via cloudflare -pydantic-core==2.18.2 +pydantic-core==2.41.5 # via pydantic -sniffio==1.3.0 - # via anyio +sniffio==1.3.1 # via cloudflare - # via httpx -typing-extensions==4.8.0 +typing-extensions==4.15.0 + # via aiosignal # via anyio # via cloudflare + # via exceptiongroup + # via multidict # via pydantic # via pydantic-core + # via typing-inspection +typing-inspection==0.4.2 + # via pydantic +yarl==1.22.0 + # via aiohttp diff --git a/scripts/bootstrap b/scripts/bootstrap index 8c5c60eba34..b430fee36d6 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/scripts/detect-breaking-changes b/scripts/detect-breaking-changes new file mode 100755 index 00000000000..fb28f3a261a --- /dev/null +++ b/scripts/detect-breaking-changes @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Detecting breaking changes" + +TEST_PATHS=( tests/api_resources tests/test_client.py tests/test_response.py ) + +for PATHSPEC in "${TEST_PATHS[@]}"; do + # Try to check out previous versions of the test files + # with the current SDK. + git checkout "$1" -- "${PATHSPEC}" 2>/dev/null || true +done + +# Instead of running the tests, use the linter to check if an +# older test is no longer compatible with the latest SDK. +./scripts/lint diff --git a/scripts/detect-breaking-changes.py b/scripts/detect-breaking-changes.py new file mode 100644 index 00000000000..f8d81890b9b --- /dev/null +++ b/scripts/detect-breaking-changes.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +import sys +from typing import Iterator +from pathlib import Path + +import rich +import griffe +from rich.text import Text +from rich.style import Style + + +def public_members(obj: griffe.Object | griffe.Alias) -> dict[str, griffe.Object | griffe.Alias]: + if isinstance(obj, griffe.Alias): + # ignore imports for now, they're technically part of the public API + # but we don't have good preventative measures in place to prevent + # changing them + return {} + + return {name: value for name, value in obj.all_members.items() if not name.startswith("_")} + + +def find_breaking_changes( + new_obj: griffe.Object | griffe.Alias, + old_obj: griffe.Object | griffe.Alias, + *, + path: list[str], +) -> Iterator[Text | str]: + new_members = public_members(new_obj) + old_members = public_members(old_obj) + + for name, old_member in old_members.items(): + if isinstance(old_member, griffe.Alias) and len(path) > 2: + # ignore imports in `/types/` for now, they're technically part of the public API + # but we don't have good preventative measures in place to prevent changing them + continue + + new_member = new_members.get(name) + if new_member is None: + cls_name = old_member.__class__.__name__ + yield Text(f"({cls_name})", style=Style(color="rgb(119, 119, 119)")) + yield from [" " for _ in range(10 - len(cls_name))] + yield f" {'.'.join(path)}.{name}" + yield "\n" + continue + + yield from find_breaking_changes(new_member, old_member, path=[*path, name]) + + +def main() -> None: + try: + against_ref = sys.argv[1] + except IndexError as err: + raise RuntimeError("You must specify a base ref to run breaking change detection against") from err + + package = griffe.load( + "cloudflare", + search_paths=[Path(__file__).parent.parent.joinpath("src")], + ) + old_package = griffe.load_git( + "cloudflare", + ref=against_ref, + search_paths=["src"], + ) + assert isinstance(package, griffe.Module) + assert isinstance(old_package, griffe.Module) + + output = list(find_breaking_changes(package, old_package, path=["cloudflare"])) + if output: + rich.print(Text("Breaking changes detected!", style=Style(color="rgb(165, 79, 87)"))) + rich.print() + + for text in output: + rich.print(text, end="") + + sys.exit(1) + + +main() diff --git a/scripts/lint b/scripts/lint index aa39f69ffbd..3c726986511 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,9 +4,13 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running lints" -rye run lint +if [ "$1" = "--fix" ]; then + echo "==> Running lints with --fix" + rye run fix:ruff +else + echo "==> Running lints" + rye run lint +fi echo "==> Making sure it imports" rye run python -c 'import cloudflare' - diff --git a/scripts/mock b/scripts/mock index fe89a1d084f..0b28f6ea23d 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ 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.8 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index b3ace9013bd..dbeda2d2176 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! prism_is_running ; then 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 -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 @@ -52,5 +52,10 @@ else echo fi +export DEFER_PYDANTIC_BUILD=false + echo "==> Running tests" rye run pytest "$@" + +echo "==> Running Pydantic v1 tests" +rye run nox -s test-pydantic-v1 -- "$@" diff --git a/scripts/utils/ruffen-docs.py b/scripts/utils/ruffen-docs.py index 37b3d94f0f8..0cf2bd2fd9d 100644 --- a/scripts/utils/ruffen-docs.py +++ b/scripts/utils/ruffen-docs.py @@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str: with _collect_error(match): code = format_code_block(code) code = textwrap.indent(code, match["indent"]) - return f'{match["before"]}{code}{match["after"]}' + return f"{match['before']}{code}{match['after']}" def _pycon_match(match: Match[str]) -> str: code = "" @@ -97,7 +97,7 @@ def finish_fragment() -> None: def _md_pycon_match(match: Match[str]) -> str: code = _pycon_match(match) code = textwrap.indent(code, match["indent"]) - return f'{match["before"]}{code}{match["after"]}' + return f"{match['before']}{code}{match['after']}" src = MD_RE.sub(_md_match, src) src = MD_PYCON_RE.sub(_md_pycon_match, src) diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh new file mode 100755 index 00000000000..fc6462eccf8 --- /dev/null +++ b/scripts/utils/upload-artifact.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -exuo pipefail + +FILENAME=$(basename dist/*.whl) + +RESPONSE=$(curl -X POST "$URL?filename=$FILENAME" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + +SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url') + +if [[ "$SIGNED_URL" == "null" ]]; then + echo -e "\033[31mFailed to get signed URL.\033[0m" + exit 1 +fi + +UPLOAD_RESPONSE=$(curl -v -X PUT \ + -H "Content-Type: binary/octet-stream" \ + --data-binary "@dist/$FILENAME" "$SIGNED_URL" 2>&1) + +if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then + echo -e "\033[32mUploaded build to Stainless storage.\033[0m" + echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/cloudflare-python/$SHA/$FILENAME'\033[0m" +else + echo -e "\033[31mFailed to upload artifact.\033[0m" + exit 1 +fi diff --git a/src/cloudflare/__init__.py b/src/cloudflare/__init__.py index bd005a22911..26a59059d51 100644 --- a/src/cloudflare/__init__.py +++ b/src/cloudflare/__init__.py @@ -1,7 +1,9 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +import typing as _t + from . import types -from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes +from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given from ._utils import file_from_path from ._client import ( Client, @@ -34,7 +36,7 @@ UnprocessableEntityError, APIResponseValidationError, ) -from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient +from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient from ._utils._logs import setup_logging as _setup_logging __all__ = [ @@ -46,6 +48,9 @@ "ProxiesTypes", "NotGiven", "NOT_GIVEN", + "not_given", + "Omit", + "omit", "CloudflareError", "APIError", "APIStatusError", @@ -75,8 +80,12 @@ "DEFAULT_CONNECTION_LIMITS", "DefaultHttpxClient", "DefaultAsyncHttpxClient", + "DefaultAioHttpClient", ] +if not _t.TYPE_CHECKING: + from ._utils._resources_proxy import resources as resources + _setup_logging() # Update the __module__ attribute for exported symbols so that diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index ac63cf2cd11..e6310e5837d 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -1,5 +1,6 @@ from __future__ import annotations +import sys import json import time import uuid @@ -35,14 +36,13 @@ import httpx import distro import pydantic -from httpx import URL, Limits +from httpx import URL from pydantic import PrivateAttr from . import _exceptions from ._qs import Querystring from ._files import to_httpx_files, async_to_httpx_files from ._types import ( - NOT_GIVEN, Body, Omit, Query, @@ -50,19 +50,21 @@ Timeout, NotGiven, ResponseT, - Transport, AnyMapping, PostParser, - ProxiesTypes, + BinaryTypes, RequestFiles, HttpxSendArgs, - AsyncTransport, + HttpxFileTypes, RequestOptions, + MultipartSyntax, + AsyncBinaryTypes, HttpxRequestFiles, ModelBuilderProtocol, + not_given, ) -from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping -from ._compat import model_copy, model_dump +from ._utils import is_dict, is_list, asyncify, is_given, is_tuple, lru_cache, is_mapping, is_mapping_t, is_sequence_t +from ._compat import PYDANTIC_V1, model_copy, model_dump from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type from ._response import ( APIResponse, @@ -101,7 +103,11 @@ _AsyncStreamT = TypeVar("_AsyncStreamT", bound=AsyncStream[Any]) if TYPE_CHECKING: - from httpx._config import DEFAULT_TIMEOUT_CONFIG as HTTPX_DEFAULT_TIMEOUT + from httpx._config import ( + DEFAULT_TIMEOUT_CONFIG, # pyright: ignore[reportPrivateImportUsage] + ) + + HTTPX_DEFAULT_TIMEOUT = DEFAULT_TIMEOUT_CONFIG else: try: from httpx._config import DEFAULT_TIMEOUT_CONFIG as HTTPX_DEFAULT_TIMEOUT @@ -118,32 +124,48 @@ class PageInfo: url: URL | NotGiven params: Query | NotGiven + json: Body | NotGiven @overload def __init__( self, *, url: URL, - ) -> None: - ... + ) -> None: ... @overload def __init__( self, *, params: Query, - ) -> None: - ... + ) -> None: ... + + @overload + def __init__( + self, + *, + json: Body, + ) -> None: ... def __init__( self, *, - url: URL | NotGiven = NOT_GIVEN, - params: Query | NotGiven = NOT_GIVEN, + url: URL | NotGiven = not_given, + json: Body | NotGiven = not_given, + params: Query | NotGiven = not_given, ) -> None: self.url = url + self.json = json self.params = params + @override + def __repr__(self) -> str: + if self.url: + return f"{self.__class__.__name__}(url={self.url})" + if self.json: + return f"{self.__class__.__name__}(json={self.json})" + return f"{self.__class__.__name__}(params={self.params})" + class BasePage(GenericModel, Generic[_T]): """ @@ -166,8 +188,7 @@ def has_next_page(self) -> bool: return False return self.next_page_info() is not None - def next_page_info(self) -> Optional[PageInfo]: - ... + def next_page_info(self) -> Optional[PageInfo]: ... def _get_page_items(self) -> Iterable[_T]: # type: ignore[empty-body] ... @@ -191,6 +212,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions: options.url = str(url) return options + if not isinstance(info.json, NotGiven): + if not is_mapping(info.json): + raise TypeError("Pagination is only supported with mappings") + + if not options.json_data: + options.json_data = {**info.json} + else: + if not is_mapping(options.json_data): + raise TypeError("Pagination is only supported with mappings") + + options.json_data = {**options.json_data, **info.json} + return options + raise ValueError("Unexpected PageInfo state") @@ -203,6 +237,9 @@ def _set_private_attributes( model: Type[_T], options: FinalRequestOptions, ) -> None: + if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options @@ -288,6 +325,9 @@ def _set_private_attributes( client: AsyncAPIClient, options: FinalRequestOptions, ) -> None: + if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options @@ -325,11 +365,9 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]): _client: _HttpxClientT _version: str _base_url: URL + _api_version: str max_retries: int timeout: Union[float, Timeout, None] - _limits: httpx.Limits - _proxies: ProxiesTypes | None - _transport: Transport | AsyncTransport | None _strict_response_validation: bool _idempotency_header: str | None _default_stream_cls: type[_DefaultStreamT] | None = None @@ -339,22 +377,18 @@ def __init__( *, version: str, base_url: str | URL, + api_version: str, _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, timeout: float | Timeout | None = DEFAULT_TIMEOUT, - limits: httpx.Limits, - transport: Transport | AsyncTransport | None, - proxies: ProxiesTypes | None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, ) -> None: self._version = version self._base_url = self._enforce_trailing_slash(URL(base_url)) + self.api_version = api_version self.max_retries = max_retries self.timeout = timeout - self._limits = limits - self._proxies = proxies - self._transport = transport self._custom_headers = custom_headers or {} self._custom_query = custom_query or {} self._strict_response_validation = _strict_response_validation @@ -402,14 +436,7 @@ def _make_status_error( ) -> _exceptions.APIStatusError: raise NotImplementedError() - def _remaining_retries( - self, - remaining_retries: Optional[int], - options: FinalRequestOptions, - ) -> int: - return remaining_retries if remaining_retries is not None else options.get_max_retries(self.max_retries) - - def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers: + def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers: custom_headers = options.headers or {} headers_dict = _merge_mappings(self.default_headers, custom_headers) self._validate_headers(headers_dict, custom_headers) @@ -418,8 +445,22 @@ def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers: headers = httpx.Headers(headers_dict) idempotency_header = self._idempotency_header - if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers: - headers[idempotency_header] = options.idempotency_key or self._idempotency_key() + if idempotency_header and options.idempotency_key and idempotency_header not in headers: + headers[idempotency_header] = options.idempotency_key + + # Don't set these headers if they were already set or removed by the caller. We check + # `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case. + lower_custom_headers = [header.lower() for header in custom_headers] + if "x-stainless-retry-count" not in lower_custom_headers: + headers["x-stainless-retry-count"] = str(retries_taken) + if "x-stainless-read-timeout" not in lower_custom_headers: + timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout + if isinstance(timeout, Timeout): + timeout = timeout.read + if timeout is not None: + headers["x-stainless-read-timeout"] = str(timeout) + + headers["api-version"] = self.api_version return headers @@ -442,10 +483,23 @@ def _make_sse_decoder(self) -> SSEDecoder | SSEBytesDecoder: def _build_request( self, options: FinalRequestOptions, + *, + retries_taken: int = 0, ) -> httpx.Request: if log.isEnabledFor(logging.DEBUG): - log.debug("Request options: %s", model_dump(options, exclude_unset=True)) - + log.debug( + "Request options: %s", + model_dump( + options, + exclude_unset=True, + # Pydantic v1 can't dump every type we support in content, so we exclude it for now. + exclude={ + "content", + } + if PYDANTIC_V1 + else {}, + ), + ) kwargs: dict[str, Any] = {} json_data = options.json_data @@ -457,7 +511,7 @@ def _build_request( else: raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`") - headers = self._build_headers(options) + headers = self._build_headers(options, retries_taken=retries_taken) params = _merge_mappings(self.default_query, options.params) content_type = headers.get("Content-Type") files = options.files @@ -480,7 +534,24 @@ def _build_request( raise TypeError( f"Expected query input to be a dictionary for multipart requests but got {type(json_data)} instead." ) - kwargs["data"] = self._serialize_multipartform(json_data) + + if options.multipart_syntax == 'json': + json_data = cast("Mapping[str, object]", json_data) + if is_mapping_t(files): + files = { + **files, + **self._serialize_multiapartform_json(json_data), + } + elif is_sequence_t(files): + files = [ + *files, + *self._serialize_multiapartform_json(json_data).items(), + ] + else: + assert not files, "this case should only be hit when there are no files" + files = self._serialize_multiapartform_json(json_data) + else: + kwargs["data"] = self._serialize_multipartform(json_data) # httpx determines whether or not to send a "multipart/form-data" # request based on the truthiness of the "files" argument. @@ -491,22 +562,59 @@ def _build_request( if not files: files = cast(HttpxRequestFiles, ForceMultipartDict()) + prepared_url = self._prepare_url(options.url) + if "_" in prepared_url.host: + # work around https://github.com/encode/httpx/discussions/2880 + kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} + + is_body_allowed = options.method.lower() != "get" + + if is_body_allowed: + if options.content is not None and json_data is not None: + raise TypeError("Passing both `content` and `json_data` is not supported") + if options.content is not None and files is not None: + raise TypeError("Passing both `content` and `files` is not supported") + if options.content is not None: + kwargs["content"] = options.content + elif isinstance(json_data, bytes): + kwargs["content"] = json_data + else: + kwargs["json"] = json_data if is_given(json_data) else None + kwargs["files"] = files + else: + headers.pop("Content-Type", None) + kwargs.pop("data", None) + # TODO: report this error to httpx return self._client.build_request( # pyright: ignore[reportUnknownMemberType] headers=headers, timeout=self.timeout if isinstance(options.timeout, NotGiven) else options.timeout, method=options.method, - url=self._prepare_url(options.url), + url=prepared_url, # the `Query` type that we use is incompatible with qs' # `Params` type as it needs to be typed as `Mapping[str, object]` # so that passing a `TypedDict` doesn't cause an error. # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, - json=json_data, - files=files, **kwargs, ) + def _serialize_multiapartform_json(self, data: Mapping[str, object]) -> dict[str, HttpxFileTypes]: + serialized: dict[str, HttpxFileTypes] = {} + for key, value in data.items(): + if isinstance(value, Mapping) or is_list(value) or is_tuple(value): + serialized[key] = (None, json.dumps(value).encode("utf-8"), "application/json") + else: + serialized[key] = ( + None, + self.qs._primitive_value_to_str( + value # type: ignore + ).encode("utf-8"), + "text/plain", + ) + + return serialized + def _serialize_multipartform(self, data: Mapping[object, object]) -> dict[str, object]: items = self.qs.stringify_items( # TODO: type ignore is required as stringify_items is well typed but we can't be @@ -547,7 +655,7 @@ def _maybe_override_cast_to(self, cast_to: type[ResponseT], options: FinalReques # we internally support defining a temporary header to override the # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response` # see _response.py for implementation details - override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN) + override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given) if is_given(override_cast_to): options.headers = headers return cast(Type[ResponseT], override_cast_to) @@ -686,7 +794,8 @@ def _calculate_retry_timeout( if retry_after is not None and 0 < retry_after <= 60: return retry_after - nb_retries = max_retries - remaining_retries + # Also cap retry count to 1000 to avoid any potential overflows with `pow` + nb_retries = min(max_retries - remaining_retries, 1000) # Apply exponential backoff, but not more than the max. sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY) @@ -757,6 +866,9 @@ def __init__(self, **kwargs: Any) -> None: class SyncHttpxClientWrapper(DefaultHttpxClient): def __del__(self) -> None: + if self.is_closed: + return + try: self.close() except Exception: @@ -772,45 +884,14 @@ def __init__( *, version: str, base_url: str | URL, + api_version: str, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, - transport: Transport | None = None, - proxies: ProxiesTypes | None = None, - limits: Limits | None = None, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, _strict_response_validation: bool, ) -> None: - if limits is not None: - warnings.warn( - "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`") - else: - limits = DEFAULT_CONNECTION_LIMITS - - if transport is not None: - warnings.warn( - "The `transport` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `transport`") - - if proxies is not None: - warnings.warn( - "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `proxies`") - if not is_given(timeout): # if the user passed in a custom http client with a non-default # timeout set then we use that timeout. @@ -831,12 +912,10 @@ def __init__( super().__init__( version=version, - limits=limits, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, base_url=base_url, - transport=transport, + api_version=api_version, max_retries=max_retries, custom_query=custom_query, custom_headers=custom_headers, @@ -846,10 +925,6 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, - limits=limits, - follow_redirects=True, ) def is_closed(self) -> bool: @@ -899,189 +974,163 @@ def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, - remaining_retries: Optional[int] = None, *, stream: Literal[True], stream_cls: Type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, - remaining_retries: Optional[int] = None, *, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, - remaining_retries: Optional[int] = None, *, stream: bool = False, stream_cls: Type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, - remaining_retries: Optional[int] = None, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: - return self._request( - cast_to=cast_to, - options=options, - stream=stream, - stream_cls=stream_cls, - remaining_retries=remaining_retries, - ) + cast_to = self._maybe_override_cast_to(cast_to, options) - def _request( - self, - *, - cast_to: Type[ResponseT], - options: FinalRequestOptions, - remaining_retries: int | None, - stream: bool, - stream_cls: type[_StreamT] | None, - ) -> ResponseT | _StreamT: # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) + if input_options.idempotency_key is None and input_options.method.lower() != "get": + # ensure the idempotency key is reused between requests + input_options.idempotency_key = self._idempotency_key() - cast_to = self._maybe_override_cast_to(cast_to, options) - options = self._prepare_options(options) + response: httpx.Response | None = None + max_retries = input_options.get_max_retries(self.max_retries) - retries = self._remaining_retries(remaining_retries, options) - request = self._build_request(options) - self._prepare_request(request) + retries_taken = 0 + for retries_taken in range(max_retries + 1): + options = model_copy(input_options) + options = self._prepare_options(options) - kwargs: HttpxSendArgs = {} - if self.custom_auth is not None: - kwargs["auth"] = self.custom_auth + remaining_retries = max_retries - retries_taken + request = self._build_request(options, retries_taken=retries_taken) + self._prepare_request(request) - log.debug("Sending HTTP Request: %s %s", request.method, request.url) + kwargs: HttpxSendArgs = {} + if self.custom_auth is not None: + kwargs["auth"] = self.custom_auth - try: - response = self._client.send( - request, - stream=stream or self._should_stream_response_body(request=request), - **kwargs, - ) - except httpx.TimeoutException as err: - log.debug("Encountered httpx.TimeoutException", exc_info=True) - - if retries > 0: - return self._retry_request( - input_options, - cast_to, - retries, - stream=stream, - stream_cls=stream_cls, - response_headers=None, - ) + if options.follow_redirects is not None: + kwargs["follow_redirects"] = options.follow_redirects - log.debug("Raising timeout error") - raise APITimeoutError(request=request) from err - except Exception as err: - log.debug("Encountered Exception", exc_info=True) + log.debug("Sending HTTP Request: %s %s", request.method, request.url) - if retries > 0: - return self._retry_request( - input_options, - cast_to, - retries, - stream=stream, - stream_cls=stream_cls, - response_headers=None, + response = None + try: + response = self._client.send( + request, + stream=stream or self._should_stream_response_body(request=request), + **kwargs, ) + except httpx.TimeoutException as err: + log.debug("Encountered httpx.TimeoutException", exc_info=True) + + if remaining_retries > 0: + self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=None, + ) + continue + + log.debug("Raising timeout error") + raise APITimeoutError(request=request) from err + except Exception as err: + log.debug("Encountered Exception", exc_info=True) + + if remaining_retries > 0: + self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=None, + ) + continue + + log.debug("Raising connection error") + raise APIConnectionError(request=request) from err + + log.debug( + 'HTTP Response: %s %s "%i %s" %s', + request.method, + request.url, + response.status_code, + response.reason_phrase, + response.headers, + ) - log.debug("Raising connection error") - raise APIConnectionError(request=request) from err + try: + response.raise_for_status() + except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code + log.debug("Encountered httpx.HTTPStatusError", exc_info=True) + + if remaining_retries > 0 and self._should_retry(err.response): + err.response.close() + self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=response, + ) + continue - log.debug( - 'HTTP Response: %s %s "%i %s" %s', - request.method, - request.url, - response.status_code, - response.reason_phrase, - response.headers, - ) + # If the response is streamed then we need to explicitly read the response + # to completion before attempting to access the response text. + if not err.response.is_closed: + err.response.read() - try: - response.raise_for_status() - except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code - log.debug("Encountered httpx.HTTPStatusError", exc_info=True) - - if retries > 0 and self._should_retry(err.response): - err.response.close() - return self._retry_request( - input_options, - cast_to, - retries, - err.response.headers, - stream=stream, - stream_cls=stream_cls, - ) + log.debug("Re-raising status error") + raise self._make_status_error_from_response(err.response) from None - # If the response is streamed then we need to explicitly read the response - # to completion before attempting to access the response text. - if not err.response.is_closed: - err.response.read() - - log.debug("Re-raising status error") - raise self._make_status_error_from_response(err.response) from None + break + assert response is not None, "could not resolve response (should never happen)" return self._process_response( cast_to=cast_to, options=options, response=response, stream=stream, stream_cls=stream_cls, + retries_taken=retries_taken, ) - def _retry_request( - self, - options: FinalRequestOptions, - cast_to: Type[ResponseT], - remaining_retries: int, - response_headers: httpx.Headers | None, - *, - stream: bool, - stream_cls: type[_StreamT] | None, - ) -> ResponseT | _StreamT: - remaining = remaining_retries - 1 - if remaining == 1: + def _sleep_for_retry( + self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Response | None + ) -> None: + remaining_retries = max_retries - retries_taken + if remaining_retries == 1: log.debug("1 retry left") else: - log.debug("%i retries left", remaining) + log.debug("%i retries left", remaining_retries) - timeout = self._calculate_retry_timeout(remaining, options, response_headers) + timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None) log.info("Retrying request to %s in %f seconds", options.url, timeout) - # In a synchronous context we are blocking the entire thread. Up to the library user to run the client in a - # different thread if necessary. time.sleep(timeout) - return self._request( - options=options, - cast_to=cast_to, - remaining_retries=remaining, - stream=stream, - stream_cls=stream_cls, - ) - def _process_response( self, *, @@ -1090,10 +1139,18 @@ def _process_response( response: httpx.Response, stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, + retries_taken: int = 0, ) -> ResponseT: origin = get_origin(cast_to) or cast_to - if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse): + if ( + inspect.isclass(origin) + and issubclass(origin, BaseAPIResponse) + # we only want to actually return the custom BaseAPIResponse class if we're + # returning the raw response, or if we're not streaming SSE, as if we're streaming + # SSE then `cast_to` doesn't actively reflect the type we need to parse into + and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER))) + ): if not issubclass(origin, APIResponse): raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}") @@ -1107,6 +1164,7 @@ def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1120,6 +1178,7 @@ def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ) if bool(response.request.headers.get(RAW_RESPONSE_HEADER)): return cast(ResponseT, api_response) @@ -1152,8 +1211,7 @@ def get( cast_to: Type[ResponseT], options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def get( @@ -1164,8 +1222,7 @@ def get( options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def get( @@ -1176,8 +1233,7 @@ def get( options: RequestOptions = {}, stream: bool, stream_cls: type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def get( self, @@ -1200,11 +1256,11 @@ def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, options: RequestOptions = {}, files: RequestFiles | None = None, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def post( @@ -1213,12 +1269,12 @@ def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, options: RequestOptions = {}, files: RequestFiles | None = None, stream: Literal[True], stream_cls: type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def post( @@ -1227,12 +1283,12 @@ def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, options: RequestOptions = {}, files: RequestFiles | None = None, stream: bool, stream_cls: type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def post( self, @@ -1240,13 +1296,25 @@ def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, options: RequestOptions = {}, files: RequestFiles | None = None, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) opts = FinalRequestOptions.construct( - method="post", url=path, json_data=body, files=to_httpx_files(files), **options + method="post", url=path, json_data=body, content=content, files=to_httpx_files(files), **options ) return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) @@ -1256,9 +1324,24 @@ def patch( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, + files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options) + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) + opts = FinalRequestOptions.construct( + method="patch", url=path, json_data=body, content=content, files=to_httpx_files(files), **options + ) return self.request(cast_to, opts) def put( @@ -1267,11 +1350,23 @@ def put( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) opts = FinalRequestOptions.construct( - method="put", url=path, json_data=body, files=to_httpx_files(files), **options + method="put", url=path, json_data=body, content=content, files=to_httpx_files(files), **options ) return self.request(cast_to, opts) @@ -1281,9 +1376,19 @@ def delete( *, cast_to: Type[ResponseT], body: Body | None = None, + content: BinaryTypes | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options) + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) + opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options) return self.request(cast_to, opts) def get_api_list( @@ -1308,6 +1413,24 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) +try: + import httpx_aiohttp +except ImportError: + + class _DefaultAioHttpClient(httpx.AsyncClient): + def __init__(self, **_kwargs: Any) -> None: + raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra") +else: + + class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore + def __init__(self, **kwargs: Any) -> None: + kwargs.setdefault("timeout", DEFAULT_TIMEOUT) + kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS) + kwargs.setdefault("follow_redirects", True) + + super().__init__(**kwargs) + + if TYPE_CHECKING: DefaultAsyncHttpxClient = httpx.AsyncClient """An alias to `httpx.AsyncClient` that provides the same defaults that this SDK @@ -1316,12 +1439,19 @@ def __init__(self, **kwargs: Any) -> None: This is useful because overriding the `http_client` with your own instance of `httpx.AsyncClient` will result in httpx's defaults being used, not ours. """ + + DefaultAioHttpClient = httpx.AsyncClient + """An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`.""" else: DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient + DefaultAioHttpClient = _DefaultAioHttpClient class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient): def __del__(self) -> None: + if self.is_closed: + return + try: # TODO(someday): support non asyncio runtimes here asyncio.get_running_loop().create_task(self.aclose()) @@ -1338,45 +1468,14 @@ def __init__( *, version: str, base_url: str | URL, + api_version: str, _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, - transport: AsyncTransport | None = None, - proxies: ProxiesTypes | None = None, - limits: Limits | None = None, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, ) -> None: - if limits is not None: - warnings.warn( - "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`") - else: - limits = DEFAULT_CONNECTION_LIMITS - - if transport is not None: - warnings.warn( - "The `transport` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `transport`") - - if proxies is not None: - warnings.warn( - "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `proxies`") - if not is_given(timeout): # if the user passed in a custom http client with a non-default # timeout set then we use that timeout. @@ -1398,11 +1497,9 @@ def __init__( super().__init__( version=version, base_url=base_url, - limits=limits, + api_version=api_version, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, max_retries=max_retries, custom_query=custom_query, custom_headers=custom_headers, @@ -1412,10 +1509,6 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, - limits=limits, - follow_redirects=True, ) def is_closed(self) -> bool: @@ -1464,9 +1557,7 @@ async def request( options: FinalRequestOptions, *, stream: Literal[False] = False, - remaining_retries: Optional[int] = None, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def request( @@ -1476,9 +1567,7 @@ async def request( *, stream: Literal[True], stream_cls: type[_AsyncStreamT], - remaining_retries: Optional[int] = None, - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def request( @@ -1488,9 +1577,7 @@ async def request( *, stream: bool, stream_cls: type[_AsyncStreamT] | None = None, - remaining_retries: Optional[int] = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def request( self, @@ -1499,148 +1586,137 @@ async def request( *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, - remaining_retries: Optional[int] = None, - ) -> ResponseT | _AsyncStreamT: - return await self._request( - cast_to=cast_to, - options=options, - stream=stream, - stream_cls=stream_cls, - remaining_retries=remaining_retries, - ) - - async def _request( - self, - cast_to: Type[ResponseT], - options: FinalRequestOptions, - *, - stream: bool, - stream_cls: type[_AsyncStreamT] | None, - remaining_retries: int | None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() + cast_to = self._maybe_override_cast_to(cast_to, options) + # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) + if input_options.idempotency_key is None and input_options.method.lower() != "get": + # ensure the idempotency key is reused between requests + input_options.idempotency_key = self._idempotency_key() - cast_to = self._maybe_override_cast_to(cast_to, options) - options = await self._prepare_options(options) + response: httpx.Response | None = None + max_retries = input_options.get_max_retries(self.max_retries) - retries = self._remaining_retries(remaining_retries, options) - request = self._build_request(options) - await self._prepare_request(request) + retries_taken = 0 + for retries_taken in range(max_retries + 1): + options = model_copy(input_options) + options = await self._prepare_options(options) - kwargs: HttpxSendArgs = {} - if self.custom_auth is not None: - kwargs["auth"] = self.custom_auth + remaining_retries = max_retries - retries_taken + request = self._build_request(options, retries_taken=retries_taken) + await self._prepare_request(request) - try: - response = await self._client.send( - request, - stream=stream or self._should_stream_response_body(request=request), - **kwargs, - ) - except httpx.TimeoutException as err: - log.debug("Encountered httpx.TimeoutException", exc_info=True) - - if retries > 0: - return await self._retry_request( - input_options, - cast_to, - retries, - stream=stream, - stream_cls=stream_cls, - response_headers=None, - ) + kwargs: HttpxSendArgs = {} + if self.custom_auth is not None: + kwargs["auth"] = self.custom_auth - log.debug("Raising timeout error") - raise APITimeoutError(request=request) from err - except Exception as err: - log.debug("Encountered Exception", exc_info=True) + if options.follow_redirects is not None: + kwargs["follow_redirects"] = options.follow_redirects - if retries > 0: - return await self._retry_request( - input_options, - cast_to, - retries, - stream=stream, - stream_cls=stream_cls, - response_headers=None, + log.debug("Sending HTTP Request: %s %s", request.method, request.url) + + response = None + try: + response = await self._client.send( + request, + stream=stream or self._should_stream_response_body(request=request), + **kwargs, ) + except httpx.TimeoutException as err: + log.debug("Encountered httpx.TimeoutException", exc_info=True) + + if remaining_retries > 0: + await self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=None, + ) + continue + + log.debug("Raising timeout error") + raise APITimeoutError(request=request) from err + except Exception as err: + log.debug("Encountered Exception", exc_info=True) + + if remaining_retries > 0: + await self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=None, + ) + continue + + log.debug("Raising connection error") + raise APIConnectionError(request=request) from err + + log.debug( + 'HTTP Response: %s %s "%i %s" %s', + request.method, + request.url, + response.status_code, + response.reason_phrase, + response.headers, + ) - log.debug("Raising connection error") - raise APIConnectionError(request=request) from err + try: + response.raise_for_status() + except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code + log.debug("Encountered httpx.HTTPStatusError", exc_info=True) + + if remaining_retries > 0 and self._should_retry(err.response): + await err.response.aclose() + await self._sleep_for_retry( + retries_taken=retries_taken, + max_retries=max_retries, + options=input_options, + response=response, + ) + continue - log.debug( - 'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase - ) + # If the response is streamed then we need to explicitly read the response + # to completion before attempting to access the response text. + if not err.response.is_closed: + await err.response.aread() - try: - response.raise_for_status() - except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code - log.debug("Encountered httpx.HTTPStatusError", exc_info=True) - - if retries > 0 and self._should_retry(err.response): - await err.response.aclose() - return await self._retry_request( - input_options, - cast_to, - retries, - err.response.headers, - stream=stream, - stream_cls=stream_cls, - ) + log.debug("Re-raising status error") + raise self._make_status_error_from_response(err.response) from None - # If the response is streamed then we need to explicitly read the response - # to completion before attempting to access the response text. - if not err.response.is_closed: - await err.response.aread() - - log.debug("Re-raising status error") - raise self._make_status_error_from_response(err.response) from None + break + assert response is not None, "could not resolve response (should never happen)" return await self._process_response( cast_to=cast_to, options=options, response=response, stream=stream, stream_cls=stream_cls, + retries_taken=retries_taken, ) - async def _retry_request( - self, - options: FinalRequestOptions, - cast_to: Type[ResponseT], - remaining_retries: int, - response_headers: httpx.Headers | None, - *, - stream: bool, - stream_cls: type[_AsyncStreamT] | None, - ) -> ResponseT | _AsyncStreamT: - remaining = remaining_retries - 1 - if remaining == 1: + async def _sleep_for_retry( + self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Response | None + ) -> None: + remaining_retries = max_retries - retries_taken + if remaining_retries == 1: log.debug("1 retry left") else: - log.debug("%i retries left", remaining) + log.debug("%i retries left", remaining_retries) - timeout = self._calculate_retry_timeout(remaining, options, response_headers) + timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None) log.info("Retrying request to %s in %f seconds", options.url, timeout) await anyio.sleep(timeout) - return await self._request( - options=options, - cast_to=cast_to, - remaining_retries=remaining, - stream=stream, - stream_cls=stream_cls, - ) - async def _process_response( self, *, @@ -1649,10 +1725,18 @@ async def _process_response( response: httpx.Response, stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, + retries_taken: int = 0, ) -> ResponseT: origin = get_origin(cast_to) or cast_to - if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse): + if ( + inspect.isclass(origin) + and issubclass(origin, BaseAPIResponse) + # we only want to actually return the custom BaseAPIResponse class if we're + # returning the raw response, or if we're not streaming SSE, as if we're streaming + # SSE then `cast_to` doesn't actively reflect the type we need to parse into + and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER))) + ): if not issubclass(origin, AsyncAPIResponse): raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}") @@ -1666,6 +1750,7 @@ async def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1679,6 +1764,7 @@ async def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ) if bool(response.request.headers.get(RAW_RESPONSE_HEADER)): return cast(ResponseT, api_response) @@ -1701,8 +1787,7 @@ async def get( cast_to: Type[ResponseT], options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def get( @@ -1713,8 +1798,7 @@ async def get( options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_AsyncStreamT], - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def get( @@ -1725,8 +1809,7 @@ async def get( options: RequestOptions = {}, stream: bool, stream_cls: type[_AsyncStreamT] | None = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def get( self, @@ -1747,11 +1830,11 @@ async def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def post( @@ -1760,12 +1843,12 @@ async def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_AsyncStreamT], - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def post( @@ -1774,12 +1857,12 @@ async def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, stream: bool, stream_cls: type[_AsyncStreamT] | None = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def post( self, @@ -1787,13 +1870,25 @@ async def post( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) opts = FinalRequestOptions.construct( - method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options + method="post", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options ) return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) @@ -1803,9 +1898,29 @@ async def patch( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, + files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options) + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) + opts = FinalRequestOptions.construct( + method="patch", + url=path, + json_data=body, + content=content, + files=await async_to_httpx_files(files), + **options, + ) return await self.request(cast_to, opts) async def put( @@ -1814,11 +1929,23 @@ async def put( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if files is not None and content is not None: + raise TypeError("Passing both `files` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) opts = FinalRequestOptions.construct( - method="put", url=path, json_data=body, files=await async_to_httpx_files(files), **options + method="put", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options ) return await self.request(cast_to, opts) @@ -1828,9 +1955,19 @@ async def delete( *, cast_to: Type[ResponseT], body: Body | None = None, + content: AsyncBinaryTypes | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options) + if body is not None and content is not None: + raise TypeError("Passing both `body` and `content` is not supported") + if isinstance(body, bytes): + warnings.warn( + "Passing raw bytes as `body` is deprecated and will be removed in a future version. " + "Please pass raw bytes via the `content` parameter instead.", + DeprecationWarning, + stacklevel=2, + ) + opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options) return await self.request(cast_to, opts) def get_api_list( @@ -1854,8 +1991,9 @@ def make_request_options( extra_query: Query | None = None, extra_body: Body | None = None, idempotency_key: str | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - post_parser: PostParser | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + post_parser: PostParser | NotGiven = not_given, + multipart_syntax: MultipartSyntax | None = None, ) -> RequestOptions: """Create a dict of type RequestOptions without keys of NotGiven values.""" options: RequestOptions = {} @@ -1881,6 +2019,9 @@ def make_request_options( # internal options["post_parser"] = post_parser # type: ignore + if multipart_syntax is not None: + options["multipart_syntax"] = multipart_syntax + return options @@ -1995,7 +2136,6 @@ def get_python_version() -> str: def get_architecture() -> Arch: try: - python_bitness, _ = platform.architecture() machine = platform.machine().lower() except Exception: return "unknown" @@ -2011,7 +2151,7 @@ def get_architecture() -> Arch: return "x64" # TODO: untested - if python_bitness == "32bit": + if sys.maxsize <= 2**32: return "x32" if machine: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 6e2928862dd..edc473185de 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -3,15 +3,15 @@ from __future__ import annotations import os -from typing import Any, Union, Mapping +from typing import TYPE_CHECKING, Any, Mapping +from datetime import datetime from typing_extensions import Self, override import httpx -from . import resources, _exceptions +from . import _exceptions from ._qs import Querystring from ._types import ( - NOT_GIVEN, Omit, Headers, Timeout, @@ -19,11 +19,10 @@ Transport, ProxiesTypes, RequestOptions, + not_given, ) -from ._utils import ( - is_given, - get_async_library, -) +from ._utils import is_given, get_async_library +from ._compat import cached_property from ._version import __version__ from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError @@ -33,12 +32,246 @@ AsyncAPIClient, ) +if TYPE_CHECKING: + from .resources import ( + ai, + d1, + kv, + r2, + acm, + dns, + iam, + ips, + rum, + ssl, + argo, + logs, + user, + web3, + cache, + calls, + fraud, + intel, + pages, + radar, + rules, + speed, + zaraz, + zones, + images, + queues, + stream, + billing, + filters, + logpush, + workers, + accounts, + aisearch, + alerting, + firewall, + rulesets, + snippets, + spectrum, + hostnames, + pipelines, + registrar, + turnstile, + vectorize, + workflows, + addressing, + ai_gateway, + audit_logs, + hyperdrive, + page_rules, + zero_trust, + api_gateway, + botnet_feed, + diagnostics, + memberships, + page_shield, + rate_limits, + url_scanner, + connectivity, + custom_pages, + dns_firewall, + healthchecks, + realtime_kit, + security_txt, + abuse_reports, + email_routing, + magic_transit, + organizations, + secrets_store, + waiting_rooms, + bot_management, + cloudforce_one, + dcv_delegation, + email_security, + load_balancers, + cloud_connector, + durable_objects, + r2_data_catalog, + request_tracers, + security_center, + brand_protection, + content_scanning, + custom_hostnames, + resource_sharing, + token_validation, + browser_rendering, + mtls_certificates, + schema_validation, + url_normalization, + custom_nameservers, + managed_transforms, + client_certificates, + custom_certificates, + keyless_certificates, + network_interconnects, + workers_for_platforms, + magic_cloud_networking, + origin_ca_certificates, + origin_tls_client_auth, + certificate_authorities, + leaked_credential_checks, + magic_network_monitoring, + origin_post_quantum_encryption, + ) + from .resources.ips import IPsResource, AsyncIPsResource + from .resources.ai.ai import AIResource, AsyncAIResource + from .resources.d1.d1 import D1Resource, AsyncD1Resource + from .resources.fraud import FraudResource, AsyncFraudResource + from .resources.kv.kv import KVResource, AsyncKVResource + from .resources.r2.r2 import R2Resource, AsyncR2Resource + from .resources.acm.acm import ACMResource, AsyncACMResource + from .resources.dns.dns import DNSResource, AsyncDNSResource + from .resources.filters import FiltersResource, AsyncFiltersResource + from .resources.iam.iam import IAMResource, AsyncIAMResource + from .resources.rum.rum import RUMResource, AsyncRUMResource + from .resources.ssl.ssl import SSLResource, AsyncSSLResource + from .resources.argo.argo import ArgoResource, AsyncArgoResource + from .resources.logs.logs import LogsResource, AsyncLogsResource + from .resources.user.user import UserResource, AsyncUserResource + from .resources.web3.web3 import Web3Resource, AsyncWeb3Resource + from .resources.audit_logs import AuditLogsResource, AsyncAuditLogsResource + from .resources.page_rules import PageRulesResource, AsyncPageRulesResource + from .resources.cache.cache import CacheResource, AsyncCacheResource + from .resources.calls.calls import CallsResource, AsyncCallsResource + from .resources.intel.intel import IntelResource, AsyncIntelResource + from .resources.memberships import MembershipsResource, AsyncMembershipsResource + from .resources.pages.pages import PagesResource, AsyncPagesResource + from .resources.radar.radar import RadarResource, AsyncRadarResource + from .resources.rate_limits import RateLimitsResource, AsyncRateLimitsResource + from .resources.rules.rules import RulesResource, AsyncRulesResource + from .resources.speed.speed import SpeedResource, AsyncSpeedResource + from .resources.zaraz.zaraz import ZarazResource, AsyncZarazResource + from .resources.zones.zones import ZonesResource, AsyncZonesResource + from .resources.custom_pages import CustomPagesResource, AsyncCustomPagesResource + from .resources.security_txt import SecurityTXTResource, AsyncSecurityTXTResource + from .resources.images.images import ImagesResource, AsyncImagesResource + from .resources.queues.queues import QueuesResource, AsyncQueuesResource + from .resources.stream.stream import StreamResource, AsyncStreamResource + from .resources.bot_management import BotManagementResource, AsyncBotManagementResource + from .resources.dcv_delegation import DCVDelegationResource, AsyncDCVDelegationResource + from .resources.billing.billing import BillingResource, AsyncBillingResource + from .resources.logpush.logpush import LogpushResource, AsyncLogpushResource + from .resources.workers.workers import WorkersResource, AsyncWorkersResource + from .resources.accounts.accounts import AccountsResource, AsyncAccountsResource + from .resources.aisearch.aisearch import AISearchResource, AsyncAISearchResource + from .resources.alerting.alerting import AlertingResource, AsyncAlertingResource + from .resources.firewall.firewall import FirewallResource, AsyncFirewallResource + from .resources.rulesets.rulesets import RulesetsResource, AsyncRulesetsResource + from .resources.snippets.snippets import SnippetsResource, AsyncSnippetsResource + from .resources.spectrum.spectrum import SpectrumResource, AsyncSpectrumResource + from .resources.url_normalization import URLNormalizationResource, AsyncURLNormalizationResource + from .resources.custom_nameservers import CustomNameserversResource, AsyncCustomNameserversResource + from .resources.managed_transforms import ManagedTransformsResource, AsyncManagedTransformsResource + from .resources.client_certificates import ClientCertificatesResource, AsyncClientCertificatesResource + from .resources.hostnames.hostnames import HostnamesResource, AsyncHostnamesResource + from .resources.pipelines.pipelines import PipelinesResource, AsyncPipelinesResource + from .resources.registrar.registrar import RegistrarResource, AsyncRegistrarResource + from .resources.turnstile.turnstile import TurnstileResource, AsyncTurnstileResource + from .resources.vectorize.vectorize import VectorizeResource, AsyncVectorizeResource + from .resources.workflows.workflows import WorkflowsResource, AsyncWorkflowsResource + from .resources.keyless_certificates import KeylessCertificatesResource, AsyncKeylessCertificatesResource + from .resources.addressing.addressing import AddressingResource, AsyncAddressingResource + from .resources.ai_gateway.ai_gateway import AIGatewayResource, AsyncAIGatewayResource + from .resources.hyperdrive.hyperdrive import HyperdriveResource, AsyncHyperdriveResource + from .resources.zero_trust.zero_trust import ZeroTrustResource, AsyncZeroTrustResource + from .resources.origin_ca_certificates import OriginCACertificatesResource, AsyncOriginCACertificatesResource + from .resources.api_gateway.api_gateway import APIGatewayResource, AsyncAPIGatewayResource + from .resources.botnet_feed.botnet_feed import BotnetFeedResource, AsyncBotnetFeedResource + from .resources.diagnostics.diagnostics import DiagnosticsResource, AsyncDiagnosticsResource + from .resources.page_shield.page_shield import PageShieldResource, AsyncPageShieldResource + from .resources.url_scanner.url_scanner import URLScannerResource, AsyncURLScannerResource + from .resources.connectivity.connectivity import ConnectivityResource, AsyncConnectivityResource + from .resources.dns_firewall.dns_firewall import DNSFirewallResource, AsyncDNSFirewallResource + from .resources.healthchecks.healthchecks import HealthchecksResource, AsyncHealthchecksResource + from .resources.realtime_kit.realtime_kit import RealtimeKitResource, AsyncRealtimeKitResource + from .resources.abuse_reports.abuse_reports import AbuseReportsResource, AsyncAbuseReportsResource + from .resources.email_routing.email_routing import EmailRoutingResource, AsyncEmailRoutingResource + from .resources.magic_transit.magic_transit import MagicTransitResource, AsyncMagicTransitResource + from .resources.organizations.organizations import OrganizationsResource, AsyncOrganizationsResource + from .resources.secrets_store.secrets_store import SecretsStoreResource, AsyncSecretsStoreResource + from .resources.waiting_rooms.waiting_rooms import WaitingRoomsResource, AsyncWaitingRoomsResource + from .resources.cloudforce_one.cloudforce_one import CloudforceOneResource, AsyncCloudforceOneResource + from .resources.email_security.email_security import EmailSecurityResource, AsyncEmailSecurityResource + from .resources.load_balancers.load_balancers import LoadBalancersResource, AsyncLoadBalancersResource + from .resources.origin_post_quantum_encryption import ( + OriginPostQuantumEncryptionResource, + AsyncOriginPostQuantumEncryptionResource, + ) + from .resources.cloud_connector.cloud_connector import CloudConnectorResource, AsyncCloudConnectorResource + from .resources.durable_objects.durable_objects import DurableObjectsResource, AsyncDurableObjectsResource + from .resources.r2_data_catalog.r2_data_catalog import R2DataCatalogResource, AsyncR2DataCatalogResource + from .resources.request_tracers.request_tracers import RequestTracersResource, AsyncRequestTracersResource + from .resources.security_center.security_center import SecurityCenterResource, AsyncSecurityCenterResource + from .resources.brand_protection.brand_protection import BrandProtectionResource, AsyncBrandProtectionResource + from .resources.content_scanning.content_scanning import ContentScanningResource, AsyncContentScanningResource + from .resources.custom_hostnames.custom_hostnames import CustomHostnamesResource, AsyncCustomHostnamesResource + from .resources.resource_sharing.resource_sharing import ResourceSharingResource, AsyncResourceSharingResource + from .resources.token_validation.token_validation import TokenValidationResource, AsyncTokenValidationResource + from .resources.browser_rendering.browser_rendering import BrowserRenderingResource, AsyncBrowserRenderingResource + from .resources.mtls_certificates.mtls_certificates import MTLSCertificatesResource, AsyncMTLSCertificatesResource + from .resources.schema_validation.schema_validation import SchemaValidationResource, AsyncSchemaValidationResource + from .resources.custom_certificates.custom_certificates import ( + CustomCertificatesResource, + AsyncCustomCertificatesResource, + ) + from .resources.network_interconnects.network_interconnects import ( + NetworkInterconnectsResource, + AsyncNetworkInterconnectsResource, + ) + from .resources.workers_for_platforms.workers_for_platforms import ( + WorkersForPlatformsResource, + AsyncWorkersForPlatformsResource, + ) + from .resources.magic_cloud_networking.magic_cloud_networking import ( + MagicCloudNetworkingResource, + AsyncMagicCloudNetworkingResource, + ) + from .resources.origin_tls_client_auth.origin_tls_client_auth import ( + OriginTLSClientAuthResource, + AsyncOriginTLSClientAuthResource, + ) + from .resources.certificate_authorities.certificate_authorities import ( + CertificateAuthoritiesResource, + AsyncCertificateAuthoritiesResource, + ) + from .resources.leaked_credential_checks.leaked_credential_checks import ( + LeakedCredentialChecksResource, + AsyncLeakedCredentialChecksResource, + ) + from .resources.magic_network_monitoring.magic_network_monitoring import ( + MagicNetworkMonitoringResource, + AsyncMagicNetworkMonitoringResource, + ) + __all__ = [ "Timeout", "Transport", "ProxiesTypes", "RequestOptions", - "resources", "Cloudflare", "AsyncCloudflare", "Client", @@ -47,94 +280,6 @@ class Cloudflare(SyncAPIClient): - accounts: resources.AccountsResource - origin_ca_certificates: resources.OriginCACertificatesResource - ips: resources.IPsResource - memberships: resources.MembershipsResource - user: resources.UserResource - zones: resources.ZonesResource - load_balancers: resources.LoadBalancersResource - cache: resources.CacheResource - ssl: resources.SSLResource - subscriptions: resources.SubscriptionsResource - acm: resources.ACMResource - argo: resources.ArgoResource - plans: resources.PlansResource - rate_plans: resources.RatePlansResource - certificate_authorities: resources.CertificateAuthoritiesResource - client_certificates: resources.ClientCertificatesResource - custom_certificates: resources.CustomCertificatesResource - custom_hostnames: resources.CustomHostnamesResource - custom_nameservers: resources.CustomNameserversResource - dns: resources.DNSResource - dnssec: resources.DNSSECResource - email_routing: resources.EmailRoutingResource - filters: resources.FiltersResource - firewall: resources.FirewallResource - healthchecks: resources.HealthchecksResource - keyless_certificates: resources.KeylessCertificatesResource - logpush: resources.LogpushResource - logs: resources.LogsResource - origin_tls_client_auth: resources.OriginTLSClientAuthResource - pagerules: resources.PagerulesResource - rate_limits: resources.RateLimitsResource - secondary_dns: resources.SecondaryDNSResource - waiting_rooms: resources.WaitingRoomsResource - web3: resources.Web3Resource - workers: resources.WorkersResource - kv: resources.KVResource - durable_objects: resources.DurableObjectsResource - queues: resources.QueuesResource - api_gateway: resources.APIGatewayResource - managed_headers: resources.ManagedHeadersResource - page_shield: resources.PageShieldResource - rulesets: resources.RulesetsResource - url_normalization: resources.URLNormalizationResource - spectrum: resources.SpectrumResource - addressing: resources.AddressingResource - audit_logs: resources.AuditLogsResource - billing: resources.BillingResource - brand_protection: resources.BrandProtectionResource - diagnostics: resources.DiagnosticsResource - images: resources.ImagesResource - intel: resources.IntelResource - magic_transit: resources.MagicTransitResource - magic_network_monitoring: resources.MagicNetworkMonitoringResource - mtls_certificates: resources.MTLSCertificatesResource - pages: resources.PagesResource - pcaps: resources.PCAPsResource - registrar: resources.RegistrarResource - request_tracers: resources.RequestTracersResource - rules: resources.RulesResource - storage: resources.StorageResource - stream: resources.StreamResource - alerting: resources.AlertingResource - d1: resources.D1Resource - r2: resources.R2Resource - warp_connector: resources.WARPConnectorResource - workers_for_platforms: resources.WorkersForPlatformsResource - zero_trust: resources.ZeroTrustResource - challenges: resources.ChallengesResource - hyperdrive: resources.HyperdriveResource - rum: resources.RUMResource - vectorize: resources.VectorizeResource - url_scanner: resources.URLScannerResource - radar: resources.RadarResource - bot_management: resources.BotManagementResource - origin_post_quantum_encryption: resources.OriginPostQuantumEncryptionResource - speed: resources.SpeedResource - dcv_delegation: resources.DCVDelegationResource - hostnames: resources.HostnamesResource - snippets: resources.SnippetsResource - calls: resources.CallsResource - cloudforce_one: resources.CloudforceOneResource - event_notifications: resources.EventNotificationsResource - ai_gateway: resources.AIGatewayResource - iam: resources.IAMResource - cloud_connector: resources.CloudConnectorResource - with_raw_response: CloudflareWithRawResponse - with_streaming_response: CloudflareWithStreamedResponse - # client options api_token: str | None api_key: str | None @@ -149,7 +294,8 @@ def __init__( api_email: str | None = None, user_service_key: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + api_version: str | None = None, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -167,7 +313,7 @@ def __init__( # part of our public interface in the future. _strict_response_validation: bool = False, ) -> None: - """Construct a new synchronous cloudflare client instance. + """Construct a new synchronous Cloudflare client instance. This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `api_token` from `CLOUDFLARE_API_TOKEN` @@ -196,9 +342,13 @@ def __init__( if base_url is None: base_url = f"https://api.cloudflare.com/client/v4" + if api_version is None: + api_version = datetime.today().strftime('%Y-%m-%d') + super().__init__( version=__version__, base_url=base_url, + api_version=api_version, max_retries=max_retries, timeout=timeout, http_client=http_client, @@ -207,93 +357,625 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.accounts = resources.AccountsResource(self) - self.origin_ca_certificates = resources.OriginCACertificatesResource(self) - self.ips = resources.IPsResource(self) - self.memberships = resources.MembershipsResource(self) - self.user = resources.UserResource(self) - self.zones = resources.ZonesResource(self) - self.load_balancers = resources.LoadBalancersResource(self) - self.cache = resources.CacheResource(self) - self.ssl = resources.SSLResource(self) - self.subscriptions = resources.SubscriptionsResource(self) - self.acm = resources.ACMResource(self) - self.argo = resources.ArgoResource(self) - self.plans = resources.PlansResource(self) - self.rate_plans = resources.RatePlansResource(self) - self.certificate_authorities = resources.CertificateAuthoritiesResource(self) - self.client_certificates = resources.ClientCertificatesResource(self) - self.custom_certificates = resources.CustomCertificatesResource(self) - self.custom_hostnames = resources.CustomHostnamesResource(self) - self.custom_nameservers = resources.CustomNameserversResource(self) - self.dns = resources.DNSResource(self) - self.dnssec = resources.DNSSECResource(self) - self.email_routing = resources.EmailRoutingResource(self) - self.filters = resources.FiltersResource(self) - self.firewall = resources.FirewallResource(self) - self.healthchecks = resources.HealthchecksResource(self) - self.keyless_certificates = resources.KeylessCertificatesResource(self) - self.logpush = resources.LogpushResource(self) - self.logs = resources.LogsResource(self) - self.origin_tls_client_auth = resources.OriginTLSClientAuthResource(self) - self.pagerules = resources.PagerulesResource(self) - self.rate_limits = resources.RateLimitsResource(self) - self.secondary_dns = resources.SecondaryDNSResource(self) - self.waiting_rooms = resources.WaitingRoomsResource(self) - self.web3 = resources.Web3Resource(self) - self.workers = resources.WorkersResource(self) - self.kv = resources.KVResource(self) - self.durable_objects = resources.DurableObjectsResource(self) - self.queues = resources.QueuesResource(self) - self.api_gateway = resources.APIGatewayResource(self) - self.managed_headers = resources.ManagedHeadersResource(self) - self.page_shield = resources.PageShieldResource(self) - self.rulesets = resources.RulesetsResource(self) - self.url_normalization = resources.URLNormalizationResource(self) - self.spectrum = resources.SpectrumResource(self) - self.addressing = resources.AddressingResource(self) - self.audit_logs = resources.AuditLogsResource(self) - self.billing = resources.BillingResource(self) - self.brand_protection = resources.BrandProtectionResource(self) - self.diagnostics = resources.DiagnosticsResource(self) - self.images = resources.ImagesResource(self) - self.intel = resources.IntelResource(self) - self.magic_transit = resources.MagicTransitResource(self) - self.magic_network_monitoring = resources.MagicNetworkMonitoringResource(self) - self.mtls_certificates = resources.MTLSCertificatesResource(self) - self.pages = resources.PagesResource(self) - self.pcaps = resources.PCAPsResource(self) - self.registrar = resources.RegistrarResource(self) - self.request_tracers = resources.RequestTracersResource(self) - self.rules = resources.RulesResource(self) - self.storage = resources.StorageResource(self) - self.stream = resources.StreamResource(self) - self.alerting = resources.AlertingResource(self) - self.d1 = resources.D1Resource(self) - self.r2 = resources.R2Resource(self) - self.warp_connector = resources.WARPConnectorResource(self) - self.workers_for_platforms = resources.WorkersForPlatformsResource(self) - self.zero_trust = resources.ZeroTrustResource(self) - self.challenges = resources.ChallengesResource(self) - self.hyperdrive = resources.HyperdriveResource(self) - self.rum = resources.RUMResource(self) - self.vectorize = resources.VectorizeResource(self) - self.url_scanner = resources.URLScannerResource(self) - self.radar = resources.RadarResource(self) - self.bot_management = resources.BotManagementResource(self) - self.origin_post_quantum_encryption = resources.OriginPostQuantumEncryptionResource(self) - self.speed = resources.SpeedResource(self) - self.dcv_delegation = resources.DCVDelegationResource(self) - self.hostnames = resources.HostnamesResource(self) - self.snippets = resources.SnippetsResource(self) - self.calls = resources.CallsResource(self) - self.cloudforce_one = resources.CloudforceOneResource(self) - self.event_notifications = resources.EventNotificationsResource(self) - self.ai_gateway = resources.AIGatewayResource(self) - self.iam = resources.IAMResource(self) - self.cloud_connector = resources.CloudConnectorResource(self) - self.with_raw_response = CloudflareWithRawResponse(self) - self.with_streaming_response = CloudflareWithStreamedResponse(self) + @cached_property + def accounts(self) -> AccountsResource: + from .resources.accounts import AccountsResource + + return AccountsResource(self) + + @cached_property + def organizations(self) -> OrganizationsResource: + from .resources.organizations import OrganizationsResource + + return OrganizationsResource(self) + + @cached_property + def origin_ca_certificates(self) -> OriginCACertificatesResource: + from .resources.origin_ca_certificates import OriginCACertificatesResource + + return OriginCACertificatesResource(self) + + @cached_property + def ips(self) -> IPsResource: + from .resources.ips import IPsResource + + return IPsResource(self) + + @cached_property + def memberships(self) -> MembershipsResource: + from .resources.memberships import MembershipsResource + + return MembershipsResource(self) + + @cached_property + def user(self) -> UserResource: + from .resources.user import UserResource + + return UserResource(self) + + @cached_property + def zones(self) -> ZonesResource: + from .resources.zones import ZonesResource + + return ZonesResource(self) + + @cached_property + def load_balancers(self) -> LoadBalancersResource: + from .resources.load_balancers import LoadBalancersResource + + return LoadBalancersResource(self) + + @cached_property + def cache(self) -> CacheResource: + from .resources.cache import CacheResource + + return CacheResource(self) + + @cached_property + def ssl(self) -> SSLResource: + from .resources.ssl import SSLResource + + return SSLResource(self) + + @cached_property + def acm(self) -> ACMResource: + from .resources.acm import ACMResource + + return ACMResource(self) + + @cached_property + def argo(self) -> ArgoResource: + from .resources.argo import ArgoResource + + return ArgoResource(self) + + @cached_property + def certificate_authorities(self) -> CertificateAuthoritiesResource: + from .resources.certificate_authorities import CertificateAuthoritiesResource + + return CertificateAuthoritiesResource(self) + + @cached_property + def client_certificates(self) -> ClientCertificatesResource: + from .resources.client_certificates import ClientCertificatesResource + + return ClientCertificatesResource(self) + + @cached_property + def custom_certificates(self) -> CustomCertificatesResource: + from .resources.custom_certificates import CustomCertificatesResource + + return CustomCertificatesResource(self) + + @cached_property + def custom_hostnames(self) -> CustomHostnamesResource: + from .resources.custom_hostnames import CustomHostnamesResource + + return CustomHostnamesResource(self) + + @cached_property + def custom_nameservers(self) -> CustomNameserversResource: + from .resources.custom_nameservers import CustomNameserversResource + + return CustomNameserversResource(self) + + @cached_property + def dns_firewall(self) -> DNSFirewallResource: + from .resources.dns_firewall import DNSFirewallResource + + return DNSFirewallResource(self) + + @cached_property + def dns(self) -> DNSResource: + from .resources.dns import DNSResource + + return DNSResource(self) + + @cached_property + def email_security(self) -> EmailSecurityResource: + from .resources.email_security import EmailSecurityResource + + return EmailSecurityResource(self) + + @cached_property + def email_routing(self) -> EmailRoutingResource: + from .resources.email_routing import EmailRoutingResource + + return EmailRoutingResource(self) + + @cached_property + def filters(self) -> FiltersResource: + from .resources.filters import FiltersResource + + return FiltersResource(self) + + @cached_property + def firewall(self) -> FirewallResource: + from .resources.firewall import FirewallResource + + return FirewallResource(self) + + @cached_property + def healthchecks(self) -> HealthchecksResource: + from .resources.healthchecks import HealthchecksResource + + return HealthchecksResource(self) + + @cached_property + def keyless_certificates(self) -> KeylessCertificatesResource: + from .resources.keyless_certificates import KeylessCertificatesResource + + return KeylessCertificatesResource(self) + + @cached_property + def logpush(self) -> LogpushResource: + from .resources.logpush import LogpushResource + + return LogpushResource(self) + + @cached_property + def logs(self) -> LogsResource: + from .resources.logs import LogsResource + + return LogsResource(self) + + @cached_property + def origin_tls_client_auth(self) -> OriginTLSClientAuthResource: + from .resources.origin_tls_client_auth import OriginTLSClientAuthResource + + return OriginTLSClientAuthResource(self) + + @cached_property + def page_rules(self) -> PageRulesResource: + from .resources.page_rules import PageRulesResource + + return PageRulesResource(self) + + @cached_property + def rate_limits(self) -> RateLimitsResource: + from .resources.rate_limits import RateLimitsResource + + return RateLimitsResource(self) + + @cached_property + def waiting_rooms(self) -> WaitingRoomsResource: + from .resources.waiting_rooms import WaitingRoomsResource + + return WaitingRoomsResource(self) + + @cached_property + def web3(self) -> Web3Resource: + from .resources.web3 import Web3Resource + + return Web3Resource(self) + + @cached_property + def workers(self) -> WorkersResource: + from .resources.workers import WorkersResource + + return WorkersResource(self) + + @cached_property + def kv(self) -> KVResource: + from .resources.kv import KVResource + + return KVResource(self) + + @cached_property + def durable_objects(self) -> DurableObjectsResource: + from .resources.durable_objects import DurableObjectsResource + + return DurableObjectsResource(self) + + @cached_property + def queues(self) -> QueuesResource: + from .resources.queues import QueuesResource + + return QueuesResource(self) + + @cached_property + def api_gateway(self) -> APIGatewayResource: + from .resources.api_gateway import APIGatewayResource + + return APIGatewayResource(self) + + @cached_property + def managed_transforms(self) -> ManagedTransformsResource: + from .resources.managed_transforms import ManagedTransformsResource + + return ManagedTransformsResource(self) + + @cached_property + def page_shield(self) -> PageShieldResource: + from .resources.page_shield import PageShieldResource + + return PageShieldResource(self) + + @cached_property + def rulesets(self) -> RulesetsResource: + from .resources.rulesets import RulesetsResource + + return RulesetsResource(self) + + @cached_property + def url_normalization(self) -> URLNormalizationResource: + from .resources.url_normalization import URLNormalizationResource + + return URLNormalizationResource(self) + + @cached_property + def spectrum(self) -> SpectrumResource: + from .resources.spectrum import SpectrumResource + + return SpectrumResource(self) + + @cached_property + def addressing(self) -> AddressingResource: + from .resources.addressing import AddressingResource + + return AddressingResource(self) + + @cached_property + def audit_logs(self) -> AuditLogsResource: + from .resources.audit_logs import AuditLogsResource + + return AuditLogsResource(self) + + @cached_property + def billing(self) -> BillingResource: + from .resources.billing import BillingResource + + return BillingResource(self) + + @cached_property + def brand_protection(self) -> BrandProtectionResource: + from .resources.brand_protection import BrandProtectionResource + + return BrandProtectionResource(self) + + @cached_property + def diagnostics(self) -> DiagnosticsResource: + from .resources.diagnostics import DiagnosticsResource + + return DiagnosticsResource(self) + + @cached_property + def images(self) -> ImagesResource: + from .resources.images import ImagesResource + + return ImagesResource(self) + + @cached_property + def intel(self) -> IntelResource: + from .resources.intel import IntelResource + + return IntelResource(self) + + @cached_property + def magic_transit(self) -> MagicTransitResource: + from .resources.magic_transit import MagicTransitResource + + return MagicTransitResource(self) + + @cached_property + def magic_network_monitoring(self) -> MagicNetworkMonitoringResource: + from .resources.magic_network_monitoring import MagicNetworkMonitoringResource + + return MagicNetworkMonitoringResource(self) + + @cached_property + def magic_cloud_networking(self) -> MagicCloudNetworkingResource: + from .resources.magic_cloud_networking import MagicCloudNetworkingResource + + return MagicCloudNetworkingResource(self) + + @cached_property + def network_interconnects(self) -> NetworkInterconnectsResource: + from .resources.network_interconnects import NetworkInterconnectsResource + + return NetworkInterconnectsResource(self) + + @cached_property + def mtls_certificates(self) -> MTLSCertificatesResource: + from .resources.mtls_certificates import MTLSCertificatesResource + + return MTLSCertificatesResource(self) + + @cached_property + def pages(self) -> PagesResource: + from .resources.pages import PagesResource + + return PagesResource(self) + + @cached_property + def registrar(self) -> RegistrarResource: + from .resources.registrar import RegistrarResource + + return RegistrarResource(self) + + @cached_property + def request_tracers(self) -> RequestTracersResource: + from .resources.request_tracers import RequestTracersResource + + return RequestTracersResource(self) + + @cached_property + def rules(self) -> RulesResource: + from .resources.rules import RulesResource + + return RulesResource(self) + + @cached_property + def stream(self) -> StreamResource: + from .resources.stream import StreamResource + + return StreamResource(self) + + @cached_property + def alerting(self) -> AlertingResource: + from .resources.alerting import AlertingResource + + return AlertingResource(self) + + @cached_property + def d1(self) -> D1Resource: + from .resources.d1 import D1Resource + + return D1Resource(self) + + @cached_property + def r2(self) -> R2Resource: + from .resources.r2 import R2Resource + + return R2Resource(self) + + @cached_property + def r2_data_catalog(self) -> R2DataCatalogResource: + from .resources.r2_data_catalog import R2DataCatalogResource + + return R2DataCatalogResource(self) + + @cached_property + def workers_for_platforms(self) -> WorkersForPlatformsResource: + from .resources.workers_for_platforms import WorkersForPlatformsResource + + return WorkersForPlatformsResource(self) + + @cached_property + def zero_trust(self) -> ZeroTrustResource: + from .resources.zero_trust import ZeroTrustResource + + return ZeroTrustResource(self) + + @cached_property + def turnstile(self) -> TurnstileResource: + from .resources.turnstile import TurnstileResource + + return TurnstileResource(self) + + @cached_property + def connectivity(self) -> ConnectivityResource: + from .resources.connectivity import ConnectivityResource + + return ConnectivityResource(self) + + @cached_property + def hyperdrive(self) -> HyperdriveResource: + from .resources.hyperdrive import HyperdriveResource + + return HyperdriveResource(self) + + @cached_property + def rum(self) -> RUMResource: + from .resources.rum import RUMResource + + return RUMResource(self) + + @cached_property + def vectorize(self) -> VectorizeResource: + from .resources.vectorize import VectorizeResource + + return VectorizeResource(self) + + @cached_property + def url_scanner(self) -> URLScannerResource: + from .resources.url_scanner import URLScannerResource + + return URLScannerResource(self) + + @cached_property + def radar(self) -> RadarResource: + from .resources.radar import RadarResource + + return RadarResource(self) + + @cached_property + def bot_management(self) -> BotManagementResource: + from .resources.bot_management import BotManagementResource + + return BotManagementResource(self) + + @cached_property + def fraud(self) -> FraudResource: + from .resources.fraud import FraudResource + + return FraudResource(self) + + @cached_property + def origin_post_quantum_encryption(self) -> OriginPostQuantumEncryptionResource: + from .resources.origin_post_quantum_encryption import OriginPostQuantumEncryptionResource + + return OriginPostQuantumEncryptionResource(self) + + @cached_property + def zaraz(self) -> ZarazResource: + from .resources.zaraz import ZarazResource + + return ZarazResource(self) + + @cached_property + def speed(self) -> SpeedResource: + from .resources.speed import SpeedResource + + return SpeedResource(self) + + @cached_property + def dcv_delegation(self) -> DCVDelegationResource: + from .resources.dcv_delegation import DCVDelegationResource + + return DCVDelegationResource(self) + + @cached_property + def hostnames(self) -> HostnamesResource: + from .resources.hostnames import HostnamesResource + + return HostnamesResource(self) + + @cached_property + def snippets(self) -> SnippetsResource: + from .resources.snippets import SnippetsResource + + return SnippetsResource(self) + + @cached_property + def realtime_kit(self) -> RealtimeKitResource: + from .resources.realtime_kit import RealtimeKitResource + + return RealtimeKitResource(self) + + @cached_property + def calls(self) -> CallsResource: + from .resources.calls import CallsResource + + return CallsResource(self) + + @cached_property + def cloudforce_one(self) -> CloudforceOneResource: + from .resources.cloudforce_one import CloudforceOneResource + + return CloudforceOneResource(self) + + @cached_property + def ai_gateway(self) -> AIGatewayResource: + from .resources.ai_gateway import AIGatewayResource + + return AIGatewayResource(self) + + @cached_property + def iam(self) -> IAMResource: + from .resources.iam import IAMResource + + return IAMResource(self) + + @cached_property + def cloud_connector(self) -> CloudConnectorResource: + from .resources.cloud_connector import CloudConnectorResource + + return CloudConnectorResource(self) + + @cached_property + def botnet_feed(self) -> BotnetFeedResource: + from .resources.botnet_feed import BotnetFeedResource + + return BotnetFeedResource(self) + + @cached_property + def security_txt(self) -> SecurityTXTResource: + from .resources.security_txt import SecurityTXTResource + + return SecurityTXTResource(self) + + @cached_property + def workflows(self) -> WorkflowsResource: + from .resources.workflows import WorkflowsResource + + return WorkflowsResource(self) + + @cached_property + def resource_sharing(self) -> ResourceSharingResource: + from .resources.resource_sharing import ResourceSharingResource + + return ResourceSharingResource(self) + + @cached_property + def leaked_credential_checks(self) -> LeakedCredentialChecksResource: + from .resources.leaked_credential_checks import LeakedCredentialChecksResource + + return LeakedCredentialChecksResource(self) + + @cached_property + def content_scanning(self) -> ContentScanningResource: + from .resources.content_scanning import ContentScanningResource + + return ContentScanningResource(self) + + @cached_property + def abuse_reports(self) -> AbuseReportsResource: + from .resources.abuse_reports import AbuseReportsResource + + return AbuseReportsResource(self) + + @cached_property + def ai(self) -> AIResource: + from .resources.ai import AIResource + + return AIResource(self) + + @cached_property + def aisearch(self) -> AISearchResource: + from .resources.aisearch import AISearchResource + + return AISearchResource(self) + + @cached_property + def security_center(self) -> SecurityCenterResource: + from .resources.security_center import SecurityCenterResource + + return SecurityCenterResource(self) + + @cached_property + def browser_rendering(self) -> BrowserRenderingResource: + from .resources.browser_rendering import BrowserRenderingResource + + return BrowserRenderingResource(self) + + @cached_property + def custom_pages(self) -> CustomPagesResource: + from .resources.custom_pages import CustomPagesResource + + return CustomPagesResource(self) + + @cached_property + def secrets_store(self) -> SecretsStoreResource: + from .resources.secrets_store import SecretsStoreResource + + return SecretsStoreResource(self) + + @cached_property + def pipelines(self) -> PipelinesResource: + from .resources.pipelines import PipelinesResource + + return PipelinesResource(self) + + @cached_property + def schema_validation(self) -> SchemaValidationResource: + from .resources.schema_validation import SchemaValidationResource + + return SchemaValidationResource(self) + + @cached_property + def token_validation(self) -> TokenValidationResource: + from .resources.token_validation import TokenValidationResource + + return TokenValidationResource(self) + + @cached_property + def with_raw_response(self) -> CloudflareWithRawResponse: + return CloudflareWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CloudflareWithStreamedResponse: + return CloudflareWithStreamedResponse(self) @property @override @@ -354,24 +1036,16 @@ def default_headers(self) -> dict[str, str | Omit]: @override def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: - if self.api_email and headers.get("X-Auth-Email"): - return - if isinstance(custom_headers.get("X-Auth-Email"), Omit): + if headers.get("X-Auth-Email") or isinstance(custom_headers.get("X-Auth-Email"), Omit): return - if self.api_key and headers.get("X-Auth-Key"): - return - if isinstance(custom_headers.get("X-Auth-Key"), Omit): + if headers.get("X-Auth-Key") or isinstance(custom_headers.get("X-Auth-Key"), Omit): return - if self.api_token and headers.get("Authorization"): - return - if isinstance(custom_headers.get("Authorization"), Omit): + if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit): return - if self.user_service_key and headers.get("X-Auth-User-Service-Key"): - return - if isinstance(custom_headers.get("X-Auth-User-Service-Key"), Omit): + if headers.get("X-Auth-User-Service-Key") or isinstance(custom_headers.get("X-Auth-User-Service-Key"), Omit): return raise TypeError( @@ -386,9 +1060,10 @@ def copy( api_email: str | None = None, user_service_key: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + api_version: str | None = None, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -423,6 +1098,7 @@ def copy( api_email=api_email or self.api_email, user_service_key=user_service_key or self.user_service_key, base_url=base_url or self.base_url, + api_version=api_version or self.api_version, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, http_client=http_client, max_retries=max_retries if is_given(max_retries) else self.max_retries, @@ -470,94 +1146,6 @@ def _make_status_error( class AsyncCloudflare(AsyncAPIClient): - accounts: resources.AsyncAccountsResource - origin_ca_certificates: resources.AsyncOriginCACertificatesResource - ips: resources.AsyncIPsResource - memberships: resources.AsyncMembershipsResource - user: resources.AsyncUserResource - zones: resources.AsyncZonesResource - load_balancers: resources.AsyncLoadBalancersResource - cache: resources.AsyncCacheResource - ssl: resources.AsyncSSLResource - subscriptions: resources.AsyncSubscriptionsResource - acm: resources.AsyncACMResource - argo: resources.AsyncArgoResource - plans: resources.AsyncPlansResource - rate_plans: resources.AsyncRatePlansResource - certificate_authorities: resources.AsyncCertificateAuthoritiesResource - client_certificates: resources.AsyncClientCertificatesResource - custom_certificates: resources.AsyncCustomCertificatesResource - custom_hostnames: resources.AsyncCustomHostnamesResource - custom_nameservers: resources.AsyncCustomNameserversResource - dns: resources.AsyncDNSResource - dnssec: resources.AsyncDNSSECResource - email_routing: resources.AsyncEmailRoutingResource - filters: resources.AsyncFiltersResource - firewall: resources.AsyncFirewallResource - healthchecks: resources.AsyncHealthchecksResource - keyless_certificates: resources.AsyncKeylessCertificatesResource - logpush: resources.AsyncLogpushResource - logs: resources.AsyncLogsResource - origin_tls_client_auth: resources.AsyncOriginTLSClientAuthResource - pagerules: resources.AsyncPagerulesResource - rate_limits: resources.AsyncRateLimitsResource - secondary_dns: resources.AsyncSecondaryDNSResource - waiting_rooms: resources.AsyncWaitingRoomsResource - web3: resources.AsyncWeb3Resource - workers: resources.AsyncWorkersResource - kv: resources.AsyncKVResource - durable_objects: resources.AsyncDurableObjectsResource - queues: resources.AsyncQueuesResource - api_gateway: resources.AsyncAPIGatewayResource - managed_headers: resources.AsyncManagedHeadersResource - page_shield: resources.AsyncPageShieldResource - rulesets: resources.AsyncRulesetsResource - url_normalization: resources.AsyncURLNormalizationResource - spectrum: resources.AsyncSpectrumResource - addressing: resources.AsyncAddressingResource - audit_logs: resources.AsyncAuditLogsResource - billing: resources.AsyncBillingResource - brand_protection: resources.AsyncBrandProtectionResource - diagnostics: resources.AsyncDiagnosticsResource - images: resources.AsyncImagesResource - intel: resources.AsyncIntelResource - magic_transit: resources.AsyncMagicTransitResource - magic_network_monitoring: resources.AsyncMagicNetworkMonitoringResource - mtls_certificates: resources.AsyncMTLSCertificatesResource - pages: resources.AsyncPagesResource - pcaps: resources.AsyncPCAPsResource - registrar: resources.AsyncRegistrarResource - request_tracers: resources.AsyncRequestTracersResource - rules: resources.AsyncRulesResource - storage: resources.AsyncStorageResource - stream: resources.AsyncStreamResource - alerting: resources.AsyncAlertingResource - d1: resources.AsyncD1Resource - r2: resources.AsyncR2Resource - warp_connector: resources.AsyncWARPConnectorResource - workers_for_platforms: resources.AsyncWorkersForPlatformsResource - zero_trust: resources.AsyncZeroTrustResource - challenges: resources.AsyncChallengesResource - hyperdrive: resources.AsyncHyperdriveResource - rum: resources.AsyncRUMResource - vectorize: resources.AsyncVectorizeResource - url_scanner: resources.AsyncURLScannerResource - radar: resources.AsyncRadarResource - bot_management: resources.AsyncBotManagementResource - origin_post_quantum_encryption: resources.AsyncOriginPostQuantumEncryptionResource - speed: resources.AsyncSpeedResource - dcv_delegation: resources.AsyncDCVDelegationResource - hostnames: resources.AsyncHostnamesResource - snippets: resources.AsyncSnippetsResource - calls: resources.AsyncCallsResource - cloudforce_one: resources.AsyncCloudforceOneResource - event_notifications: resources.AsyncEventNotificationsResource - ai_gateway: resources.AsyncAIGatewayResource - iam: resources.AsyncIAMResource - cloud_connector: resources.AsyncCloudConnectorResource - with_raw_response: AsyncCloudflareWithRawResponse - with_streaming_response: AsyncCloudflareWithStreamedResponse - # client options api_token: str | None api_key: str | None @@ -572,7 +1160,8 @@ def __init__( api_email: str | None = None, user_service_key: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + api_version: str | None = None, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -590,7 +1179,7 @@ def __init__( # part of our public interface in the future. _strict_response_validation: bool = False, ) -> None: - """Construct a new async cloudflare client instance. + """Construct a new async AsyncCloudflare client instance. This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `api_token` from `CLOUDFLARE_API_TOKEN` @@ -619,9 +1208,13 @@ def __init__( if base_url is None: base_url = f"https://api.cloudflare.com/client/v4" + if api_version is None: + api_version = datetime.today().strftime('%Y-%m-%d') + super().__init__( version=__version__, base_url=base_url, + api_version=api_version, max_retries=max_retries, timeout=timeout, http_client=http_client, @@ -630,141 +1223,673 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.accounts = resources.AsyncAccountsResource(self) - self.origin_ca_certificates = resources.AsyncOriginCACertificatesResource(self) - self.ips = resources.AsyncIPsResource(self) - self.memberships = resources.AsyncMembershipsResource(self) - self.user = resources.AsyncUserResource(self) - self.zones = resources.AsyncZonesResource(self) - self.load_balancers = resources.AsyncLoadBalancersResource(self) - self.cache = resources.AsyncCacheResource(self) - self.ssl = resources.AsyncSSLResource(self) - self.subscriptions = resources.AsyncSubscriptionsResource(self) - self.acm = resources.AsyncACMResource(self) - self.argo = resources.AsyncArgoResource(self) - self.plans = resources.AsyncPlansResource(self) - self.rate_plans = resources.AsyncRatePlansResource(self) - self.certificate_authorities = resources.AsyncCertificateAuthoritiesResource(self) - self.client_certificates = resources.AsyncClientCertificatesResource(self) - self.custom_certificates = resources.AsyncCustomCertificatesResource(self) - self.custom_hostnames = resources.AsyncCustomHostnamesResource(self) - self.custom_nameservers = resources.AsyncCustomNameserversResource(self) - self.dns = resources.AsyncDNSResource(self) - self.dnssec = resources.AsyncDNSSECResource(self) - self.email_routing = resources.AsyncEmailRoutingResource(self) - self.filters = resources.AsyncFiltersResource(self) - self.firewall = resources.AsyncFirewallResource(self) - self.healthchecks = resources.AsyncHealthchecksResource(self) - self.keyless_certificates = resources.AsyncKeylessCertificatesResource(self) - self.logpush = resources.AsyncLogpushResource(self) - self.logs = resources.AsyncLogsResource(self) - self.origin_tls_client_auth = resources.AsyncOriginTLSClientAuthResource(self) - self.pagerules = resources.AsyncPagerulesResource(self) - self.rate_limits = resources.AsyncRateLimitsResource(self) - self.secondary_dns = resources.AsyncSecondaryDNSResource(self) - self.waiting_rooms = resources.AsyncWaitingRoomsResource(self) - self.web3 = resources.AsyncWeb3Resource(self) - self.workers = resources.AsyncWorkersResource(self) - self.kv = resources.AsyncKVResource(self) - self.durable_objects = resources.AsyncDurableObjectsResource(self) - self.queues = resources.AsyncQueuesResource(self) - self.api_gateway = resources.AsyncAPIGatewayResource(self) - self.managed_headers = resources.AsyncManagedHeadersResource(self) - self.page_shield = resources.AsyncPageShieldResource(self) - self.rulesets = resources.AsyncRulesetsResource(self) - self.url_normalization = resources.AsyncURLNormalizationResource(self) - self.spectrum = resources.AsyncSpectrumResource(self) - self.addressing = resources.AsyncAddressingResource(self) - self.audit_logs = resources.AsyncAuditLogsResource(self) - self.billing = resources.AsyncBillingResource(self) - self.brand_protection = resources.AsyncBrandProtectionResource(self) - self.diagnostics = resources.AsyncDiagnosticsResource(self) - self.images = resources.AsyncImagesResource(self) - self.intel = resources.AsyncIntelResource(self) - self.magic_transit = resources.AsyncMagicTransitResource(self) - self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoringResource(self) - self.mtls_certificates = resources.AsyncMTLSCertificatesResource(self) - self.pages = resources.AsyncPagesResource(self) - self.pcaps = resources.AsyncPCAPsResource(self) - self.registrar = resources.AsyncRegistrarResource(self) - self.request_tracers = resources.AsyncRequestTracersResource(self) - self.rules = resources.AsyncRulesResource(self) - self.storage = resources.AsyncStorageResource(self) - self.stream = resources.AsyncStreamResource(self) - self.alerting = resources.AsyncAlertingResource(self) - self.d1 = resources.AsyncD1Resource(self) - self.r2 = resources.AsyncR2Resource(self) - self.warp_connector = resources.AsyncWARPConnectorResource(self) - self.workers_for_platforms = resources.AsyncWorkersForPlatformsResource(self) - self.zero_trust = resources.AsyncZeroTrustResource(self) - self.challenges = resources.AsyncChallengesResource(self) - self.hyperdrive = resources.AsyncHyperdriveResource(self) - self.rum = resources.AsyncRUMResource(self) - self.vectorize = resources.AsyncVectorizeResource(self) - self.url_scanner = resources.AsyncURLScannerResource(self) - self.radar = resources.AsyncRadarResource(self) - self.bot_management = resources.AsyncBotManagementResource(self) - self.origin_post_quantum_encryption = resources.AsyncOriginPostQuantumEncryptionResource(self) - self.speed = resources.AsyncSpeedResource(self) - self.dcv_delegation = resources.AsyncDCVDelegationResource(self) - self.hostnames = resources.AsyncHostnamesResource(self) - self.snippets = resources.AsyncSnippetsResource(self) - self.calls = resources.AsyncCallsResource(self) - self.cloudforce_one = resources.AsyncCloudforceOneResource(self) - self.event_notifications = resources.AsyncEventNotificationsResource(self) - self.ai_gateway = resources.AsyncAIGatewayResource(self) - self.iam = resources.AsyncIAMResource(self) - self.cloud_connector = resources.AsyncCloudConnectorResource(self) - self.with_raw_response = AsyncCloudflareWithRawResponse(self) - self.with_streaming_response = AsyncCloudflareWithStreamedResponse(self) + @cached_property + def accounts(self) -> AsyncAccountsResource: + from .resources.accounts import AsyncAccountsResource - @property - @override - def qs(self) -> Querystring: - return Querystring(nested_format="dots", array_format="repeat") + return AsyncAccountsResource(self) - @property - @override - def auth_headers(self) -> dict[str, str]: - if self._api_email: - return self._api_email - if self._api_key: - return self._api_key - if self._api_token: - return self._api_token - if self._user_service_key: - return self._user_service_key - return {} + @cached_property + def organizations(self) -> AsyncOrganizationsResource: + from .resources.organizations import AsyncOrganizationsResource - @property - def _api_email(self) -> dict[str, str]: - api_email = self.api_email - if api_email is None: - return {} - return {"X-Auth-Email": api_email} + return AsyncOrganizationsResource(self) - @property - def _api_key(self) -> dict[str, str]: - api_key = self.api_key - if api_key is None: - return {} - return {"X-Auth-Key": api_key} + @cached_property + def origin_ca_certificates(self) -> AsyncOriginCACertificatesResource: + from .resources.origin_ca_certificates import AsyncOriginCACertificatesResource - @property - def _api_token(self) -> dict[str, str]: - api_token = self.api_token - if api_token is None: - return {} - return {"Authorization": f"Bearer {api_token}"} + return AsyncOriginCACertificatesResource(self) - @property - def _user_service_key(self) -> dict[str, str]: - user_service_key = self.user_service_key - if user_service_key is None: - return {} - return {"X-Auth-User-Service-Key": user_service_key} + @cached_property + def ips(self) -> AsyncIPsResource: + from .resources.ips import AsyncIPsResource - @property + return AsyncIPsResource(self) + + @cached_property + def memberships(self) -> AsyncMembershipsResource: + from .resources.memberships import AsyncMembershipsResource + + return AsyncMembershipsResource(self) + + @cached_property + def user(self) -> AsyncUserResource: + from .resources.user import AsyncUserResource + + return AsyncUserResource(self) + + @cached_property + def zones(self) -> AsyncZonesResource: + from .resources.zones import AsyncZonesResource + + return AsyncZonesResource(self) + + @cached_property + def load_balancers(self) -> AsyncLoadBalancersResource: + from .resources.load_balancers import AsyncLoadBalancersResource + + return AsyncLoadBalancersResource(self) + + @cached_property + def cache(self) -> AsyncCacheResource: + from .resources.cache import AsyncCacheResource + + return AsyncCacheResource(self) + + @cached_property + def ssl(self) -> AsyncSSLResource: + from .resources.ssl import AsyncSSLResource + + return AsyncSSLResource(self) + + @cached_property + def acm(self) -> AsyncACMResource: + from .resources.acm import AsyncACMResource + + return AsyncACMResource(self) + + @cached_property + def argo(self) -> AsyncArgoResource: + from .resources.argo import AsyncArgoResource + + return AsyncArgoResource(self) + + @cached_property + def certificate_authorities(self) -> AsyncCertificateAuthoritiesResource: + from .resources.certificate_authorities import AsyncCertificateAuthoritiesResource + + return AsyncCertificateAuthoritiesResource(self) + + @cached_property + def client_certificates(self) -> AsyncClientCertificatesResource: + from .resources.client_certificates import AsyncClientCertificatesResource + + return AsyncClientCertificatesResource(self) + + @cached_property + def custom_certificates(self) -> AsyncCustomCertificatesResource: + from .resources.custom_certificates import AsyncCustomCertificatesResource + + return AsyncCustomCertificatesResource(self) + + @cached_property + def custom_hostnames(self) -> AsyncCustomHostnamesResource: + from .resources.custom_hostnames import AsyncCustomHostnamesResource + + return AsyncCustomHostnamesResource(self) + + @cached_property + def custom_nameservers(self) -> AsyncCustomNameserversResource: + from .resources.custom_nameservers import AsyncCustomNameserversResource + + return AsyncCustomNameserversResource(self) + + @cached_property + def dns_firewall(self) -> AsyncDNSFirewallResource: + from .resources.dns_firewall import AsyncDNSFirewallResource + + return AsyncDNSFirewallResource(self) + + @cached_property + def dns(self) -> AsyncDNSResource: + from .resources.dns import AsyncDNSResource + + return AsyncDNSResource(self) + + @cached_property + def email_security(self) -> AsyncEmailSecurityResource: + from .resources.email_security import AsyncEmailSecurityResource + + return AsyncEmailSecurityResource(self) + + @cached_property + def email_routing(self) -> AsyncEmailRoutingResource: + from .resources.email_routing import AsyncEmailRoutingResource + + return AsyncEmailRoutingResource(self) + + @cached_property + def filters(self) -> AsyncFiltersResource: + from .resources.filters import AsyncFiltersResource + + return AsyncFiltersResource(self) + + @cached_property + def firewall(self) -> AsyncFirewallResource: + from .resources.firewall import AsyncFirewallResource + + return AsyncFirewallResource(self) + + @cached_property + def healthchecks(self) -> AsyncHealthchecksResource: + from .resources.healthchecks import AsyncHealthchecksResource + + return AsyncHealthchecksResource(self) + + @cached_property + def keyless_certificates(self) -> AsyncKeylessCertificatesResource: + from .resources.keyless_certificates import AsyncKeylessCertificatesResource + + return AsyncKeylessCertificatesResource(self) + + @cached_property + def logpush(self) -> AsyncLogpushResource: + from .resources.logpush import AsyncLogpushResource + + return AsyncLogpushResource(self) + + @cached_property + def logs(self) -> AsyncLogsResource: + from .resources.logs import AsyncLogsResource + + return AsyncLogsResource(self) + + @cached_property + def origin_tls_client_auth(self) -> AsyncOriginTLSClientAuthResource: + from .resources.origin_tls_client_auth import AsyncOriginTLSClientAuthResource + + return AsyncOriginTLSClientAuthResource(self) + + @cached_property + def page_rules(self) -> AsyncPageRulesResource: + from .resources.page_rules import AsyncPageRulesResource + + return AsyncPageRulesResource(self) + + @cached_property + def rate_limits(self) -> AsyncRateLimitsResource: + from .resources.rate_limits import AsyncRateLimitsResource + + return AsyncRateLimitsResource(self) + + @cached_property + def waiting_rooms(self) -> AsyncWaitingRoomsResource: + from .resources.waiting_rooms import AsyncWaitingRoomsResource + + return AsyncWaitingRoomsResource(self) + + @cached_property + def web3(self) -> AsyncWeb3Resource: + from .resources.web3 import AsyncWeb3Resource + + return AsyncWeb3Resource(self) + + @cached_property + def workers(self) -> AsyncWorkersResource: + from .resources.workers import AsyncWorkersResource + + return AsyncWorkersResource(self) + + @cached_property + def kv(self) -> AsyncKVResource: + from .resources.kv import AsyncKVResource + + return AsyncKVResource(self) + + @cached_property + def durable_objects(self) -> AsyncDurableObjectsResource: + from .resources.durable_objects import AsyncDurableObjectsResource + + return AsyncDurableObjectsResource(self) + + @cached_property + def queues(self) -> AsyncQueuesResource: + from .resources.queues import AsyncQueuesResource + + return AsyncQueuesResource(self) + + @cached_property + def api_gateway(self) -> AsyncAPIGatewayResource: + from .resources.api_gateway import AsyncAPIGatewayResource + + return AsyncAPIGatewayResource(self) + + @cached_property + def managed_transforms(self) -> AsyncManagedTransformsResource: + from .resources.managed_transforms import AsyncManagedTransformsResource + + return AsyncManagedTransformsResource(self) + + @cached_property + def page_shield(self) -> AsyncPageShieldResource: + from .resources.page_shield import AsyncPageShieldResource + + return AsyncPageShieldResource(self) + + @cached_property + def rulesets(self) -> AsyncRulesetsResource: + from .resources.rulesets import AsyncRulesetsResource + + return AsyncRulesetsResource(self) + + @cached_property + def url_normalization(self) -> AsyncURLNormalizationResource: + from .resources.url_normalization import AsyncURLNormalizationResource + + return AsyncURLNormalizationResource(self) + + @cached_property + def spectrum(self) -> AsyncSpectrumResource: + from .resources.spectrum import AsyncSpectrumResource + + return AsyncSpectrumResource(self) + + @cached_property + def addressing(self) -> AsyncAddressingResource: + from .resources.addressing import AsyncAddressingResource + + return AsyncAddressingResource(self) + + @cached_property + def audit_logs(self) -> AsyncAuditLogsResource: + from .resources.audit_logs import AsyncAuditLogsResource + + return AsyncAuditLogsResource(self) + + @cached_property + def billing(self) -> AsyncBillingResource: + from .resources.billing import AsyncBillingResource + + return AsyncBillingResource(self) + + @cached_property + def brand_protection(self) -> AsyncBrandProtectionResource: + from .resources.brand_protection import AsyncBrandProtectionResource + + return AsyncBrandProtectionResource(self) + + @cached_property + def diagnostics(self) -> AsyncDiagnosticsResource: + from .resources.diagnostics import AsyncDiagnosticsResource + + return AsyncDiagnosticsResource(self) + + @cached_property + def images(self) -> AsyncImagesResource: + from .resources.images import AsyncImagesResource + + return AsyncImagesResource(self) + + @cached_property + def intel(self) -> AsyncIntelResource: + from .resources.intel import AsyncIntelResource + + return AsyncIntelResource(self) + + @cached_property + def magic_transit(self) -> AsyncMagicTransitResource: + from .resources.magic_transit import AsyncMagicTransitResource + + return AsyncMagicTransitResource(self) + + @cached_property + def magic_network_monitoring(self) -> AsyncMagicNetworkMonitoringResource: + from .resources.magic_network_monitoring import AsyncMagicNetworkMonitoringResource + + return AsyncMagicNetworkMonitoringResource(self) + + @cached_property + def magic_cloud_networking(self) -> AsyncMagicCloudNetworkingResource: + from .resources.magic_cloud_networking import AsyncMagicCloudNetworkingResource + + return AsyncMagicCloudNetworkingResource(self) + + @cached_property + def network_interconnects(self) -> AsyncNetworkInterconnectsResource: + from .resources.network_interconnects import AsyncNetworkInterconnectsResource + + return AsyncNetworkInterconnectsResource(self) + + @cached_property + def mtls_certificates(self) -> AsyncMTLSCertificatesResource: + from .resources.mtls_certificates import AsyncMTLSCertificatesResource + + return AsyncMTLSCertificatesResource(self) + + @cached_property + def pages(self) -> AsyncPagesResource: + from .resources.pages import AsyncPagesResource + + return AsyncPagesResource(self) + + @cached_property + def registrar(self) -> AsyncRegistrarResource: + from .resources.registrar import AsyncRegistrarResource + + return AsyncRegistrarResource(self) + + @cached_property + def request_tracers(self) -> AsyncRequestTracersResource: + from .resources.request_tracers import AsyncRequestTracersResource + + return AsyncRequestTracersResource(self) + + @cached_property + def rules(self) -> AsyncRulesResource: + from .resources.rules import AsyncRulesResource + + return AsyncRulesResource(self) + + @cached_property + def stream(self) -> AsyncStreamResource: + from .resources.stream import AsyncStreamResource + + return AsyncStreamResource(self) + + @cached_property + def alerting(self) -> AsyncAlertingResource: + from .resources.alerting import AsyncAlertingResource + + return AsyncAlertingResource(self) + + @cached_property + def d1(self) -> AsyncD1Resource: + from .resources.d1 import AsyncD1Resource + + return AsyncD1Resource(self) + + @cached_property + def r2(self) -> AsyncR2Resource: + from .resources.r2 import AsyncR2Resource + + return AsyncR2Resource(self) + + @cached_property + def r2_data_catalog(self) -> AsyncR2DataCatalogResource: + from .resources.r2_data_catalog import AsyncR2DataCatalogResource + + return AsyncR2DataCatalogResource(self) + + @cached_property + def workers_for_platforms(self) -> AsyncWorkersForPlatformsResource: + from .resources.workers_for_platforms import AsyncWorkersForPlatformsResource + + return AsyncWorkersForPlatformsResource(self) + + @cached_property + def zero_trust(self) -> AsyncZeroTrustResource: + from .resources.zero_trust import AsyncZeroTrustResource + + return AsyncZeroTrustResource(self) + + @cached_property + def turnstile(self) -> AsyncTurnstileResource: + from .resources.turnstile import AsyncTurnstileResource + + return AsyncTurnstileResource(self) + + @cached_property + def connectivity(self) -> AsyncConnectivityResource: + from .resources.connectivity import AsyncConnectivityResource + + return AsyncConnectivityResource(self) + + @cached_property + def hyperdrive(self) -> AsyncHyperdriveResource: + from .resources.hyperdrive import AsyncHyperdriveResource + + return AsyncHyperdriveResource(self) + + @cached_property + def rum(self) -> AsyncRUMResource: + from .resources.rum import AsyncRUMResource + + return AsyncRUMResource(self) + + @cached_property + def vectorize(self) -> AsyncVectorizeResource: + from .resources.vectorize import AsyncVectorizeResource + + return AsyncVectorizeResource(self) + + @cached_property + def url_scanner(self) -> AsyncURLScannerResource: + from .resources.url_scanner import AsyncURLScannerResource + + return AsyncURLScannerResource(self) + + @cached_property + def radar(self) -> AsyncRadarResource: + from .resources.radar import AsyncRadarResource + + return AsyncRadarResource(self) + + @cached_property + def bot_management(self) -> AsyncBotManagementResource: + from .resources.bot_management import AsyncBotManagementResource + + return AsyncBotManagementResource(self) + + @cached_property + def fraud(self) -> AsyncFraudResource: + from .resources.fraud import AsyncFraudResource + + return AsyncFraudResource(self) + + @cached_property + def origin_post_quantum_encryption(self) -> AsyncOriginPostQuantumEncryptionResource: + from .resources.origin_post_quantum_encryption import AsyncOriginPostQuantumEncryptionResource + + return AsyncOriginPostQuantumEncryptionResource(self) + + @cached_property + def zaraz(self) -> AsyncZarazResource: + from .resources.zaraz import AsyncZarazResource + + return AsyncZarazResource(self) + + @cached_property + def speed(self) -> AsyncSpeedResource: + from .resources.speed import AsyncSpeedResource + + return AsyncSpeedResource(self) + + @cached_property + def dcv_delegation(self) -> AsyncDCVDelegationResource: + from .resources.dcv_delegation import AsyncDCVDelegationResource + + return AsyncDCVDelegationResource(self) + + @cached_property + def hostnames(self) -> AsyncHostnamesResource: + from .resources.hostnames import AsyncHostnamesResource + + return AsyncHostnamesResource(self) + + @cached_property + def snippets(self) -> AsyncSnippetsResource: + from .resources.snippets import AsyncSnippetsResource + + return AsyncSnippetsResource(self) + + @cached_property + def realtime_kit(self) -> AsyncRealtimeKitResource: + from .resources.realtime_kit import AsyncRealtimeKitResource + + return AsyncRealtimeKitResource(self) + + @cached_property + def calls(self) -> AsyncCallsResource: + from .resources.calls import AsyncCallsResource + + return AsyncCallsResource(self) + + @cached_property + def cloudforce_one(self) -> AsyncCloudforceOneResource: + from .resources.cloudforce_one import AsyncCloudforceOneResource + + return AsyncCloudforceOneResource(self) + + @cached_property + def ai_gateway(self) -> AsyncAIGatewayResource: + from .resources.ai_gateway import AsyncAIGatewayResource + + return AsyncAIGatewayResource(self) + + @cached_property + def iam(self) -> AsyncIAMResource: + from .resources.iam import AsyncIAMResource + + return AsyncIAMResource(self) + + @cached_property + def cloud_connector(self) -> AsyncCloudConnectorResource: + from .resources.cloud_connector import AsyncCloudConnectorResource + + return AsyncCloudConnectorResource(self) + + @cached_property + def botnet_feed(self) -> AsyncBotnetFeedResource: + from .resources.botnet_feed import AsyncBotnetFeedResource + + return AsyncBotnetFeedResource(self) + + @cached_property + def security_txt(self) -> AsyncSecurityTXTResource: + from .resources.security_txt import AsyncSecurityTXTResource + + return AsyncSecurityTXTResource(self) + + @cached_property + def workflows(self) -> AsyncWorkflowsResource: + from .resources.workflows import AsyncWorkflowsResource + + return AsyncWorkflowsResource(self) + + @cached_property + def resource_sharing(self) -> AsyncResourceSharingResource: + from .resources.resource_sharing import AsyncResourceSharingResource + + return AsyncResourceSharingResource(self) + + @cached_property + def leaked_credential_checks(self) -> AsyncLeakedCredentialChecksResource: + from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResource + + return AsyncLeakedCredentialChecksResource(self) + + @cached_property + def content_scanning(self) -> AsyncContentScanningResource: + from .resources.content_scanning import AsyncContentScanningResource + + return AsyncContentScanningResource(self) + + @cached_property + def abuse_reports(self) -> AsyncAbuseReportsResource: + from .resources.abuse_reports import AsyncAbuseReportsResource + + return AsyncAbuseReportsResource(self) + + @cached_property + def ai(self) -> AsyncAIResource: + from .resources.ai import AsyncAIResource + + return AsyncAIResource(self) + + @cached_property + def aisearch(self) -> AsyncAISearchResource: + from .resources.aisearch import AsyncAISearchResource + + return AsyncAISearchResource(self) + + @cached_property + def security_center(self) -> AsyncSecurityCenterResource: + from .resources.security_center import AsyncSecurityCenterResource + + return AsyncSecurityCenterResource(self) + + @cached_property + def browser_rendering(self) -> AsyncBrowserRenderingResource: + from .resources.browser_rendering import AsyncBrowserRenderingResource + + return AsyncBrowserRenderingResource(self) + + @cached_property + def custom_pages(self) -> AsyncCustomPagesResource: + from .resources.custom_pages import AsyncCustomPagesResource + + return AsyncCustomPagesResource(self) + + @cached_property + def secrets_store(self) -> AsyncSecretsStoreResource: + from .resources.secrets_store import AsyncSecretsStoreResource + + return AsyncSecretsStoreResource(self) + + @cached_property + def pipelines(self) -> AsyncPipelinesResource: + from .resources.pipelines import AsyncPipelinesResource + + return AsyncPipelinesResource(self) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResource: + from .resources.schema_validation import AsyncSchemaValidationResource + + return AsyncSchemaValidationResource(self) + + @cached_property + def token_validation(self) -> AsyncTokenValidationResource: + from .resources.token_validation import AsyncTokenValidationResource + + return AsyncTokenValidationResource(self) + + @cached_property + def with_raw_response(self) -> AsyncCloudflareWithRawResponse: + return AsyncCloudflareWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCloudflareWithStreamedResponse: + return AsyncCloudflareWithStreamedResponse(self) + + @property + @override + def qs(self) -> Querystring: + return Querystring(nested_format="dots", array_format="repeat") + + @property + @override + def auth_headers(self) -> dict[str, str]: + if self._api_email: + return self._api_email + if self._api_key: + return self._api_key + if self._api_token: + return self._api_token + if self._user_service_key: + return self._user_service_key + return {} + + @property + def _api_email(self) -> dict[str, str]: + api_email = self.api_email + if api_email is None: + return {} + return {"X-Auth-Email": api_email} + + @property + def _api_key(self) -> dict[str, str]: + api_key = self.api_key + if api_key is None: + return {} + return {"X-Auth-Key": api_key} + + @property + def _api_token(self) -> dict[str, str]: + api_token = self.api_token + if api_token is None: + return {} + return {"Authorization": f"Bearer {api_token}"} + + @property + def _user_service_key(self) -> dict[str, str]: + user_service_key = self.user_service_key + if user_service_key is None: + return {} + return {"X-Auth-User-Service-Key": user_service_key} + + @property @override def default_headers(self) -> dict[str, str | Omit]: return { @@ -777,24 +1902,16 @@ def default_headers(self) -> dict[str, str | Omit]: @override def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: - if self.api_email and headers.get("X-Auth-Email"): - return - if isinstance(custom_headers.get("X-Auth-Email"), Omit): + if headers.get("X-Auth-Email") or isinstance(custom_headers.get("X-Auth-Email"), Omit): return - if self.api_key and headers.get("X-Auth-Key"): - return - if isinstance(custom_headers.get("X-Auth-Key"), Omit): + if headers.get("X-Auth-Key") or isinstance(custom_headers.get("X-Auth-Key"), Omit): return - if self.api_token and headers.get("Authorization"): - return - if isinstance(custom_headers.get("Authorization"), Omit): + if headers.get("Authorization") or isinstance(custom_headers.get("Authorization"), Omit): return - if self.user_service_key and headers.get("X-Auth-User-Service-Key"): - return - if isinstance(custom_headers.get("X-Auth-User-Service-Key"), Omit): + if headers.get("X-Auth-User-Service-Key") or isinstance(custom_headers.get("X-Auth-User-Service-Key"), Omit): return raise TypeError( @@ -809,9 +1926,10 @@ def copy( api_email: str | None = None, user_service_key: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + api_version: str | None = None, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -846,6 +1964,7 @@ def copy( api_email=api_email or self.api_email, user_service_key=user_service_key or self.user_service_key, base_url=base_url or self.base_url, + api_version=api_version or self.api_version, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, http_client=http_client, max_retries=max_retries if is_given(max_retries) else self.max_retries, @@ -893,419 +2012,2497 @@ def _make_status_error( class CloudflareWithRawResponse: + _client: Cloudflare + def __init__(self, client: Cloudflare) -> None: - self.accounts = resources.AccountsResourceWithRawResponse(client.accounts) - self.origin_ca_certificates = resources.OriginCACertificatesResourceWithRawResponse( - client.origin_ca_certificates - ) - self.ips = resources.IPsResourceWithRawResponse(client.ips) - self.memberships = resources.MembershipsResourceWithRawResponse(client.memberships) - self.user = resources.UserResourceWithRawResponse(client.user) - self.zones = resources.ZonesResourceWithRawResponse(client.zones) - self.load_balancers = resources.LoadBalancersResourceWithRawResponse(client.load_balancers) - self.cache = resources.CacheResourceWithRawResponse(client.cache) - self.ssl = resources.SSLResourceWithRawResponse(client.ssl) - self.subscriptions = resources.SubscriptionsResourceWithRawResponse(client.subscriptions) - self.acm = resources.ACMResourceWithRawResponse(client.acm) - self.argo = resources.ArgoResourceWithRawResponse(client.argo) - self.plans = resources.PlansResourceWithRawResponse(client.plans) - self.rate_plans = resources.RatePlansResourceWithRawResponse(client.rate_plans) - self.certificate_authorities = resources.CertificateAuthoritiesResourceWithRawResponse( - client.certificate_authorities - ) - self.client_certificates = resources.ClientCertificatesResourceWithRawResponse(client.client_certificates) - self.custom_certificates = resources.CustomCertificatesResourceWithRawResponse(client.custom_certificates) - self.custom_hostnames = resources.CustomHostnamesResourceWithRawResponse(client.custom_hostnames) - self.custom_nameservers = resources.CustomNameserversResourceWithRawResponse(client.custom_nameservers) - self.dns = resources.DNSResourceWithRawResponse(client.dns) - self.dnssec = resources.DNSSECResourceWithRawResponse(client.dnssec) - self.email_routing = resources.EmailRoutingResourceWithRawResponse(client.email_routing) - self.filters = resources.FiltersResourceWithRawResponse(client.filters) - self.firewall = resources.FirewallResourceWithRawResponse(client.firewall) - self.healthchecks = resources.HealthchecksResourceWithRawResponse(client.healthchecks) - self.keyless_certificates = resources.KeylessCertificatesResourceWithRawResponse(client.keyless_certificates) - self.logpush = resources.LogpushResourceWithRawResponse(client.logpush) - self.logs = resources.LogsResourceWithRawResponse(client.logs) - self.origin_tls_client_auth = resources.OriginTLSClientAuthResourceWithRawResponse( - client.origin_tls_client_auth - ) - self.pagerules = resources.PagerulesResourceWithRawResponse(client.pagerules) - self.rate_limits = resources.RateLimitsResourceWithRawResponse(client.rate_limits) - self.secondary_dns = resources.SecondaryDNSResourceWithRawResponse(client.secondary_dns) - self.waiting_rooms = resources.WaitingRoomsResourceWithRawResponse(client.waiting_rooms) - self.web3 = resources.Web3ResourceWithRawResponse(client.web3) - self.workers = resources.WorkersResourceWithRawResponse(client.workers) - self.kv = resources.KVResourceWithRawResponse(client.kv) - self.durable_objects = resources.DurableObjectsResourceWithRawResponse(client.durable_objects) - self.queues = resources.QueuesResourceWithRawResponse(client.queues) - self.api_gateway = resources.APIGatewayResourceWithRawResponse(client.api_gateway) - self.managed_headers = resources.ManagedHeadersResourceWithRawResponse(client.managed_headers) - self.page_shield = resources.PageShieldResourceWithRawResponse(client.page_shield) - self.rulesets = resources.RulesetsResourceWithRawResponse(client.rulesets) - self.url_normalization = resources.URLNormalizationResourceWithRawResponse(client.url_normalization) - self.spectrum = resources.SpectrumResourceWithRawResponse(client.spectrum) - self.addressing = resources.AddressingResourceWithRawResponse(client.addressing) - self.audit_logs = resources.AuditLogsResourceWithRawResponse(client.audit_logs) - self.billing = resources.BillingResourceWithRawResponse(client.billing) - self.brand_protection = resources.BrandProtectionResourceWithRawResponse(client.brand_protection) - self.diagnostics = resources.DiagnosticsResourceWithRawResponse(client.diagnostics) - self.images = resources.ImagesResourceWithRawResponse(client.images) - self.intel = resources.IntelResourceWithRawResponse(client.intel) - self.magic_transit = resources.MagicTransitResourceWithRawResponse(client.magic_transit) - self.magic_network_monitoring = resources.MagicNetworkMonitoringResourceWithRawResponse( - client.magic_network_monitoring - ) - self.mtls_certificates = resources.MTLSCertificatesResourceWithRawResponse(client.mtls_certificates) - self.pages = resources.PagesResourceWithRawResponse(client.pages) - self.pcaps = resources.PCAPsResourceWithRawResponse(client.pcaps) - self.registrar = resources.RegistrarResourceWithRawResponse(client.registrar) - self.request_tracers = resources.RequestTracersResourceWithRawResponse(client.request_tracers) - self.rules = resources.RulesResourceWithRawResponse(client.rules) - self.storage = resources.StorageResourceWithRawResponse(client.storage) - self.stream = resources.StreamResourceWithRawResponse(client.stream) - self.alerting = resources.AlertingResourceWithRawResponse(client.alerting) - self.d1 = resources.D1ResourceWithRawResponse(client.d1) - self.r2 = resources.R2ResourceWithRawResponse(client.r2) - self.warp_connector = resources.WARPConnectorResourceWithRawResponse(client.warp_connector) - self.workers_for_platforms = resources.WorkersForPlatformsResourceWithRawResponse(client.workers_for_platforms) - self.zero_trust = resources.ZeroTrustResourceWithRawResponse(client.zero_trust) - self.challenges = resources.ChallengesResourceWithRawResponse(client.challenges) - self.hyperdrive = resources.HyperdriveResourceWithRawResponse(client.hyperdrive) - self.rum = resources.RUMResourceWithRawResponse(client.rum) - self.vectorize = resources.VectorizeResourceWithRawResponse(client.vectorize) - self.url_scanner = resources.URLScannerResourceWithRawResponse(client.url_scanner) - self.radar = resources.RadarResourceWithRawResponse(client.radar) - self.bot_management = resources.BotManagementResourceWithRawResponse(client.bot_management) - self.origin_post_quantum_encryption = resources.OriginPostQuantumEncryptionResourceWithRawResponse( - client.origin_post_quantum_encryption - ) - self.speed = resources.SpeedResourceWithRawResponse(client.speed) - self.dcv_delegation = resources.DCVDelegationResourceWithRawResponse(client.dcv_delegation) - self.hostnames = resources.HostnamesResourceWithRawResponse(client.hostnames) - self.snippets = resources.SnippetsResourceWithRawResponse(client.snippets) - self.calls = resources.CallsResourceWithRawResponse(client.calls) - self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one) - self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications) - self.ai_gateway = resources.AIGatewayResourceWithRawResponse(client.ai_gateway) - self.iam = resources.IAMResourceWithRawResponse(client.iam) - self.cloud_connector = resources.CloudConnectorResourceWithRawResponse(client.cloud_connector) + self._client = client + + @cached_property + def accounts(self) -> accounts.AccountsResourceWithRawResponse: + from .resources.accounts import AccountsResourceWithRawResponse + + return AccountsResourceWithRawResponse(self._client.accounts) + + @cached_property + def organizations(self) -> organizations.OrganizationsResourceWithRawResponse: + from .resources.organizations import OrganizationsResourceWithRawResponse + + return OrganizationsResourceWithRawResponse(self._client.organizations) + + @cached_property + def origin_ca_certificates(self) -> origin_ca_certificates.OriginCACertificatesResourceWithRawResponse: + from .resources.origin_ca_certificates import OriginCACertificatesResourceWithRawResponse + + return OriginCACertificatesResourceWithRawResponse(self._client.origin_ca_certificates) + + @cached_property + def ips(self) -> ips.IPsResourceWithRawResponse: + from .resources.ips import IPsResourceWithRawResponse + + return IPsResourceWithRawResponse(self._client.ips) + + @cached_property + def memberships(self) -> memberships.MembershipsResourceWithRawResponse: + from .resources.memberships import MembershipsResourceWithRawResponse + + return MembershipsResourceWithRawResponse(self._client.memberships) + + @cached_property + def user(self) -> user.UserResourceWithRawResponse: + from .resources.user import UserResourceWithRawResponse + + return UserResourceWithRawResponse(self._client.user) + + @cached_property + def zones(self) -> zones.ZonesResourceWithRawResponse: + from .resources.zones import ZonesResourceWithRawResponse + + return ZonesResourceWithRawResponse(self._client.zones) + + @cached_property + def load_balancers(self) -> load_balancers.LoadBalancersResourceWithRawResponse: + from .resources.load_balancers import LoadBalancersResourceWithRawResponse + + return LoadBalancersResourceWithRawResponse(self._client.load_balancers) + + @cached_property + def cache(self) -> cache.CacheResourceWithRawResponse: + from .resources.cache import CacheResourceWithRawResponse + + return CacheResourceWithRawResponse(self._client.cache) + + @cached_property + def ssl(self) -> ssl.SSLResourceWithRawResponse: + from .resources.ssl import SSLResourceWithRawResponse + + return SSLResourceWithRawResponse(self._client.ssl) + + @cached_property + def acm(self) -> acm.ACMResourceWithRawResponse: + from .resources.acm import ACMResourceWithRawResponse + + return ACMResourceWithRawResponse(self._client.acm) + + @cached_property + def argo(self) -> argo.ArgoResourceWithRawResponse: + from .resources.argo import ArgoResourceWithRawResponse + + return ArgoResourceWithRawResponse(self._client.argo) + + @cached_property + def certificate_authorities(self) -> certificate_authorities.CertificateAuthoritiesResourceWithRawResponse: + from .resources.certificate_authorities import CertificateAuthoritiesResourceWithRawResponse + + return CertificateAuthoritiesResourceWithRawResponse(self._client.certificate_authorities) + + @cached_property + def client_certificates(self) -> client_certificates.ClientCertificatesResourceWithRawResponse: + from .resources.client_certificates import ClientCertificatesResourceWithRawResponse + + return ClientCertificatesResourceWithRawResponse(self._client.client_certificates) + + @cached_property + def custom_certificates(self) -> custom_certificates.CustomCertificatesResourceWithRawResponse: + from .resources.custom_certificates import CustomCertificatesResourceWithRawResponse + + return CustomCertificatesResourceWithRawResponse(self._client.custom_certificates) + + @cached_property + def custom_hostnames(self) -> custom_hostnames.CustomHostnamesResourceWithRawResponse: + from .resources.custom_hostnames import CustomHostnamesResourceWithRawResponse + + return CustomHostnamesResourceWithRawResponse(self._client.custom_hostnames) + + @cached_property + def custom_nameservers(self) -> custom_nameservers.CustomNameserversResourceWithRawResponse: + from .resources.custom_nameservers import CustomNameserversResourceWithRawResponse + + return CustomNameserversResourceWithRawResponse(self._client.custom_nameservers) + + @cached_property + def dns_firewall(self) -> dns_firewall.DNSFirewallResourceWithRawResponse: + from .resources.dns_firewall import DNSFirewallResourceWithRawResponse + + return DNSFirewallResourceWithRawResponse(self._client.dns_firewall) + + @cached_property + def dns(self) -> dns.DNSResourceWithRawResponse: + from .resources.dns import DNSResourceWithRawResponse + + return DNSResourceWithRawResponse(self._client.dns) + + @cached_property + def email_security(self) -> email_security.EmailSecurityResourceWithRawResponse: + from .resources.email_security import EmailSecurityResourceWithRawResponse + + return EmailSecurityResourceWithRawResponse(self._client.email_security) + + @cached_property + def email_routing(self) -> email_routing.EmailRoutingResourceWithRawResponse: + from .resources.email_routing import EmailRoutingResourceWithRawResponse + + return EmailRoutingResourceWithRawResponse(self._client.email_routing) + + @cached_property + def filters(self) -> filters.FiltersResourceWithRawResponse: + from .resources.filters import FiltersResourceWithRawResponse + + return FiltersResourceWithRawResponse(self._client.filters) + + @cached_property + def firewall(self) -> firewall.FirewallResourceWithRawResponse: + from .resources.firewall import FirewallResourceWithRawResponse + + return FirewallResourceWithRawResponse(self._client.firewall) + + @cached_property + def healthchecks(self) -> healthchecks.HealthchecksResourceWithRawResponse: + from .resources.healthchecks import HealthchecksResourceWithRawResponse + + return HealthchecksResourceWithRawResponse(self._client.healthchecks) + + @cached_property + def keyless_certificates(self) -> keyless_certificates.KeylessCertificatesResourceWithRawResponse: + from .resources.keyless_certificates import KeylessCertificatesResourceWithRawResponse + + return KeylessCertificatesResourceWithRawResponse(self._client.keyless_certificates) + + @cached_property + def logpush(self) -> logpush.LogpushResourceWithRawResponse: + from .resources.logpush import LogpushResourceWithRawResponse + + return LogpushResourceWithRawResponse(self._client.logpush) + + @cached_property + def logs(self) -> logs.LogsResourceWithRawResponse: + from .resources.logs import LogsResourceWithRawResponse + + return LogsResourceWithRawResponse(self._client.logs) + + @cached_property + def origin_tls_client_auth(self) -> origin_tls_client_auth.OriginTLSClientAuthResourceWithRawResponse: + from .resources.origin_tls_client_auth import OriginTLSClientAuthResourceWithRawResponse + + return OriginTLSClientAuthResourceWithRawResponse(self._client.origin_tls_client_auth) + + @cached_property + def page_rules(self) -> page_rules.PageRulesResourceWithRawResponse: + from .resources.page_rules import PageRulesResourceWithRawResponse + + return PageRulesResourceWithRawResponse(self._client.page_rules) + + @cached_property + def rate_limits(self) -> rate_limits.RateLimitsResourceWithRawResponse: + from .resources.rate_limits import RateLimitsResourceWithRawResponse + + return RateLimitsResourceWithRawResponse(self._client.rate_limits) + + @cached_property + def waiting_rooms(self) -> waiting_rooms.WaitingRoomsResourceWithRawResponse: + from .resources.waiting_rooms import WaitingRoomsResourceWithRawResponse + + return WaitingRoomsResourceWithRawResponse(self._client.waiting_rooms) + + @cached_property + def web3(self) -> web3.Web3ResourceWithRawResponse: + from .resources.web3 import Web3ResourceWithRawResponse + + return Web3ResourceWithRawResponse(self._client.web3) + + @cached_property + def workers(self) -> workers.WorkersResourceWithRawResponse: + from .resources.workers import WorkersResourceWithRawResponse + + return WorkersResourceWithRawResponse(self._client.workers) + + @cached_property + def kv(self) -> kv.KVResourceWithRawResponse: + from .resources.kv import KVResourceWithRawResponse + + return KVResourceWithRawResponse(self._client.kv) + + @cached_property + def durable_objects(self) -> durable_objects.DurableObjectsResourceWithRawResponse: + from .resources.durable_objects import DurableObjectsResourceWithRawResponse + + return DurableObjectsResourceWithRawResponse(self._client.durable_objects) + + @cached_property + def queues(self) -> queues.QueuesResourceWithRawResponse: + from .resources.queues import QueuesResourceWithRawResponse + + return QueuesResourceWithRawResponse(self._client.queues) + + @cached_property + def api_gateway(self) -> api_gateway.APIGatewayResourceWithRawResponse: + from .resources.api_gateway import APIGatewayResourceWithRawResponse + + return APIGatewayResourceWithRawResponse(self._client.api_gateway) + + @cached_property + def managed_transforms(self) -> managed_transforms.ManagedTransformsResourceWithRawResponse: + from .resources.managed_transforms import ManagedTransformsResourceWithRawResponse + + return ManagedTransformsResourceWithRawResponse(self._client.managed_transforms) + + @cached_property + def page_shield(self) -> page_shield.PageShieldResourceWithRawResponse: + from .resources.page_shield import PageShieldResourceWithRawResponse + + return PageShieldResourceWithRawResponse(self._client.page_shield) + + @cached_property + def rulesets(self) -> rulesets.RulesetsResourceWithRawResponse: + from .resources.rulesets import RulesetsResourceWithRawResponse + + return RulesetsResourceWithRawResponse(self._client.rulesets) + + @cached_property + def url_normalization(self) -> url_normalization.URLNormalizationResourceWithRawResponse: + from .resources.url_normalization import URLNormalizationResourceWithRawResponse + + return URLNormalizationResourceWithRawResponse(self._client.url_normalization) + + @cached_property + def spectrum(self) -> spectrum.SpectrumResourceWithRawResponse: + from .resources.spectrum import SpectrumResourceWithRawResponse + + return SpectrumResourceWithRawResponse(self._client.spectrum) + + @cached_property + def addressing(self) -> addressing.AddressingResourceWithRawResponse: + from .resources.addressing import AddressingResourceWithRawResponse + + return AddressingResourceWithRawResponse(self._client.addressing) + + @cached_property + def audit_logs(self) -> audit_logs.AuditLogsResourceWithRawResponse: + from .resources.audit_logs import AuditLogsResourceWithRawResponse + + return AuditLogsResourceWithRawResponse(self._client.audit_logs) + + @cached_property + def billing(self) -> billing.BillingResourceWithRawResponse: + from .resources.billing import BillingResourceWithRawResponse + + return BillingResourceWithRawResponse(self._client.billing) + + @cached_property + def brand_protection(self) -> brand_protection.BrandProtectionResourceWithRawResponse: + from .resources.brand_protection import BrandProtectionResourceWithRawResponse + + return BrandProtectionResourceWithRawResponse(self._client.brand_protection) + + @cached_property + def diagnostics(self) -> diagnostics.DiagnosticsResourceWithRawResponse: + from .resources.diagnostics import DiagnosticsResourceWithRawResponse + + return DiagnosticsResourceWithRawResponse(self._client.diagnostics) + + @cached_property + def images(self) -> images.ImagesResourceWithRawResponse: + from .resources.images import ImagesResourceWithRawResponse + + return ImagesResourceWithRawResponse(self._client.images) + + @cached_property + def intel(self) -> intel.IntelResourceWithRawResponse: + from .resources.intel import IntelResourceWithRawResponse + + return IntelResourceWithRawResponse(self._client.intel) + + @cached_property + def magic_transit(self) -> magic_transit.MagicTransitResourceWithRawResponse: + from .resources.magic_transit import MagicTransitResourceWithRawResponse + + return MagicTransitResourceWithRawResponse(self._client.magic_transit) + + @cached_property + def magic_network_monitoring(self) -> magic_network_monitoring.MagicNetworkMonitoringResourceWithRawResponse: + from .resources.magic_network_monitoring import MagicNetworkMonitoringResourceWithRawResponse + + return MagicNetworkMonitoringResourceWithRawResponse(self._client.magic_network_monitoring) + + @cached_property + def magic_cloud_networking(self) -> magic_cloud_networking.MagicCloudNetworkingResourceWithRawResponse: + from .resources.magic_cloud_networking import MagicCloudNetworkingResourceWithRawResponse + + return MagicCloudNetworkingResourceWithRawResponse(self._client.magic_cloud_networking) + + @cached_property + def network_interconnects(self) -> network_interconnects.NetworkInterconnectsResourceWithRawResponse: + from .resources.network_interconnects import NetworkInterconnectsResourceWithRawResponse + + return NetworkInterconnectsResourceWithRawResponse(self._client.network_interconnects) + + @cached_property + def mtls_certificates(self) -> mtls_certificates.MTLSCertificatesResourceWithRawResponse: + from .resources.mtls_certificates import MTLSCertificatesResourceWithRawResponse + + return MTLSCertificatesResourceWithRawResponse(self._client.mtls_certificates) + + @cached_property + def pages(self) -> pages.PagesResourceWithRawResponse: + from .resources.pages import PagesResourceWithRawResponse + + return PagesResourceWithRawResponse(self._client.pages) + + @cached_property + def registrar(self) -> registrar.RegistrarResourceWithRawResponse: + from .resources.registrar import RegistrarResourceWithRawResponse + + return RegistrarResourceWithRawResponse(self._client.registrar) + + @cached_property + def request_tracers(self) -> request_tracers.RequestTracersResourceWithRawResponse: + from .resources.request_tracers import RequestTracersResourceWithRawResponse + + return RequestTracersResourceWithRawResponse(self._client.request_tracers) + + @cached_property + def rules(self) -> rules.RulesResourceWithRawResponse: + from .resources.rules import RulesResourceWithRawResponse + + return RulesResourceWithRawResponse(self._client.rules) + + @cached_property + def stream(self) -> stream.StreamResourceWithRawResponse: + from .resources.stream import StreamResourceWithRawResponse + + return StreamResourceWithRawResponse(self._client.stream) + + @cached_property + def alerting(self) -> alerting.AlertingResourceWithRawResponse: + from .resources.alerting import AlertingResourceWithRawResponse + + return AlertingResourceWithRawResponse(self._client.alerting) + + @cached_property + def d1(self) -> d1.D1ResourceWithRawResponse: + from .resources.d1 import D1ResourceWithRawResponse + + return D1ResourceWithRawResponse(self._client.d1) + + @cached_property + def r2(self) -> r2.R2ResourceWithRawResponse: + from .resources.r2 import R2ResourceWithRawResponse + + return R2ResourceWithRawResponse(self._client.r2) + + @cached_property + def r2_data_catalog(self) -> r2_data_catalog.R2DataCatalogResourceWithRawResponse: + from .resources.r2_data_catalog import R2DataCatalogResourceWithRawResponse + + return R2DataCatalogResourceWithRawResponse(self._client.r2_data_catalog) + + @cached_property + def workers_for_platforms(self) -> workers_for_platforms.WorkersForPlatformsResourceWithRawResponse: + from .resources.workers_for_platforms import WorkersForPlatformsResourceWithRawResponse + + return WorkersForPlatformsResourceWithRawResponse(self._client.workers_for_platforms) + + @cached_property + def zero_trust(self) -> zero_trust.ZeroTrustResourceWithRawResponse: + from .resources.zero_trust import ZeroTrustResourceWithRawResponse + + return ZeroTrustResourceWithRawResponse(self._client.zero_trust) + + @cached_property + def turnstile(self) -> turnstile.TurnstileResourceWithRawResponse: + from .resources.turnstile import TurnstileResourceWithRawResponse + + return TurnstileResourceWithRawResponse(self._client.turnstile) + + @cached_property + def connectivity(self) -> connectivity.ConnectivityResourceWithRawResponse: + from .resources.connectivity import ConnectivityResourceWithRawResponse + + return ConnectivityResourceWithRawResponse(self._client.connectivity) + + @cached_property + def hyperdrive(self) -> hyperdrive.HyperdriveResourceWithRawResponse: + from .resources.hyperdrive import HyperdriveResourceWithRawResponse + + return HyperdriveResourceWithRawResponse(self._client.hyperdrive) + + @cached_property + def rum(self) -> rum.RUMResourceWithRawResponse: + from .resources.rum import RUMResourceWithRawResponse + + return RUMResourceWithRawResponse(self._client.rum) + + @cached_property + def vectorize(self) -> vectorize.VectorizeResourceWithRawResponse: + from .resources.vectorize import VectorizeResourceWithRawResponse + + return VectorizeResourceWithRawResponse(self._client.vectorize) + + @cached_property + def url_scanner(self) -> url_scanner.URLScannerResourceWithRawResponse: + from .resources.url_scanner import URLScannerResourceWithRawResponse + + return URLScannerResourceWithRawResponse(self._client.url_scanner) + + @cached_property + def radar(self) -> radar.RadarResourceWithRawResponse: + from .resources.radar import RadarResourceWithRawResponse + + return RadarResourceWithRawResponse(self._client.radar) + + @cached_property + def bot_management(self) -> bot_management.BotManagementResourceWithRawResponse: + from .resources.bot_management import BotManagementResourceWithRawResponse + + return BotManagementResourceWithRawResponse(self._client.bot_management) + + @cached_property + def fraud(self) -> fraud.FraudResourceWithRawResponse: + from .resources.fraud import FraudResourceWithRawResponse + + return FraudResourceWithRawResponse(self._client.fraud) + + @cached_property + def origin_post_quantum_encryption( + self, + ) -> origin_post_quantum_encryption.OriginPostQuantumEncryptionResourceWithRawResponse: + from .resources.origin_post_quantum_encryption import OriginPostQuantumEncryptionResourceWithRawResponse + + return OriginPostQuantumEncryptionResourceWithRawResponse(self._client.origin_post_quantum_encryption) + + @cached_property + def zaraz(self) -> zaraz.ZarazResourceWithRawResponse: + from .resources.zaraz import ZarazResourceWithRawResponse + + return ZarazResourceWithRawResponse(self._client.zaraz) + + @cached_property + def speed(self) -> speed.SpeedResourceWithRawResponse: + from .resources.speed import SpeedResourceWithRawResponse + + return SpeedResourceWithRawResponse(self._client.speed) + + @cached_property + def dcv_delegation(self) -> dcv_delegation.DCVDelegationResourceWithRawResponse: + from .resources.dcv_delegation import DCVDelegationResourceWithRawResponse + + return DCVDelegationResourceWithRawResponse(self._client.dcv_delegation) + + @cached_property + def hostnames(self) -> hostnames.HostnamesResourceWithRawResponse: + from .resources.hostnames import HostnamesResourceWithRawResponse + + return HostnamesResourceWithRawResponse(self._client.hostnames) + + @cached_property + def snippets(self) -> snippets.SnippetsResourceWithRawResponse: + from .resources.snippets import SnippetsResourceWithRawResponse + + return SnippetsResourceWithRawResponse(self._client.snippets) + + @cached_property + def realtime_kit(self) -> realtime_kit.RealtimeKitResourceWithRawResponse: + from .resources.realtime_kit import RealtimeKitResourceWithRawResponse + + return RealtimeKitResourceWithRawResponse(self._client.realtime_kit) + + @cached_property + def calls(self) -> calls.CallsResourceWithRawResponse: + from .resources.calls import CallsResourceWithRawResponse + + return CallsResourceWithRawResponse(self._client.calls) + + @cached_property + def cloudforce_one(self) -> cloudforce_one.CloudforceOneResourceWithRawResponse: + from .resources.cloudforce_one import CloudforceOneResourceWithRawResponse + + return CloudforceOneResourceWithRawResponse(self._client.cloudforce_one) + + @cached_property + def ai_gateway(self) -> ai_gateway.AIGatewayResourceWithRawResponse: + from .resources.ai_gateway import AIGatewayResourceWithRawResponse + + return AIGatewayResourceWithRawResponse(self._client.ai_gateway) + + @cached_property + def iam(self) -> iam.IAMResourceWithRawResponse: + from .resources.iam import IAMResourceWithRawResponse + + return IAMResourceWithRawResponse(self._client.iam) + + @cached_property + def cloud_connector(self) -> cloud_connector.CloudConnectorResourceWithRawResponse: + from .resources.cloud_connector import CloudConnectorResourceWithRawResponse + + return CloudConnectorResourceWithRawResponse(self._client.cloud_connector) + + @cached_property + def botnet_feed(self) -> botnet_feed.BotnetFeedResourceWithRawResponse: + from .resources.botnet_feed import BotnetFeedResourceWithRawResponse + + return BotnetFeedResourceWithRawResponse(self._client.botnet_feed) + + @cached_property + def security_txt(self) -> security_txt.SecurityTXTResourceWithRawResponse: + from .resources.security_txt import SecurityTXTResourceWithRawResponse + + return SecurityTXTResourceWithRawResponse(self._client.security_txt) + + @cached_property + def workflows(self) -> workflows.WorkflowsResourceWithRawResponse: + from .resources.workflows import WorkflowsResourceWithRawResponse + + return WorkflowsResourceWithRawResponse(self._client.workflows) + + @cached_property + def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithRawResponse: + from .resources.resource_sharing import ResourceSharingResourceWithRawResponse + + return ResourceSharingResourceWithRawResponse(self._client.resource_sharing) + + @cached_property + def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithRawResponse: + from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithRawResponse + + return LeakedCredentialChecksResourceWithRawResponse(self._client.leaked_credential_checks) + + @cached_property + def content_scanning(self) -> content_scanning.ContentScanningResourceWithRawResponse: + from .resources.content_scanning import ContentScanningResourceWithRawResponse + + return ContentScanningResourceWithRawResponse(self._client.content_scanning) + + @cached_property + def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithRawResponse: + from .resources.abuse_reports import AbuseReportsResourceWithRawResponse + + return AbuseReportsResourceWithRawResponse(self._client.abuse_reports) + + @cached_property + def ai(self) -> ai.AIResourceWithRawResponse: + from .resources.ai import AIResourceWithRawResponse + + return AIResourceWithRawResponse(self._client.ai) + + @cached_property + def aisearch(self) -> aisearch.AISearchResourceWithRawResponse: + from .resources.aisearch import AISearchResourceWithRawResponse + + return AISearchResourceWithRawResponse(self._client.aisearch) + + @cached_property + def security_center(self) -> security_center.SecurityCenterResourceWithRawResponse: + from .resources.security_center import SecurityCenterResourceWithRawResponse + + return SecurityCenterResourceWithRawResponse(self._client.security_center) + + @cached_property + def browser_rendering(self) -> browser_rendering.BrowserRenderingResourceWithRawResponse: + from .resources.browser_rendering import BrowserRenderingResourceWithRawResponse + + return BrowserRenderingResourceWithRawResponse(self._client.browser_rendering) + + @cached_property + def custom_pages(self) -> custom_pages.CustomPagesResourceWithRawResponse: + from .resources.custom_pages import CustomPagesResourceWithRawResponse + + return CustomPagesResourceWithRawResponse(self._client.custom_pages) + + @cached_property + def secrets_store(self) -> secrets_store.SecretsStoreResourceWithRawResponse: + from .resources.secrets_store import SecretsStoreResourceWithRawResponse + + return SecretsStoreResourceWithRawResponse(self._client.secrets_store) + + @cached_property + def pipelines(self) -> pipelines.PipelinesResourceWithRawResponse: + from .resources.pipelines import PipelinesResourceWithRawResponse + + return PipelinesResourceWithRawResponse(self._client.pipelines) + + @cached_property + def schema_validation(self) -> schema_validation.SchemaValidationResourceWithRawResponse: + from .resources.schema_validation import SchemaValidationResourceWithRawResponse + + return SchemaValidationResourceWithRawResponse(self._client.schema_validation) + + @cached_property + def token_validation(self) -> token_validation.TokenValidationResourceWithRawResponse: + from .resources.token_validation import TokenValidationResourceWithRawResponse + + return TokenValidationResourceWithRawResponse(self._client.token_validation) class AsyncCloudflareWithRawResponse: + _client: AsyncCloudflare + def __init__(self, client: AsyncCloudflare) -> None: - self.accounts = resources.AsyncAccountsResourceWithRawResponse(client.accounts) - self.origin_ca_certificates = resources.AsyncOriginCACertificatesResourceWithRawResponse( - client.origin_ca_certificates - ) - self.ips = resources.AsyncIPsResourceWithRawResponse(client.ips) - self.memberships = resources.AsyncMembershipsResourceWithRawResponse(client.memberships) - self.user = resources.AsyncUserResourceWithRawResponse(client.user) - self.zones = resources.AsyncZonesResourceWithRawResponse(client.zones) - self.load_balancers = resources.AsyncLoadBalancersResourceWithRawResponse(client.load_balancers) - self.cache = resources.AsyncCacheResourceWithRawResponse(client.cache) - self.ssl = resources.AsyncSSLResourceWithRawResponse(client.ssl) - self.subscriptions = resources.AsyncSubscriptionsResourceWithRawResponse(client.subscriptions) - self.acm = resources.AsyncACMResourceWithRawResponse(client.acm) - self.argo = resources.AsyncArgoResourceWithRawResponse(client.argo) - self.plans = resources.AsyncPlansResourceWithRawResponse(client.plans) - self.rate_plans = resources.AsyncRatePlansResourceWithRawResponse(client.rate_plans) - self.certificate_authorities = resources.AsyncCertificateAuthoritiesResourceWithRawResponse( - client.certificate_authorities - ) - self.client_certificates = resources.AsyncClientCertificatesResourceWithRawResponse(client.client_certificates) - self.custom_certificates = resources.AsyncCustomCertificatesResourceWithRawResponse(client.custom_certificates) - self.custom_hostnames = resources.AsyncCustomHostnamesResourceWithRawResponse(client.custom_hostnames) - self.custom_nameservers = resources.AsyncCustomNameserversResourceWithRawResponse(client.custom_nameservers) - self.dns = resources.AsyncDNSResourceWithRawResponse(client.dns) - self.dnssec = resources.AsyncDNSSECResourceWithRawResponse(client.dnssec) - self.email_routing = resources.AsyncEmailRoutingResourceWithRawResponse(client.email_routing) - self.filters = resources.AsyncFiltersResourceWithRawResponse(client.filters) - self.firewall = resources.AsyncFirewallResourceWithRawResponse(client.firewall) - self.healthchecks = resources.AsyncHealthchecksResourceWithRawResponse(client.healthchecks) - self.keyless_certificates = resources.AsyncKeylessCertificatesResourceWithRawResponse( - client.keyless_certificates - ) - self.logpush = resources.AsyncLogpushResourceWithRawResponse(client.logpush) - self.logs = resources.AsyncLogsResourceWithRawResponse(client.logs) - self.origin_tls_client_auth = resources.AsyncOriginTLSClientAuthResourceWithRawResponse( - client.origin_tls_client_auth - ) - self.pagerules = resources.AsyncPagerulesResourceWithRawResponse(client.pagerules) - self.rate_limits = resources.AsyncRateLimitsResourceWithRawResponse(client.rate_limits) - self.secondary_dns = resources.AsyncSecondaryDNSResourceWithRawResponse(client.secondary_dns) - self.waiting_rooms = resources.AsyncWaitingRoomsResourceWithRawResponse(client.waiting_rooms) - self.web3 = resources.AsyncWeb3ResourceWithRawResponse(client.web3) - self.workers = resources.AsyncWorkersResourceWithRawResponse(client.workers) - self.kv = resources.AsyncKVResourceWithRawResponse(client.kv) - self.durable_objects = resources.AsyncDurableObjectsResourceWithRawResponse(client.durable_objects) - self.queues = resources.AsyncQueuesResourceWithRawResponse(client.queues) - self.api_gateway = resources.AsyncAPIGatewayResourceWithRawResponse(client.api_gateway) - self.managed_headers = resources.AsyncManagedHeadersResourceWithRawResponse(client.managed_headers) - self.page_shield = resources.AsyncPageShieldResourceWithRawResponse(client.page_shield) - self.rulesets = resources.AsyncRulesetsResourceWithRawResponse(client.rulesets) - self.url_normalization = resources.AsyncURLNormalizationResourceWithRawResponse(client.url_normalization) - self.spectrum = resources.AsyncSpectrumResourceWithRawResponse(client.spectrum) - self.addressing = resources.AsyncAddressingResourceWithRawResponse(client.addressing) - self.audit_logs = resources.AsyncAuditLogsResourceWithRawResponse(client.audit_logs) - self.billing = resources.AsyncBillingResourceWithRawResponse(client.billing) - self.brand_protection = resources.AsyncBrandProtectionResourceWithRawResponse(client.brand_protection) - self.diagnostics = resources.AsyncDiagnosticsResourceWithRawResponse(client.diagnostics) - self.images = resources.AsyncImagesResourceWithRawResponse(client.images) - self.intel = resources.AsyncIntelResourceWithRawResponse(client.intel) - self.magic_transit = resources.AsyncMagicTransitResourceWithRawResponse(client.magic_transit) - self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoringResourceWithRawResponse( - client.magic_network_monitoring - ) - self.mtls_certificates = resources.AsyncMTLSCertificatesResourceWithRawResponse(client.mtls_certificates) - self.pages = resources.AsyncPagesResourceWithRawResponse(client.pages) - self.pcaps = resources.AsyncPCAPsResourceWithRawResponse(client.pcaps) - self.registrar = resources.AsyncRegistrarResourceWithRawResponse(client.registrar) - self.request_tracers = resources.AsyncRequestTracersResourceWithRawResponse(client.request_tracers) - self.rules = resources.AsyncRulesResourceWithRawResponse(client.rules) - self.storage = resources.AsyncStorageResourceWithRawResponse(client.storage) - self.stream = resources.AsyncStreamResourceWithRawResponse(client.stream) - self.alerting = resources.AsyncAlertingResourceWithRawResponse(client.alerting) - self.d1 = resources.AsyncD1ResourceWithRawResponse(client.d1) - self.r2 = resources.AsyncR2ResourceWithRawResponse(client.r2) - self.warp_connector = resources.AsyncWARPConnectorResourceWithRawResponse(client.warp_connector) - self.workers_for_platforms = resources.AsyncWorkersForPlatformsResourceWithRawResponse( - client.workers_for_platforms - ) - self.zero_trust = resources.AsyncZeroTrustResourceWithRawResponse(client.zero_trust) - self.challenges = resources.AsyncChallengesResourceWithRawResponse(client.challenges) - self.hyperdrive = resources.AsyncHyperdriveResourceWithRawResponse(client.hyperdrive) - self.rum = resources.AsyncRUMResourceWithRawResponse(client.rum) - self.vectorize = resources.AsyncVectorizeResourceWithRawResponse(client.vectorize) - self.url_scanner = resources.AsyncURLScannerResourceWithRawResponse(client.url_scanner) - self.radar = resources.AsyncRadarResourceWithRawResponse(client.radar) - self.bot_management = resources.AsyncBotManagementResourceWithRawResponse(client.bot_management) - self.origin_post_quantum_encryption = resources.AsyncOriginPostQuantumEncryptionResourceWithRawResponse( - client.origin_post_quantum_encryption - ) - self.speed = resources.AsyncSpeedResourceWithRawResponse(client.speed) - self.dcv_delegation = resources.AsyncDCVDelegationResourceWithRawResponse(client.dcv_delegation) - self.hostnames = resources.AsyncHostnamesResourceWithRawResponse(client.hostnames) - self.snippets = resources.AsyncSnippetsResourceWithRawResponse(client.snippets) - self.calls = resources.AsyncCallsResourceWithRawResponse(client.calls) - self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one) - self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications) - self.ai_gateway = resources.AsyncAIGatewayResourceWithRawResponse(client.ai_gateway) - self.iam = resources.AsyncIAMResourceWithRawResponse(client.iam) - self.cloud_connector = resources.AsyncCloudConnectorResourceWithRawResponse(client.cloud_connector) + self._client = client + + @cached_property + def accounts(self) -> accounts.AsyncAccountsResourceWithRawResponse: + from .resources.accounts import AsyncAccountsResourceWithRawResponse + + return AsyncAccountsResourceWithRawResponse(self._client.accounts) + + @cached_property + def organizations(self) -> organizations.AsyncOrganizationsResourceWithRawResponse: + from .resources.organizations import AsyncOrganizationsResourceWithRawResponse + + return AsyncOrganizationsResourceWithRawResponse(self._client.organizations) + + @cached_property + def origin_ca_certificates(self) -> origin_ca_certificates.AsyncOriginCACertificatesResourceWithRawResponse: + from .resources.origin_ca_certificates import AsyncOriginCACertificatesResourceWithRawResponse + + return AsyncOriginCACertificatesResourceWithRawResponse(self._client.origin_ca_certificates) + + @cached_property + def ips(self) -> ips.AsyncIPsResourceWithRawResponse: + from .resources.ips import AsyncIPsResourceWithRawResponse + + return AsyncIPsResourceWithRawResponse(self._client.ips) + + @cached_property + def memberships(self) -> memberships.AsyncMembershipsResourceWithRawResponse: + from .resources.memberships import AsyncMembershipsResourceWithRawResponse + + return AsyncMembershipsResourceWithRawResponse(self._client.memberships) + + @cached_property + def user(self) -> user.AsyncUserResourceWithRawResponse: + from .resources.user import AsyncUserResourceWithRawResponse + + return AsyncUserResourceWithRawResponse(self._client.user) + + @cached_property + def zones(self) -> zones.AsyncZonesResourceWithRawResponse: + from .resources.zones import AsyncZonesResourceWithRawResponse + + return AsyncZonesResourceWithRawResponse(self._client.zones) + + @cached_property + def load_balancers(self) -> load_balancers.AsyncLoadBalancersResourceWithRawResponse: + from .resources.load_balancers import AsyncLoadBalancersResourceWithRawResponse + + return AsyncLoadBalancersResourceWithRawResponse(self._client.load_balancers) + + @cached_property + def cache(self) -> cache.AsyncCacheResourceWithRawResponse: + from .resources.cache import AsyncCacheResourceWithRawResponse + + return AsyncCacheResourceWithRawResponse(self._client.cache) + + @cached_property + def ssl(self) -> ssl.AsyncSSLResourceWithRawResponse: + from .resources.ssl import AsyncSSLResourceWithRawResponse + + return AsyncSSLResourceWithRawResponse(self._client.ssl) + + @cached_property + def acm(self) -> acm.AsyncACMResourceWithRawResponse: + from .resources.acm import AsyncACMResourceWithRawResponse + + return AsyncACMResourceWithRawResponse(self._client.acm) + + @cached_property + def argo(self) -> argo.AsyncArgoResourceWithRawResponse: + from .resources.argo import AsyncArgoResourceWithRawResponse + + return AsyncArgoResourceWithRawResponse(self._client.argo) + + @cached_property + def certificate_authorities(self) -> certificate_authorities.AsyncCertificateAuthoritiesResourceWithRawResponse: + from .resources.certificate_authorities import AsyncCertificateAuthoritiesResourceWithRawResponse + + return AsyncCertificateAuthoritiesResourceWithRawResponse(self._client.certificate_authorities) + + @cached_property + def client_certificates(self) -> client_certificates.AsyncClientCertificatesResourceWithRawResponse: + from .resources.client_certificates import AsyncClientCertificatesResourceWithRawResponse + + return AsyncClientCertificatesResourceWithRawResponse(self._client.client_certificates) + + @cached_property + def custom_certificates(self) -> custom_certificates.AsyncCustomCertificatesResourceWithRawResponse: + from .resources.custom_certificates import AsyncCustomCertificatesResourceWithRawResponse + + return AsyncCustomCertificatesResourceWithRawResponse(self._client.custom_certificates) + + @cached_property + def custom_hostnames(self) -> custom_hostnames.AsyncCustomHostnamesResourceWithRawResponse: + from .resources.custom_hostnames import AsyncCustomHostnamesResourceWithRawResponse + + return AsyncCustomHostnamesResourceWithRawResponse(self._client.custom_hostnames) + + @cached_property + def custom_nameservers(self) -> custom_nameservers.AsyncCustomNameserversResourceWithRawResponse: + from .resources.custom_nameservers import AsyncCustomNameserversResourceWithRawResponse + + return AsyncCustomNameserversResourceWithRawResponse(self._client.custom_nameservers) + + @cached_property + def dns_firewall(self) -> dns_firewall.AsyncDNSFirewallResourceWithRawResponse: + from .resources.dns_firewall import AsyncDNSFirewallResourceWithRawResponse + + return AsyncDNSFirewallResourceWithRawResponse(self._client.dns_firewall) + + @cached_property + def dns(self) -> dns.AsyncDNSResourceWithRawResponse: + from .resources.dns import AsyncDNSResourceWithRawResponse + + return AsyncDNSResourceWithRawResponse(self._client.dns) + + @cached_property + def email_security(self) -> email_security.AsyncEmailSecurityResourceWithRawResponse: + from .resources.email_security import AsyncEmailSecurityResourceWithRawResponse + + return AsyncEmailSecurityResourceWithRawResponse(self._client.email_security) + + @cached_property + def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithRawResponse: + from .resources.email_routing import AsyncEmailRoutingResourceWithRawResponse + + return AsyncEmailRoutingResourceWithRawResponse(self._client.email_routing) + + @cached_property + def filters(self) -> filters.AsyncFiltersResourceWithRawResponse: + from .resources.filters import AsyncFiltersResourceWithRawResponse + + return AsyncFiltersResourceWithRawResponse(self._client.filters) + + @cached_property + def firewall(self) -> firewall.AsyncFirewallResourceWithRawResponse: + from .resources.firewall import AsyncFirewallResourceWithRawResponse + + return AsyncFirewallResourceWithRawResponse(self._client.firewall) + + @cached_property + def healthchecks(self) -> healthchecks.AsyncHealthchecksResourceWithRawResponse: + from .resources.healthchecks import AsyncHealthchecksResourceWithRawResponse + + return AsyncHealthchecksResourceWithRawResponse(self._client.healthchecks) + + @cached_property + def keyless_certificates(self) -> keyless_certificates.AsyncKeylessCertificatesResourceWithRawResponse: + from .resources.keyless_certificates import AsyncKeylessCertificatesResourceWithRawResponse + + return AsyncKeylessCertificatesResourceWithRawResponse(self._client.keyless_certificates) + + @cached_property + def logpush(self) -> logpush.AsyncLogpushResourceWithRawResponse: + from .resources.logpush import AsyncLogpushResourceWithRawResponse + + return AsyncLogpushResourceWithRawResponse(self._client.logpush) + + @cached_property + def logs(self) -> logs.AsyncLogsResourceWithRawResponse: + from .resources.logs import AsyncLogsResourceWithRawResponse + + return AsyncLogsResourceWithRawResponse(self._client.logs) + + @cached_property + def origin_tls_client_auth(self) -> origin_tls_client_auth.AsyncOriginTLSClientAuthResourceWithRawResponse: + from .resources.origin_tls_client_auth import AsyncOriginTLSClientAuthResourceWithRawResponse + + return AsyncOriginTLSClientAuthResourceWithRawResponse(self._client.origin_tls_client_auth) + + @cached_property + def page_rules(self) -> page_rules.AsyncPageRulesResourceWithRawResponse: + from .resources.page_rules import AsyncPageRulesResourceWithRawResponse + + return AsyncPageRulesResourceWithRawResponse(self._client.page_rules) + + @cached_property + def rate_limits(self) -> rate_limits.AsyncRateLimitsResourceWithRawResponse: + from .resources.rate_limits import AsyncRateLimitsResourceWithRawResponse + + return AsyncRateLimitsResourceWithRawResponse(self._client.rate_limits) + + @cached_property + def waiting_rooms(self) -> waiting_rooms.AsyncWaitingRoomsResourceWithRawResponse: + from .resources.waiting_rooms import AsyncWaitingRoomsResourceWithRawResponse + + return AsyncWaitingRoomsResourceWithRawResponse(self._client.waiting_rooms) + + @cached_property + def web3(self) -> web3.AsyncWeb3ResourceWithRawResponse: + from .resources.web3 import AsyncWeb3ResourceWithRawResponse + + return AsyncWeb3ResourceWithRawResponse(self._client.web3) + + @cached_property + def workers(self) -> workers.AsyncWorkersResourceWithRawResponse: + from .resources.workers import AsyncWorkersResourceWithRawResponse + + return AsyncWorkersResourceWithRawResponse(self._client.workers) + + @cached_property + def kv(self) -> kv.AsyncKVResourceWithRawResponse: + from .resources.kv import AsyncKVResourceWithRawResponse + + return AsyncKVResourceWithRawResponse(self._client.kv) + + @cached_property + def durable_objects(self) -> durable_objects.AsyncDurableObjectsResourceWithRawResponse: + from .resources.durable_objects import AsyncDurableObjectsResourceWithRawResponse + + return AsyncDurableObjectsResourceWithRawResponse(self._client.durable_objects) + + @cached_property + def queues(self) -> queues.AsyncQueuesResourceWithRawResponse: + from .resources.queues import AsyncQueuesResourceWithRawResponse + + return AsyncQueuesResourceWithRawResponse(self._client.queues) + + @cached_property + def api_gateway(self) -> api_gateway.AsyncAPIGatewayResourceWithRawResponse: + from .resources.api_gateway import AsyncAPIGatewayResourceWithRawResponse + + return AsyncAPIGatewayResourceWithRawResponse(self._client.api_gateway) + + @cached_property + def managed_transforms(self) -> managed_transforms.AsyncManagedTransformsResourceWithRawResponse: + from .resources.managed_transforms import AsyncManagedTransformsResourceWithRawResponse + + return AsyncManagedTransformsResourceWithRawResponse(self._client.managed_transforms) + + @cached_property + def page_shield(self) -> page_shield.AsyncPageShieldResourceWithRawResponse: + from .resources.page_shield import AsyncPageShieldResourceWithRawResponse + + return AsyncPageShieldResourceWithRawResponse(self._client.page_shield) + + @cached_property + def rulesets(self) -> rulesets.AsyncRulesetsResourceWithRawResponse: + from .resources.rulesets import AsyncRulesetsResourceWithRawResponse + + return AsyncRulesetsResourceWithRawResponse(self._client.rulesets) + + @cached_property + def url_normalization(self) -> url_normalization.AsyncURLNormalizationResourceWithRawResponse: + from .resources.url_normalization import AsyncURLNormalizationResourceWithRawResponse + + return AsyncURLNormalizationResourceWithRawResponse(self._client.url_normalization) + + @cached_property + def spectrum(self) -> spectrum.AsyncSpectrumResourceWithRawResponse: + from .resources.spectrum import AsyncSpectrumResourceWithRawResponse + + return AsyncSpectrumResourceWithRawResponse(self._client.spectrum) + + @cached_property + def addressing(self) -> addressing.AsyncAddressingResourceWithRawResponse: + from .resources.addressing import AsyncAddressingResourceWithRawResponse + + return AsyncAddressingResourceWithRawResponse(self._client.addressing) + + @cached_property + def audit_logs(self) -> audit_logs.AsyncAuditLogsResourceWithRawResponse: + from .resources.audit_logs import AsyncAuditLogsResourceWithRawResponse + + return AsyncAuditLogsResourceWithRawResponse(self._client.audit_logs) + + @cached_property + def billing(self) -> billing.AsyncBillingResourceWithRawResponse: + from .resources.billing import AsyncBillingResourceWithRawResponse + + return AsyncBillingResourceWithRawResponse(self._client.billing) + + @cached_property + def brand_protection(self) -> brand_protection.AsyncBrandProtectionResourceWithRawResponse: + from .resources.brand_protection import AsyncBrandProtectionResourceWithRawResponse + + return AsyncBrandProtectionResourceWithRawResponse(self._client.brand_protection) + + @cached_property + def diagnostics(self) -> diagnostics.AsyncDiagnosticsResourceWithRawResponse: + from .resources.diagnostics import AsyncDiagnosticsResourceWithRawResponse + + return AsyncDiagnosticsResourceWithRawResponse(self._client.diagnostics) + + @cached_property + def images(self) -> images.AsyncImagesResourceWithRawResponse: + from .resources.images import AsyncImagesResourceWithRawResponse + + return AsyncImagesResourceWithRawResponse(self._client.images) + + @cached_property + def intel(self) -> intel.AsyncIntelResourceWithRawResponse: + from .resources.intel import AsyncIntelResourceWithRawResponse + + return AsyncIntelResourceWithRawResponse(self._client.intel) + + @cached_property + def magic_transit(self) -> magic_transit.AsyncMagicTransitResourceWithRawResponse: + from .resources.magic_transit import AsyncMagicTransitResourceWithRawResponse + + return AsyncMagicTransitResourceWithRawResponse(self._client.magic_transit) + + @cached_property + def magic_network_monitoring(self) -> magic_network_monitoring.AsyncMagicNetworkMonitoringResourceWithRawResponse: + from .resources.magic_network_monitoring import AsyncMagicNetworkMonitoringResourceWithRawResponse + + return AsyncMagicNetworkMonitoringResourceWithRawResponse(self._client.magic_network_monitoring) + + @cached_property + def magic_cloud_networking(self) -> magic_cloud_networking.AsyncMagicCloudNetworkingResourceWithRawResponse: + from .resources.magic_cloud_networking import AsyncMagicCloudNetworkingResourceWithRawResponse + + return AsyncMagicCloudNetworkingResourceWithRawResponse(self._client.magic_cloud_networking) + + @cached_property + def network_interconnects(self) -> network_interconnects.AsyncNetworkInterconnectsResourceWithRawResponse: + from .resources.network_interconnects import AsyncNetworkInterconnectsResourceWithRawResponse + + return AsyncNetworkInterconnectsResourceWithRawResponse(self._client.network_interconnects) + + @cached_property + def mtls_certificates(self) -> mtls_certificates.AsyncMTLSCertificatesResourceWithRawResponse: + from .resources.mtls_certificates import AsyncMTLSCertificatesResourceWithRawResponse + + return AsyncMTLSCertificatesResourceWithRawResponse(self._client.mtls_certificates) + + @cached_property + def pages(self) -> pages.AsyncPagesResourceWithRawResponse: + from .resources.pages import AsyncPagesResourceWithRawResponse + + return AsyncPagesResourceWithRawResponse(self._client.pages) + + @cached_property + def registrar(self) -> registrar.AsyncRegistrarResourceWithRawResponse: + from .resources.registrar import AsyncRegistrarResourceWithRawResponse + + return AsyncRegistrarResourceWithRawResponse(self._client.registrar) + + @cached_property + def request_tracers(self) -> request_tracers.AsyncRequestTracersResourceWithRawResponse: + from .resources.request_tracers import AsyncRequestTracersResourceWithRawResponse + + return AsyncRequestTracersResourceWithRawResponse(self._client.request_tracers) + + @cached_property + def rules(self) -> rules.AsyncRulesResourceWithRawResponse: + from .resources.rules import AsyncRulesResourceWithRawResponse + + return AsyncRulesResourceWithRawResponse(self._client.rules) + + @cached_property + def stream(self) -> stream.AsyncStreamResourceWithRawResponse: + from .resources.stream import AsyncStreamResourceWithRawResponse + + return AsyncStreamResourceWithRawResponse(self._client.stream) + + @cached_property + def alerting(self) -> alerting.AsyncAlertingResourceWithRawResponse: + from .resources.alerting import AsyncAlertingResourceWithRawResponse + + return AsyncAlertingResourceWithRawResponse(self._client.alerting) + + @cached_property + def d1(self) -> d1.AsyncD1ResourceWithRawResponse: + from .resources.d1 import AsyncD1ResourceWithRawResponse + + return AsyncD1ResourceWithRawResponse(self._client.d1) + + @cached_property + def r2(self) -> r2.AsyncR2ResourceWithRawResponse: + from .resources.r2 import AsyncR2ResourceWithRawResponse + + return AsyncR2ResourceWithRawResponse(self._client.r2) + + @cached_property + def r2_data_catalog(self) -> r2_data_catalog.AsyncR2DataCatalogResourceWithRawResponse: + from .resources.r2_data_catalog import AsyncR2DataCatalogResourceWithRawResponse + + return AsyncR2DataCatalogResourceWithRawResponse(self._client.r2_data_catalog) + + @cached_property + def workers_for_platforms(self) -> workers_for_platforms.AsyncWorkersForPlatformsResourceWithRawResponse: + from .resources.workers_for_platforms import AsyncWorkersForPlatformsResourceWithRawResponse + + return AsyncWorkersForPlatformsResourceWithRawResponse(self._client.workers_for_platforms) + + @cached_property + def zero_trust(self) -> zero_trust.AsyncZeroTrustResourceWithRawResponse: + from .resources.zero_trust import AsyncZeroTrustResourceWithRawResponse + + return AsyncZeroTrustResourceWithRawResponse(self._client.zero_trust) + + @cached_property + def turnstile(self) -> turnstile.AsyncTurnstileResourceWithRawResponse: + from .resources.turnstile import AsyncTurnstileResourceWithRawResponse + + return AsyncTurnstileResourceWithRawResponse(self._client.turnstile) + + @cached_property + def connectivity(self) -> connectivity.AsyncConnectivityResourceWithRawResponse: + from .resources.connectivity import AsyncConnectivityResourceWithRawResponse + + return AsyncConnectivityResourceWithRawResponse(self._client.connectivity) + + @cached_property + def hyperdrive(self) -> hyperdrive.AsyncHyperdriveResourceWithRawResponse: + from .resources.hyperdrive import AsyncHyperdriveResourceWithRawResponse + + return AsyncHyperdriveResourceWithRawResponse(self._client.hyperdrive) + + @cached_property + def rum(self) -> rum.AsyncRUMResourceWithRawResponse: + from .resources.rum import AsyncRUMResourceWithRawResponse + + return AsyncRUMResourceWithRawResponse(self._client.rum) + + @cached_property + def vectorize(self) -> vectorize.AsyncVectorizeResourceWithRawResponse: + from .resources.vectorize import AsyncVectorizeResourceWithRawResponse + + return AsyncVectorizeResourceWithRawResponse(self._client.vectorize) + + @cached_property + def url_scanner(self) -> url_scanner.AsyncURLScannerResourceWithRawResponse: + from .resources.url_scanner import AsyncURLScannerResourceWithRawResponse + + return AsyncURLScannerResourceWithRawResponse(self._client.url_scanner) + + @cached_property + def radar(self) -> radar.AsyncRadarResourceWithRawResponse: + from .resources.radar import AsyncRadarResourceWithRawResponse + + return AsyncRadarResourceWithRawResponse(self._client.radar) + + @cached_property + def bot_management(self) -> bot_management.AsyncBotManagementResourceWithRawResponse: + from .resources.bot_management import AsyncBotManagementResourceWithRawResponse + + return AsyncBotManagementResourceWithRawResponse(self._client.bot_management) + + @cached_property + def fraud(self) -> fraud.AsyncFraudResourceWithRawResponse: + from .resources.fraud import AsyncFraudResourceWithRawResponse + + return AsyncFraudResourceWithRawResponse(self._client.fraud) + + @cached_property + def origin_post_quantum_encryption( + self, + ) -> origin_post_quantum_encryption.AsyncOriginPostQuantumEncryptionResourceWithRawResponse: + from .resources.origin_post_quantum_encryption import AsyncOriginPostQuantumEncryptionResourceWithRawResponse + + return AsyncOriginPostQuantumEncryptionResourceWithRawResponse(self._client.origin_post_quantum_encryption) + + @cached_property + def zaraz(self) -> zaraz.AsyncZarazResourceWithRawResponse: + from .resources.zaraz import AsyncZarazResourceWithRawResponse + + return AsyncZarazResourceWithRawResponse(self._client.zaraz) + + @cached_property + def speed(self) -> speed.AsyncSpeedResourceWithRawResponse: + from .resources.speed import AsyncSpeedResourceWithRawResponse + + return AsyncSpeedResourceWithRawResponse(self._client.speed) + + @cached_property + def dcv_delegation(self) -> dcv_delegation.AsyncDCVDelegationResourceWithRawResponse: + from .resources.dcv_delegation import AsyncDCVDelegationResourceWithRawResponse + + return AsyncDCVDelegationResourceWithRawResponse(self._client.dcv_delegation) + + @cached_property + def hostnames(self) -> hostnames.AsyncHostnamesResourceWithRawResponse: + from .resources.hostnames import AsyncHostnamesResourceWithRawResponse + + return AsyncHostnamesResourceWithRawResponse(self._client.hostnames) + + @cached_property + def snippets(self) -> snippets.AsyncSnippetsResourceWithRawResponse: + from .resources.snippets import AsyncSnippetsResourceWithRawResponse + + return AsyncSnippetsResourceWithRawResponse(self._client.snippets) + + @cached_property + def realtime_kit(self) -> realtime_kit.AsyncRealtimeKitResourceWithRawResponse: + from .resources.realtime_kit import AsyncRealtimeKitResourceWithRawResponse + + return AsyncRealtimeKitResourceWithRawResponse(self._client.realtime_kit) + + @cached_property + def calls(self) -> calls.AsyncCallsResourceWithRawResponse: + from .resources.calls import AsyncCallsResourceWithRawResponse + + return AsyncCallsResourceWithRawResponse(self._client.calls) + + @cached_property + def cloudforce_one(self) -> cloudforce_one.AsyncCloudforceOneResourceWithRawResponse: + from .resources.cloudforce_one import AsyncCloudforceOneResourceWithRawResponse + + return AsyncCloudforceOneResourceWithRawResponse(self._client.cloudforce_one) + + @cached_property + def ai_gateway(self) -> ai_gateway.AsyncAIGatewayResourceWithRawResponse: + from .resources.ai_gateway import AsyncAIGatewayResourceWithRawResponse + + return AsyncAIGatewayResourceWithRawResponse(self._client.ai_gateway) + + @cached_property + def iam(self) -> iam.AsyncIAMResourceWithRawResponse: + from .resources.iam import AsyncIAMResourceWithRawResponse + + return AsyncIAMResourceWithRawResponse(self._client.iam) + + @cached_property + def cloud_connector(self) -> cloud_connector.AsyncCloudConnectorResourceWithRawResponse: + from .resources.cloud_connector import AsyncCloudConnectorResourceWithRawResponse + + return AsyncCloudConnectorResourceWithRawResponse(self._client.cloud_connector) + + @cached_property + def botnet_feed(self) -> botnet_feed.AsyncBotnetFeedResourceWithRawResponse: + from .resources.botnet_feed import AsyncBotnetFeedResourceWithRawResponse + + return AsyncBotnetFeedResourceWithRawResponse(self._client.botnet_feed) + + @cached_property + def security_txt(self) -> security_txt.AsyncSecurityTXTResourceWithRawResponse: + from .resources.security_txt import AsyncSecurityTXTResourceWithRawResponse + + return AsyncSecurityTXTResourceWithRawResponse(self._client.security_txt) + + @cached_property + def workflows(self) -> workflows.AsyncWorkflowsResourceWithRawResponse: + from .resources.workflows import AsyncWorkflowsResourceWithRawResponse + + return AsyncWorkflowsResourceWithRawResponse(self._client.workflows) + + @cached_property + def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithRawResponse: + from .resources.resource_sharing import AsyncResourceSharingResourceWithRawResponse + + return AsyncResourceSharingResourceWithRawResponse(self._client.resource_sharing) + + @cached_property + def leaked_credential_checks(self) -> leaked_credential_checks.AsyncLeakedCredentialChecksResourceWithRawResponse: + from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResourceWithRawResponse + + return AsyncLeakedCredentialChecksResourceWithRawResponse(self._client.leaked_credential_checks) + + @cached_property + def content_scanning(self) -> content_scanning.AsyncContentScanningResourceWithRawResponse: + from .resources.content_scanning import AsyncContentScanningResourceWithRawResponse + + return AsyncContentScanningResourceWithRawResponse(self._client.content_scanning) + + @cached_property + def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithRawResponse: + from .resources.abuse_reports import AsyncAbuseReportsResourceWithRawResponse + + return AsyncAbuseReportsResourceWithRawResponse(self._client.abuse_reports) + + @cached_property + def ai(self) -> ai.AsyncAIResourceWithRawResponse: + from .resources.ai import AsyncAIResourceWithRawResponse + + return AsyncAIResourceWithRawResponse(self._client.ai) + + @cached_property + def aisearch(self) -> aisearch.AsyncAISearchResourceWithRawResponse: + from .resources.aisearch import AsyncAISearchResourceWithRawResponse + + return AsyncAISearchResourceWithRawResponse(self._client.aisearch) + + @cached_property + def security_center(self) -> security_center.AsyncSecurityCenterResourceWithRawResponse: + from .resources.security_center import AsyncSecurityCenterResourceWithRawResponse + + return AsyncSecurityCenterResourceWithRawResponse(self._client.security_center) + + @cached_property + def browser_rendering(self) -> browser_rendering.AsyncBrowserRenderingResourceWithRawResponse: + from .resources.browser_rendering import AsyncBrowserRenderingResourceWithRawResponse + + return AsyncBrowserRenderingResourceWithRawResponse(self._client.browser_rendering) + + @cached_property + def custom_pages(self) -> custom_pages.AsyncCustomPagesResourceWithRawResponse: + from .resources.custom_pages import AsyncCustomPagesResourceWithRawResponse + + return AsyncCustomPagesResourceWithRawResponse(self._client.custom_pages) + + @cached_property + def secrets_store(self) -> secrets_store.AsyncSecretsStoreResourceWithRawResponse: + from .resources.secrets_store import AsyncSecretsStoreResourceWithRawResponse + + return AsyncSecretsStoreResourceWithRawResponse(self._client.secrets_store) + + @cached_property + def pipelines(self) -> pipelines.AsyncPipelinesResourceWithRawResponse: + from .resources.pipelines import AsyncPipelinesResourceWithRawResponse + + return AsyncPipelinesResourceWithRawResponse(self._client.pipelines) + + @cached_property + def schema_validation(self) -> schema_validation.AsyncSchemaValidationResourceWithRawResponse: + from .resources.schema_validation import AsyncSchemaValidationResourceWithRawResponse + + return AsyncSchemaValidationResourceWithRawResponse(self._client.schema_validation) + + @cached_property + def token_validation(self) -> token_validation.AsyncTokenValidationResourceWithRawResponse: + from .resources.token_validation import AsyncTokenValidationResourceWithRawResponse + + return AsyncTokenValidationResourceWithRawResponse(self._client.token_validation) + + +class CloudflareWithStreamedResponse: + _client: Cloudflare + + def __init__(self, client: Cloudflare) -> None: + self._client = client + + @cached_property + def accounts(self) -> accounts.AccountsResourceWithStreamingResponse: + from .resources.accounts import AccountsResourceWithStreamingResponse + + return AccountsResourceWithStreamingResponse(self._client.accounts) + + @cached_property + def organizations(self) -> organizations.OrganizationsResourceWithStreamingResponse: + from .resources.organizations import OrganizationsResourceWithStreamingResponse + + return OrganizationsResourceWithStreamingResponse(self._client.organizations) + + @cached_property + def origin_ca_certificates(self) -> origin_ca_certificates.OriginCACertificatesResourceWithStreamingResponse: + from .resources.origin_ca_certificates import OriginCACertificatesResourceWithStreamingResponse + + return OriginCACertificatesResourceWithStreamingResponse(self._client.origin_ca_certificates) + + @cached_property + def ips(self) -> ips.IPsResourceWithStreamingResponse: + from .resources.ips import IPsResourceWithStreamingResponse + + return IPsResourceWithStreamingResponse(self._client.ips) + + @cached_property + def memberships(self) -> memberships.MembershipsResourceWithStreamingResponse: + from .resources.memberships import MembershipsResourceWithStreamingResponse + + return MembershipsResourceWithStreamingResponse(self._client.memberships) + + @cached_property + def user(self) -> user.UserResourceWithStreamingResponse: + from .resources.user import UserResourceWithStreamingResponse + + return UserResourceWithStreamingResponse(self._client.user) + + @cached_property + def zones(self) -> zones.ZonesResourceWithStreamingResponse: + from .resources.zones import ZonesResourceWithStreamingResponse + + return ZonesResourceWithStreamingResponse(self._client.zones) + + @cached_property + def load_balancers(self) -> load_balancers.LoadBalancersResourceWithStreamingResponse: + from .resources.load_balancers import LoadBalancersResourceWithStreamingResponse + + return LoadBalancersResourceWithStreamingResponse(self._client.load_balancers) + + @cached_property + def cache(self) -> cache.CacheResourceWithStreamingResponse: + from .resources.cache import CacheResourceWithStreamingResponse + + return CacheResourceWithStreamingResponse(self._client.cache) + + @cached_property + def ssl(self) -> ssl.SSLResourceWithStreamingResponse: + from .resources.ssl import SSLResourceWithStreamingResponse + + return SSLResourceWithStreamingResponse(self._client.ssl) + + @cached_property + def acm(self) -> acm.ACMResourceWithStreamingResponse: + from .resources.acm import ACMResourceWithStreamingResponse + + return ACMResourceWithStreamingResponse(self._client.acm) + + @cached_property + def argo(self) -> argo.ArgoResourceWithStreamingResponse: + from .resources.argo import ArgoResourceWithStreamingResponse + + return ArgoResourceWithStreamingResponse(self._client.argo) + + @cached_property + def certificate_authorities(self) -> certificate_authorities.CertificateAuthoritiesResourceWithStreamingResponse: + from .resources.certificate_authorities import CertificateAuthoritiesResourceWithStreamingResponse + + return CertificateAuthoritiesResourceWithStreamingResponse(self._client.certificate_authorities) + + @cached_property + def client_certificates(self) -> client_certificates.ClientCertificatesResourceWithStreamingResponse: + from .resources.client_certificates import ClientCertificatesResourceWithStreamingResponse + + return ClientCertificatesResourceWithStreamingResponse(self._client.client_certificates) + + @cached_property + def custom_certificates(self) -> custom_certificates.CustomCertificatesResourceWithStreamingResponse: + from .resources.custom_certificates import CustomCertificatesResourceWithStreamingResponse + + return CustomCertificatesResourceWithStreamingResponse(self._client.custom_certificates) + + @cached_property + def custom_hostnames(self) -> custom_hostnames.CustomHostnamesResourceWithStreamingResponse: + from .resources.custom_hostnames import CustomHostnamesResourceWithStreamingResponse + + return CustomHostnamesResourceWithStreamingResponse(self._client.custom_hostnames) + + @cached_property + def custom_nameservers(self) -> custom_nameservers.CustomNameserversResourceWithStreamingResponse: + from .resources.custom_nameservers import CustomNameserversResourceWithStreamingResponse + + return CustomNameserversResourceWithStreamingResponse(self._client.custom_nameservers) + + @cached_property + def dns_firewall(self) -> dns_firewall.DNSFirewallResourceWithStreamingResponse: + from .resources.dns_firewall import DNSFirewallResourceWithStreamingResponse + + return DNSFirewallResourceWithStreamingResponse(self._client.dns_firewall) + + @cached_property + def dns(self) -> dns.DNSResourceWithStreamingResponse: + from .resources.dns import DNSResourceWithStreamingResponse + + return DNSResourceWithStreamingResponse(self._client.dns) + + @cached_property + def email_security(self) -> email_security.EmailSecurityResourceWithStreamingResponse: + from .resources.email_security import EmailSecurityResourceWithStreamingResponse + + return EmailSecurityResourceWithStreamingResponse(self._client.email_security) + + @cached_property + def email_routing(self) -> email_routing.EmailRoutingResourceWithStreamingResponse: + from .resources.email_routing import EmailRoutingResourceWithStreamingResponse + + return EmailRoutingResourceWithStreamingResponse(self._client.email_routing) + + @cached_property + def filters(self) -> filters.FiltersResourceWithStreamingResponse: + from .resources.filters import FiltersResourceWithStreamingResponse + + return FiltersResourceWithStreamingResponse(self._client.filters) + + @cached_property + def firewall(self) -> firewall.FirewallResourceWithStreamingResponse: + from .resources.firewall import FirewallResourceWithStreamingResponse + + return FirewallResourceWithStreamingResponse(self._client.firewall) + + @cached_property + def healthchecks(self) -> healthchecks.HealthchecksResourceWithStreamingResponse: + from .resources.healthchecks import HealthchecksResourceWithStreamingResponse + + return HealthchecksResourceWithStreamingResponse(self._client.healthchecks) + + @cached_property + def keyless_certificates(self) -> keyless_certificates.KeylessCertificatesResourceWithStreamingResponse: + from .resources.keyless_certificates import KeylessCertificatesResourceWithStreamingResponse + + return KeylessCertificatesResourceWithStreamingResponse(self._client.keyless_certificates) + + @cached_property + def logpush(self) -> logpush.LogpushResourceWithStreamingResponse: + from .resources.logpush import LogpushResourceWithStreamingResponse + + return LogpushResourceWithStreamingResponse(self._client.logpush) + + @cached_property + def logs(self) -> logs.LogsResourceWithStreamingResponse: + from .resources.logs import LogsResourceWithStreamingResponse + + return LogsResourceWithStreamingResponse(self._client.logs) + + @cached_property + def origin_tls_client_auth(self) -> origin_tls_client_auth.OriginTLSClientAuthResourceWithStreamingResponse: + from .resources.origin_tls_client_auth import OriginTLSClientAuthResourceWithStreamingResponse + + return OriginTLSClientAuthResourceWithStreamingResponse(self._client.origin_tls_client_auth) + + @cached_property + def page_rules(self) -> page_rules.PageRulesResourceWithStreamingResponse: + from .resources.page_rules import PageRulesResourceWithStreamingResponse + + return PageRulesResourceWithStreamingResponse(self._client.page_rules) + + @cached_property + def rate_limits(self) -> rate_limits.RateLimitsResourceWithStreamingResponse: + from .resources.rate_limits import RateLimitsResourceWithStreamingResponse + + return RateLimitsResourceWithStreamingResponse(self._client.rate_limits) + + @cached_property + def waiting_rooms(self) -> waiting_rooms.WaitingRoomsResourceWithStreamingResponse: + from .resources.waiting_rooms import WaitingRoomsResourceWithStreamingResponse + + return WaitingRoomsResourceWithStreamingResponse(self._client.waiting_rooms) + + @cached_property + def web3(self) -> web3.Web3ResourceWithStreamingResponse: + from .resources.web3 import Web3ResourceWithStreamingResponse + + return Web3ResourceWithStreamingResponse(self._client.web3) + + @cached_property + def workers(self) -> workers.WorkersResourceWithStreamingResponse: + from .resources.workers import WorkersResourceWithStreamingResponse + + return WorkersResourceWithStreamingResponse(self._client.workers) + + @cached_property + def kv(self) -> kv.KVResourceWithStreamingResponse: + from .resources.kv import KVResourceWithStreamingResponse + + return KVResourceWithStreamingResponse(self._client.kv) + + @cached_property + def durable_objects(self) -> durable_objects.DurableObjectsResourceWithStreamingResponse: + from .resources.durable_objects import DurableObjectsResourceWithStreamingResponse + + return DurableObjectsResourceWithStreamingResponse(self._client.durable_objects) + + @cached_property + def queues(self) -> queues.QueuesResourceWithStreamingResponse: + from .resources.queues import QueuesResourceWithStreamingResponse + + return QueuesResourceWithStreamingResponse(self._client.queues) + + @cached_property + def api_gateway(self) -> api_gateway.APIGatewayResourceWithStreamingResponse: + from .resources.api_gateway import APIGatewayResourceWithStreamingResponse + + return APIGatewayResourceWithStreamingResponse(self._client.api_gateway) + + @cached_property + def managed_transforms(self) -> managed_transforms.ManagedTransformsResourceWithStreamingResponse: + from .resources.managed_transforms import ManagedTransformsResourceWithStreamingResponse + + return ManagedTransformsResourceWithStreamingResponse(self._client.managed_transforms) + + @cached_property + def page_shield(self) -> page_shield.PageShieldResourceWithStreamingResponse: + from .resources.page_shield import PageShieldResourceWithStreamingResponse + + return PageShieldResourceWithStreamingResponse(self._client.page_shield) + + @cached_property + def rulesets(self) -> rulesets.RulesetsResourceWithStreamingResponse: + from .resources.rulesets import RulesetsResourceWithStreamingResponse + + return RulesetsResourceWithStreamingResponse(self._client.rulesets) + + @cached_property + def url_normalization(self) -> url_normalization.URLNormalizationResourceWithStreamingResponse: + from .resources.url_normalization import URLNormalizationResourceWithStreamingResponse + + return URLNormalizationResourceWithStreamingResponse(self._client.url_normalization) + + @cached_property + def spectrum(self) -> spectrum.SpectrumResourceWithStreamingResponse: + from .resources.spectrum import SpectrumResourceWithStreamingResponse + + return SpectrumResourceWithStreamingResponse(self._client.spectrum) + + @cached_property + def addressing(self) -> addressing.AddressingResourceWithStreamingResponse: + from .resources.addressing import AddressingResourceWithStreamingResponse + + return AddressingResourceWithStreamingResponse(self._client.addressing) + + @cached_property + def audit_logs(self) -> audit_logs.AuditLogsResourceWithStreamingResponse: + from .resources.audit_logs import AuditLogsResourceWithStreamingResponse + + return AuditLogsResourceWithStreamingResponse(self._client.audit_logs) + + @cached_property + def billing(self) -> billing.BillingResourceWithStreamingResponse: + from .resources.billing import BillingResourceWithStreamingResponse + + return BillingResourceWithStreamingResponse(self._client.billing) + + @cached_property + def brand_protection(self) -> brand_protection.BrandProtectionResourceWithStreamingResponse: + from .resources.brand_protection import BrandProtectionResourceWithStreamingResponse + + return BrandProtectionResourceWithStreamingResponse(self._client.brand_protection) + + @cached_property + def diagnostics(self) -> diagnostics.DiagnosticsResourceWithStreamingResponse: + from .resources.diagnostics import DiagnosticsResourceWithStreamingResponse + + return DiagnosticsResourceWithStreamingResponse(self._client.diagnostics) + + @cached_property + def images(self) -> images.ImagesResourceWithStreamingResponse: + from .resources.images import ImagesResourceWithStreamingResponse + + return ImagesResourceWithStreamingResponse(self._client.images) + + @cached_property + def intel(self) -> intel.IntelResourceWithStreamingResponse: + from .resources.intel import IntelResourceWithStreamingResponse + + return IntelResourceWithStreamingResponse(self._client.intel) + + @cached_property + def magic_transit(self) -> magic_transit.MagicTransitResourceWithStreamingResponse: + from .resources.magic_transit import MagicTransitResourceWithStreamingResponse + + return MagicTransitResourceWithStreamingResponse(self._client.magic_transit) + + @cached_property + def magic_network_monitoring(self) -> magic_network_monitoring.MagicNetworkMonitoringResourceWithStreamingResponse: + from .resources.magic_network_monitoring import MagicNetworkMonitoringResourceWithStreamingResponse + + return MagicNetworkMonitoringResourceWithStreamingResponse(self._client.magic_network_monitoring) + + @cached_property + def magic_cloud_networking(self) -> magic_cloud_networking.MagicCloudNetworkingResourceWithStreamingResponse: + from .resources.magic_cloud_networking import MagicCloudNetworkingResourceWithStreamingResponse + + return MagicCloudNetworkingResourceWithStreamingResponse(self._client.magic_cloud_networking) + + @cached_property + def network_interconnects(self) -> network_interconnects.NetworkInterconnectsResourceWithStreamingResponse: + from .resources.network_interconnects import NetworkInterconnectsResourceWithStreamingResponse + + return NetworkInterconnectsResourceWithStreamingResponse(self._client.network_interconnects) + + @cached_property + def mtls_certificates(self) -> mtls_certificates.MTLSCertificatesResourceWithStreamingResponse: + from .resources.mtls_certificates import MTLSCertificatesResourceWithStreamingResponse + + return MTLSCertificatesResourceWithStreamingResponse(self._client.mtls_certificates) + + @cached_property + def pages(self) -> pages.PagesResourceWithStreamingResponse: + from .resources.pages import PagesResourceWithStreamingResponse + + return PagesResourceWithStreamingResponse(self._client.pages) + + @cached_property + def registrar(self) -> registrar.RegistrarResourceWithStreamingResponse: + from .resources.registrar import RegistrarResourceWithStreamingResponse + + return RegistrarResourceWithStreamingResponse(self._client.registrar) + + @cached_property + def request_tracers(self) -> request_tracers.RequestTracersResourceWithStreamingResponse: + from .resources.request_tracers import RequestTracersResourceWithStreamingResponse + + return RequestTracersResourceWithStreamingResponse(self._client.request_tracers) + + @cached_property + def rules(self) -> rules.RulesResourceWithStreamingResponse: + from .resources.rules import RulesResourceWithStreamingResponse + + return RulesResourceWithStreamingResponse(self._client.rules) + + @cached_property + def stream(self) -> stream.StreamResourceWithStreamingResponse: + from .resources.stream import StreamResourceWithStreamingResponse + + return StreamResourceWithStreamingResponse(self._client.stream) + + @cached_property + def alerting(self) -> alerting.AlertingResourceWithStreamingResponse: + from .resources.alerting import AlertingResourceWithStreamingResponse + + return AlertingResourceWithStreamingResponse(self._client.alerting) + + @cached_property + def d1(self) -> d1.D1ResourceWithStreamingResponse: + from .resources.d1 import D1ResourceWithStreamingResponse + + return D1ResourceWithStreamingResponse(self._client.d1) + + @cached_property + def r2(self) -> r2.R2ResourceWithStreamingResponse: + from .resources.r2 import R2ResourceWithStreamingResponse + + return R2ResourceWithStreamingResponse(self._client.r2) + + @cached_property + def r2_data_catalog(self) -> r2_data_catalog.R2DataCatalogResourceWithStreamingResponse: + from .resources.r2_data_catalog import R2DataCatalogResourceWithStreamingResponse + + return R2DataCatalogResourceWithStreamingResponse(self._client.r2_data_catalog) + + @cached_property + def workers_for_platforms(self) -> workers_for_platforms.WorkersForPlatformsResourceWithStreamingResponse: + from .resources.workers_for_platforms import WorkersForPlatformsResourceWithStreamingResponse + + return WorkersForPlatformsResourceWithStreamingResponse(self._client.workers_for_platforms) + + @cached_property + def zero_trust(self) -> zero_trust.ZeroTrustResourceWithStreamingResponse: + from .resources.zero_trust import ZeroTrustResourceWithStreamingResponse + + return ZeroTrustResourceWithStreamingResponse(self._client.zero_trust) + + @cached_property + def turnstile(self) -> turnstile.TurnstileResourceWithStreamingResponse: + from .resources.turnstile import TurnstileResourceWithStreamingResponse + + return TurnstileResourceWithStreamingResponse(self._client.turnstile) + + @cached_property + def connectivity(self) -> connectivity.ConnectivityResourceWithStreamingResponse: + from .resources.connectivity import ConnectivityResourceWithStreamingResponse + + return ConnectivityResourceWithStreamingResponse(self._client.connectivity) + + @cached_property + def hyperdrive(self) -> hyperdrive.HyperdriveResourceWithStreamingResponse: + from .resources.hyperdrive import HyperdriveResourceWithStreamingResponse + + return HyperdriveResourceWithStreamingResponse(self._client.hyperdrive) + + @cached_property + def rum(self) -> rum.RUMResourceWithStreamingResponse: + from .resources.rum import RUMResourceWithStreamingResponse + + return RUMResourceWithStreamingResponse(self._client.rum) + + @cached_property + def vectorize(self) -> vectorize.VectorizeResourceWithStreamingResponse: + from .resources.vectorize import VectorizeResourceWithStreamingResponse + + return VectorizeResourceWithStreamingResponse(self._client.vectorize) + + @cached_property + def url_scanner(self) -> url_scanner.URLScannerResourceWithStreamingResponse: + from .resources.url_scanner import URLScannerResourceWithStreamingResponse + + return URLScannerResourceWithStreamingResponse(self._client.url_scanner) + + @cached_property + def radar(self) -> radar.RadarResourceWithStreamingResponse: + from .resources.radar import RadarResourceWithStreamingResponse + + return RadarResourceWithStreamingResponse(self._client.radar) + + @cached_property + def bot_management(self) -> bot_management.BotManagementResourceWithStreamingResponse: + from .resources.bot_management import BotManagementResourceWithStreamingResponse + + return BotManagementResourceWithStreamingResponse(self._client.bot_management) + + @cached_property + def fraud(self) -> fraud.FraudResourceWithStreamingResponse: + from .resources.fraud import FraudResourceWithStreamingResponse + + return FraudResourceWithStreamingResponse(self._client.fraud) + + @cached_property + def origin_post_quantum_encryption( + self, + ) -> origin_post_quantum_encryption.OriginPostQuantumEncryptionResourceWithStreamingResponse: + from .resources.origin_post_quantum_encryption import OriginPostQuantumEncryptionResourceWithStreamingResponse + + return OriginPostQuantumEncryptionResourceWithStreamingResponse(self._client.origin_post_quantum_encryption) + + @cached_property + def zaraz(self) -> zaraz.ZarazResourceWithStreamingResponse: + from .resources.zaraz import ZarazResourceWithStreamingResponse + + return ZarazResourceWithStreamingResponse(self._client.zaraz) + + @cached_property + def speed(self) -> speed.SpeedResourceWithStreamingResponse: + from .resources.speed import SpeedResourceWithStreamingResponse + + return SpeedResourceWithStreamingResponse(self._client.speed) + + @cached_property + def dcv_delegation(self) -> dcv_delegation.DCVDelegationResourceWithStreamingResponse: + from .resources.dcv_delegation import DCVDelegationResourceWithStreamingResponse + + return DCVDelegationResourceWithStreamingResponse(self._client.dcv_delegation) + + @cached_property + def hostnames(self) -> hostnames.HostnamesResourceWithStreamingResponse: + from .resources.hostnames import HostnamesResourceWithStreamingResponse + + return HostnamesResourceWithStreamingResponse(self._client.hostnames) + + @cached_property + def snippets(self) -> snippets.SnippetsResourceWithStreamingResponse: + from .resources.snippets import SnippetsResourceWithStreamingResponse + + return SnippetsResourceWithStreamingResponse(self._client.snippets) + + @cached_property + def realtime_kit(self) -> realtime_kit.RealtimeKitResourceWithStreamingResponse: + from .resources.realtime_kit import RealtimeKitResourceWithStreamingResponse + + return RealtimeKitResourceWithStreamingResponse(self._client.realtime_kit) + + @cached_property + def calls(self) -> calls.CallsResourceWithStreamingResponse: + from .resources.calls import CallsResourceWithStreamingResponse + + return CallsResourceWithStreamingResponse(self._client.calls) + + @cached_property + def cloudforce_one(self) -> cloudforce_one.CloudforceOneResourceWithStreamingResponse: + from .resources.cloudforce_one import CloudforceOneResourceWithStreamingResponse + + return CloudforceOneResourceWithStreamingResponse(self._client.cloudforce_one) + + @cached_property + def ai_gateway(self) -> ai_gateway.AIGatewayResourceWithStreamingResponse: + from .resources.ai_gateway import AIGatewayResourceWithStreamingResponse + + return AIGatewayResourceWithStreamingResponse(self._client.ai_gateway) + + @cached_property + def iam(self) -> iam.IAMResourceWithStreamingResponse: + from .resources.iam import IAMResourceWithStreamingResponse + + return IAMResourceWithStreamingResponse(self._client.iam) + + @cached_property + def cloud_connector(self) -> cloud_connector.CloudConnectorResourceWithStreamingResponse: + from .resources.cloud_connector import CloudConnectorResourceWithStreamingResponse + + return CloudConnectorResourceWithStreamingResponse(self._client.cloud_connector) + + @cached_property + def botnet_feed(self) -> botnet_feed.BotnetFeedResourceWithStreamingResponse: + from .resources.botnet_feed import BotnetFeedResourceWithStreamingResponse + return BotnetFeedResourceWithStreamingResponse(self._client.botnet_feed) -class CloudflareWithStreamedResponse: - def __init__(self, client: Cloudflare) -> None: - self.accounts = resources.AccountsResourceWithStreamingResponse(client.accounts) - self.origin_ca_certificates = resources.OriginCACertificatesResourceWithStreamingResponse( - client.origin_ca_certificates - ) - self.ips = resources.IPsResourceWithStreamingResponse(client.ips) - self.memberships = resources.MembershipsResourceWithStreamingResponse(client.memberships) - self.user = resources.UserResourceWithStreamingResponse(client.user) - self.zones = resources.ZonesResourceWithStreamingResponse(client.zones) - self.load_balancers = resources.LoadBalancersResourceWithStreamingResponse(client.load_balancers) - self.cache = resources.CacheResourceWithStreamingResponse(client.cache) - self.ssl = resources.SSLResourceWithStreamingResponse(client.ssl) - self.subscriptions = resources.SubscriptionsResourceWithStreamingResponse(client.subscriptions) - self.acm = resources.ACMResourceWithStreamingResponse(client.acm) - self.argo = resources.ArgoResourceWithStreamingResponse(client.argo) - self.plans = resources.PlansResourceWithStreamingResponse(client.plans) - self.rate_plans = resources.RatePlansResourceWithStreamingResponse(client.rate_plans) - self.certificate_authorities = resources.CertificateAuthoritiesResourceWithStreamingResponse( - client.certificate_authorities - ) - self.client_certificates = resources.ClientCertificatesResourceWithStreamingResponse(client.client_certificates) - self.custom_certificates = resources.CustomCertificatesResourceWithStreamingResponse(client.custom_certificates) - self.custom_hostnames = resources.CustomHostnamesResourceWithStreamingResponse(client.custom_hostnames) - self.custom_nameservers = resources.CustomNameserversResourceWithStreamingResponse(client.custom_nameservers) - self.dns = resources.DNSResourceWithStreamingResponse(client.dns) - self.dnssec = resources.DNSSECResourceWithStreamingResponse(client.dnssec) - self.email_routing = resources.EmailRoutingResourceWithStreamingResponse(client.email_routing) - self.filters = resources.FiltersResourceWithStreamingResponse(client.filters) - self.firewall = resources.FirewallResourceWithStreamingResponse(client.firewall) - self.healthchecks = resources.HealthchecksResourceWithStreamingResponse(client.healthchecks) - self.keyless_certificates = resources.KeylessCertificatesResourceWithStreamingResponse( - client.keyless_certificates - ) - self.logpush = resources.LogpushResourceWithStreamingResponse(client.logpush) - self.logs = resources.LogsResourceWithStreamingResponse(client.logs) - self.origin_tls_client_auth = resources.OriginTLSClientAuthResourceWithStreamingResponse( - client.origin_tls_client_auth - ) - self.pagerules = resources.PagerulesResourceWithStreamingResponse(client.pagerules) - self.rate_limits = resources.RateLimitsResourceWithStreamingResponse(client.rate_limits) - self.secondary_dns = resources.SecondaryDNSResourceWithStreamingResponse(client.secondary_dns) - self.waiting_rooms = resources.WaitingRoomsResourceWithStreamingResponse(client.waiting_rooms) - self.web3 = resources.Web3ResourceWithStreamingResponse(client.web3) - self.workers = resources.WorkersResourceWithStreamingResponse(client.workers) - self.kv = resources.KVResourceWithStreamingResponse(client.kv) - self.durable_objects = resources.DurableObjectsResourceWithStreamingResponse(client.durable_objects) - self.queues = resources.QueuesResourceWithStreamingResponse(client.queues) - self.api_gateway = resources.APIGatewayResourceWithStreamingResponse(client.api_gateway) - self.managed_headers = resources.ManagedHeadersResourceWithStreamingResponse(client.managed_headers) - self.page_shield = resources.PageShieldResourceWithStreamingResponse(client.page_shield) - self.rulesets = resources.RulesetsResourceWithStreamingResponse(client.rulesets) - self.url_normalization = resources.URLNormalizationResourceWithStreamingResponse(client.url_normalization) - self.spectrum = resources.SpectrumResourceWithStreamingResponse(client.spectrum) - self.addressing = resources.AddressingResourceWithStreamingResponse(client.addressing) - self.audit_logs = resources.AuditLogsResourceWithStreamingResponse(client.audit_logs) - self.billing = resources.BillingResourceWithStreamingResponse(client.billing) - self.brand_protection = resources.BrandProtectionResourceWithStreamingResponse(client.brand_protection) - self.diagnostics = resources.DiagnosticsResourceWithStreamingResponse(client.diagnostics) - self.images = resources.ImagesResourceWithStreamingResponse(client.images) - self.intel = resources.IntelResourceWithStreamingResponse(client.intel) - self.magic_transit = resources.MagicTransitResourceWithStreamingResponse(client.magic_transit) - self.magic_network_monitoring = resources.MagicNetworkMonitoringResourceWithStreamingResponse( - client.magic_network_monitoring - ) - self.mtls_certificates = resources.MTLSCertificatesResourceWithStreamingResponse(client.mtls_certificates) - self.pages = resources.PagesResourceWithStreamingResponse(client.pages) - self.pcaps = resources.PCAPsResourceWithStreamingResponse(client.pcaps) - self.registrar = resources.RegistrarResourceWithStreamingResponse(client.registrar) - self.request_tracers = resources.RequestTracersResourceWithStreamingResponse(client.request_tracers) - self.rules = resources.RulesResourceWithStreamingResponse(client.rules) - self.storage = resources.StorageResourceWithStreamingResponse(client.storage) - self.stream = resources.StreamResourceWithStreamingResponse(client.stream) - self.alerting = resources.AlertingResourceWithStreamingResponse(client.alerting) - self.d1 = resources.D1ResourceWithStreamingResponse(client.d1) - self.r2 = resources.R2ResourceWithStreamingResponse(client.r2) - self.warp_connector = resources.WARPConnectorResourceWithStreamingResponse(client.warp_connector) - self.workers_for_platforms = resources.WorkersForPlatformsResourceWithStreamingResponse( - client.workers_for_platforms - ) - self.zero_trust = resources.ZeroTrustResourceWithStreamingResponse(client.zero_trust) - self.challenges = resources.ChallengesResourceWithStreamingResponse(client.challenges) - self.hyperdrive = resources.HyperdriveResourceWithStreamingResponse(client.hyperdrive) - self.rum = resources.RUMResourceWithStreamingResponse(client.rum) - self.vectorize = resources.VectorizeResourceWithStreamingResponse(client.vectorize) - self.url_scanner = resources.URLScannerResourceWithStreamingResponse(client.url_scanner) - self.radar = resources.RadarResourceWithStreamingResponse(client.radar) - self.bot_management = resources.BotManagementResourceWithStreamingResponse(client.bot_management) - self.origin_post_quantum_encryption = resources.OriginPostQuantumEncryptionResourceWithStreamingResponse( - client.origin_post_quantum_encryption - ) - self.speed = resources.SpeedResourceWithStreamingResponse(client.speed) - self.dcv_delegation = resources.DCVDelegationResourceWithStreamingResponse(client.dcv_delegation) - self.hostnames = resources.HostnamesResourceWithStreamingResponse(client.hostnames) - self.snippets = resources.SnippetsResourceWithStreamingResponse(client.snippets) - self.calls = resources.CallsResourceWithStreamingResponse(client.calls) - self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one) - self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications) - self.ai_gateway = resources.AIGatewayResourceWithStreamingResponse(client.ai_gateway) - self.iam = resources.IAMResourceWithStreamingResponse(client.iam) - self.cloud_connector = resources.CloudConnectorResourceWithStreamingResponse(client.cloud_connector) + @cached_property + def security_txt(self) -> security_txt.SecurityTXTResourceWithStreamingResponse: + from .resources.security_txt import SecurityTXTResourceWithStreamingResponse + + return SecurityTXTResourceWithStreamingResponse(self._client.security_txt) + + @cached_property + def workflows(self) -> workflows.WorkflowsResourceWithStreamingResponse: + from .resources.workflows import WorkflowsResourceWithStreamingResponse + + return WorkflowsResourceWithStreamingResponse(self._client.workflows) + + @cached_property + def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithStreamingResponse: + from .resources.resource_sharing import ResourceSharingResourceWithStreamingResponse + + return ResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + + @cached_property + def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithStreamingResponse: + from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithStreamingResponse + + return LeakedCredentialChecksResourceWithStreamingResponse(self._client.leaked_credential_checks) + + @cached_property + def content_scanning(self) -> content_scanning.ContentScanningResourceWithStreamingResponse: + from .resources.content_scanning import ContentScanningResourceWithStreamingResponse + + return ContentScanningResourceWithStreamingResponse(self._client.content_scanning) + + @cached_property + def abuse_reports(self) -> abuse_reports.AbuseReportsResourceWithStreamingResponse: + from .resources.abuse_reports import AbuseReportsResourceWithStreamingResponse + + return AbuseReportsResourceWithStreamingResponse(self._client.abuse_reports) + + @cached_property + def ai(self) -> ai.AIResourceWithStreamingResponse: + from .resources.ai import AIResourceWithStreamingResponse + + return AIResourceWithStreamingResponse(self._client.ai) + + @cached_property + def aisearch(self) -> aisearch.AISearchResourceWithStreamingResponse: + from .resources.aisearch import AISearchResourceWithStreamingResponse + + return AISearchResourceWithStreamingResponse(self._client.aisearch) + + @cached_property + def security_center(self) -> security_center.SecurityCenterResourceWithStreamingResponse: + from .resources.security_center import SecurityCenterResourceWithStreamingResponse + + return SecurityCenterResourceWithStreamingResponse(self._client.security_center) + + @cached_property + def browser_rendering(self) -> browser_rendering.BrowserRenderingResourceWithStreamingResponse: + from .resources.browser_rendering import BrowserRenderingResourceWithStreamingResponse + + return BrowserRenderingResourceWithStreamingResponse(self._client.browser_rendering) + + @cached_property + def custom_pages(self) -> custom_pages.CustomPagesResourceWithStreamingResponse: + from .resources.custom_pages import CustomPagesResourceWithStreamingResponse + + return CustomPagesResourceWithStreamingResponse(self._client.custom_pages) + + @cached_property + def secrets_store(self) -> secrets_store.SecretsStoreResourceWithStreamingResponse: + from .resources.secrets_store import SecretsStoreResourceWithStreamingResponse + + return SecretsStoreResourceWithStreamingResponse(self._client.secrets_store) + + @cached_property + def pipelines(self) -> pipelines.PipelinesResourceWithStreamingResponse: + from .resources.pipelines import PipelinesResourceWithStreamingResponse + + return PipelinesResourceWithStreamingResponse(self._client.pipelines) + + @cached_property + def schema_validation(self) -> schema_validation.SchemaValidationResourceWithStreamingResponse: + from .resources.schema_validation import SchemaValidationResourceWithStreamingResponse + + return SchemaValidationResourceWithStreamingResponse(self._client.schema_validation) + + @cached_property + def token_validation(self) -> token_validation.TokenValidationResourceWithStreamingResponse: + from .resources.token_validation import TokenValidationResourceWithStreamingResponse + + return TokenValidationResourceWithStreamingResponse(self._client.token_validation) class AsyncCloudflareWithStreamedResponse: + _client: AsyncCloudflare + def __init__(self, client: AsyncCloudflare) -> None: - self.accounts = resources.AsyncAccountsResourceWithStreamingResponse(client.accounts) - self.origin_ca_certificates = resources.AsyncOriginCACertificatesResourceWithStreamingResponse( - client.origin_ca_certificates - ) - self.ips = resources.AsyncIPsResourceWithStreamingResponse(client.ips) - self.memberships = resources.AsyncMembershipsResourceWithStreamingResponse(client.memberships) - self.user = resources.AsyncUserResourceWithStreamingResponse(client.user) - self.zones = resources.AsyncZonesResourceWithStreamingResponse(client.zones) - self.load_balancers = resources.AsyncLoadBalancersResourceWithStreamingResponse(client.load_balancers) - self.cache = resources.AsyncCacheResourceWithStreamingResponse(client.cache) - self.ssl = resources.AsyncSSLResourceWithStreamingResponse(client.ssl) - self.subscriptions = resources.AsyncSubscriptionsResourceWithStreamingResponse(client.subscriptions) - self.acm = resources.AsyncACMResourceWithStreamingResponse(client.acm) - self.argo = resources.AsyncArgoResourceWithStreamingResponse(client.argo) - self.plans = resources.AsyncPlansResourceWithStreamingResponse(client.plans) - self.rate_plans = resources.AsyncRatePlansResourceWithStreamingResponse(client.rate_plans) - self.certificate_authorities = resources.AsyncCertificateAuthoritiesResourceWithStreamingResponse( - client.certificate_authorities - ) - self.client_certificates = resources.AsyncClientCertificatesResourceWithStreamingResponse( - client.client_certificates - ) - self.custom_certificates = resources.AsyncCustomCertificatesResourceWithStreamingResponse( - client.custom_certificates - ) - self.custom_hostnames = resources.AsyncCustomHostnamesResourceWithStreamingResponse(client.custom_hostnames) - self.custom_nameservers = resources.AsyncCustomNameserversResourceWithStreamingResponse( - client.custom_nameservers - ) - self.dns = resources.AsyncDNSResourceWithStreamingResponse(client.dns) - self.dnssec = resources.AsyncDNSSECResourceWithStreamingResponse(client.dnssec) - self.email_routing = resources.AsyncEmailRoutingResourceWithStreamingResponse(client.email_routing) - self.filters = resources.AsyncFiltersResourceWithStreamingResponse(client.filters) - self.firewall = resources.AsyncFirewallResourceWithStreamingResponse(client.firewall) - self.healthchecks = resources.AsyncHealthchecksResourceWithStreamingResponse(client.healthchecks) - self.keyless_certificates = resources.AsyncKeylessCertificatesResourceWithStreamingResponse( - client.keyless_certificates - ) - self.logpush = resources.AsyncLogpushResourceWithStreamingResponse(client.logpush) - self.logs = resources.AsyncLogsResourceWithStreamingResponse(client.logs) - self.origin_tls_client_auth = resources.AsyncOriginTLSClientAuthResourceWithStreamingResponse( - client.origin_tls_client_auth - ) - self.pagerules = resources.AsyncPagerulesResourceWithStreamingResponse(client.pagerules) - self.rate_limits = resources.AsyncRateLimitsResourceWithStreamingResponse(client.rate_limits) - self.secondary_dns = resources.AsyncSecondaryDNSResourceWithStreamingResponse(client.secondary_dns) - self.waiting_rooms = resources.AsyncWaitingRoomsResourceWithStreamingResponse(client.waiting_rooms) - self.web3 = resources.AsyncWeb3ResourceWithStreamingResponse(client.web3) - self.workers = resources.AsyncWorkersResourceWithStreamingResponse(client.workers) - self.kv = resources.AsyncKVResourceWithStreamingResponse(client.kv) - self.durable_objects = resources.AsyncDurableObjectsResourceWithStreamingResponse(client.durable_objects) - self.queues = resources.AsyncQueuesResourceWithStreamingResponse(client.queues) - self.api_gateway = resources.AsyncAPIGatewayResourceWithStreamingResponse(client.api_gateway) - self.managed_headers = resources.AsyncManagedHeadersResourceWithStreamingResponse(client.managed_headers) - self.page_shield = resources.AsyncPageShieldResourceWithStreamingResponse(client.page_shield) - self.rulesets = resources.AsyncRulesetsResourceWithStreamingResponse(client.rulesets) - self.url_normalization = resources.AsyncURLNormalizationResourceWithStreamingResponse(client.url_normalization) - self.spectrum = resources.AsyncSpectrumResourceWithStreamingResponse(client.spectrum) - self.addressing = resources.AsyncAddressingResourceWithStreamingResponse(client.addressing) - self.audit_logs = resources.AsyncAuditLogsResourceWithStreamingResponse(client.audit_logs) - self.billing = resources.AsyncBillingResourceWithStreamingResponse(client.billing) - self.brand_protection = resources.AsyncBrandProtectionResourceWithStreamingResponse(client.brand_protection) - self.diagnostics = resources.AsyncDiagnosticsResourceWithStreamingResponse(client.diagnostics) - self.images = resources.AsyncImagesResourceWithStreamingResponse(client.images) - self.intel = resources.AsyncIntelResourceWithStreamingResponse(client.intel) - self.magic_transit = resources.AsyncMagicTransitResourceWithStreamingResponse(client.magic_transit) - self.magic_network_monitoring = resources.AsyncMagicNetworkMonitoringResourceWithStreamingResponse( - client.magic_network_monitoring - ) - self.mtls_certificates = resources.AsyncMTLSCertificatesResourceWithStreamingResponse(client.mtls_certificates) - self.pages = resources.AsyncPagesResourceWithStreamingResponse(client.pages) - self.pcaps = resources.AsyncPCAPsResourceWithStreamingResponse(client.pcaps) - self.registrar = resources.AsyncRegistrarResourceWithStreamingResponse(client.registrar) - self.request_tracers = resources.AsyncRequestTracersResourceWithStreamingResponse(client.request_tracers) - self.rules = resources.AsyncRulesResourceWithStreamingResponse(client.rules) - self.storage = resources.AsyncStorageResourceWithStreamingResponse(client.storage) - self.stream = resources.AsyncStreamResourceWithStreamingResponse(client.stream) - self.alerting = resources.AsyncAlertingResourceWithStreamingResponse(client.alerting) - self.d1 = resources.AsyncD1ResourceWithStreamingResponse(client.d1) - self.r2 = resources.AsyncR2ResourceWithStreamingResponse(client.r2) - self.warp_connector = resources.AsyncWARPConnectorResourceWithStreamingResponse(client.warp_connector) - self.workers_for_platforms = resources.AsyncWorkersForPlatformsResourceWithStreamingResponse( - client.workers_for_platforms - ) - self.zero_trust = resources.AsyncZeroTrustResourceWithStreamingResponse(client.zero_trust) - self.challenges = resources.AsyncChallengesResourceWithStreamingResponse(client.challenges) - self.hyperdrive = resources.AsyncHyperdriveResourceWithStreamingResponse(client.hyperdrive) - self.rum = resources.AsyncRUMResourceWithStreamingResponse(client.rum) - self.vectorize = resources.AsyncVectorizeResourceWithStreamingResponse(client.vectorize) - self.url_scanner = resources.AsyncURLScannerResourceWithStreamingResponse(client.url_scanner) - self.radar = resources.AsyncRadarResourceWithStreamingResponse(client.radar) - self.bot_management = resources.AsyncBotManagementResourceWithStreamingResponse(client.bot_management) - self.origin_post_quantum_encryption = resources.AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse( - client.origin_post_quantum_encryption + self._client = client + + @cached_property + def accounts(self) -> accounts.AsyncAccountsResourceWithStreamingResponse: + from .resources.accounts import AsyncAccountsResourceWithStreamingResponse + + return AsyncAccountsResourceWithStreamingResponse(self._client.accounts) + + @cached_property + def organizations(self) -> organizations.AsyncOrganizationsResourceWithStreamingResponse: + from .resources.organizations import AsyncOrganizationsResourceWithStreamingResponse + + return AsyncOrganizationsResourceWithStreamingResponse(self._client.organizations) + + @cached_property + def origin_ca_certificates(self) -> origin_ca_certificates.AsyncOriginCACertificatesResourceWithStreamingResponse: + from .resources.origin_ca_certificates import AsyncOriginCACertificatesResourceWithStreamingResponse + + return AsyncOriginCACertificatesResourceWithStreamingResponse(self._client.origin_ca_certificates) + + @cached_property + def ips(self) -> ips.AsyncIPsResourceWithStreamingResponse: + from .resources.ips import AsyncIPsResourceWithStreamingResponse + + return AsyncIPsResourceWithStreamingResponse(self._client.ips) + + @cached_property + def memberships(self) -> memberships.AsyncMembershipsResourceWithStreamingResponse: + from .resources.memberships import AsyncMembershipsResourceWithStreamingResponse + + return AsyncMembershipsResourceWithStreamingResponse(self._client.memberships) + + @cached_property + def user(self) -> user.AsyncUserResourceWithStreamingResponse: + from .resources.user import AsyncUserResourceWithStreamingResponse + + return AsyncUserResourceWithStreamingResponse(self._client.user) + + @cached_property + def zones(self) -> zones.AsyncZonesResourceWithStreamingResponse: + from .resources.zones import AsyncZonesResourceWithStreamingResponse + + return AsyncZonesResourceWithStreamingResponse(self._client.zones) + + @cached_property + def load_balancers(self) -> load_balancers.AsyncLoadBalancersResourceWithStreamingResponse: + from .resources.load_balancers import AsyncLoadBalancersResourceWithStreamingResponse + + return AsyncLoadBalancersResourceWithStreamingResponse(self._client.load_balancers) + + @cached_property + def cache(self) -> cache.AsyncCacheResourceWithStreamingResponse: + from .resources.cache import AsyncCacheResourceWithStreamingResponse + + return AsyncCacheResourceWithStreamingResponse(self._client.cache) + + @cached_property + def ssl(self) -> ssl.AsyncSSLResourceWithStreamingResponse: + from .resources.ssl import AsyncSSLResourceWithStreamingResponse + + return AsyncSSLResourceWithStreamingResponse(self._client.ssl) + + @cached_property + def acm(self) -> acm.AsyncACMResourceWithStreamingResponse: + from .resources.acm import AsyncACMResourceWithStreamingResponse + + return AsyncACMResourceWithStreamingResponse(self._client.acm) + + @cached_property + def argo(self) -> argo.AsyncArgoResourceWithStreamingResponse: + from .resources.argo import AsyncArgoResourceWithStreamingResponse + + return AsyncArgoResourceWithStreamingResponse(self._client.argo) + + @cached_property + def certificate_authorities( + self, + ) -> certificate_authorities.AsyncCertificateAuthoritiesResourceWithStreamingResponse: + from .resources.certificate_authorities import AsyncCertificateAuthoritiesResourceWithStreamingResponse + + return AsyncCertificateAuthoritiesResourceWithStreamingResponse(self._client.certificate_authorities) + + @cached_property + def client_certificates(self) -> client_certificates.AsyncClientCertificatesResourceWithStreamingResponse: + from .resources.client_certificates import AsyncClientCertificatesResourceWithStreamingResponse + + return AsyncClientCertificatesResourceWithStreamingResponse(self._client.client_certificates) + + @cached_property + def custom_certificates(self) -> custom_certificates.AsyncCustomCertificatesResourceWithStreamingResponse: + from .resources.custom_certificates import AsyncCustomCertificatesResourceWithStreamingResponse + + return AsyncCustomCertificatesResourceWithStreamingResponse(self._client.custom_certificates) + + @cached_property + def custom_hostnames(self) -> custom_hostnames.AsyncCustomHostnamesResourceWithStreamingResponse: + from .resources.custom_hostnames import AsyncCustomHostnamesResourceWithStreamingResponse + + return AsyncCustomHostnamesResourceWithStreamingResponse(self._client.custom_hostnames) + + @cached_property + def custom_nameservers(self) -> custom_nameservers.AsyncCustomNameserversResourceWithStreamingResponse: + from .resources.custom_nameservers import AsyncCustomNameserversResourceWithStreamingResponse + + return AsyncCustomNameserversResourceWithStreamingResponse(self._client.custom_nameservers) + + @cached_property + def dns_firewall(self) -> dns_firewall.AsyncDNSFirewallResourceWithStreamingResponse: + from .resources.dns_firewall import AsyncDNSFirewallResourceWithStreamingResponse + + return AsyncDNSFirewallResourceWithStreamingResponse(self._client.dns_firewall) + + @cached_property + def dns(self) -> dns.AsyncDNSResourceWithStreamingResponse: + from .resources.dns import AsyncDNSResourceWithStreamingResponse + + return AsyncDNSResourceWithStreamingResponse(self._client.dns) + + @cached_property + def email_security(self) -> email_security.AsyncEmailSecurityResourceWithStreamingResponse: + from .resources.email_security import AsyncEmailSecurityResourceWithStreamingResponse + + return AsyncEmailSecurityResourceWithStreamingResponse(self._client.email_security) + + @cached_property + def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithStreamingResponse: + from .resources.email_routing import AsyncEmailRoutingResourceWithStreamingResponse + + return AsyncEmailRoutingResourceWithStreamingResponse(self._client.email_routing) + + @cached_property + def filters(self) -> filters.AsyncFiltersResourceWithStreamingResponse: + from .resources.filters import AsyncFiltersResourceWithStreamingResponse + + return AsyncFiltersResourceWithStreamingResponse(self._client.filters) + + @cached_property + def firewall(self) -> firewall.AsyncFirewallResourceWithStreamingResponse: + from .resources.firewall import AsyncFirewallResourceWithStreamingResponse + + return AsyncFirewallResourceWithStreamingResponse(self._client.firewall) + + @cached_property + def healthchecks(self) -> healthchecks.AsyncHealthchecksResourceWithStreamingResponse: + from .resources.healthchecks import AsyncHealthchecksResourceWithStreamingResponse + + return AsyncHealthchecksResourceWithStreamingResponse(self._client.healthchecks) + + @cached_property + def keyless_certificates(self) -> keyless_certificates.AsyncKeylessCertificatesResourceWithStreamingResponse: + from .resources.keyless_certificates import AsyncKeylessCertificatesResourceWithStreamingResponse + + return AsyncKeylessCertificatesResourceWithStreamingResponse(self._client.keyless_certificates) + + @cached_property + def logpush(self) -> logpush.AsyncLogpushResourceWithStreamingResponse: + from .resources.logpush import AsyncLogpushResourceWithStreamingResponse + + return AsyncLogpushResourceWithStreamingResponse(self._client.logpush) + + @cached_property + def logs(self) -> logs.AsyncLogsResourceWithStreamingResponse: + from .resources.logs import AsyncLogsResourceWithStreamingResponse + + return AsyncLogsResourceWithStreamingResponse(self._client.logs) + + @cached_property + def origin_tls_client_auth(self) -> origin_tls_client_auth.AsyncOriginTLSClientAuthResourceWithStreamingResponse: + from .resources.origin_tls_client_auth import AsyncOriginTLSClientAuthResourceWithStreamingResponse + + return AsyncOriginTLSClientAuthResourceWithStreamingResponse(self._client.origin_tls_client_auth) + + @cached_property + def page_rules(self) -> page_rules.AsyncPageRulesResourceWithStreamingResponse: + from .resources.page_rules import AsyncPageRulesResourceWithStreamingResponse + + return AsyncPageRulesResourceWithStreamingResponse(self._client.page_rules) + + @cached_property + def rate_limits(self) -> rate_limits.AsyncRateLimitsResourceWithStreamingResponse: + from .resources.rate_limits import AsyncRateLimitsResourceWithStreamingResponse + + return AsyncRateLimitsResourceWithStreamingResponse(self._client.rate_limits) + + @cached_property + def waiting_rooms(self) -> waiting_rooms.AsyncWaitingRoomsResourceWithStreamingResponse: + from .resources.waiting_rooms import AsyncWaitingRoomsResourceWithStreamingResponse + + return AsyncWaitingRoomsResourceWithStreamingResponse(self._client.waiting_rooms) + + @cached_property + def web3(self) -> web3.AsyncWeb3ResourceWithStreamingResponse: + from .resources.web3 import AsyncWeb3ResourceWithStreamingResponse + + return AsyncWeb3ResourceWithStreamingResponse(self._client.web3) + + @cached_property + def workers(self) -> workers.AsyncWorkersResourceWithStreamingResponse: + from .resources.workers import AsyncWorkersResourceWithStreamingResponse + + return AsyncWorkersResourceWithStreamingResponse(self._client.workers) + + @cached_property + def kv(self) -> kv.AsyncKVResourceWithStreamingResponse: + from .resources.kv import AsyncKVResourceWithStreamingResponse + + return AsyncKVResourceWithStreamingResponse(self._client.kv) + + @cached_property + def durable_objects(self) -> durable_objects.AsyncDurableObjectsResourceWithStreamingResponse: + from .resources.durable_objects import AsyncDurableObjectsResourceWithStreamingResponse + + return AsyncDurableObjectsResourceWithStreamingResponse(self._client.durable_objects) + + @cached_property + def queues(self) -> queues.AsyncQueuesResourceWithStreamingResponse: + from .resources.queues import AsyncQueuesResourceWithStreamingResponse + + return AsyncQueuesResourceWithStreamingResponse(self._client.queues) + + @cached_property + def api_gateway(self) -> api_gateway.AsyncAPIGatewayResourceWithStreamingResponse: + from .resources.api_gateway import AsyncAPIGatewayResourceWithStreamingResponse + + return AsyncAPIGatewayResourceWithStreamingResponse(self._client.api_gateway) + + @cached_property + def managed_transforms(self) -> managed_transforms.AsyncManagedTransformsResourceWithStreamingResponse: + from .resources.managed_transforms import AsyncManagedTransformsResourceWithStreamingResponse + + return AsyncManagedTransformsResourceWithStreamingResponse(self._client.managed_transforms) + + @cached_property + def page_shield(self) -> page_shield.AsyncPageShieldResourceWithStreamingResponse: + from .resources.page_shield import AsyncPageShieldResourceWithStreamingResponse + + return AsyncPageShieldResourceWithStreamingResponse(self._client.page_shield) + + @cached_property + def rulesets(self) -> rulesets.AsyncRulesetsResourceWithStreamingResponse: + from .resources.rulesets import AsyncRulesetsResourceWithStreamingResponse + + return AsyncRulesetsResourceWithStreamingResponse(self._client.rulesets) + + @cached_property + def url_normalization(self) -> url_normalization.AsyncURLNormalizationResourceWithStreamingResponse: + from .resources.url_normalization import AsyncURLNormalizationResourceWithStreamingResponse + + return AsyncURLNormalizationResourceWithStreamingResponse(self._client.url_normalization) + + @cached_property + def spectrum(self) -> spectrum.AsyncSpectrumResourceWithStreamingResponse: + from .resources.spectrum import AsyncSpectrumResourceWithStreamingResponse + + return AsyncSpectrumResourceWithStreamingResponse(self._client.spectrum) + + @cached_property + def addressing(self) -> addressing.AsyncAddressingResourceWithStreamingResponse: + from .resources.addressing import AsyncAddressingResourceWithStreamingResponse + + return AsyncAddressingResourceWithStreamingResponse(self._client.addressing) + + @cached_property + def audit_logs(self) -> audit_logs.AsyncAuditLogsResourceWithStreamingResponse: + from .resources.audit_logs import AsyncAuditLogsResourceWithStreamingResponse + + return AsyncAuditLogsResourceWithStreamingResponse(self._client.audit_logs) + + @cached_property + def billing(self) -> billing.AsyncBillingResourceWithStreamingResponse: + from .resources.billing import AsyncBillingResourceWithStreamingResponse + + return AsyncBillingResourceWithStreamingResponse(self._client.billing) + + @cached_property + def brand_protection(self) -> brand_protection.AsyncBrandProtectionResourceWithStreamingResponse: + from .resources.brand_protection import AsyncBrandProtectionResourceWithStreamingResponse + + return AsyncBrandProtectionResourceWithStreamingResponse(self._client.brand_protection) + + @cached_property + def diagnostics(self) -> diagnostics.AsyncDiagnosticsResourceWithStreamingResponse: + from .resources.diagnostics import AsyncDiagnosticsResourceWithStreamingResponse + + return AsyncDiagnosticsResourceWithStreamingResponse(self._client.diagnostics) + + @cached_property + def images(self) -> images.AsyncImagesResourceWithStreamingResponse: + from .resources.images import AsyncImagesResourceWithStreamingResponse + + return AsyncImagesResourceWithStreamingResponse(self._client.images) + + @cached_property + def intel(self) -> intel.AsyncIntelResourceWithStreamingResponse: + from .resources.intel import AsyncIntelResourceWithStreamingResponse + + return AsyncIntelResourceWithStreamingResponse(self._client.intel) + + @cached_property + def magic_transit(self) -> magic_transit.AsyncMagicTransitResourceWithStreamingResponse: + from .resources.magic_transit import AsyncMagicTransitResourceWithStreamingResponse + + return AsyncMagicTransitResourceWithStreamingResponse(self._client.magic_transit) + + @cached_property + def magic_network_monitoring( + self, + ) -> magic_network_monitoring.AsyncMagicNetworkMonitoringResourceWithStreamingResponse: + from .resources.magic_network_monitoring import AsyncMagicNetworkMonitoringResourceWithStreamingResponse + + return AsyncMagicNetworkMonitoringResourceWithStreamingResponse(self._client.magic_network_monitoring) + + @cached_property + def magic_cloud_networking(self) -> magic_cloud_networking.AsyncMagicCloudNetworkingResourceWithStreamingResponse: + from .resources.magic_cloud_networking import AsyncMagicCloudNetworkingResourceWithStreamingResponse + + return AsyncMagicCloudNetworkingResourceWithStreamingResponse(self._client.magic_cloud_networking) + + @cached_property + def network_interconnects(self) -> network_interconnects.AsyncNetworkInterconnectsResourceWithStreamingResponse: + from .resources.network_interconnects import AsyncNetworkInterconnectsResourceWithStreamingResponse + + return AsyncNetworkInterconnectsResourceWithStreamingResponse(self._client.network_interconnects) + + @cached_property + def mtls_certificates(self) -> mtls_certificates.AsyncMTLSCertificatesResourceWithStreamingResponse: + from .resources.mtls_certificates import AsyncMTLSCertificatesResourceWithStreamingResponse + + return AsyncMTLSCertificatesResourceWithStreamingResponse(self._client.mtls_certificates) + + @cached_property + def pages(self) -> pages.AsyncPagesResourceWithStreamingResponse: + from .resources.pages import AsyncPagesResourceWithStreamingResponse + + return AsyncPagesResourceWithStreamingResponse(self._client.pages) + + @cached_property + def registrar(self) -> registrar.AsyncRegistrarResourceWithStreamingResponse: + from .resources.registrar import AsyncRegistrarResourceWithStreamingResponse + + return AsyncRegistrarResourceWithStreamingResponse(self._client.registrar) + + @cached_property + def request_tracers(self) -> request_tracers.AsyncRequestTracersResourceWithStreamingResponse: + from .resources.request_tracers import AsyncRequestTracersResourceWithStreamingResponse + + return AsyncRequestTracersResourceWithStreamingResponse(self._client.request_tracers) + + @cached_property + def rules(self) -> rules.AsyncRulesResourceWithStreamingResponse: + from .resources.rules import AsyncRulesResourceWithStreamingResponse + + return AsyncRulesResourceWithStreamingResponse(self._client.rules) + + @cached_property + def stream(self) -> stream.AsyncStreamResourceWithStreamingResponse: + from .resources.stream import AsyncStreamResourceWithStreamingResponse + + return AsyncStreamResourceWithStreamingResponse(self._client.stream) + + @cached_property + def alerting(self) -> alerting.AsyncAlertingResourceWithStreamingResponse: + from .resources.alerting import AsyncAlertingResourceWithStreamingResponse + + return AsyncAlertingResourceWithStreamingResponse(self._client.alerting) + + @cached_property + def d1(self) -> d1.AsyncD1ResourceWithStreamingResponse: + from .resources.d1 import AsyncD1ResourceWithStreamingResponse + + return AsyncD1ResourceWithStreamingResponse(self._client.d1) + + @cached_property + def r2(self) -> r2.AsyncR2ResourceWithStreamingResponse: + from .resources.r2 import AsyncR2ResourceWithStreamingResponse + + return AsyncR2ResourceWithStreamingResponse(self._client.r2) + + @cached_property + def r2_data_catalog(self) -> r2_data_catalog.AsyncR2DataCatalogResourceWithStreamingResponse: + from .resources.r2_data_catalog import AsyncR2DataCatalogResourceWithStreamingResponse + + return AsyncR2DataCatalogResourceWithStreamingResponse(self._client.r2_data_catalog) + + @cached_property + def workers_for_platforms(self) -> workers_for_platforms.AsyncWorkersForPlatformsResourceWithStreamingResponse: + from .resources.workers_for_platforms import AsyncWorkersForPlatformsResourceWithStreamingResponse + + return AsyncWorkersForPlatformsResourceWithStreamingResponse(self._client.workers_for_platforms) + + @cached_property + def zero_trust(self) -> zero_trust.AsyncZeroTrustResourceWithStreamingResponse: + from .resources.zero_trust import AsyncZeroTrustResourceWithStreamingResponse + + return AsyncZeroTrustResourceWithStreamingResponse(self._client.zero_trust) + + @cached_property + def turnstile(self) -> turnstile.AsyncTurnstileResourceWithStreamingResponse: + from .resources.turnstile import AsyncTurnstileResourceWithStreamingResponse + + return AsyncTurnstileResourceWithStreamingResponse(self._client.turnstile) + + @cached_property + def connectivity(self) -> connectivity.AsyncConnectivityResourceWithStreamingResponse: + from .resources.connectivity import AsyncConnectivityResourceWithStreamingResponse + + return AsyncConnectivityResourceWithStreamingResponse(self._client.connectivity) + + @cached_property + def hyperdrive(self) -> hyperdrive.AsyncHyperdriveResourceWithStreamingResponse: + from .resources.hyperdrive import AsyncHyperdriveResourceWithStreamingResponse + + return AsyncHyperdriveResourceWithStreamingResponse(self._client.hyperdrive) + + @cached_property + def rum(self) -> rum.AsyncRUMResourceWithStreamingResponse: + from .resources.rum import AsyncRUMResourceWithStreamingResponse + + return AsyncRUMResourceWithStreamingResponse(self._client.rum) + + @cached_property + def vectorize(self) -> vectorize.AsyncVectorizeResourceWithStreamingResponse: + from .resources.vectorize import AsyncVectorizeResourceWithStreamingResponse + + return AsyncVectorizeResourceWithStreamingResponse(self._client.vectorize) + + @cached_property + def url_scanner(self) -> url_scanner.AsyncURLScannerResourceWithStreamingResponse: + from .resources.url_scanner import AsyncURLScannerResourceWithStreamingResponse + + return AsyncURLScannerResourceWithStreamingResponse(self._client.url_scanner) + + @cached_property + def radar(self) -> radar.AsyncRadarResourceWithStreamingResponse: + from .resources.radar import AsyncRadarResourceWithStreamingResponse + + return AsyncRadarResourceWithStreamingResponse(self._client.radar) + + @cached_property + def bot_management(self) -> bot_management.AsyncBotManagementResourceWithStreamingResponse: + from .resources.bot_management import AsyncBotManagementResourceWithStreamingResponse + + return AsyncBotManagementResourceWithStreamingResponse(self._client.bot_management) + + @cached_property + def fraud(self) -> fraud.AsyncFraudResourceWithStreamingResponse: + from .resources.fraud import AsyncFraudResourceWithStreamingResponse + + return AsyncFraudResourceWithStreamingResponse(self._client.fraud) + + @cached_property + def origin_post_quantum_encryption( + self, + ) -> origin_post_quantum_encryption.AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse: + from .resources.origin_post_quantum_encryption import ( + AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse, ) - self.speed = resources.AsyncSpeedResourceWithStreamingResponse(client.speed) - self.dcv_delegation = resources.AsyncDCVDelegationResourceWithStreamingResponse(client.dcv_delegation) - self.hostnames = resources.AsyncHostnamesResourceWithStreamingResponse(client.hostnames) - self.snippets = resources.AsyncSnippetsResourceWithStreamingResponse(client.snippets) - self.calls = resources.AsyncCallsResourceWithStreamingResponse(client.calls) - self.cloudforce_one = resources.AsyncCloudforceOneResourceWithStreamingResponse(client.cloudforce_one) - self.event_notifications = resources.AsyncEventNotificationsResourceWithStreamingResponse( - client.event_notifications + + return AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse( + self._client.origin_post_quantum_encryption ) - self.ai_gateway = resources.AsyncAIGatewayResourceWithStreamingResponse(client.ai_gateway) - self.iam = resources.AsyncIAMResourceWithStreamingResponse(client.iam) - self.cloud_connector = resources.AsyncCloudConnectorResourceWithStreamingResponse(client.cloud_connector) + + @cached_property + def zaraz(self) -> zaraz.AsyncZarazResourceWithStreamingResponse: + from .resources.zaraz import AsyncZarazResourceWithStreamingResponse + + return AsyncZarazResourceWithStreamingResponse(self._client.zaraz) + + @cached_property + def speed(self) -> speed.AsyncSpeedResourceWithStreamingResponse: + from .resources.speed import AsyncSpeedResourceWithStreamingResponse + + return AsyncSpeedResourceWithStreamingResponse(self._client.speed) + + @cached_property + def dcv_delegation(self) -> dcv_delegation.AsyncDCVDelegationResourceWithStreamingResponse: + from .resources.dcv_delegation import AsyncDCVDelegationResourceWithStreamingResponse + + return AsyncDCVDelegationResourceWithStreamingResponse(self._client.dcv_delegation) + + @cached_property + def hostnames(self) -> hostnames.AsyncHostnamesResourceWithStreamingResponse: + from .resources.hostnames import AsyncHostnamesResourceWithStreamingResponse + + return AsyncHostnamesResourceWithStreamingResponse(self._client.hostnames) + + @cached_property + def snippets(self) -> snippets.AsyncSnippetsResourceWithStreamingResponse: + from .resources.snippets import AsyncSnippetsResourceWithStreamingResponse + + return AsyncSnippetsResourceWithStreamingResponse(self._client.snippets) + + @cached_property + def realtime_kit(self) -> realtime_kit.AsyncRealtimeKitResourceWithStreamingResponse: + from .resources.realtime_kit import AsyncRealtimeKitResourceWithStreamingResponse + + return AsyncRealtimeKitResourceWithStreamingResponse(self._client.realtime_kit) + + @cached_property + def calls(self) -> calls.AsyncCallsResourceWithStreamingResponse: + from .resources.calls import AsyncCallsResourceWithStreamingResponse + + return AsyncCallsResourceWithStreamingResponse(self._client.calls) + + @cached_property + def cloudforce_one(self) -> cloudforce_one.AsyncCloudforceOneResourceWithStreamingResponse: + from .resources.cloudforce_one import AsyncCloudforceOneResourceWithStreamingResponse + + return AsyncCloudforceOneResourceWithStreamingResponse(self._client.cloudforce_one) + + @cached_property + def ai_gateway(self) -> ai_gateway.AsyncAIGatewayResourceWithStreamingResponse: + from .resources.ai_gateway import AsyncAIGatewayResourceWithStreamingResponse + + return AsyncAIGatewayResourceWithStreamingResponse(self._client.ai_gateway) + + @cached_property + def iam(self) -> iam.AsyncIAMResourceWithStreamingResponse: + from .resources.iam import AsyncIAMResourceWithStreamingResponse + + return AsyncIAMResourceWithStreamingResponse(self._client.iam) + + @cached_property + def cloud_connector(self) -> cloud_connector.AsyncCloudConnectorResourceWithStreamingResponse: + from .resources.cloud_connector import AsyncCloudConnectorResourceWithStreamingResponse + + return AsyncCloudConnectorResourceWithStreamingResponse(self._client.cloud_connector) + + @cached_property + def botnet_feed(self) -> botnet_feed.AsyncBotnetFeedResourceWithStreamingResponse: + from .resources.botnet_feed import AsyncBotnetFeedResourceWithStreamingResponse + + return AsyncBotnetFeedResourceWithStreamingResponse(self._client.botnet_feed) + + @cached_property + def security_txt(self) -> security_txt.AsyncSecurityTXTResourceWithStreamingResponse: + from .resources.security_txt import AsyncSecurityTXTResourceWithStreamingResponse + + return AsyncSecurityTXTResourceWithStreamingResponse(self._client.security_txt) + + @cached_property + def workflows(self) -> workflows.AsyncWorkflowsResourceWithStreamingResponse: + from .resources.workflows import AsyncWorkflowsResourceWithStreamingResponse + + return AsyncWorkflowsResourceWithStreamingResponse(self._client.workflows) + + @cached_property + def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithStreamingResponse: + from .resources.resource_sharing import AsyncResourceSharingResourceWithStreamingResponse + + return AsyncResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + + @cached_property + def leaked_credential_checks( + self, + ) -> leaked_credential_checks.AsyncLeakedCredentialChecksResourceWithStreamingResponse: + from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResourceWithStreamingResponse + + return AsyncLeakedCredentialChecksResourceWithStreamingResponse(self._client.leaked_credential_checks) + + @cached_property + def content_scanning(self) -> content_scanning.AsyncContentScanningResourceWithStreamingResponse: + from .resources.content_scanning import AsyncContentScanningResourceWithStreamingResponse + + return AsyncContentScanningResourceWithStreamingResponse(self._client.content_scanning) + + @cached_property + def abuse_reports(self) -> abuse_reports.AsyncAbuseReportsResourceWithStreamingResponse: + from .resources.abuse_reports import AsyncAbuseReportsResourceWithStreamingResponse + + return AsyncAbuseReportsResourceWithStreamingResponse(self._client.abuse_reports) + + @cached_property + def ai(self) -> ai.AsyncAIResourceWithStreamingResponse: + from .resources.ai import AsyncAIResourceWithStreamingResponse + + return AsyncAIResourceWithStreamingResponse(self._client.ai) + + @cached_property + def aisearch(self) -> aisearch.AsyncAISearchResourceWithStreamingResponse: + from .resources.aisearch import AsyncAISearchResourceWithStreamingResponse + + return AsyncAISearchResourceWithStreamingResponse(self._client.aisearch) + + @cached_property + def security_center(self) -> security_center.AsyncSecurityCenterResourceWithStreamingResponse: + from .resources.security_center import AsyncSecurityCenterResourceWithStreamingResponse + + return AsyncSecurityCenterResourceWithStreamingResponse(self._client.security_center) + + @cached_property + def browser_rendering(self) -> browser_rendering.AsyncBrowserRenderingResourceWithStreamingResponse: + from .resources.browser_rendering import AsyncBrowserRenderingResourceWithStreamingResponse + + return AsyncBrowserRenderingResourceWithStreamingResponse(self._client.browser_rendering) + + @cached_property + def custom_pages(self) -> custom_pages.AsyncCustomPagesResourceWithStreamingResponse: + from .resources.custom_pages import AsyncCustomPagesResourceWithStreamingResponse + + return AsyncCustomPagesResourceWithStreamingResponse(self._client.custom_pages) + + @cached_property + def secrets_store(self) -> secrets_store.AsyncSecretsStoreResourceWithStreamingResponse: + from .resources.secrets_store import AsyncSecretsStoreResourceWithStreamingResponse + + return AsyncSecretsStoreResourceWithStreamingResponse(self._client.secrets_store) + + @cached_property + def pipelines(self) -> pipelines.AsyncPipelinesResourceWithStreamingResponse: + from .resources.pipelines import AsyncPipelinesResourceWithStreamingResponse + + return AsyncPipelinesResourceWithStreamingResponse(self._client.pipelines) + + @cached_property + def schema_validation(self) -> schema_validation.AsyncSchemaValidationResourceWithStreamingResponse: + from .resources.schema_validation import AsyncSchemaValidationResourceWithStreamingResponse + + return AsyncSchemaValidationResourceWithStreamingResponse(self._client.schema_validation) + + @cached_property + def token_validation(self) -> token_validation.AsyncTokenValidationResourceWithStreamingResponse: + from .resources.token_validation import AsyncTokenValidationResourceWithStreamingResponse + + return AsyncTokenValidationResourceWithStreamingResponse(self._client.token_validation) Client = Cloudflare diff --git a/src/cloudflare/_compat.py b/src/cloudflare/_compat.py index c919b5adb3e..be9bcfb2c1f 100644 --- a/src/cloudflare/_compat.py +++ b/src/cloudflare/_compat.py @@ -2,24 +2,24 @@ from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload from datetime import date, datetime -from typing_extensions import Self +from typing_extensions import Self, Literal import pydantic from pydantic.fields import FieldInfo -from ._types import StrBytesIntFloat +from ._types import IncEx, StrBytesIntFloat _T = TypeVar("_T") _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel) -# --------------- Pydantic v2 compatibility --------------- +# --------------- Pydantic v2, v3 compatibility --------------- # Pyright incorrectly reports some of our functions as overriding a method when they don't # pyright: reportIncompatibleMethodOverride=false +PYDANTIC_V1 = pydantic.VERSION.startswith("1.") PYDANTIC_V2 = pydantic.VERSION.startswith("2.") -# v1 re-exports if TYPE_CHECKING: def parse_date(value: date | StrBytesIntFloat) -> date: # noqa: ARG001 @@ -44,106 +44,116 @@ def is_typeddict(type_: type[Any]) -> bool: # noqa: ARG001 ... else: - if PYDANTIC_V2: - from pydantic.v1.typing import ( + # v1 re-exports + if PYDANTIC_V1: + from pydantic.typing import ( get_args as get_args, is_union as is_union, get_origin as get_origin, is_typeddict as is_typeddict, is_literal_type as is_literal_type, ) - from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime + from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime else: - from pydantic.typing import ( + from ._utils import ( get_args as get_args, is_union as is_union, get_origin as get_origin, + parse_date as parse_date, is_typeddict as is_typeddict, + parse_datetime as parse_datetime, is_literal_type as is_literal_type, ) - from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime # refactored config if TYPE_CHECKING: from pydantic import ConfigDict as ConfigDict else: - if PYDANTIC_V2: - from pydantic import ConfigDict - else: + if PYDANTIC_V1: # TODO: provide an error message here? ConfigDict = None + else: + from pydantic import ConfigDict as ConfigDict # renamed methods / properties def parse_obj(model: type[_ModelT], value: object) -> _ModelT: - if PYDANTIC_V2: - return model.model_validate(value) - else: + if PYDANTIC_V1: return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + else: + return model.model_validate(value) def field_is_required(field: FieldInfo) -> bool: - if PYDANTIC_V2: - return field.is_required() - return field.required # type: ignore + if PYDANTIC_V1: + return field.required # type: ignore + return field.is_required() def field_get_default(field: FieldInfo) -> Any: value = field.get_default() - if PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None + if PYDANTIC_V1: return value + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None return value def field_outer_type(field: FieldInfo) -> Any: - if PYDANTIC_V2: - return field.annotation - return field.outer_type_ # type: ignore + if PYDANTIC_V1: + return field.outer_type_ # type: ignore + return field.annotation def get_model_config(model: type[pydantic.BaseModel]) -> Any: - if PYDANTIC_V2: - return model.model_config - return model.__config__ # type: ignore + if PYDANTIC_V1: + return model.__config__ # type: ignore + return model.model_config def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]: - if PYDANTIC_V2: - return model.model_fields - return model.__fields__ # type: ignore + if PYDANTIC_V1: + return model.__fields__ # type: ignore + return model.model_fields def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT: - if PYDANTIC_V2: - return model.model_copy(deep=deep) - return model.copy(deep=deep) # type: ignore + if PYDANTIC_V1: + return model.copy(deep=deep) # type: ignore + return model.model_copy(deep=deep) def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str: - if PYDANTIC_V2: - return model.model_dump_json(indent=indent) - return model.json(indent=indent) # type: ignore + if PYDANTIC_V1: + return model.json(indent=indent) # type: ignore + return model.model_dump_json(indent=indent) def model_dump( model: pydantic.BaseModel, *, + exclude: IncEx | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, + warnings: bool = True, + mode: Literal["json", "python"] = "python", ) -> dict[str, Any]: - if PYDANTIC_V2: + if (not PYDANTIC_V1) or hasattr(model, "model_dump"): return model.model_dump( + mode=mode, + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, + # warnings are not supported in Pydantic v1 + warnings=True if PYDANTIC_V1 else warnings, ) return cast( "dict[str, Any]", model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, ), @@ -151,30 +161,26 @@ def model_dump( def model_parse(model: type[_ModelT], data: Any) -> _ModelT: - if PYDANTIC_V2: - return model.model_validate(data) - return model.parse_obj(data) # pyright: ignore[reportDeprecated] + if PYDANTIC_V1: + return model.parse_obj(data) # pyright: ignore[reportDeprecated] + return model.model_validate(data) # generic models if TYPE_CHECKING: - class GenericModel(pydantic.BaseModel): - ... + class GenericModel(pydantic.BaseModel): ... else: - if PYDANTIC_V2: + if PYDANTIC_V1: + import pydantic.generics + + class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ... + else: # there no longer needs to be a distinction in v2 but # we still have to create our own subclass to avoid # inconsistent MRO ordering errors - class GenericModel(pydantic.BaseModel): - ... - - else: - import pydantic.generics - - class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): - ... + class GenericModel(pydantic.BaseModel): ... # cached properties @@ -193,30 +199,22 @@ class typed_cached_property(Generic[_T]): func: Callable[[Any], _T] attrname: str | None - def __init__(self, func: Callable[[Any], _T]) -> None: - ... + def __init__(self, func: Callable[[Any], _T]) -> None: ... @overload - def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: - ... + def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... @overload - def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: - ... + def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... def __get__(self, instance: object, owner: type[Any] | None = None) -> _T | Self: raise NotImplementedError() - def __set_name__(self, owner: type[Any], name: str) -> None: - ... + def __set_name__(self, owner: type[Any], name: str) -> None: ... # __set__ is not defined at runtime, but @cached_property is designed to be settable - def __set__(self, instance: object, value: _T) -> None: - ... + def __set__(self, instance: object, value: _T) -> None: ... else: - try: - from functools import cached_property as cached_property - except ImportError: - from cached_property import cached_property as cached_property + from functools import cached_property as cached_property typed_cached_property = cached_property diff --git a/src/cloudflare/_constants.py b/src/cloudflare/_constants.py index a2ac3b6f327..6ddf2c7170b 100644 --- a/src/cloudflare/_constants.py +++ b/src/cloudflare/_constants.py @@ -6,7 +6,7 @@ OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to" # default timeout is 1 minute -DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0) +DEFAULT_TIMEOUT = httpx.Timeout(timeout=60, connect=5.0) DEFAULT_MAX_RETRIES = 2 DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20) diff --git a/src/cloudflare/_files.py b/src/cloudflare/_files.py index 0d2022ae79e..0c0ce12faaa 100644 --- a/src/cloudflare/_files.py +++ b/src/cloudflare/_files.py @@ -34,18 +34,16 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None: if not is_file_content(obj): prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`" raise RuntimeError( - f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead." + f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/cloudflare/cloudflare-python/tree/main#file-uploads" ) from None @overload -def to_httpx_files(files: None) -> None: - ... +def to_httpx_files(files: None) -> None: ... @overload -def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: - ... +def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ... def to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None: @@ -71,25 +69,23 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], _read_file_content(file[1]), *file[2:]) + return (file[0], read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -def _read_file_content(file: FileContent) -> HttpxFileContent: +def read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return pathlib.Path(file).read_bytes() return file @overload -async def async_to_httpx_files(files: None) -> None: - ... +async def async_to_httpx_files(files: None) -> None: ... @overload -async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: - ... +async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ... async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None: @@ -115,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], await _async_read_file_content(file[1]), *file[2:]) + return (file[0], await async_read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -async def _async_read_file_content(file: FileContent) -> HttpxFileContent: +async def async_read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return await anyio.Path(file).read_bytes() diff --git a/src/cloudflare/_models.py b/src/cloudflare/_models.py index eb7ce3bde92..e2736299361 100644 --- a/src/cloudflare/_models.py +++ b/src/cloudflare/_models.py @@ -2,9 +2,24 @@ import os import inspect -from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast +import weakref +from typing import ( + IO, + TYPE_CHECKING, + Any, + Type, + Union, + Generic, + TypeVar, + Callable, + Iterable, + Optional, + AsyncIterable, + cast, +) from datetime import date, datetime from typing_extensions import ( + List, Unpack, Literal, ClassVar, @@ -19,7 +34,6 @@ ) import pydantic -import pydantic.generics from pydantic.fields import FieldInfo from ._types import ( @@ -31,12 +45,14 @@ Timeout, NotGiven, AnyMapping, + MultipartSyntax, HttpxRequestFiles, ) from ._utils import ( PropertyInfo, is_list, is_given, + json_safe, lru_cache, is_mapping, parse_date, @@ -45,10 +61,11 @@ strip_not_given, extract_type_arg, is_annotated_type, + is_type_alias_type, strip_annotated_type, ) from ._compat import ( - PYDANTIC_V2, + PYDANTIC_V1, ConfigDict, GenericModel as BaseGenericModel, get_args, @@ -63,7 +80,7 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: - from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema + from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema __all__ = ["BaseModel", "GenericModel"] @@ -79,11 +96,7 @@ class _ConfigProtocol(Protocol): class BaseModel(pydantic.BaseModel): - if PYDANTIC_V2: - model_config: ClassVar[ConfigDict] = ConfigDict( - extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")) - ) - else: + if PYDANTIC_V1: @property @override @@ -93,6 +106,10 @@ def model_fields_set(self) -> set[str]: class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated] extra: Any = pydantic.Extra.allow # type: ignore + else: + model_config: ClassVar[ConfigDict] = ConfigDict( + extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")) + ) def to_dict( self, @@ -170,21 +187,21 @@ def to_json( @override def __str__(self) -> str: # mypy complains about an invalid self arg - return f'{self.__repr_name__()}({self.__repr_str__(", ")})' # type: ignore[misc] + return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc] # Override the 'construct' method in a way that supports recursive parsing without validation. # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836. @classmethod @override - def construct( - cls: Type[ModelT], + def construct( # pyright: ignore[reportIncompatibleMethodOverride] + __cls: Type[ModelT], _fields_set: set[str] | None = None, **values: object, ) -> ModelT: - m = cls.__new__(cls) + m = __cls.__new__(__cls) fields_values: dict[str, object] = {} - config = get_model_config(cls) + config = get_model_config(__cls) populate_by_name = ( config.allow_population_by_field_name if isinstance(config, _ConfigProtocol) @@ -194,7 +211,7 @@ def construct( if _fields_set is None: _fields_set = set() - model_fields = get_model_fields(cls) + model_fields = get_model_fields(__cls) for name, field in model_fields.items(): key = field.alias if key is None or (key not in values and populate_by_name): @@ -206,28 +223,32 @@ def construct( else: fields_values[name] = field_get_default(field) + extra_field_type = _get_extra_fields_type(__cls) + _extra = {} for key, value in values.items(): if key not in model_fields: - if PYDANTIC_V2: - _extra[key] = value - else: + parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value + + if PYDANTIC_V1: _fields_set.add(key) - fields_values[key] = value + fields_values[key] = parsed + else: + _extra[key] = parsed object.__setattr__(m, "__dict__", fields_values) - if PYDANTIC_V2: - # these properties are copied from Pydantic's `model_construct()` method - object.__setattr__(m, "__pydantic_private__", None) - object.__setattr__(m, "__pydantic_extra__", _extra) - object.__setattr__(m, "__pydantic_fields_set__", _fields_set) - else: + if PYDANTIC_V1: # init_private_attributes() does not exist in v2 m._init_private_attributes() # type: ignore # copied from Pydantic v1's `construct()` method object.__setattr__(m, "__fields_set__", _fields_set) + else: + # these properties are copied from Pydantic's `model_construct()` method + object.__setattr__(m, "__pydantic_private__", None) + object.__setattr__(m, "__pydantic_extra__", _extra) + object.__setattr__(m, "__pydantic_fields_set__", _fields_set) return m @@ -237,7 +258,7 @@ def construct( # although not in practice model_construct = construct - if not PYDANTIC_V2: + if PYDANTIC_V1: # we define aliases for some of the new pydantic v2 methods so # that we can just document these methods without having to specify # a specific pydantic version as some users may not know which @@ -248,15 +269,17 @@ def model_dump( self, *, mode: Literal["json", "python"] | str = "python", - include: IncEx = None, - exclude: IncEx = None, - by_alias: bool = False, + include: IncEx | None = None, + exclude: IncEx | None = None, + context: Any | None = None, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, + exclude_computed_fields: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, - context: dict[str, Any] | None = None, + fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False, ) -> dict[str, Any]: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump @@ -265,22 +288,30 @@ def model_dump( Args: mode: The mode in which `to_python` should run. - If mode is 'json', the dictionary will only contain JSON serializable types. - If mode is 'python', the dictionary may contain any Python objects. - include: A list of fields to include in the output. - exclude: A list of fields to exclude from the output. + If mode is 'json', the output will only contain JSON serializable types. + If mode is 'python', the output may contain non-JSON-serializable Python objects. + include: A set of fields to include in the output. + exclude: A set of fields to exclude from the output. + context: Additional context to pass to the serializer. by_alias: Whether to use the field's alias in the dictionary key if defined. - exclude_unset: Whether to exclude fields that are unset or None from the output. - exclude_defaults: Whether to exclude fields that are set to their default value from the output. - exclude_none: Whether to exclude fields that have a value of `None` from the output. - round_trip: Whether to enable serialization and deserialization round-trip support. - warnings: Whether to log warnings when invalid fields are encountered. + exclude_unset: Whether to exclude fields that have not been explicitly set. + exclude_defaults: Whether to exclude fields that are set to their default value. + exclude_none: Whether to exclude fields that have a value of `None`. + exclude_computed_fields: Whether to exclude computed fields. + While this can be useful for round-tripping, it is usually recommended to use the dedicated + `round_trip` parameter instead. + round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. + warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, + "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. + fallback: A function to call when an unknown value is encountered. If not provided, + a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised. + serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. Returns: A dictionary representation of the model. """ - if mode != "python": - raise ValueError("mode is only supported in Pydantic v2") + if mode not in {"json", "python"}: + raise ValueError("mode must be either 'json' or 'python'") if round_trip != False: raise ValueError("round_trip is only supported in Pydantic v2") if warnings != True: @@ -289,29 +320,38 @@ def model_dump( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") - return super().dict( # pyright: ignore[reportDeprecated] + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") + if exclude_computed_fields != False: + raise ValueError("exclude_computed_fields is only supported in Pydantic v2") + dumped = super().dict( # pyright: ignore[reportDeprecated] include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, ) + return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped + @override def model_dump_json( self, *, indent: int | None = None, - include: IncEx = None, - exclude: IncEx = None, - by_alias: bool = False, + ensure_ascii: bool = False, + include: IncEx | None = None, + exclude: IncEx | None = None, + context: Any | None = None, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, + exclude_computed_fields: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, - context: dict[str, Any] | None = None, + fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False, ) -> str: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json @@ -340,11 +380,17 @@ def model_dump_json( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") + if ensure_ascii != False: + raise ValueError("ensure_ascii is only supported in Pydantic v2") + if exclude_computed_fields != False: + raise ValueError("exclude_computed_fields is only supported in Pydantic v2") return super().json( # type: ignore[reportDeprecated] indent=indent, include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, @@ -355,15 +401,32 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object: if value is None: return field_get_default(field) - if PYDANTIC_V2: - type_ = field.annotation - else: + if PYDANTIC_V1: type_ = cast(type, field.outer_type_) # type: ignore + else: + type_ = field.annotation # type: ignore if type_ is None: raise RuntimeError(f"Unexpected field type is None for {key}") - return construct_type(value=value, type_=type_) + return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None)) + + +def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None: + if PYDANTIC_V1: + # TODO + return None + + schema = cls.__pydantic_core_schema__ + if schema["type"] == "model": + fields = schema["schema"] + if fields["type"] == "model-fields": + extras = fields.get("extras_schema") + if extras and "cls" in extras: + # mypy can't narrow the type + return extras["cls"] # type: ignore[no-any-return] + + return None def is_basemodel(type_: type) -> bool: @@ -380,6 +443,8 @@ def is_basemodel(type_: type) -> bool: def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericModel]]: origin = get_origin(type_) or type_ + if not inspect.isclass(origin): + return False return issubclass(origin, BaseModel) or issubclass(origin, GenericModel) @@ -406,18 +471,37 @@ def build( return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs)) -def construct_type(*, value: object, type_: object) -> object: +def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T: + """Loose coercion to the expected type with construction of nested values. + + Note: the returned value from this function is not guaranteed to match the + given type. + """ + return cast(_T, construct_type(value=value, type_=type_)) + + +def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object: """Loose coercion to the expected type with construction of nested values. If the given value does not match the expected type then it is returned as-is. """ + + # store a reference to the original type we were given before we extract any inner + # types so that we can properly resolve forward references in `TypeAliasType` annotations + original_type = None + # we allow `object` as the input type because otherwise, passing things like # `Literal['value']` will be reported as a type error by type checkers type_ = cast("type[object]", type_) + if is_type_alias_type(type_): + original_type = type_ # type: ignore[unreachable] + type_ = type_.__value__ # type: ignore[unreachable] # unwrap `Annotated[T, ...]` -> `T` - if is_annotated_type(type_): - meta: tuple[Any, ...] = get_args(type_)[1:] + if metadata is not None and len(metadata) > 0: + meta: tuple[Any, ...] = tuple(metadata) + elif is_annotated_type(type_): + meta = get_args(type_)[1:] type_ = extract_type_arg(type_, 0) else: meta = tuple() @@ -429,7 +513,7 @@ def construct_type(*, value: object, type_: object) -> object: if is_union(origin): try: - return validate_type(type_=cast("type[object]", type_), value=value) + return validate_type(type_=cast("type[object]", original_type or type_), value=value) except Exception: pass @@ -471,7 +555,11 @@ def construct_type(*, value: object, type_: object) -> object: _, items_type = get_args(type_) # Dict[_, items_type] return {key: construct_type(value=item, type_=items_type) for key, item in value.items()} - if not is_literal_type(type_) and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel)): + if ( + not is_literal_type(type_) + and inspect.isclass(origin) + and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel)) + ): if is_list(value): return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value] @@ -517,6 +605,9 @@ class CachedDiscriminatorType(Protocol): __discriminator__: DiscriminatorDetails +DISCRIMINATOR_CACHE: weakref.WeakKeyDictionary[type, DiscriminatorDetails] = weakref.WeakKeyDictionary() + + class DiscriminatorDetails: field_name: str """The name of the discriminator field in the variant class, e.g. @@ -559,8 +650,9 @@ def __init__( def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None: - if isinstance(union, CachedDiscriminatorType): - return union.__discriminator__ + cached = DISCRIMINATOR_CACHE.get(union) + if cached is not None: + return cached discriminator_field_name: str | None = None @@ -578,30 +670,30 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, for variant in get_args(union): variant = strip_annotated_type(variant) if is_basemodel_type(variant): - if PYDANTIC_V2: - field = _extract_field_schema_pv2(variant, discriminator_field_name) - if not field: + if PYDANTIC_V1: + field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + if not field_info: continue # Note: if one variant defines an alias then they all should - discriminator_alias = field.get("serialization_alias") - - field_schema = field["schema"] + discriminator_alias = field_info.alias - if field_schema["type"] == "literal": - for entry in cast("LiteralSchema", field_schema)["expected"]: + if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation): + for entry in get_args(annotation): if isinstance(entry, str): mapping[entry] = variant else: - field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] - if not field_info: + field = _extract_field_schema_pv2(variant, discriminator_field_name) + if not field: continue # Note: if one variant defines an alias then they all should - discriminator_alias = field_info.alias + discriminator_alias = field.get("serialization_alias") + + field_schema = field["schema"] - if field_info.annotation and is_literal_type(field_info.annotation): - for entry in get_args(field_info.annotation): + if field_schema["type"] == "literal": + for entry in cast("LiteralSchema", field_schema)["expected"]: if isinstance(entry, str): mapping[entry] = variant @@ -613,21 +705,24 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, discriminator_field=discriminator_field_name, discriminator_alias=discriminator_alias, ) - cast(CachedDiscriminatorType, union).__discriminator__ = details + DISCRIMINATOR_CACHE.setdefault(union, details) return details def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None: schema = model.__pydantic_core_schema__ + if schema["type"] == "definitions": + schema = schema["schema"] + if schema["type"] != "model": return None + schema = cast("ModelSchema", schema) fields_schema = schema["schema"] if fields_schema["type"] != "model-fields": return None fields_schema = cast("ModelFieldsSchema", fields_schema) - field = fields_schema["fields"].get(field_name) if not field: return None @@ -651,7 +746,7 @@ def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None: setattr(typ, "__pydantic_config__", config) # noqa: B010 -# our use of subclasssing here causes weirdness for type checkers, +# our use of subclassing here causes weirdness for type checkers, # so we just pretend that we don't subclass if TYPE_CHECKING: GenericModel = BaseModel @@ -661,7 +756,7 @@ class GenericModel(BaseGenericModel, BaseModel): pass -if PYDANTIC_V2: +if not PYDANTIC_V1: from pydantic import TypeAdapter as _TypeAdapter _CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter)) @@ -706,8 +801,11 @@ class FinalRequestOptionsInput(TypedDict, total=False): timeout: float | Timeout | None files: HttpxRequestFiles | None idempotency_key: str + content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] json_data: Body extra_json: AnyMapping + multipart_syntax: MultipartSyntax + follow_redirects: bool @final @@ -720,19 +818,22 @@ class FinalRequestOptions(pydantic.BaseModel): timeout: Union[float, Timeout, None, NotGiven] = NotGiven() files: Union[HttpxRequestFiles, None] = None idempotency_key: Union[str, None] = None + multipart_syntax: Union[MultipartSyntax, None] = None post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven() + follow_redirects: Union[bool, None] = None + content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None # It should be noted that we cannot use `json` here as that would override # a BaseModel method in an incompatible fashion. json_data: Union[Body, None] = None extra_json: Union[AnyMapping, None] = None - if PYDANTIC_V2: - model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) - else: + if PYDANTIC_V1: class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated] arbitrary_types_allowed: bool = True + else: + model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) def get_max_retries(self, max_retries: int) -> int: if isinstance(self.max_retries, NotGiven): @@ -765,9 +866,9 @@ def construct( # type: ignore key: strip_not_given(value) for key, value in values.items() } - if PYDANTIC_V2: - return super().model_construct(_fields_set, **kwargs) - return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated] + if PYDANTIC_V1: + return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated] + return super().model_construct(_fields_set, **kwargs) if not TYPE_CHECKING: # type checkers incorrectly complain about this assignment diff --git a/src/cloudflare/_qs.py b/src/cloudflare/_qs.py index 274320ca5ee..ada6fd3f721 100644 --- a/src/cloudflare/_qs.py +++ b/src/cloudflare/_qs.py @@ -4,7 +4,7 @@ from urllib.parse import parse_qs, urlencode from typing_extensions import Literal, get_args -from ._types import NOT_GIVEN, NotGiven, NotGivenOr +from ._types import NotGiven, not_given from ._utils import flatten _T = TypeVar("_T") @@ -41,8 +41,8 @@ def stringify( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> str: return urlencode( self.stringify_items( @@ -56,8 +56,8 @@ def stringify_items( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> list[tuple[str, str]]: opts = Options( qs=self, @@ -143,8 +143,8 @@ def __init__( self, qs: Querystring = _qs, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> None: self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format diff --git a/src/cloudflare/_response.py b/src/cloudflare/_response.py index 50eb875a5af..c23d0dd7811 100644 --- a/src/cloudflare/_response.py +++ b/src/cloudflare/_response.py @@ -25,7 +25,7 @@ import pydantic from ._types import NoneType -from ._utils import is_given, extract_type_arg, is_annotated_type, extract_type_var_from_base +from ._utils import is_given, extract_type_arg, is_annotated_type, is_type_alias_type, extract_type_var_from_base from ._models import BaseModel, is_basemodel from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type @@ -55,6 +55,9 @@ class BaseAPIResponse(Generic[R]): http_response: httpx.Response + retries_taken: int + """The number of retries made. If no retries happened this will be `0`""" + def __init__( self, *, @@ -64,6 +67,7 @@ def __init__( stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, options: FinalRequestOptions, + retries_taken: int = 0, ) -> None: self._cast_to = cast_to self._client = client @@ -72,6 +76,7 @@ def __init__( self._stream_cls = stream_cls self._options = options self.http_response = raw + self.retries_taken = retries_taken @property def headers(self) -> httpx.Headers: @@ -121,9 +126,17 @@ def __repr__(self) -> str: ) def _parse(self, *, to: type[_T] | None = None) -> R | _T: + cast_to = to if to is not None else self._cast_to + + # unwrap `TypeAlias('Name', T)` -> `T` + if is_type_alias_type(cast_to): + cast_to = cast_to.__value__ # type: ignore[unreachable] + # unwrap `Annotated[T, ...]` -> `T` - if to and is_annotated_type(to): - to = extract_type_arg(to, 0) + if cast_to and is_annotated_type(cast_to): + cast_to = extract_type_arg(cast_to, 0) + + origin = get_origin(cast_to) or cast_to if self._is_sse_stream: if to: @@ -159,18 +172,12 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: return cast( R, stream_cls( - cast_to=self._cast_to, + cast_to=cast_to, response=self.http_response, client=cast(Any, self._client), ), ) - cast_to = to if to is not None else self._cast_to - - # unwrap `Annotated[T, ...]` -> `T` - if is_annotated_type(cast_to): - cast_to = extract_type_arg(cast_to, 0) - if cast_to is NoneType: return cast(R, None) @@ -187,7 +194,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: if cast_to == float: return cast(R, float(response.text)) - origin = get_origin(cast_to) or cast_to + if cast_to == bool: + return cast(R, response.text.lower() == "true") if origin == APIResponse: raise RuntimeError("Unexpected state - cast_to is `APIResponse`") @@ -202,7 +210,13 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`") return cast(R, response) - if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel): + if ( + inspect.isclass( + origin # pyright: ignore[reportUnknownArgumentType] + ) + and not issubclass(origin, BaseModel) + and issubclass(origin, pydantic.BaseModel) + ): raise TypeError( "Pydantic models must subclass our base model type, e.g. `from cloudflare import BaseModel`" ) @@ -221,7 +235,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: # split is required to handle cases where additional information is included # in the response, e.g. application/json; charset=utf-8 content_type, *_ = response.headers.get("content-type", "*").split(";") - if content_type != "application/json": + if not content_type.endswith("json"): if is_basemodel(cast_to): try: data = response.json() @@ -257,12 +271,10 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: class APIResponse(BaseAPIResponse[R]): @overload - def parse(self, *, to: type[_T]) -> _T: - ... + def parse(self, *, to: type[_T]) -> _T: ... @overload - def parse(self) -> R: - ... + def parse(self) -> R: ... def parse(self, *, to: type[_T] | None = None) -> R | _T: """Returns the rich python representation of this response's data. @@ -361,12 +373,10 @@ def iter_lines(self) -> Iterator[str]: class AsyncAPIResponse(BaseAPIResponse[R]): @overload - async def parse(self, *, to: type[_T]) -> _T: - ... + async def parse(self, *, to: type[_T]) -> _T: ... @overload - async def parse(self) -> R: - ... + async def parse(self) -> R: ... async def parse(self, *, to: type[_T] | None = None) -> R | _T: """Returns the rich python representation of this response's data. diff --git a/src/cloudflare/_streaming.py b/src/cloudflare/_streaming.py index 0be44fec67a..d26f2aaf70a 100644 --- a/src/cloudflare/_streaming.py +++ b/src/cloudflare/_streaming.py @@ -54,12 +54,12 @@ def __stream__(self) -> Iterator[_T]: process_data = self._client._process_response_data iterator = self._iter_events() - for sse in iterator: - yield process_data(data=sse.json(), cast_to=cast_to, response=response) - - # Ensure the entire stream is consumed - for _sse in iterator: - ... + try: + for sse in iterator: + yield process_data(data=sse.json(), cast_to=cast_to, response=response) + finally: + # Ensure the response is closed even if the consumer doesn't read all data + response.close() def __enter__(self) -> Self: return self @@ -118,12 +118,12 @@ async def __stream__(self) -> AsyncIterator[_T]: process_data = self._client._process_response_data iterator = self._iter_events() - async for sse in iterator: - yield process_data(data=sse.json(), cast_to=cast_to, response=response) - - # Ensure the entire stream is consumed - async for _sse in iterator: - ... + try: + async for sse in iterator: + yield process_data(data=sse.json(), cast_to=cast_to, response=response) + finally: + # Ensure the response is closed even if the consumer doesn't read all data + await response.aclose() async def __aenter__(self) -> Self: return self diff --git a/src/cloudflare/_types.py b/src/cloudflare/_types.py index c9d9bf596ca..e5a095d8f3f 100644 --- a/src/cloudflare/_types.py +++ b/src/cloudflare/_types.py @@ -13,10 +13,23 @@ Mapping, TypeVar, Callable, + Iterable, + Iterator, Optional, Sequence, + AsyncIterable, +) +from typing_extensions import ( + Set, + Literal, + Protocol, + TypeAlias, + TypedDict, + SupportsIndex, + overload, + override, + runtime_checkable, ) -from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable import httpx import pydantic @@ -45,6 +58,13 @@ else: Base64FileInput = Union[IO[bytes], PathLike] FileContent = Union[IO[bytes], bytes, PathLike] # PathLike is not subscriptable in Python 3.8. + + +# Used for sending raw binary data / streaming data in request bodies +# e.g. for file uploads without multipart encoding +BinaryTypes = Union[bytes, bytearray, IO[bytes], Iterable[bytes]] +AsyncBinaryTypes = Union[bytes, bytearray, IO[bytes], AsyncIterable[bytes]] + FileTypes = Union[ # file (or bytes) FileContent, @@ -71,6 +91,8 @@ ] HttpxRequestFiles = Union[Mapping[str, HttpxFileTypes], Sequence[Tuple[str, HttpxFileTypes]]] +MultipartSyntax = Literal["query", "json"] + # Workaround to support (cast_to: Type[ResponseT]) -> ResponseT # where ResponseT includes `None`. In order to support directly # passing `None`, overloads would have to be defined for every @@ -100,24 +122,28 @@ class RequestOptions(TypedDict, total=False): params: Query extra_json: AnyMapping idempotency_key: str + multipart_syntax: MultipartSyntax + follow_redirects: bool # Sentinel class used until PEP 0661 is accepted class NotGiven: """ - A sentinel singleton class used to distinguish omitted keyword arguments - from those passed in with the value None (which may have different behavior). + For parameters with a meaningful None value, we need to distinguish between + the user explicitly passing None, and the user not passing the parameter at + all. + + User code shouldn't need to use not_given directly. For example: ```py - def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: - ... + def create(timeout: Timeout | None | NotGiven = not_given): ... - get(timeout=1) # 1s timeout - get(timeout=None) # No timeout - get() # Default timeout behavior, which may not be statically known at the method definition. + create(timeout=1) # 1s timeout + create(timeout=None) # No timeout + create() # Default timeout behavior ``` """ @@ -129,13 +155,14 @@ def __repr__(self) -> str: return "NOT_GIVEN" -NotGivenOr = Union[_T, NotGiven] +not_given = NotGiven() +# for backwards compatibility: NOT_GIVEN = NotGiven() class Omit: - """In certain situations you need to be able to represent a case where a default value has - to be explicitly removed and `None` is not an appropriate substitute, for example: + """ + To explicitly omit something from being sent in a request, use `omit`. ```py # as the default `Content-Type` header is `application/json` that will be sent @@ -145,8 +172,8 @@ class Omit: # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983' client.post(..., headers={"Content-Type": "multipart/form-data"}) - # instead you can remove the default `application/json` header by passing Omit - client.post(..., headers={"Content-Type": Omit()}) + # instead you can remove the default `application/json` header by passing omit + client.post(..., headers={"Content-Type": omit}) ``` """ @@ -154,6 +181,9 @@ def __bool__(self) -> Literal[False]: return False +omit = Omit() + + @runtime_checkable class ModelBuilderProtocol(Protocol): @classmethod @@ -162,16 +192,14 @@ def build( *, response: Response, data: object, - ) -> _T: - ... + ) -> _T: ... Headers = Mapping[str, Union[str, Omit]] class HeadersLikeProtocol(Protocol): - def get(self, __key: str) -> str | None: - ... + def get(self, __key: str) -> str | None: ... HeadersLike = Union[Headers, HeadersLikeProtocol] @@ -195,8 +223,8 @@ def get(self, __key: str) -> str | None: StrBytesIntFloat = Union[str, bytes, int, float] # Note: copied from Pydantic -# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49 -IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None" +# https://github.com/pydantic/pydantic/blob/6f31f8f68ef011f84357330186f603ff295312fd/pydantic/main.py#L79 +IncEx: TypeAlias = Union[Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]]] PostParser = Callable[[Any], Any] @@ -218,3 +246,28 @@ class _GenericAlias(Protocol): class HttpxSendArgs(TypedDict, total=False): auth: httpx.Auth + follow_redirects: bool + + +_T_co = TypeVar("_T_co", covariant=True) + + +if TYPE_CHECKING: + # This works because str.__contains__ does not accept object (either in typeshed or at runtime) + # https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285 + # + # Note: index() and count() methods are intentionally omitted to allow pyright to properly + # infer TypedDict types when dict literals are used in lists assigned to SequenceNotStr. + class SequenceNotStr(Protocol[_T_co]): + @overload + def __getitem__(self, index: SupportsIndex, /) -> _T_co: ... + @overload + def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ... + def __contains__(self, value: object, /) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T_co]: ... + def __reversed__(self) -> Iterator[_T_co]: ... +else: + # just point this to a normal `Sequence` at runtime to avoid having to special case + # deserializing our custom sequence type + SequenceNotStr = Sequence diff --git a/src/cloudflare/_utils/__init__.py b/src/cloudflare/_utils/__init__.py index 3efe66c8e85..dc64e29a1c0 100644 --- a/src/cloudflare/_utils/__init__.py +++ b/src/cloudflare/_utils/__init__.py @@ -6,10 +6,10 @@ is_list as is_list, is_given as is_given, is_tuple as is_tuple, + json_safe as json_safe, lru_cache as lru_cache, is_mapping as is_mapping, is_tuple_t as is_tuple_t, - parse_date as parse_date, is_iterable as is_iterable, is_sequence as is_sequence, coerce_float as coerce_float, @@ -22,7 +22,6 @@ coerce_boolean as coerce_boolean, coerce_integer as coerce_integer, file_from_path as file_from_path, - parse_datetime as parse_datetime, strip_not_given as strip_not_given, deepcopy_minimal as deepcopy_minimal, get_async_library as get_async_library, @@ -31,13 +30,22 @@ maybe_coerce_boolean as maybe_coerce_boolean, maybe_coerce_integer as maybe_coerce_integer, ) +from ._compat import ( + get_args as get_args, + is_union as is_union, + get_origin as get_origin, + is_typeddict as is_typeddict, + is_literal_type as is_literal_type, +) from ._typing import ( is_list_type as is_list_type, is_union_type as is_union_type, extract_type_arg as extract_type_arg, is_iterable_type as is_iterable_type, is_required_type as is_required_type, + is_sequence_type as is_sequence_type, is_annotated_type as is_annotated_type, + is_type_alias_type as is_type_alias_type, strip_annotated_type as strip_annotated_type, extract_type_var_from_base as extract_type_var_from_base, ) @@ -53,3 +61,4 @@ function_has_argument as function_has_argument, assert_signatures_in_sync as assert_signatures_in_sync, ) +from ._datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime diff --git a/src/cloudflare/_utils/_compat.py b/src/cloudflare/_utils/_compat.py new file mode 100644 index 00000000000..dd703233c56 --- /dev/null +++ b/src/cloudflare/_utils/_compat.py @@ -0,0 +1,45 @@ +from __future__ import annotations + +import sys +import typing_extensions +from typing import Any, Type, Union, Literal, Optional +from datetime import date, datetime +from typing_extensions import get_args as _get_args, get_origin as _get_origin + +from .._types import StrBytesIntFloat +from ._datetime_parse import parse_date as _parse_date, parse_datetime as _parse_datetime + +_LITERAL_TYPES = {Literal, typing_extensions.Literal} + + +def get_args(tp: type[Any]) -> tuple[Any, ...]: + return _get_args(tp) + + +def get_origin(tp: type[Any]) -> type[Any] | None: + return _get_origin(tp) + + +def is_union(tp: Optional[Type[Any]]) -> bool: + if sys.version_info < (3, 10): + return tp is Union # type: ignore[comparison-overlap] + else: + import types + + return tp is Union or tp is types.UnionType + + +def is_typeddict(tp: Type[Any]) -> bool: + return typing_extensions.is_typeddict(tp) + + +def is_literal_type(tp: Type[Any]) -> bool: + return get_origin(tp) in _LITERAL_TYPES + + +def parse_date(value: Union[date, StrBytesIntFloat]) -> date: + return _parse_date(value) + + +def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: + return _parse_datetime(value) diff --git a/src/cloudflare/_utils/_datetime_parse.py b/src/cloudflare/_utils/_datetime_parse.py new file mode 100644 index 00000000000..7cb9d9e668c --- /dev/null +++ b/src/cloudflare/_utils/_datetime_parse.py @@ -0,0 +1,136 @@ +""" +This file contains code from https://github.com/pydantic/pydantic/blob/main/pydantic/v1/datetime_parse.py +without the Pydantic v1 specific errors. +""" + +from __future__ import annotations + +import re +from typing import Dict, Union, Optional +from datetime import date, datetime, timezone, timedelta + +from .._types import StrBytesIntFloat + +date_expr = r"(?P\d{4})-(?P\d{1,2})-(?P\d{1,2})" +time_expr = ( + r"(?P\d{1,2}):(?P\d{1,2})" + r"(?::(?P\d{1,2})(?:\.(?P\d{1,6})\d{0,6})?)?" + r"(?PZ|[+-]\d{2}(?::?\d{2})?)?$" +) + +date_re = re.compile(f"{date_expr}$") +datetime_re = re.compile(f"{date_expr}[T ]{time_expr}") + + +EPOCH = datetime(1970, 1, 1) +# if greater than this, the number is in ms, if less than or equal it's in seconds +# (in seconds this is 11th October 2603, in ms it's 20th August 1970) +MS_WATERSHED = int(2e10) +# slightly more than datetime.max in ns - (datetime.max - EPOCH).total_seconds() * 1e9 +MAX_NUMBER = int(3e20) + + +def _get_numeric(value: StrBytesIntFloat, native_expected_type: str) -> Union[None, int, float]: + if isinstance(value, (int, float)): + return value + try: + return float(value) + except ValueError: + return None + except TypeError: + raise TypeError(f"invalid type; expected {native_expected_type}, string, bytes, int or float") from None + + +def _from_unix_seconds(seconds: Union[int, float]) -> datetime: + if seconds > MAX_NUMBER: + return datetime.max + elif seconds < -MAX_NUMBER: + return datetime.min + + while abs(seconds) > MS_WATERSHED: + seconds /= 1000 + dt = EPOCH + timedelta(seconds=seconds) + return dt.replace(tzinfo=timezone.utc) + + +def _parse_timezone(value: Optional[str]) -> Union[None, int, timezone]: + if value == "Z": + return timezone.utc + elif value is not None: + offset_mins = int(value[-2:]) if len(value) > 3 else 0 + offset = 60 * int(value[1:3]) + offset_mins + if value[0] == "-": + offset = -offset + return timezone(timedelta(minutes=offset)) + else: + return None + + +def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: + """ + Parse a datetime/int/float/string and return a datetime.datetime. + + This function supports time zone offsets. When the input contains one, + the output uses a timezone with a fixed offset from UTC. + + Raise ValueError if the input is well formatted but not a valid datetime. + Raise ValueError if the input isn't well formatted. + """ + if isinstance(value, datetime): + return value + + number = _get_numeric(value, "datetime") + if number is not None: + return _from_unix_seconds(number) + + if isinstance(value, bytes): + value = value.decode() + + assert not isinstance(value, (float, int)) + + match = datetime_re.match(value) + if match is None: + raise ValueError("invalid datetime format") + + kw = match.groupdict() + if kw["microsecond"]: + kw["microsecond"] = kw["microsecond"].ljust(6, "0") + + tzinfo = _parse_timezone(kw.pop("tzinfo")) + kw_: Dict[str, Union[None, int, timezone]] = {k: int(v) for k, v in kw.items() if v is not None} + kw_["tzinfo"] = tzinfo + + return datetime(**kw_) # type: ignore + + +def parse_date(value: Union[date, StrBytesIntFloat]) -> date: + """ + Parse a date/int/float/string and return a datetime.date. + + Raise ValueError if the input is well formatted but not a valid date. + Raise ValueError if the input isn't well formatted. + """ + if isinstance(value, date): + if isinstance(value, datetime): + return value.date() + else: + return value + + number = _get_numeric(value, "date") + if number is not None: + return _from_unix_seconds(number).date() + + if isinstance(value, bytes): + value = value.decode() + + assert not isinstance(value, (float, int)) + match = date_re.match(value) + if match is None: + raise ValueError("invalid date format") + + kw = {k: int(v) for k, v in match.groupdict().items()} + + try: + return date(**kw) + except ValueError: + raise ValueError("invalid date format") from None diff --git a/src/cloudflare/_utils/_proxy.py b/src/cloudflare/_utils/_proxy.py index c46a62a6982..0f239a33c6d 100644 --- a/src/cloudflare/_utils/_proxy.py +++ b/src/cloudflare/_utils/_proxy.py @@ -46,7 +46,10 @@ def __dir__(self) -> Iterable[str]: @property # type: ignore @override def __class__(self) -> type: # pyright: ignore - proxied = self.__get_proxied__() + try: + proxied = self.__get_proxied__() + except Exception: + return type(self) if issubclass(type(proxied), LazyProxy): return type(proxied) return proxied.__class__ @@ -59,5 +62,4 @@ def __as_proxied__(self) -> T: return cast(T, self) @abstractmethod - def __load__(self) -> T: - ... + def __load__(self) -> T: ... diff --git a/src/cloudflare/_utils/_reflection.py b/src/cloudflare/_utils/_reflection.py index 9a53c7bd21c..89aa712ac4c 100644 --- a/src/cloudflare/_utils/_reflection.py +++ b/src/cloudflare/_utils/_reflection.py @@ -34,7 +34,7 @@ def assert_signatures_in_sync( if custom_param.annotation != source_param.annotation: errors.append( - f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(source_param.annotation)}" + f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(custom_param.annotation)}" ) continue diff --git a/src/cloudflare/_utils/_resources_proxy.py b/src/cloudflare/_utils/_resources_proxy.py new file mode 100644 index 00000000000..f7fa42f9c30 --- /dev/null +++ b/src/cloudflare/_utils/_resources_proxy.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +from typing import Any +from typing_extensions import override + +from ._proxy import LazyProxy + + +class ResourcesProxy(LazyProxy[Any]): + """A proxy for the `cloudflare.resources` module. + + This is used so that we can lazily import `cloudflare.resources` only when + needed *and* so that users can just import `cloudflare` and reference `cloudflare.resources` + """ + + @override + def __load__(self) -> Any: + import importlib + + mod = importlib.import_module("cloudflare.resources") + return mod + + +resources = ResourcesProxy().__as_proxied__() diff --git a/src/cloudflare/_utils/_sync.py b/src/cloudflare/_utils/_sync.py index d0d810337ec..f6027c183d1 100644 --- a/src/cloudflare/_utils/_sync.py +++ b/src/cloudflare/_utils/_sync.py @@ -1,56 +1,49 @@ from __future__ import annotations +import asyncio import functools from typing import TypeVar, Callable, Awaitable from typing_extensions import ParamSpec import anyio +import sniffio import anyio.to_thread -from ._reflection import function_has_argument - T_Retval = TypeVar("T_Retval") T_ParamSpec = ParamSpec("T_ParamSpec") -# copied from `asyncer`, https://github.com/tiangolo/asyncer -def asyncify( - function: Callable[T_ParamSpec, T_Retval], - *, - cancellable: bool = False, - limiter: anyio.CapacityLimiter | None = None, -) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: +async def to_thread( + func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs +) -> T_Retval: + if sniffio.current_async_library() == "asyncio": + return await asyncio.to_thread(func, *args, **kwargs) + + return await anyio.to_thread.run_sync( + functools.partial(func, *args, **kwargs), + ) + + +# inspired by `asyncer`, https://github.com/tiangolo/asyncer +def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: """ Take a blocking function and create an async one that receives the same - positional and keyword arguments, and that when called, calls the original function - in a worker thread using `anyio.to_thread.run_sync()`. Internally, - `asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports - keyword arguments additional to positional arguments and it adds better support for - autocompletion and inline errors for the arguments of the function called and the - return value. - - If the `cancellable` option is enabled and the task waiting for its completion is - cancelled, the thread will still run its course but its return value (or any raised - exception) will be ignored. + positional and keyword arguments. - Use it like this: + Usage: - ```Python - def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str: - # Do work - return "Some result" + ```python + def blocking_func(arg1, arg2, kwarg1=None): + # blocking code + return result - result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b") - print(result) + result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1) ``` ## Arguments `function`: a blocking regular callable (e.g. a function) - `cancellable`: `True` to allow cancellation of the operation - `limiter`: capacity limiter to use to limit the total amount of threads running - (if omitted, the default limiter is used) ## Return @@ -60,22 +53,6 @@ def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str: """ async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval: - partial_f = functools.partial(function, *args, **kwargs) - - # In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old - # `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid - # surfacing deprecation warnings. - if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"): - return await anyio.to_thread.run_sync( - partial_f, - abandon_on_cancel=cancellable, - limiter=limiter, - ) - - return await anyio.to_thread.run_sync( - partial_f, - cancellable=cancellable, - limiter=limiter, - ) + return await to_thread(function, *args, **kwargs) return wrapper diff --git a/src/cloudflare/_utils/_transform.py b/src/cloudflare/_utils/_transform.py index 47e262a515d..5207549207e 100644 --- a/src/cloudflare/_utils/_transform.py +++ b/src/cloudflare/_utils/_transform.py @@ -5,27 +5,31 @@ import pathlib from typing import Any, Mapping, TypeVar, cast from datetime import date, datetime -from typing_extensions import Literal, get_args, override, get_type_hints +from typing_extensions import Literal, get_args, override, get_type_hints as _get_type_hints import anyio import pydantic from ._utils import ( is_list, + is_given, + lru_cache, is_mapping, is_iterable, + is_sequence, ) from .._files import is_base64_file_input +from ._compat import get_origin, is_typeddict from ._typing import ( is_list_type, is_union_type, extract_type_arg, is_iterable_type, is_required_type, + is_sequence_type, is_annotated_type, strip_annotated_type, ) -from .._compat import model_dump, is_typeddict _T = TypeVar("_T") @@ -108,6 +112,7 @@ class Params(TypedDict, total=False): return cast(_T, transformed) +@lru_cache(maxsize=8096) def _get_annotated_type(type_: type) -> type | None: """If the given type is an `Annotated` type then it is returned, if not `None` is returned. @@ -126,7 +131,7 @@ def _get_annotated_type(type_: type) -> type | None: def _maybe_transform_key(key: str, type_: type) -> str: """Transform the given `data` based on the annotations provided in `type_`. - Note: this function only looks at `Annotated` types that contain `PropertInfo` metadata. + Note: this function only looks at `Annotated` types that contain `PropertyInfo` metadata. """ annotated_type = _get_annotated_type(type_) if annotated_type is None: @@ -142,6 +147,10 @@ def _maybe_transform_key(key: str, type_: type) -> str: return key +def _no_transform_needed(annotation: type) -> bool: + return annotation == float or annotation == int + + def _transform_recursive( data: object, *, @@ -160,20 +169,43 @@ def _transform_recursive( Defaults to the same value as the `annotation` argument. """ + from .._compat import model_dump + if inner_type is None: inner_type = annotation stripped_type = strip_annotated_type(inner_type) + origin = get_origin(stripped_type) or stripped_type if is_typeddict(stripped_type) and is_mapping(data): return _transform_typeddict(data, stripped_type) + if origin == dict and is_mapping(data): + items_type = get_args(stripped_type)[1] + return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} + if ( # List[T] (is_list_type(stripped_type) and is_list(data)) # Iterable[T] or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str)) + # Sequence[T] + or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str)) ): + # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually + # intended as an iterable, so we don't transform it. + if isinstance(data, dict): + return cast(object, data) + inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): @@ -186,7 +218,7 @@ def _transform_recursive( return data if isinstance(data, pydantic.BaseModel): - return model_dump(data, exclude_unset=True) + return model_dump(data, exclude_unset=True, mode="json") annotated_type = _get_annotated_type(annotation) if annotated_type is None: @@ -235,6 +267,11 @@ def _transform_typeddict( result: dict[str, object] = {} annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): + if not is_given(value): + # we don't need to include omitted values here as they'll + # be stripped out before the request is sent anyway + continue + type_ = annotations.get(key) if type_ is None: # we do not have a type annotation for this field, leave it as is @@ -298,20 +335,43 @@ async def _async_transform_recursive( Defaults to the same value as the `annotation` argument. """ + from .._compat import model_dump + if inner_type is None: inner_type = annotation stripped_type = strip_annotated_type(inner_type) + origin = get_origin(stripped_type) or stripped_type if is_typeddict(stripped_type) and is_mapping(data): return await _async_transform_typeddict(data, stripped_type) + if origin == dict and is_mapping(data): + items_type = get_args(stripped_type)[1] + return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} + if ( # List[T] (is_list_type(stripped_type) and is_list(data)) # Iterable[T] or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str)) + # Sequence[T] + or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str)) ): + # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually + # intended as an iterable, so we don't transform it. + if isinstance(data, dict): + return cast(object, data) + inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): @@ -324,7 +384,7 @@ async def _async_transform_recursive( return data if isinstance(data, pydantic.BaseModel): - return model_dump(data, exclude_unset=True) + return model_dump(data, exclude_unset=True, mode="json") annotated_type = _get_annotated_type(annotation) if annotated_type is None: @@ -373,6 +433,11 @@ async def _async_transform_typeddict( result: dict[str, object] = {} annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): + if not is_given(value): + # we don't need to include omitted values here as they'll + # be stripped out before the request is sent anyway + continue + type_ = annotations.get(key) if type_ is None: # we do not have a type annotation for this field, leave it as is @@ -380,3 +445,13 @@ async def _async_transform_typeddict( else: result[_maybe_transform_key(key, type_)] = await _async_transform_recursive(value, annotation=type_) return result + + +@lru_cache(maxsize=8096) +def get_type_hints( + obj: Any, + globalns: dict[str, Any] | None = None, + localns: Mapping[str, Any] | None = None, + include_extras: bool = False, +) -> dict[str, Any]: + return _get_type_hints(obj, globalns=globalns, localns=localns, include_extras=include_extras) diff --git a/src/cloudflare/_utils/_typing.py b/src/cloudflare/_utils/_typing.py index c036991f043..193109f3ad2 100644 --- a/src/cloudflare/_utils/_typing.py +++ b/src/cloudflare/_utils/_typing.py @@ -1,11 +1,21 @@ from __future__ import annotations +import sys +import typing +import typing_extensions from typing import Any, TypeVar, Iterable, cast from collections import abc as _c_abc -from typing_extensions import Required, Annotated, get_args, get_origin - +from typing_extensions import ( + TypeIs, + Required, + Annotated, + get_args, + get_origin, +) + +from ._utils import lru_cache from .._types import InheritsGeneric -from .._compat import is_union as _is_union +from ._compat import is_union as _is_union def is_annotated_type(typ: type) -> bool: @@ -16,6 +26,11 @@ def is_list_type(typ: type) -> bool: return (get_origin(typ) or typ) == list +def is_sequence_type(typ: type) -> bool: + origin = get_origin(typ) or typ + return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence + + def is_iterable_type(typ: type) -> bool: """If the given type is `typing.Iterable[T]`""" origin = get_origin(typ) or typ @@ -36,7 +51,28 @@ def is_typevar(typ: type) -> bool: return type(typ) == TypeVar # type: ignore +_TYPE_ALIAS_TYPES: tuple[type[typing_extensions.TypeAliasType], ...] = (typing_extensions.TypeAliasType,) +if sys.version_info >= (3, 12): + _TYPE_ALIAS_TYPES = (*_TYPE_ALIAS_TYPES, typing.TypeAliasType) + + +def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasType]: + """Return whether the provided argument is an instance of `TypeAliasType`. + + ```python + type Int = int + is_type_alias_type(Int) + # > True + Str = TypeAliasType("Str", str) + is_type_alias_type(Str) + # > True + ``` + """ + return isinstance(tp, _TYPE_ALIAS_TYPES) + + # Extracts T from Annotated[T, ...] or from Required[Annotated[T, ...]] +@lru_cache(maxsize=8096) def strip_annotated_type(typ: type) -> type: if is_required_type(typ) or is_annotated_type(typ): return strip_annotated_type(cast(type, get_args(typ)[0])) @@ -79,7 +115,7 @@ class MyResponse(Foo[_T]): ``` """ cls = cast(object, get_origin(typ) or typ) - if cls in generic_bases: + if cls in generic_bases: # pyright: ignore[reportUnnecessaryContains] # we're given the class directly return extract_type_arg(typ, index) diff --git a/src/cloudflare/_utils/_utils.py b/src/cloudflare/_utils/_utils.py index 34797c29057..eec7f4a1f23 100644 --- a/src/cloudflare/_utils/_utils.py +++ b/src/cloudflare/_utils/_utils.py @@ -16,12 +16,12 @@ overload, ) from pathlib import Path +from datetime import date, datetime from typing_extensions import TypeGuard import sniffio -from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike -from .._compat import parse_date as parse_date, parse_datetime as parse_datetime +from .._types import Omit, NotGiven, FileTypes, HeadersLike _T = TypeVar("_T") _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...]) @@ -63,7 +63,7 @@ def _extract_items( try: key = path[index] except IndexError: - if isinstance(obj, NotGiven): + if not is_given(obj): # no value was provided - we can safely ignore return [] @@ -71,8 +71,16 @@ def _extract_items( from .._files import assert_is_file_content # We have exhausted the path, return the entry we found. - assert_is_file_content(obj, key=flattened_key) assert flattened_key is not None + + if is_list(obj): + files: list[tuple[str, FileTypes]] = [] + for entry in obj: + assert_is_file_content(entry, key=flattened_key + "[]" if flattened_key else "") + files.append((flattened_key + "[]", cast(FileTypes, entry))) + return files + + assert_is_file_content(obj, key=flattened_key) return [(flattened_key, cast(FileTypes, obj))] index += 1 @@ -118,14 +126,14 @@ def _extract_items( return [] -def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]: - return not isinstance(obj, NotGiven) +def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]: + return not isinstance(obj, NotGiven) and not isinstance(obj, Omit) # Type safe methods for narrowing types with TypeVars. # The default narrowing for isinstance(obj, dict) is dict[unknown, unknown], # however this cause Pyright to rightfully report errors. As we know we don't -# care about the contained types we can safely use `object` in it's place. +# care about the contained types we can safely use `object` in its place. # # There are two separate functions defined, `is_*` and `is_*_t` for different use cases. # `is_*` is for when you're dealing with an unknown input @@ -211,20 +219,17 @@ def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]: Example usage: ```py @overload - def foo(*, a: str) -> str: - ... + def foo(*, a: str) -> str: ... @overload - def foo(*, b: bool) -> str: - ... + def foo(*, b: bool) -> str: ... # This enforces the same constraints that a static type checker would # i.e. that either a or b must be passed to the function @required_args(["a"], ["b"]) - def foo(*, a: str | None = None, b: bool | None = None) -> str: - ... + def foo(*, a: str | None = None, b: bool | None = None) -> str: ... ``` """ @@ -286,18 +291,15 @@ def wrapper(*args: object, **kwargs: object) -> object: @overload -def strip_not_given(obj: None) -> None: - ... +def strip_not_given(obj: None) -> None: ... @overload -def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: - ... +def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ... @overload -def strip_not_given(obj: object) -> object: - ... +def strip_not_given(obj: object) -> object: ... def strip_not_given(obj: object | None) -> object: @@ -369,12 +371,13 @@ def file_from_path(path: str) -> FileTypes: def get_required_header(headers: HeadersLike, header: str) -> str: lower_header = header.lower() - if isinstance(headers, Mapping): - for k, v in headers.items(): + if is_mapping_t(headers): + # mypy doesn't understand the type narrowing here + for k, v in headers.items(): # type: ignore if k.lower() == lower_header and isinstance(v, str): return v - """ to deal with the case where the header looks like Stainless-Event-Id """ + # to deal with the case where the header looks like Stainless-Event-Id intercaps_header = re.sub(r"([^\w])(\w)", lambda pat: pat.group(1) + pat.group(2).upper(), header.capitalize()) for normalized_header in [header, lower_header, header.upper(), intercaps_header]: @@ -400,3 +403,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]: maxsize=maxsize, ) return cast(Any, wrapper) # type: ignore[no-any-return] + + +def json_safe(data: object) -> object: + """Translates a mapping / sequence recursively in the same fashion + as `pydantic` v2's `model_dump(mode="json")`. + """ + if is_mapping(data): + return {json_safe(key): json_safe(value) for key, value in data.items()} + + if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)): + return [json_safe(item) for item in data] + + if isinstance(data, (datetime, date)): + return data.isoformat() + + return data diff --git a/src/cloudflare/_version.py b/src/cloudflare/_version.py index bb20a7d3b8f..d358440ad0c 100644 --- a/src/cloudflare/_version.py +++ b/src/cloudflare/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "cloudflare" -__version__ = "3.1.1" # x-release-please-version +__version__ = "5.0.0-beta.1" # x-release-please-version diff --git a/src/cloudflare/pagination.py b/src/cloudflare/pagination.py index 7d52fed691a..ee3916506ff 100644 --- a/src/cloudflare/pagination.py +++ b/src/cloudflare/pagination.py @@ -17,6 +17,10 @@ "CursorPaginationResultInfo", "SyncCursorPagination", "AsyncCursorPagination", + "CursorPaginationAfterResultInfo", + "CursorPaginationAfterCursors", + "SyncCursorPaginationAfter", + "AsyncCursorPaginationAfter", "CursorLimitPaginationResultInfo", "SyncCursorLimitPagination", "AsyncCursorLimitPagination", @@ -45,7 +49,8 @@ class SyncV4PagePagination(BaseSyncPage[_T], BasePage[_T], Generic[_T]): def _get_page_items(self) -> List[_T]: items = None if self.result is not None: - items = self.result.items + if self.result.items is not None: + items = self.result.items if not items: return [] return items @@ -65,7 +70,8 @@ class AsyncV4PagePagination(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): def _get_page_items(self) -> List[_T]: items = None if self.result is not None: - items = self.result.items + if self.result.items is not None: + items = self.result.items if not items: return [] return items @@ -142,7 +148,8 @@ def _get_page_items(self) -> List[_T]: def next_page_info(self) -> Optional[PageInfo]: cursor = None if self.result_info is not None: - cursor = self.result_info.cursor + if self.result_info.cursor is not None: + cursor = self.result_info.cursor if not cursor: return None @@ -164,13 +171,70 @@ def _get_page_items(self) -> List[_T]: def next_page_info(self) -> Optional[PageInfo]: cursor = None if self.result_info is not None: - cursor = self.result_info.cursor + if self.result_info.cursor is not None: + cursor = self.result_info.cursor if not cursor: return None return PageInfo(params={"cursor": cursor}) +class CursorPaginationAfterCursors(BaseModel): + after: Optional[str] = None + + +class CursorPaginationAfterResultInfo(BaseModel): + cursors: Optional[CursorPaginationAfterCursors] = None + + +class SyncCursorPaginationAfter(BaseSyncPage[_T], BasePage[_T], Generic[_T]): + result: List[_T] + result_info: Optional[CursorPaginationAfterResultInfo] = None + + @override + def _get_page_items(self) -> List[_T]: + result = self.result + if not result: + return [] + return result + + @override + def next_page_info(self) -> Optional[PageInfo]: + after = None + if self.result_info is not None: + if self.result_info.cursors is not None: + if self.result_info.cursors.after is not None: + after = self.result_info.cursors.after + if not after: + return None + + return PageInfo(params={"cursor": after}) + + +class AsyncCursorPaginationAfter(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): + result: List[_T] + result_info: Optional[CursorPaginationAfterResultInfo] = None + + @override + def _get_page_items(self) -> List[_T]: + result = self.result + if not result: + return [] + return result + + @override + def next_page_info(self) -> Optional[PageInfo]: + after = None + if self.result_info is not None: + if self.result_info.cursors is not None: + if self.result_info.cursors.after is not None: + after = self.result_info.cursors.after + if not after: + return None + + return PageInfo(params={"cursor": after}) + + class CursorLimitPaginationResultInfo(BaseModel): count: Optional[int] = None @@ -194,7 +258,8 @@ def _get_page_items(self) -> List[_T]: def next_page_info(self) -> Optional[PageInfo]: cursor = None if self.result_info is not None: - cursor = self.result_info.cursor + if self.result_info.cursor is not None: + cursor = self.result_info.cursor if not cursor: return None @@ -216,7 +281,8 @@ def _get_page_items(self) -> List[_T]: def next_page_info(self) -> Optional[PageInfo]: cursor = None if self.result_info is not None: - cursor = self.result_info.cursor + if self.result_info.cursor is not None: + cursor = self.result_info.cursor if not cursor: return None diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 35be298a563..fd8019a9a1a 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -1,1195 +1 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .d1 import ( - D1Resource, - AsyncD1Resource, - D1ResourceWithRawResponse, - AsyncD1ResourceWithRawResponse, - D1ResourceWithStreamingResponse, - AsyncD1ResourceWithStreamingResponse, -) -from .kv import ( - KVResource, - AsyncKVResource, - KVResourceWithRawResponse, - AsyncKVResourceWithRawResponse, - KVResourceWithStreamingResponse, - AsyncKVResourceWithStreamingResponse, -) -from .r2 import ( - R2Resource, - AsyncR2Resource, - R2ResourceWithRawResponse, - AsyncR2ResourceWithRawResponse, - R2ResourceWithStreamingResponse, - AsyncR2ResourceWithStreamingResponse, -) -from .acm import ( - ACMResource, - AsyncACMResource, - ACMResourceWithRawResponse, - AsyncACMResourceWithRawResponse, - ACMResourceWithStreamingResponse, - AsyncACMResourceWithStreamingResponse, -) -from .dns import ( - DNSResource, - AsyncDNSResource, - DNSResourceWithRawResponse, - AsyncDNSResourceWithRawResponse, - DNSResourceWithStreamingResponse, - AsyncDNSResourceWithStreamingResponse, -) -from .iam import ( - IAMResource, - AsyncIAMResource, - IAMResourceWithRawResponse, - AsyncIAMResourceWithRawResponse, - IAMResourceWithStreamingResponse, - AsyncIAMResourceWithStreamingResponse, -) -from .ips import ( - IPsResource, - AsyncIPsResource, - IPsResourceWithRawResponse, - AsyncIPsResourceWithRawResponse, - IPsResourceWithStreamingResponse, - AsyncIPsResourceWithStreamingResponse, -) -from .rum import ( - RUMResource, - AsyncRUMResource, - RUMResourceWithRawResponse, - AsyncRUMResourceWithRawResponse, - RUMResourceWithStreamingResponse, - AsyncRUMResourceWithStreamingResponse, -) -from .ssl import ( - SSLResource, - AsyncSSLResource, - SSLResourceWithRawResponse, - AsyncSSLResourceWithRawResponse, - SSLResourceWithStreamingResponse, - AsyncSSLResourceWithStreamingResponse, -) -from .argo import ( - ArgoResource, - AsyncArgoResource, - ArgoResourceWithRawResponse, - AsyncArgoResourceWithRawResponse, - ArgoResourceWithStreamingResponse, - AsyncArgoResourceWithStreamingResponse, -) -from .logs import ( - LogsResource, - AsyncLogsResource, - LogsResourceWithRawResponse, - AsyncLogsResourceWithRawResponse, - LogsResourceWithStreamingResponse, - AsyncLogsResourceWithStreamingResponse, -) -from .user import ( - UserResource, - AsyncUserResource, - UserResourceWithRawResponse, - AsyncUserResourceWithRawResponse, - UserResourceWithStreamingResponse, - AsyncUserResourceWithStreamingResponse, -) -from .web3 import ( - Web3Resource, - AsyncWeb3Resource, - Web3ResourceWithRawResponse, - AsyncWeb3ResourceWithRawResponse, - Web3ResourceWithStreamingResponse, - AsyncWeb3ResourceWithStreamingResponse, -) -from .cache import ( - CacheResource, - AsyncCacheResource, - CacheResourceWithRawResponse, - AsyncCacheResourceWithRawResponse, - CacheResourceWithStreamingResponse, - AsyncCacheResourceWithStreamingResponse, -) -from .calls import ( - CallsResource, - AsyncCallsResource, - CallsResourceWithRawResponse, - AsyncCallsResourceWithRawResponse, - CallsResourceWithStreamingResponse, - AsyncCallsResourceWithStreamingResponse, -) -from .intel import ( - IntelResource, - AsyncIntelResource, - IntelResourceWithRawResponse, - AsyncIntelResourceWithRawResponse, - IntelResourceWithStreamingResponse, - AsyncIntelResourceWithStreamingResponse, -) -from .pages import ( - PagesResource, - AsyncPagesResource, - PagesResourceWithRawResponse, - AsyncPagesResourceWithRawResponse, - PagesResourceWithStreamingResponse, - AsyncPagesResourceWithStreamingResponse, -) -from .pcaps import ( - PCAPsResource, - AsyncPCAPsResource, - PCAPsResourceWithRawResponse, - AsyncPCAPsResourceWithRawResponse, - PCAPsResourceWithStreamingResponse, - AsyncPCAPsResourceWithStreamingResponse, -) -from .plans import ( - PlansResource, - AsyncPlansResource, - PlansResourceWithRawResponse, - AsyncPlansResourceWithRawResponse, - PlansResourceWithStreamingResponse, - AsyncPlansResourceWithStreamingResponse, -) -from .radar import ( - RadarResource, - AsyncRadarResource, - RadarResourceWithRawResponse, - AsyncRadarResourceWithRawResponse, - RadarResourceWithStreamingResponse, - AsyncRadarResourceWithStreamingResponse, -) -from .rules import ( - RulesResource, - AsyncRulesResource, - RulesResourceWithRawResponse, - AsyncRulesResourceWithRawResponse, - RulesResourceWithStreamingResponse, - AsyncRulesResourceWithStreamingResponse, -) -from .speed import ( - SpeedResource, - AsyncSpeedResource, - SpeedResourceWithRawResponse, - AsyncSpeedResourceWithRawResponse, - SpeedResourceWithStreamingResponse, - AsyncSpeedResourceWithStreamingResponse, -) -from .zones import ( - ZonesResource, - AsyncZonesResource, - ZonesResourceWithRawResponse, - AsyncZonesResourceWithRawResponse, - ZonesResourceWithStreamingResponse, - AsyncZonesResourceWithStreamingResponse, -) -from .dnssec import ( - DNSSECResource, - AsyncDNSSECResource, - DNSSECResourceWithRawResponse, - AsyncDNSSECResourceWithRawResponse, - DNSSECResourceWithStreamingResponse, - AsyncDNSSECResourceWithStreamingResponse, -) -from .images import ( - ImagesResource, - AsyncImagesResource, - ImagesResourceWithRawResponse, - AsyncImagesResourceWithRawResponse, - ImagesResourceWithStreamingResponse, - AsyncImagesResourceWithStreamingResponse, -) -from .queues import ( - QueuesResource, - AsyncQueuesResource, - QueuesResourceWithRawResponse, - AsyncQueuesResourceWithRawResponse, - QueuesResourceWithStreamingResponse, - AsyncQueuesResourceWithStreamingResponse, -) -from .stream import ( - StreamResource, - AsyncStreamResource, - StreamResourceWithRawResponse, - AsyncStreamResourceWithRawResponse, - StreamResourceWithStreamingResponse, - AsyncStreamResourceWithStreamingResponse, -) -from .billing import ( - BillingResource, - AsyncBillingResource, - BillingResourceWithRawResponse, - AsyncBillingResourceWithRawResponse, - BillingResourceWithStreamingResponse, - AsyncBillingResourceWithStreamingResponse, -) -from .filters import ( - FiltersResource, - AsyncFiltersResource, - FiltersResourceWithRawResponse, - AsyncFiltersResourceWithRawResponse, - FiltersResourceWithStreamingResponse, - AsyncFiltersResourceWithStreamingResponse, -) -from .logpush import ( - LogpushResource, - AsyncLogpushResource, - LogpushResourceWithRawResponse, - AsyncLogpushResourceWithRawResponse, - LogpushResourceWithStreamingResponse, - AsyncLogpushResourceWithStreamingResponse, -) -from .storage import ( - StorageResource, - AsyncStorageResource, - StorageResourceWithRawResponse, - AsyncStorageResourceWithRawResponse, - StorageResourceWithStreamingResponse, - AsyncStorageResourceWithStreamingResponse, -) -from .workers import ( - WorkersResource, - AsyncWorkersResource, - WorkersResourceWithRawResponse, - AsyncWorkersResourceWithRawResponse, - WorkersResourceWithStreamingResponse, - AsyncWorkersResourceWithStreamingResponse, -) -from .accounts import ( - AccountsResource, - AsyncAccountsResource, - AccountsResourceWithRawResponse, - AsyncAccountsResourceWithRawResponse, - AccountsResourceWithStreamingResponse, - AsyncAccountsResourceWithStreamingResponse, -) -from .alerting import ( - AlertingResource, - AsyncAlertingResource, - AlertingResourceWithRawResponse, - AsyncAlertingResourceWithRawResponse, - AlertingResourceWithStreamingResponse, - AsyncAlertingResourceWithStreamingResponse, -) -from .firewall import ( - FirewallResource, - AsyncFirewallResource, - FirewallResourceWithRawResponse, - AsyncFirewallResourceWithRawResponse, - FirewallResourceWithStreamingResponse, - AsyncFirewallResourceWithStreamingResponse, -) -from .rulesets import ( - RulesetsResource, - AsyncRulesetsResource, - RulesetsResourceWithRawResponse, - AsyncRulesetsResourceWithRawResponse, - RulesetsResourceWithStreamingResponse, - AsyncRulesetsResourceWithStreamingResponse, -) -from .snippets import ( - SnippetsResource, - AsyncSnippetsResource, - SnippetsResourceWithRawResponse, - AsyncSnippetsResourceWithRawResponse, - SnippetsResourceWithStreamingResponse, - AsyncSnippetsResourceWithStreamingResponse, -) -from .spectrum import ( - SpectrumResource, - AsyncSpectrumResource, - SpectrumResourceWithRawResponse, - AsyncSpectrumResourceWithRawResponse, - SpectrumResourceWithStreamingResponse, - AsyncSpectrumResourceWithStreamingResponse, -) -from .hostnames import ( - HostnamesResource, - AsyncHostnamesResource, - HostnamesResourceWithRawResponse, - AsyncHostnamesResourceWithRawResponse, - HostnamesResourceWithStreamingResponse, - AsyncHostnamesResourceWithStreamingResponse, -) -from .pagerules import ( - PagerulesResource, - AsyncPagerulesResource, - PagerulesResourceWithRawResponse, - AsyncPagerulesResourceWithRawResponse, - PagerulesResourceWithStreamingResponse, - AsyncPagerulesResourceWithStreamingResponse, -) -from .registrar import ( - RegistrarResource, - AsyncRegistrarResource, - RegistrarResourceWithRawResponse, - AsyncRegistrarResourceWithRawResponse, - RegistrarResourceWithStreamingResponse, - AsyncRegistrarResourceWithStreamingResponse, -) -from .vectorize import ( - VectorizeResource, - AsyncVectorizeResource, - VectorizeResourceWithRawResponse, - AsyncVectorizeResourceWithRawResponse, - VectorizeResourceWithStreamingResponse, - AsyncVectorizeResourceWithStreamingResponse, -) -from .addressing import ( - AddressingResource, - AsyncAddressingResource, - AddressingResourceWithRawResponse, - AsyncAddressingResourceWithRawResponse, - AddressingResourceWithStreamingResponse, - AsyncAddressingResourceWithStreamingResponse, -) -from .ai_gateway import ( - AIGatewayResource, - AsyncAIGatewayResource, - AIGatewayResourceWithRawResponse, - AsyncAIGatewayResourceWithRawResponse, - AIGatewayResourceWithStreamingResponse, - AsyncAIGatewayResourceWithStreamingResponse, -) -from .audit_logs import ( - AuditLogsResource, - AsyncAuditLogsResource, - AuditLogsResourceWithRawResponse, - AsyncAuditLogsResourceWithRawResponse, - AuditLogsResourceWithStreamingResponse, - AsyncAuditLogsResourceWithStreamingResponse, -) -from .challenges import ( - ChallengesResource, - AsyncChallengesResource, - ChallengesResourceWithRawResponse, - AsyncChallengesResourceWithRawResponse, - ChallengesResourceWithStreamingResponse, - AsyncChallengesResourceWithStreamingResponse, -) -from .hyperdrive import ( - HyperdriveResource, - AsyncHyperdriveResource, - HyperdriveResourceWithRawResponse, - AsyncHyperdriveResourceWithRawResponse, - HyperdriveResourceWithStreamingResponse, - AsyncHyperdriveResourceWithStreamingResponse, -) -from .rate_plans import ( - RatePlansResource, - AsyncRatePlansResource, - RatePlansResourceWithRawResponse, - AsyncRatePlansResourceWithRawResponse, - RatePlansResourceWithStreamingResponse, - AsyncRatePlansResourceWithStreamingResponse, -) -from .zero_trust import ( - ZeroTrustResource, - AsyncZeroTrustResource, - ZeroTrustResourceWithRawResponse, - AsyncZeroTrustResourceWithRawResponse, - ZeroTrustResourceWithStreamingResponse, - AsyncZeroTrustResourceWithStreamingResponse, -) -from .api_gateway import ( - APIGatewayResource, - AsyncAPIGatewayResource, - APIGatewayResourceWithRawResponse, - AsyncAPIGatewayResourceWithRawResponse, - APIGatewayResourceWithStreamingResponse, - AsyncAPIGatewayResourceWithStreamingResponse, -) -from .diagnostics import ( - DiagnosticsResource, - AsyncDiagnosticsResource, - DiagnosticsResourceWithRawResponse, - AsyncDiagnosticsResourceWithRawResponse, - DiagnosticsResourceWithStreamingResponse, - AsyncDiagnosticsResourceWithStreamingResponse, -) -from .memberships import ( - MembershipsResource, - AsyncMembershipsResource, - MembershipsResourceWithRawResponse, - AsyncMembershipsResourceWithRawResponse, - MembershipsResourceWithStreamingResponse, - AsyncMembershipsResourceWithStreamingResponse, -) -from .page_shield import ( - PageShieldResource, - AsyncPageShieldResource, - PageShieldResourceWithRawResponse, - AsyncPageShieldResourceWithRawResponse, - PageShieldResourceWithStreamingResponse, - AsyncPageShieldResourceWithStreamingResponse, -) -from .rate_limits import ( - RateLimitsResource, - AsyncRateLimitsResource, - RateLimitsResourceWithRawResponse, - AsyncRateLimitsResourceWithRawResponse, - RateLimitsResourceWithStreamingResponse, - AsyncRateLimitsResourceWithStreamingResponse, -) -from .url_scanner import ( - URLScannerResource, - AsyncURLScannerResource, - URLScannerResourceWithRawResponse, - AsyncURLScannerResourceWithRawResponse, - URLScannerResourceWithStreamingResponse, - AsyncURLScannerResourceWithStreamingResponse, -) -from .healthchecks import ( - HealthchecksResource, - AsyncHealthchecksResource, - HealthchecksResourceWithRawResponse, - AsyncHealthchecksResourceWithRawResponse, - HealthchecksResourceWithStreamingResponse, - AsyncHealthchecksResourceWithStreamingResponse, -) -from .email_routing import ( - EmailRoutingResource, - AsyncEmailRoutingResource, - EmailRoutingResourceWithRawResponse, - AsyncEmailRoutingResourceWithRawResponse, - EmailRoutingResourceWithStreamingResponse, - AsyncEmailRoutingResourceWithStreamingResponse, -) -from .magic_transit import ( - MagicTransitResource, - AsyncMagicTransitResource, - MagicTransitResourceWithRawResponse, - AsyncMagicTransitResourceWithRawResponse, - MagicTransitResourceWithStreamingResponse, - AsyncMagicTransitResourceWithStreamingResponse, -) -from .secondary_dns import ( - SecondaryDNSResource, - AsyncSecondaryDNSResource, - SecondaryDNSResourceWithRawResponse, - AsyncSecondaryDNSResourceWithRawResponse, - SecondaryDNSResourceWithStreamingResponse, - AsyncSecondaryDNSResourceWithStreamingResponse, -) -from .subscriptions import ( - SubscriptionsResource, - AsyncSubscriptionsResource, - SubscriptionsResourceWithRawResponse, - AsyncSubscriptionsResourceWithRawResponse, - SubscriptionsResourceWithStreamingResponse, - AsyncSubscriptionsResourceWithStreamingResponse, -) -from .waiting_rooms import ( - WaitingRoomsResource, - AsyncWaitingRoomsResource, - WaitingRoomsResourceWithRawResponse, - AsyncWaitingRoomsResourceWithRawResponse, - WaitingRoomsResourceWithStreamingResponse, - AsyncWaitingRoomsResourceWithStreamingResponse, -) -from .bot_management import ( - BotManagementResource, - AsyncBotManagementResource, - BotManagementResourceWithRawResponse, - AsyncBotManagementResourceWithRawResponse, - BotManagementResourceWithStreamingResponse, - AsyncBotManagementResourceWithStreamingResponse, -) -from .cloudforce_one import ( - CloudforceOneResource, - AsyncCloudforceOneResource, - CloudforceOneResourceWithRawResponse, - AsyncCloudforceOneResourceWithRawResponse, - CloudforceOneResourceWithStreamingResponse, - AsyncCloudforceOneResourceWithStreamingResponse, -) -from .dcv_delegation import ( - DCVDelegationResource, - AsyncDCVDelegationResource, - DCVDelegationResourceWithRawResponse, - AsyncDCVDelegationResourceWithRawResponse, - DCVDelegationResourceWithStreamingResponse, - AsyncDCVDelegationResourceWithStreamingResponse, -) -from .load_balancers import ( - LoadBalancersResource, - AsyncLoadBalancersResource, - LoadBalancersResourceWithRawResponse, - AsyncLoadBalancersResourceWithRawResponse, - LoadBalancersResourceWithStreamingResponse, - AsyncLoadBalancersResourceWithStreamingResponse, -) -from .warp_connector import ( - WARPConnectorResource, - AsyncWARPConnectorResource, - WARPConnectorResourceWithRawResponse, - AsyncWARPConnectorResourceWithRawResponse, - WARPConnectorResourceWithStreamingResponse, - AsyncWARPConnectorResourceWithStreamingResponse, -) -from .cloud_connector import ( - CloudConnectorResource, - AsyncCloudConnectorResource, - CloudConnectorResourceWithRawResponse, - AsyncCloudConnectorResourceWithRawResponse, - CloudConnectorResourceWithStreamingResponse, - AsyncCloudConnectorResourceWithStreamingResponse, -) -from .durable_objects import ( - DurableObjectsResource, - AsyncDurableObjectsResource, - DurableObjectsResourceWithRawResponse, - AsyncDurableObjectsResourceWithRawResponse, - DurableObjectsResourceWithStreamingResponse, - AsyncDurableObjectsResourceWithStreamingResponse, -) -from .managed_headers import ( - ManagedHeadersResource, - AsyncManagedHeadersResource, - ManagedHeadersResourceWithRawResponse, - AsyncManagedHeadersResourceWithRawResponse, - ManagedHeadersResourceWithStreamingResponse, - AsyncManagedHeadersResourceWithStreamingResponse, -) -from .request_tracers import ( - RequestTracersResource, - AsyncRequestTracersResource, - RequestTracersResourceWithRawResponse, - AsyncRequestTracersResourceWithRawResponse, - RequestTracersResourceWithStreamingResponse, - AsyncRequestTracersResourceWithStreamingResponse, -) -from .brand_protection import ( - BrandProtectionResource, - AsyncBrandProtectionResource, - BrandProtectionResourceWithRawResponse, - AsyncBrandProtectionResourceWithRawResponse, - BrandProtectionResourceWithStreamingResponse, - AsyncBrandProtectionResourceWithStreamingResponse, -) -from .custom_hostnames import ( - CustomHostnamesResource, - AsyncCustomHostnamesResource, - CustomHostnamesResourceWithRawResponse, - AsyncCustomHostnamesResourceWithRawResponse, - CustomHostnamesResourceWithStreamingResponse, - AsyncCustomHostnamesResourceWithStreamingResponse, -) -from .mtls_certificates import ( - MTLSCertificatesResource, - AsyncMTLSCertificatesResource, - MTLSCertificatesResourceWithRawResponse, - AsyncMTLSCertificatesResourceWithRawResponse, - MTLSCertificatesResourceWithStreamingResponse, - AsyncMTLSCertificatesResourceWithStreamingResponse, -) -from .url_normalization import ( - URLNormalizationResource, - AsyncURLNormalizationResource, - URLNormalizationResourceWithRawResponse, - AsyncURLNormalizationResourceWithRawResponse, - URLNormalizationResourceWithStreamingResponse, - AsyncURLNormalizationResourceWithStreamingResponse, -) -from .custom_nameservers import ( - CustomNameserversResource, - AsyncCustomNameserversResource, - CustomNameserversResourceWithRawResponse, - AsyncCustomNameserversResourceWithRawResponse, - CustomNameserversResourceWithStreamingResponse, - AsyncCustomNameserversResourceWithStreamingResponse, -) -from .client_certificates import ( - ClientCertificatesResource, - AsyncClientCertificatesResource, - ClientCertificatesResourceWithRawResponse, - AsyncClientCertificatesResourceWithRawResponse, - ClientCertificatesResourceWithStreamingResponse, - AsyncClientCertificatesResourceWithStreamingResponse, -) -from .custom_certificates import ( - CustomCertificatesResource, - AsyncCustomCertificatesResource, - CustomCertificatesResourceWithRawResponse, - AsyncCustomCertificatesResourceWithRawResponse, - CustomCertificatesResourceWithStreamingResponse, - AsyncCustomCertificatesResourceWithStreamingResponse, -) -from .event_notifications import ( - EventNotificationsResource, - AsyncEventNotificationsResource, - EventNotificationsResourceWithRawResponse, - AsyncEventNotificationsResourceWithRawResponse, - EventNotificationsResourceWithStreamingResponse, - AsyncEventNotificationsResourceWithStreamingResponse, -) -from .keyless_certificates import ( - KeylessCertificatesResource, - AsyncKeylessCertificatesResource, - KeylessCertificatesResourceWithRawResponse, - AsyncKeylessCertificatesResourceWithRawResponse, - KeylessCertificatesResourceWithStreamingResponse, - AsyncKeylessCertificatesResourceWithStreamingResponse, -) -from .workers_for_platforms import ( - WorkersForPlatformsResource, - AsyncWorkersForPlatformsResource, - WorkersForPlatformsResourceWithRawResponse, - AsyncWorkersForPlatformsResourceWithRawResponse, - WorkersForPlatformsResourceWithStreamingResponse, - AsyncWorkersForPlatformsResourceWithStreamingResponse, -) -from .origin_ca_certificates import ( - OriginCACertificatesResource, - AsyncOriginCACertificatesResource, - OriginCACertificatesResourceWithRawResponse, - AsyncOriginCACertificatesResourceWithRawResponse, - OriginCACertificatesResourceWithStreamingResponse, - AsyncOriginCACertificatesResourceWithStreamingResponse, -) -from .origin_tls_client_auth import ( - OriginTLSClientAuthResource, - AsyncOriginTLSClientAuthResource, - OriginTLSClientAuthResourceWithRawResponse, - AsyncOriginTLSClientAuthResourceWithRawResponse, - OriginTLSClientAuthResourceWithStreamingResponse, - AsyncOriginTLSClientAuthResourceWithStreamingResponse, -) -from .certificate_authorities import ( - CertificateAuthoritiesResource, - AsyncCertificateAuthoritiesResource, - CertificateAuthoritiesResourceWithRawResponse, - AsyncCertificateAuthoritiesResourceWithRawResponse, - CertificateAuthoritiesResourceWithStreamingResponse, - AsyncCertificateAuthoritiesResourceWithStreamingResponse, -) -from .magic_network_monitoring import ( - MagicNetworkMonitoringResource, - AsyncMagicNetworkMonitoringResource, - MagicNetworkMonitoringResourceWithRawResponse, - AsyncMagicNetworkMonitoringResourceWithRawResponse, - MagicNetworkMonitoringResourceWithStreamingResponse, - AsyncMagicNetworkMonitoringResourceWithStreamingResponse, -) -from .origin_post_quantum_encryption import ( - OriginPostQuantumEncryptionResource, - AsyncOriginPostQuantumEncryptionResource, - OriginPostQuantumEncryptionResourceWithRawResponse, - AsyncOriginPostQuantumEncryptionResourceWithRawResponse, - OriginPostQuantumEncryptionResourceWithStreamingResponse, - AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse, -) - -__all__ = [ - "AccountsResource", - "AsyncAccountsResource", - "AccountsResourceWithRawResponse", - "AsyncAccountsResourceWithRawResponse", - "AccountsResourceWithStreamingResponse", - "AsyncAccountsResourceWithStreamingResponse", - "OriginCACertificatesResource", - "AsyncOriginCACertificatesResource", - "OriginCACertificatesResourceWithRawResponse", - "AsyncOriginCACertificatesResourceWithRawResponse", - "OriginCACertificatesResourceWithStreamingResponse", - "AsyncOriginCACertificatesResourceWithStreamingResponse", - "IPsResource", - "AsyncIPsResource", - "IPsResourceWithRawResponse", - "AsyncIPsResourceWithRawResponse", - "IPsResourceWithStreamingResponse", - "AsyncIPsResourceWithStreamingResponse", - "MembershipsResource", - "AsyncMembershipsResource", - "MembershipsResourceWithRawResponse", - "AsyncMembershipsResourceWithRawResponse", - "MembershipsResourceWithStreamingResponse", - "AsyncMembershipsResourceWithStreamingResponse", - "UserResource", - "AsyncUserResource", - "UserResourceWithRawResponse", - "AsyncUserResourceWithRawResponse", - "UserResourceWithStreamingResponse", - "AsyncUserResourceWithStreamingResponse", - "ZonesResource", - "AsyncZonesResource", - "ZonesResourceWithRawResponse", - "AsyncZonesResourceWithRawResponse", - "ZonesResourceWithStreamingResponse", - "AsyncZonesResourceWithStreamingResponse", - "LoadBalancersResource", - "AsyncLoadBalancersResource", - "LoadBalancersResourceWithRawResponse", - "AsyncLoadBalancersResourceWithRawResponse", - "LoadBalancersResourceWithStreamingResponse", - "AsyncLoadBalancersResourceWithStreamingResponse", - "CacheResource", - "AsyncCacheResource", - "CacheResourceWithRawResponse", - "AsyncCacheResourceWithRawResponse", - "CacheResourceWithStreamingResponse", - "AsyncCacheResourceWithStreamingResponse", - "SSLResource", - "AsyncSSLResource", - "SSLResourceWithRawResponse", - "AsyncSSLResourceWithRawResponse", - "SSLResourceWithStreamingResponse", - "AsyncSSLResourceWithStreamingResponse", - "SubscriptionsResource", - "AsyncSubscriptionsResource", - "SubscriptionsResourceWithRawResponse", - "AsyncSubscriptionsResourceWithRawResponse", - "SubscriptionsResourceWithStreamingResponse", - "AsyncSubscriptionsResourceWithStreamingResponse", - "ACMResource", - "AsyncACMResource", - "ACMResourceWithRawResponse", - "AsyncACMResourceWithRawResponse", - "ACMResourceWithStreamingResponse", - "AsyncACMResourceWithStreamingResponse", - "ArgoResource", - "AsyncArgoResource", - "ArgoResourceWithRawResponse", - "AsyncArgoResourceWithRawResponse", - "ArgoResourceWithStreamingResponse", - "AsyncArgoResourceWithStreamingResponse", - "PlansResource", - "AsyncPlansResource", - "PlansResourceWithRawResponse", - "AsyncPlansResourceWithRawResponse", - "PlansResourceWithStreamingResponse", - "AsyncPlansResourceWithStreamingResponse", - "RatePlansResource", - "AsyncRatePlansResource", - "RatePlansResourceWithRawResponse", - "AsyncRatePlansResourceWithRawResponse", - "RatePlansResourceWithStreamingResponse", - "AsyncRatePlansResourceWithStreamingResponse", - "CertificateAuthoritiesResource", - "AsyncCertificateAuthoritiesResource", - "CertificateAuthoritiesResourceWithRawResponse", - "AsyncCertificateAuthoritiesResourceWithRawResponse", - "CertificateAuthoritiesResourceWithStreamingResponse", - "AsyncCertificateAuthoritiesResourceWithStreamingResponse", - "ClientCertificatesResource", - "AsyncClientCertificatesResource", - "ClientCertificatesResourceWithRawResponse", - "AsyncClientCertificatesResourceWithRawResponse", - "ClientCertificatesResourceWithStreamingResponse", - "AsyncClientCertificatesResourceWithStreamingResponse", - "CustomCertificatesResource", - "AsyncCustomCertificatesResource", - "CustomCertificatesResourceWithRawResponse", - "AsyncCustomCertificatesResourceWithRawResponse", - "CustomCertificatesResourceWithStreamingResponse", - "AsyncCustomCertificatesResourceWithStreamingResponse", - "CustomHostnamesResource", - "AsyncCustomHostnamesResource", - "CustomHostnamesResourceWithRawResponse", - "AsyncCustomHostnamesResourceWithRawResponse", - "CustomHostnamesResourceWithStreamingResponse", - "AsyncCustomHostnamesResourceWithStreamingResponse", - "CustomNameserversResource", - "AsyncCustomNameserversResource", - "CustomNameserversResourceWithRawResponse", - "AsyncCustomNameserversResourceWithRawResponse", - "CustomNameserversResourceWithStreamingResponse", - "AsyncCustomNameserversResourceWithStreamingResponse", - "DNSResource", - "AsyncDNSResource", - "DNSResourceWithRawResponse", - "AsyncDNSResourceWithRawResponse", - "DNSResourceWithStreamingResponse", - "AsyncDNSResourceWithStreamingResponse", - "DNSSECResource", - "AsyncDNSSECResource", - "DNSSECResourceWithRawResponse", - "AsyncDNSSECResourceWithRawResponse", - "DNSSECResourceWithStreamingResponse", - "AsyncDNSSECResourceWithStreamingResponse", - "EmailRoutingResource", - "AsyncEmailRoutingResource", - "EmailRoutingResourceWithRawResponse", - "AsyncEmailRoutingResourceWithRawResponse", - "EmailRoutingResourceWithStreamingResponse", - "AsyncEmailRoutingResourceWithStreamingResponse", - "FiltersResource", - "AsyncFiltersResource", - "FiltersResourceWithRawResponse", - "AsyncFiltersResourceWithRawResponse", - "FiltersResourceWithStreamingResponse", - "AsyncFiltersResourceWithStreamingResponse", - "FirewallResource", - "AsyncFirewallResource", - "FirewallResourceWithRawResponse", - "AsyncFirewallResourceWithRawResponse", - "FirewallResourceWithStreamingResponse", - "AsyncFirewallResourceWithStreamingResponse", - "HealthchecksResource", - "AsyncHealthchecksResource", - "HealthchecksResourceWithRawResponse", - "AsyncHealthchecksResourceWithRawResponse", - "HealthchecksResourceWithStreamingResponse", - "AsyncHealthchecksResourceWithStreamingResponse", - "KeylessCertificatesResource", - "AsyncKeylessCertificatesResource", - "KeylessCertificatesResourceWithRawResponse", - "AsyncKeylessCertificatesResourceWithRawResponse", - "KeylessCertificatesResourceWithStreamingResponse", - "AsyncKeylessCertificatesResourceWithStreamingResponse", - "LogpushResource", - "AsyncLogpushResource", - "LogpushResourceWithRawResponse", - "AsyncLogpushResourceWithRawResponse", - "LogpushResourceWithStreamingResponse", - "AsyncLogpushResourceWithStreamingResponse", - "LogsResource", - "AsyncLogsResource", - "LogsResourceWithRawResponse", - "AsyncLogsResourceWithRawResponse", - "LogsResourceWithStreamingResponse", - "AsyncLogsResourceWithStreamingResponse", - "OriginTLSClientAuthResource", - "AsyncOriginTLSClientAuthResource", - "OriginTLSClientAuthResourceWithRawResponse", - "AsyncOriginTLSClientAuthResourceWithRawResponse", - "OriginTLSClientAuthResourceWithStreamingResponse", - "AsyncOriginTLSClientAuthResourceWithStreamingResponse", - "PagerulesResource", - "AsyncPagerulesResource", - "PagerulesResourceWithRawResponse", - "AsyncPagerulesResourceWithRawResponse", - "PagerulesResourceWithStreamingResponse", - "AsyncPagerulesResourceWithStreamingResponse", - "RateLimitsResource", - "AsyncRateLimitsResource", - "RateLimitsResourceWithRawResponse", - "AsyncRateLimitsResourceWithRawResponse", - "RateLimitsResourceWithStreamingResponse", - "AsyncRateLimitsResourceWithStreamingResponse", - "SecondaryDNSResource", - "AsyncSecondaryDNSResource", - "SecondaryDNSResourceWithRawResponse", - "AsyncSecondaryDNSResourceWithRawResponse", - "SecondaryDNSResourceWithStreamingResponse", - "AsyncSecondaryDNSResourceWithStreamingResponse", - "WaitingRoomsResource", - "AsyncWaitingRoomsResource", - "WaitingRoomsResourceWithRawResponse", - "AsyncWaitingRoomsResourceWithRawResponse", - "WaitingRoomsResourceWithStreamingResponse", - "AsyncWaitingRoomsResourceWithStreamingResponse", - "Web3Resource", - "AsyncWeb3Resource", - "Web3ResourceWithRawResponse", - "AsyncWeb3ResourceWithRawResponse", - "Web3ResourceWithStreamingResponse", - "AsyncWeb3ResourceWithStreamingResponse", - "WorkersResource", - "AsyncWorkersResource", - "WorkersResourceWithRawResponse", - "AsyncWorkersResourceWithRawResponse", - "WorkersResourceWithStreamingResponse", - "AsyncWorkersResourceWithStreamingResponse", - "KVResource", - "AsyncKVResource", - "KVResourceWithRawResponse", - "AsyncKVResourceWithRawResponse", - "KVResourceWithStreamingResponse", - "AsyncKVResourceWithStreamingResponse", - "DurableObjectsResource", - "AsyncDurableObjectsResource", - "DurableObjectsResourceWithRawResponse", - "AsyncDurableObjectsResourceWithRawResponse", - "DurableObjectsResourceWithStreamingResponse", - "AsyncDurableObjectsResourceWithStreamingResponse", - "QueuesResource", - "AsyncQueuesResource", - "QueuesResourceWithRawResponse", - "AsyncQueuesResourceWithRawResponse", - "QueuesResourceWithStreamingResponse", - "AsyncQueuesResourceWithStreamingResponse", - "APIGatewayResource", - "AsyncAPIGatewayResource", - "APIGatewayResourceWithRawResponse", - "AsyncAPIGatewayResourceWithRawResponse", - "APIGatewayResourceWithStreamingResponse", - "AsyncAPIGatewayResourceWithStreamingResponse", - "ManagedHeadersResource", - "AsyncManagedHeadersResource", - "ManagedHeadersResourceWithRawResponse", - "AsyncManagedHeadersResourceWithRawResponse", - "ManagedHeadersResourceWithStreamingResponse", - "AsyncManagedHeadersResourceWithStreamingResponse", - "PageShieldResource", - "AsyncPageShieldResource", - "PageShieldResourceWithRawResponse", - "AsyncPageShieldResourceWithRawResponse", - "PageShieldResourceWithStreamingResponse", - "AsyncPageShieldResourceWithStreamingResponse", - "RulesetsResource", - "AsyncRulesetsResource", - "RulesetsResourceWithRawResponse", - "AsyncRulesetsResourceWithRawResponse", - "RulesetsResourceWithStreamingResponse", - "AsyncRulesetsResourceWithStreamingResponse", - "URLNormalizationResource", - "AsyncURLNormalizationResource", - "URLNormalizationResourceWithRawResponse", - "AsyncURLNormalizationResourceWithRawResponse", - "URLNormalizationResourceWithStreamingResponse", - "AsyncURLNormalizationResourceWithStreamingResponse", - "SpectrumResource", - "AsyncSpectrumResource", - "SpectrumResourceWithRawResponse", - "AsyncSpectrumResourceWithRawResponse", - "SpectrumResourceWithStreamingResponse", - "AsyncSpectrumResourceWithStreamingResponse", - "AddressingResource", - "AsyncAddressingResource", - "AddressingResourceWithRawResponse", - "AsyncAddressingResourceWithRawResponse", - "AddressingResourceWithStreamingResponse", - "AsyncAddressingResourceWithStreamingResponse", - "AuditLogsResource", - "AsyncAuditLogsResource", - "AuditLogsResourceWithRawResponse", - "AsyncAuditLogsResourceWithRawResponse", - "AuditLogsResourceWithStreamingResponse", - "AsyncAuditLogsResourceWithStreamingResponse", - "BillingResource", - "AsyncBillingResource", - "BillingResourceWithRawResponse", - "AsyncBillingResourceWithRawResponse", - "BillingResourceWithStreamingResponse", - "AsyncBillingResourceWithStreamingResponse", - "BrandProtectionResource", - "AsyncBrandProtectionResource", - "BrandProtectionResourceWithRawResponse", - "AsyncBrandProtectionResourceWithRawResponse", - "BrandProtectionResourceWithStreamingResponse", - "AsyncBrandProtectionResourceWithStreamingResponse", - "DiagnosticsResource", - "AsyncDiagnosticsResource", - "DiagnosticsResourceWithRawResponse", - "AsyncDiagnosticsResourceWithRawResponse", - "DiagnosticsResourceWithStreamingResponse", - "AsyncDiagnosticsResourceWithStreamingResponse", - "ImagesResource", - "AsyncImagesResource", - "ImagesResourceWithRawResponse", - "AsyncImagesResourceWithRawResponse", - "ImagesResourceWithStreamingResponse", - "AsyncImagesResourceWithStreamingResponse", - "IntelResource", - "AsyncIntelResource", - "IntelResourceWithRawResponse", - "AsyncIntelResourceWithRawResponse", - "IntelResourceWithStreamingResponse", - "AsyncIntelResourceWithStreamingResponse", - "MagicTransitResource", - "AsyncMagicTransitResource", - "MagicTransitResourceWithRawResponse", - "AsyncMagicTransitResourceWithRawResponse", - "MagicTransitResourceWithStreamingResponse", - "AsyncMagicTransitResourceWithStreamingResponse", - "MagicNetworkMonitoringResource", - "AsyncMagicNetworkMonitoringResource", - "MagicNetworkMonitoringResourceWithRawResponse", - "AsyncMagicNetworkMonitoringResourceWithRawResponse", - "MagicNetworkMonitoringResourceWithStreamingResponse", - "AsyncMagicNetworkMonitoringResourceWithStreamingResponse", - "MTLSCertificatesResource", - "AsyncMTLSCertificatesResource", - "MTLSCertificatesResourceWithRawResponse", - "AsyncMTLSCertificatesResourceWithRawResponse", - "MTLSCertificatesResourceWithStreamingResponse", - "AsyncMTLSCertificatesResourceWithStreamingResponse", - "PagesResource", - "AsyncPagesResource", - "PagesResourceWithRawResponse", - "AsyncPagesResourceWithRawResponse", - "PagesResourceWithStreamingResponse", - "AsyncPagesResourceWithStreamingResponse", - "PCAPsResource", - "AsyncPCAPsResource", - "PCAPsResourceWithRawResponse", - "AsyncPCAPsResourceWithRawResponse", - "PCAPsResourceWithStreamingResponse", - "AsyncPCAPsResourceWithStreamingResponse", - "RegistrarResource", - "AsyncRegistrarResource", - "RegistrarResourceWithRawResponse", - "AsyncRegistrarResourceWithRawResponse", - "RegistrarResourceWithStreamingResponse", - "AsyncRegistrarResourceWithStreamingResponse", - "RequestTracersResource", - "AsyncRequestTracersResource", - "RequestTracersResourceWithRawResponse", - "AsyncRequestTracersResourceWithRawResponse", - "RequestTracersResourceWithStreamingResponse", - "AsyncRequestTracersResourceWithStreamingResponse", - "RulesResource", - "AsyncRulesResource", - "RulesResourceWithRawResponse", - "AsyncRulesResourceWithRawResponse", - "RulesResourceWithStreamingResponse", - "AsyncRulesResourceWithStreamingResponse", - "StorageResource", - "AsyncStorageResource", - "StorageResourceWithRawResponse", - "AsyncStorageResourceWithRawResponse", - "StorageResourceWithStreamingResponse", - "AsyncStorageResourceWithStreamingResponse", - "StreamResource", - "AsyncStreamResource", - "StreamResourceWithRawResponse", - "AsyncStreamResourceWithRawResponse", - "StreamResourceWithStreamingResponse", - "AsyncStreamResourceWithStreamingResponse", - "AlertingResource", - "AsyncAlertingResource", - "AlertingResourceWithRawResponse", - "AsyncAlertingResourceWithRawResponse", - "AlertingResourceWithStreamingResponse", - "AsyncAlertingResourceWithStreamingResponse", - "D1Resource", - "AsyncD1Resource", - "D1ResourceWithRawResponse", - "AsyncD1ResourceWithRawResponse", - "D1ResourceWithStreamingResponse", - "AsyncD1ResourceWithStreamingResponse", - "R2Resource", - "AsyncR2Resource", - "R2ResourceWithRawResponse", - "AsyncR2ResourceWithRawResponse", - "R2ResourceWithStreamingResponse", - "AsyncR2ResourceWithStreamingResponse", - "WARPConnectorResource", - "AsyncWARPConnectorResource", - "WARPConnectorResourceWithRawResponse", - "AsyncWARPConnectorResourceWithRawResponse", - "WARPConnectorResourceWithStreamingResponse", - "AsyncWARPConnectorResourceWithStreamingResponse", - "WorkersForPlatformsResource", - "AsyncWorkersForPlatformsResource", - "WorkersForPlatformsResourceWithRawResponse", - "AsyncWorkersForPlatformsResourceWithRawResponse", - "WorkersForPlatformsResourceWithStreamingResponse", - "AsyncWorkersForPlatformsResourceWithStreamingResponse", - "ZeroTrustResource", - "AsyncZeroTrustResource", - "ZeroTrustResourceWithRawResponse", - "AsyncZeroTrustResourceWithRawResponse", - "ZeroTrustResourceWithStreamingResponse", - "AsyncZeroTrustResourceWithStreamingResponse", - "ChallengesResource", - "AsyncChallengesResource", - "ChallengesResourceWithRawResponse", - "AsyncChallengesResourceWithRawResponse", - "ChallengesResourceWithStreamingResponse", - "AsyncChallengesResourceWithStreamingResponse", - "HyperdriveResource", - "AsyncHyperdriveResource", - "HyperdriveResourceWithRawResponse", - "AsyncHyperdriveResourceWithRawResponse", - "HyperdriveResourceWithStreamingResponse", - "AsyncHyperdriveResourceWithStreamingResponse", - "RUMResource", - "AsyncRUMResource", - "RUMResourceWithRawResponse", - "AsyncRUMResourceWithRawResponse", - "RUMResourceWithStreamingResponse", - "AsyncRUMResourceWithStreamingResponse", - "VectorizeResource", - "AsyncVectorizeResource", - "VectorizeResourceWithRawResponse", - "AsyncVectorizeResourceWithRawResponse", - "VectorizeResourceWithStreamingResponse", - "AsyncVectorizeResourceWithStreamingResponse", - "URLScannerResource", - "AsyncURLScannerResource", - "URLScannerResourceWithRawResponse", - "AsyncURLScannerResourceWithRawResponse", - "URLScannerResourceWithStreamingResponse", - "AsyncURLScannerResourceWithStreamingResponse", - "RadarResource", - "AsyncRadarResource", - "RadarResourceWithRawResponse", - "AsyncRadarResourceWithRawResponse", - "RadarResourceWithStreamingResponse", - "AsyncRadarResourceWithStreamingResponse", - "BotManagementResource", - "AsyncBotManagementResource", - "BotManagementResourceWithRawResponse", - "AsyncBotManagementResourceWithRawResponse", - "BotManagementResourceWithStreamingResponse", - "AsyncBotManagementResourceWithStreamingResponse", - "OriginPostQuantumEncryptionResource", - "AsyncOriginPostQuantumEncryptionResource", - "OriginPostQuantumEncryptionResourceWithRawResponse", - "AsyncOriginPostQuantumEncryptionResourceWithRawResponse", - "OriginPostQuantumEncryptionResourceWithStreamingResponse", - "AsyncOriginPostQuantumEncryptionResourceWithStreamingResponse", - "SpeedResource", - "AsyncSpeedResource", - "SpeedResourceWithRawResponse", - "AsyncSpeedResourceWithRawResponse", - "SpeedResourceWithStreamingResponse", - "AsyncSpeedResourceWithStreamingResponse", - "DCVDelegationResource", - "AsyncDCVDelegationResource", - "DCVDelegationResourceWithRawResponse", - "AsyncDCVDelegationResourceWithRawResponse", - "DCVDelegationResourceWithStreamingResponse", - "AsyncDCVDelegationResourceWithStreamingResponse", - "HostnamesResource", - "AsyncHostnamesResource", - "HostnamesResourceWithRawResponse", - "AsyncHostnamesResourceWithRawResponse", - "HostnamesResourceWithStreamingResponse", - "AsyncHostnamesResourceWithStreamingResponse", - "SnippetsResource", - "AsyncSnippetsResource", - "SnippetsResourceWithRawResponse", - "AsyncSnippetsResourceWithRawResponse", - "SnippetsResourceWithStreamingResponse", - "AsyncSnippetsResourceWithStreamingResponse", - "CallsResource", - "AsyncCallsResource", - "CallsResourceWithRawResponse", - "AsyncCallsResourceWithRawResponse", - "CallsResourceWithStreamingResponse", - "AsyncCallsResourceWithStreamingResponse", - "CloudforceOneResource", - "AsyncCloudforceOneResource", - "CloudforceOneResourceWithRawResponse", - "AsyncCloudforceOneResourceWithRawResponse", - "CloudforceOneResourceWithStreamingResponse", - "AsyncCloudforceOneResourceWithStreamingResponse", - "EventNotificationsResource", - "AsyncEventNotificationsResource", - "EventNotificationsResourceWithRawResponse", - "AsyncEventNotificationsResourceWithRawResponse", - "EventNotificationsResourceWithStreamingResponse", - "AsyncEventNotificationsResourceWithStreamingResponse", - "AIGatewayResource", - "AsyncAIGatewayResource", - "AIGatewayResourceWithRawResponse", - "AsyncAIGatewayResourceWithRawResponse", - "AIGatewayResourceWithStreamingResponse", - "AsyncAIGatewayResourceWithStreamingResponse", - "IAMResource", - "AsyncIAMResource", - "IAMResourceWithRawResponse", - "AsyncIAMResourceWithRawResponse", - "IAMResourceWithStreamingResponse", - "AsyncIAMResourceWithStreamingResponse", - "CloudConnectorResource", - "AsyncCloudConnectorResource", - "CloudConnectorResourceWithRawResponse", - "AsyncCloudConnectorResourceWithRawResponse", - "CloudConnectorResourceWithStreamingResponse", - "AsyncCloudConnectorResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/abuse_reports/__init__.py b/src/cloudflare/resources/abuse_reports/__init__.py new file mode 100644 index 00000000000..4283c591bc4 --- /dev/null +++ b/src/cloudflare/resources/abuse_reports/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .mitigations import ( + MitigationsResource, + AsyncMitigationsResource, + MitigationsResourceWithRawResponse, + AsyncMitigationsResourceWithRawResponse, + MitigationsResourceWithStreamingResponse, + AsyncMitigationsResourceWithStreamingResponse, +) +from .abuse_reports import ( + AbuseReportsResource, + AsyncAbuseReportsResource, + AbuseReportsResourceWithRawResponse, + AsyncAbuseReportsResourceWithRawResponse, + AbuseReportsResourceWithStreamingResponse, + AsyncAbuseReportsResourceWithStreamingResponse, +) + +__all__ = [ + "MitigationsResource", + "AsyncMitigationsResource", + "MitigationsResourceWithRawResponse", + "AsyncMitigationsResourceWithRawResponse", + "MitigationsResourceWithStreamingResponse", + "AsyncMitigationsResourceWithStreamingResponse", + "AbuseReportsResource", + "AsyncAbuseReportsResource", + "AbuseReportsResourceWithRawResponse", + "AsyncAbuseReportsResourceWithRawResponse", + "AbuseReportsResourceWithStreamingResponse", + "AsyncAbuseReportsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/abuse_reports/abuse_reports.py b/src/cloudflare/resources/abuse_reports/abuse_reports.py new file mode 100644 index 00000000000..9cf0a64aa03 --- /dev/null +++ b/src/cloudflare/resources/abuse_reports/abuse_reports.py @@ -0,0 +1,2164 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from .mitigations import ( + MitigationsResource, + AsyncMitigationsResource, + MitigationsResourceWithRawResponse, + AsyncMitigationsResourceWithRawResponse, + MitigationsResourceWithStreamingResponse, + AsyncMitigationsResourceWithStreamingResponse, +) +from ...pagination import SyncV4PagePagination, AsyncV4PagePagination +from ..._base_client import AsyncPaginator, make_request_options +from ...types.abuse_reports import abuse_report_list_params, abuse_report_create_params +from ...types.abuse_reports.abuse_report_get_response import AbuseReportGetResponse +from ...types.abuse_reports.abuse_report_list_response import AbuseReportListResponse +from ...types.abuse_reports.abuse_report_create_response import AbuseReportCreateResponse + +__all__ = ["AbuseReportsResource", "AsyncAbuseReportsResource"] + + +class AbuseReportsResource(SyncAPIResource): + @cached_property + def mitigations(self) -> MitigationsResource: + return MitigationsResource(self._client) + + @cached_property + def with_raw_response(self) -> AbuseReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AbuseReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AbuseReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AbuseReportsResourceWithStreamingResponse(self) + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_dmca"], + address1: str, + agent_name: str, + agree: Literal[1], + city: str, + country: str, + email: str, + email2: str, + host_notification: Literal["send"], + name: str, + original_work: str, + owner_notification: Literal["send"], + signature: str, + state: str, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + address1: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + agent_name: The name of the copyright holder. Text not exceeding 60 characters. This field + may be released by Cloudflare to third parties such as the Lumen Database + (https://lumendatabase.org/). + + agree: Can be `0` for false or `1` for true. Must be value: 1 for DMCA reports + + city: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + original_work: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + signature: Required for DMCA reports, should be same as Name. An affirmation that all + information in the report is true and accurate while agreeing to the policies of + Cloudflare's abuse reports + + state: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_trademark"], + email: str, + email2: str, + host_notification: Literal["send"], + justification: str, + name: str, + owner_notification: Literal["send"], + trademark_number: str, + trademark_office: str, + trademark_symbol: str, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + trademark_number: Text not exceeding 1000 characters + + trademark_office: Text not exceeding 1000 characters + + trademark_symbol: Text not exceeding 1000 characters + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_general"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + destination_ips: str | Omit = omit, + ports_protocols: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + source_ips: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + destination_ips: A list of IP addresses separated by ‘\n’ (new line character). The list of + destination IPs should not exceed 30 IP addresses. Each one of the IP addresses + ought to be unique. + + ports_protocols: A comma separated list of ports and protocols e.g. 80/TCP, 22/UDP. The total + size of the field should not exceed 2000 characters. Each individual + port/protocol should not exceed 100 characters. The list should not have more + than 30 unique ports and protocols. + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + source_ips: A list of IP addresses separated by ‘\n’ (new line character). The list of + source IPs should not exceed 30 IP addresses. Each one of the IP addresses ought + to be unique. + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_phishing"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + original_work: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + original_work: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_children"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + ncmec_notification: Literal["send", "send-anon"], + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + country: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + ncmec_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_threat"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_registrar_whois"], + email: str, + email2: str, + name: str, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_ncsei"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + name: str, + ncsei_subject_representation: bool, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + country: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + ncsei_subject_representation: If the submitter is the target of NCSEI in the URLs of the abuse report. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + [ + "account_id", + "act", + "address1", + "agent_name", + "agree", + "city", + "country", + "email", + "email2", + "host_notification", + "name", + "original_work", + "owner_notification", + "signature", + "state", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "owner_notification", + "trademark_number", + "trademark_office", + "trademark_symbol", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "owner_notification", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "ncmec_notification", + "owner_notification", + "urls", + ], + ["account_id", "act", "email", "email2", "name", "owner_notification", "urls"], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "name", + "ncsei_subject_representation", + "owner_notification", + "urls", + ], + ) + def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_dmca"] + | Literal["abuse_trademark"] + | Literal["abuse_general"] + | Literal["abuse_phishing"] + | Literal["abuse_children"] + | Literal["abuse_threat"] + | Literal["abuse_registrar_whois"] + | Literal["abuse_ncsei"], + address1: str | Omit = omit, + agent_name: str | Omit = omit, + agree: Literal[1] | Omit = omit, + city: str | Omit = omit, + country: str | Omit = omit, + email: str, + email2: str, + host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, + name: str, + original_work: str | Omit = omit, + owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + signature: str | Omit = omit, + state: str | Omit = omit, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + justification: str | Omit = omit, + trademark_number: str | Omit = omit, + trademark_office: str | Omit = omit, + trademark_symbol: str | Omit = omit, + destination_ips: str | Omit = omit, + ports_protocols: str | Omit = omit, + source_ips: str | Omit = omit, + ncmec_notification: Literal["send", "send-anon"] | Omit = omit, + ncsei_subject_representation: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_param: + raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}") + return self._post( + f"/accounts/{account_id}/abuse-reports/{report_param}", + body=maybe_transform( + { + "act": act, + "address1": address1, + "agent_name": agent_name, + "agree": agree, + "city": city, + "country": country, + "email": email, + "email2": email2, + "host_notification": host_notification, + "name": name, + "original_work": original_work, + "owner_notification": owner_notification, + "signature": signature, + "state": state, + "urls": urls, + "comments": comments, + "company": company, + "reported_country": reported_country, + "reported_user_agent": reported_user_agent, + "tele": tele, + "title": title, + "justification": justification, + "trademark_number": trademark_number, + "trademark_office": trademark_office, + "trademark_symbol": trademark_symbol, + "destination_ips": destination_ips, + "ports_protocols": ports_protocols, + "source_ips": source_ips, + "ncmec_notification": ncmec_notification, + "ncsei_subject_representation": ncsei_subject_representation, + }, + abuse_report_create_params.AbuseReportCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportCreateResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + def list( + self, + *, + account_id: str, + created_after: str | Omit = omit, + created_before: str | Omit = omit, + domain: str | Omit = omit, + mitigation_status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + sort: str | Omit = omit, + status: Literal["accepted", "in_review"] | Omit = omit, + type: Literal["PHISH", "GEN", "THREAT", "DMCA", "EMER", "TM", "REG_WHO", "NCSEI", "NETWORK"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePagination[Optional[AbuseReportListResponse]]: + """ + List the abuse reports for a given account + + Args: + created_after: Returns reports created after the specified date + + created_before: Returns reports created before the specified date + + domain: Filter by domain name related to the abuse report + + mitigation_status: Filter reports that have any mitigations in the given status. + + page: Where in pagination to start listing abuse reports + + per_page: How many abuse reports per page to list + + sort: A property to sort by, followed by the order (id, cdate, domain, type, status) + + status: Filter by the status of the report. + + type: Filter by the type of the report. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports", + page=SyncV4PagePagination[Optional[AbuseReportListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "created_after": created_after, + "created_before": created_before, + "domain": domain, + "mitigation_status": mitigation_status, + "page": page, + "per_page": per_page, + "sort": sort, + "status": status, + "type": type, + }, + abuse_report_list_params.AbuseReportListParams, + ), + ), + model=AbuseReportListResponse, + ) + + def get( + self, + report_param: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AbuseReportGetResponse: + """ + Retrieve the details of an abuse report. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_param: + raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}") + return self._get( + f"/accounts/{account_id}/abuse-reports/{report_param}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportGetResponse]._unwrapper, + ), + cast_to=cast(Type[AbuseReportGetResponse], ResultWrapper[AbuseReportGetResponse]), + ) + + +class AsyncAbuseReportsResource(AsyncAPIResource): + @cached_property + def mitigations(self) -> AsyncMitigationsResource: + return AsyncMitigationsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAbuseReportsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAbuseReportsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAbuseReportsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAbuseReportsResourceWithStreamingResponse(self) + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_dmca"], + address1: str, + agent_name: str, + agree: Literal[1], + city: str, + country: str, + email: str, + email2: str, + host_notification: Literal["send"], + name: str, + original_work: str, + owner_notification: Literal["send"], + signature: str, + state: str, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + address1: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + agent_name: The name of the copyright holder. Text not exceeding 60 characters. This field + may be released by Cloudflare to third parties such as the Lumen Database + (https://lumendatabase.org/). + + agree: Can be `0` for false or `1` for true. Must be value: 1 for DMCA reports + + city: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + original_work: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + signature: Required for DMCA reports, should be same as Name. An affirmation that all + information in the report is true and accurate while agreeing to the policies of + Cloudflare's abuse reports + + state: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_trademark"], + email: str, + email2: str, + host_notification: Literal["send"], + justification: str, + name: str, + owner_notification: Literal["send"], + trademark_number: str, + trademark_office: str, + trademark_symbol: str, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + trademark_number: Text not exceeding 1000 characters + + trademark_office: Text not exceeding 1000 characters + + trademark_symbol: Text not exceeding 1000 characters + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_general"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + destination_ips: str | Omit = omit, + ports_protocols: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + source_ips: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + destination_ips: A list of IP addresses separated by ‘\n’ (new line character). The list of + destination IPs should not exceed 30 IP addresses. Each one of the IP addresses + ought to be unique. + + ports_protocols: A comma separated list of ports and protocols e.g. 80/TCP, 22/UDP. The total + size of the field should not exceed 2000 characters. Each individual + port/protocol should not exceed 100 characters. The list should not have more + than 30 unique ports and protocols. + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + source_ips: A list of IP addresses separated by ‘\n’ (new line character). The list of + source IPs should not exceed 30 IP addresses. Each one of the IP addresses ought + to be unique. + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_phishing"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + original_work: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + original_work: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_children"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + ncmec_notification: Literal["send", "send-anon"], + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + country: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + ncmec_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_threat"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + justification: str, + name: str, + owner_notification: Literal["send", "send-anon"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + justification: A detailed description of the infringement, including any necessary access + details and the exact steps needed to view the content, not exceeding 5000 + characters. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_registrar_whois"], + email: str, + email2: str, + name: str, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_ncsei"], + email: str, + email2: str, + host_notification: Literal["send", "send-anon"], + name: str, + ncsei_subject_representation: bool, + owner_notification: Literal["send", "send-anon", "none"], + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + country: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Submit the Abuse Report of a particular type + + Args: + report_param: The report type for submitted reports. + + act: The report type for submitted reports. + + email: A valid email of the abuse reporter. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + email2: Should match the value provided in `email` + + host_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + name: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + ncsei_subject_representation: If the submitter is the target of NCSEI in the URLs of the abuse report. + + owner_notification: Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark + reports cannot be anonymous. + + urls: A list of valid URLs separated by ‘\n’ (new line character). The list of the + URLs should not exceed 250 URLs. All URLs should have the same hostname. Each + URL should be unique. This field may be released by Cloudflare to third parties + such as the Lumen Database (https://lumendatabase.org/). + + comments: Any additional comments about the infringement not exceeding 2000 characters + + company: Text not exceeding 100 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + country: Text not exceeding 255 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + reported_country: Text containing 2 characters + + reported_user_agent: Text not exceeding 255 characters + + tele: Text not exceeding 20 characters. This field may be released by Cloudflare to + third parties such as the Lumen Database (https://lumendatabase.org/). + + title: Text not exceeding 255 characters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + [ + "account_id", + "act", + "address1", + "agent_name", + "agree", + "city", + "country", + "email", + "email2", + "host_notification", + "name", + "original_work", + "owner_notification", + "signature", + "state", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "owner_notification", + "trademark_number", + "trademark_office", + "trademark_symbol", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "owner_notification", + "urls", + ], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "justification", + "name", + "ncmec_notification", + "owner_notification", + "urls", + ], + ["account_id", "act", "email", "email2", "name", "owner_notification", "urls"], + [ + "account_id", + "act", + "email", + "email2", + "host_notification", + "name", + "ncsei_subject_representation", + "owner_notification", + "urls", + ], + ) + async def create( + self, + report_param: str, + *, + account_id: str, + act: Literal["abuse_dmca"] + | Literal["abuse_trademark"] + | Literal["abuse_general"] + | Literal["abuse_phishing"] + | Literal["abuse_children"] + | Literal["abuse_threat"] + | Literal["abuse_registrar_whois"] + | Literal["abuse_ncsei"], + address1: str | Omit = omit, + agent_name: str | Omit = omit, + agree: Literal[1] | Omit = omit, + city: str | Omit = omit, + country: str | Omit = omit, + email: str, + email2: str, + host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, + name: str, + original_work: str | Omit = omit, + owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + signature: str | Omit = omit, + state: str | Omit = omit, + urls: str, + comments: str | Omit = omit, + company: str | Omit = omit, + reported_country: str | Omit = omit, + reported_user_agent: str | Omit = omit, + tele: str | Omit = omit, + title: str | Omit = omit, + justification: str | Omit = omit, + trademark_number: str | Omit = omit, + trademark_office: str | Omit = omit, + trademark_symbol: str | Omit = omit, + destination_ips: str | Omit = omit, + ports_protocols: str | Omit = omit, + source_ips: str | Omit = omit, + ncmec_notification: Literal["send", "send-anon"] | Omit = omit, + ncsei_subject_representation: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_param: + raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}") + return await self._post( + f"/accounts/{account_id}/abuse-reports/{report_param}", + body=await async_maybe_transform( + { + "act": act, + "address1": address1, + "agent_name": agent_name, + "agree": agree, + "city": city, + "country": country, + "email": email, + "email2": email2, + "host_notification": host_notification, + "name": name, + "original_work": original_work, + "owner_notification": owner_notification, + "signature": signature, + "state": state, + "urls": urls, + "comments": comments, + "company": company, + "reported_country": reported_country, + "reported_user_agent": reported_user_agent, + "tele": tele, + "title": title, + "justification": justification, + "trademark_number": trademark_number, + "trademark_office": trademark_office, + "trademark_symbol": trademark_symbol, + "destination_ips": destination_ips, + "ports_protocols": ports_protocols, + "source_ips": source_ips, + "ncmec_notification": ncmec_notification, + "ncsei_subject_representation": ncsei_subject_representation, + }, + abuse_report_create_params.AbuseReportCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportCreateResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + def list( + self, + *, + account_id: str, + created_after: str | Omit = omit, + created_before: str | Omit = omit, + domain: str | Omit = omit, + mitigation_status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + sort: str | Omit = omit, + status: Literal["accepted", "in_review"] | Omit = omit, + type: Literal["PHISH", "GEN", "THREAT", "DMCA", "EMER", "TM", "REG_WHO", "NCSEI", "NETWORK"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Optional[AbuseReportListResponse], AsyncV4PagePagination[Optional[AbuseReportListResponse]]]: + """ + List the abuse reports for a given account + + Args: + created_after: Returns reports created after the specified date + + created_before: Returns reports created before the specified date + + domain: Filter by domain name related to the abuse report + + mitigation_status: Filter reports that have any mitigations in the given status. + + page: Where in pagination to start listing abuse reports + + per_page: How many abuse reports per page to list + + sort: A property to sort by, followed by the order (id, cdate, domain, type, status) + + status: Filter by the status of the report. + + type: Filter by the type of the report. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports", + page=AsyncV4PagePagination[Optional[AbuseReportListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "created_after": created_after, + "created_before": created_before, + "domain": domain, + "mitigation_status": mitigation_status, + "page": page, + "per_page": per_page, + "sort": sort, + "status": status, + "type": type, + }, + abuse_report_list_params.AbuseReportListParams, + ), + ), + model=AbuseReportListResponse, + ) + + async def get( + self, + report_param: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AbuseReportGetResponse: + """ + Retrieve the details of an abuse report. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_param: + raise ValueError(f"Expected a non-empty value for `report_param` but received {report_param!r}") + return await self._get( + f"/accounts/{account_id}/abuse-reports/{report_param}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AbuseReportGetResponse]._unwrapper, + ), + cast_to=cast(Type[AbuseReportGetResponse], ResultWrapper[AbuseReportGetResponse]), + ) + + +class AbuseReportsResourceWithRawResponse: + def __init__(self, abuse_reports: AbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = to_raw_response_wrapper( + abuse_reports.create, + ) + self.list = to_raw_response_wrapper( + abuse_reports.list, + ) + self.get = to_raw_response_wrapper( + abuse_reports.get, + ) + + @cached_property + def mitigations(self) -> MitigationsResourceWithRawResponse: + return MitigationsResourceWithRawResponse(self._abuse_reports.mitigations) + + +class AsyncAbuseReportsResourceWithRawResponse: + def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = async_to_raw_response_wrapper( + abuse_reports.create, + ) + self.list = async_to_raw_response_wrapper( + abuse_reports.list, + ) + self.get = async_to_raw_response_wrapper( + abuse_reports.get, + ) + + @cached_property + def mitigations(self) -> AsyncMitigationsResourceWithRawResponse: + return AsyncMitigationsResourceWithRawResponse(self._abuse_reports.mitigations) + + +class AbuseReportsResourceWithStreamingResponse: + def __init__(self, abuse_reports: AbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = to_streamed_response_wrapper( + abuse_reports.create, + ) + self.list = to_streamed_response_wrapper( + abuse_reports.list, + ) + self.get = to_streamed_response_wrapper( + abuse_reports.get, + ) + + @cached_property + def mitigations(self) -> MitigationsResourceWithStreamingResponse: + return MitigationsResourceWithStreamingResponse(self._abuse_reports.mitigations) + + +class AsyncAbuseReportsResourceWithStreamingResponse: + def __init__(self, abuse_reports: AsyncAbuseReportsResource) -> None: + self._abuse_reports = abuse_reports + + self.create = async_to_streamed_response_wrapper( + abuse_reports.create, + ) + self.list = async_to_streamed_response_wrapper( + abuse_reports.list, + ) + self.get = async_to_streamed_response_wrapper( + abuse_reports.get, + ) + + @cached_property + def mitigations(self) -> AsyncMitigationsResourceWithStreamingResponse: + return AsyncMitigationsResourceWithStreamingResponse(self._abuse_reports.mitigations) diff --git a/src/cloudflare/resources/abuse_reports/mitigations.py b/src/cloudflare/resources/abuse_reports/mitigations.py new file mode 100644 index 00000000000..298b58d4143 --- /dev/null +++ b/src/cloudflare/resources/abuse_reports/mitigations.py @@ -0,0 +1,394 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable, Optional +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePagination, AsyncV4PagePagination +from ..._base_client import AsyncPaginator, make_request_options +from ...types.abuse_reports import mitigation_list_params, mitigation_review_params +from ...types.abuse_reports.mitigation_list_response import MitigationListResponse +from ...types.abuse_reports.mitigation_review_response import MitigationReviewResponse + +__all__ = ["MitigationsResource", "AsyncMitigationsResource"] + + +class MitigationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MitigationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return MitigationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MitigationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return MitigationsResourceWithStreamingResponse(self) + + def list( + self, + report_id: str, + *, + account_id: str, + effective_after: str | Omit = omit, + effective_before: str | Omit = omit, + entity_type: Literal["url_pattern", "account", "zone"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + sort: Literal[ + "type,asc", + "type,desc", + "effective_date,asc", + "effective_date,desc", + "status,asc", + "status,desc", + "entity_type,asc", + "entity_type,desc", + ] + | Omit = omit, + status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, + type: Literal[ + "legal_block", + "phishing_interstitial", + "network_block", + "rate_limit_cache", + "account_suspend", + "redirect_video_stream", + ] + | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePagination[Optional[MitigationListResponse]]: + """ + List mitigations done to remediate the abuse report. + + Args: + effective_after: Returns mitigation that were dispatched after the given date + + effective_before: Returns mitigations that were dispatched before the given date + + entity_type: Filter by the type of entity the mitigation impacts. + + page: Where in pagination to start listing abuse reports + + per_page: How many abuse reports per page to list + + sort: A property to sort by, followed by the order + + status: Filter by the status of the mitigation. + + type: Filter by the type of mitigation. This filter parameter can be specified + multiple times to include multiple types of mitigations in the result set, e.g. + ?type=rate_limit_cache&type=legal_block. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_id: + raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports/{report_id}/mitigations", + page=SyncV4PagePagination[Optional[MitigationListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "effective_after": effective_after, + "effective_before": effective_before, + "entity_type": entity_type, + "page": page, + "per_page": per_page, + "sort": sort, + "status": status, + "type": type, + }, + mitigation_list_params.MitigationListParams, + ), + ), + model=MitigationListResponse, + ) + + def review( + self, + report_id: str, + *, + account_id: str, + appeals: Iterable[mitigation_review_params.Appeal], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[MitigationReviewResponse]: + """ + Request a review for mitigations on an account. + + Args: + appeals: List of mitigations to appeal. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_id: + raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports/{report_id}/mitigations/appeal", + page=SyncSinglePage[MitigationReviewResponse], + body=maybe_transform({"appeals": appeals}, mitigation_review_params.MitigationReviewParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=MitigationReviewResponse, + method="post", + ) + + +class AsyncMitigationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMitigationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncMitigationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMitigationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncMitigationsResourceWithStreamingResponse(self) + + def list( + self, + report_id: str, + *, + account_id: str, + effective_after: str | Omit = omit, + effective_before: str | Omit = omit, + entity_type: Literal["url_pattern", "account", "zone"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + sort: Literal[ + "type,asc", + "type,desc", + "effective_date,asc", + "effective_date,desc", + "status,asc", + "status,desc", + "entity_type,asc", + "entity_type,desc", + ] + | Omit = omit, + status: Literal["pending", "active", "in_review", "cancelled", "removed"] | Omit = omit, + type: Literal[ + "legal_block", + "phishing_interstitial", + "network_block", + "rate_limit_cache", + "account_suspend", + "redirect_video_stream", + ] + | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Optional[MitigationListResponse], AsyncV4PagePagination[Optional[MitigationListResponse]]]: + """ + List mitigations done to remediate the abuse report. + + Args: + effective_after: Returns mitigation that were dispatched after the given date + + effective_before: Returns mitigations that were dispatched before the given date + + entity_type: Filter by the type of entity the mitigation impacts. + + page: Where in pagination to start listing abuse reports + + per_page: How many abuse reports per page to list + + sort: A property to sort by, followed by the order + + status: Filter by the status of the mitigation. + + type: Filter by the type of mitigation. This filter parameter can be specified + multiple times to include multiple types of mitigations in the result set, e.g. + ?type=rate_limit_cache&type=legal_block. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_id: + raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports/{report_id}/mitigations", + page=AsyncV4PagePagination[Optional[MitigationListResponse]], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "effective_after": effective_after, + "effective_before": effective_before, + "entity_type": entity_type, + "page": page, + "per_page": per_page, + "sort": sort, + "status": status, + "type": type, + }, + mitigation_list_params.MitigationListParams, + ), + ), + model=MitigationListResponse, + ) + + def review( + self, + report_id: str, + *, + account_id: str, + appeals: Iterable[mitigation_review_params.Appeal], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[MitigationReviewResponse, AsyncSinglePage[MitigationReviewResponse]]: + """ + Request a review for mitigations on an account. + + Args: + appeals: List of mitigations to appeal. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not report_id: + raise ValueError(f"Expected a non-empty value for `report_id` but received {report_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/abuse-reports/{report_id}/mitigations/appeal", + page=AsyncSinglePage[MitigationReviewResponse], + body=maybe_transform({"appeals": appeals}, mitigation_review_params.MitigationReviewParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=MitigationReviewResponse, + method="post", + ) + + +class MitigationsResourceWithRawResponse: + def __init__(self, mitigations: MitigationsResource) -> None: + self._mitigations = mitigations + + self.list = to_raw_response_wrapper( + mitigations.list, + ) + self.review = to_raw_response_wrapper( + mitigations.review, + ) + + +class AsyncMitigationsResourceWithRawResponse: + def __init__(self, mitigations: AsyncMitigationsResource) -> None: + self._mitigations = mitigations + + self.list = async_to_raw_response_wrapper( + mitigations.list, + ) + self.review = async_to_raw_response_wrapper( + mitigations.review, + ) + + +class MitigationsResourceWithStreamingResponse: + def __init__(self, mitigations: MitigationsResource) -> None: + self._mitigations = mitigations + + self.list = to_streamed_response_wrapper( + mitigations.list, + ) + self.review = to_streamed_response_wrapper( + mitigations.review, + ) + + +class AsyncMitigationsResourceWithStreamingResponse: + def __init__(self, mitigations: AsyncMitigationsResource) -> None: + self._mitigations = mitigations + + self.list = async_to_streamed_response_wrapper( + mitigations.list, + ) + self.review = async_to_streamed_response_wrapper( + mitigations.review, + ) diff --git a/src/cloudflare/resources/accounts/__init__.py b/src/cloudflare/resources/accounts/__init__.py index 4e9d5ed34dd..f136ec47000 100644 --- a/src/cloudflare/resources/accounts/__init__.py +++ b/src/cloudflare/resources/accounts/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) from .roles import ( RolesResource, AsyncRolesResource, @@ -8,6 +16,14 @@ RolesResourceWithStreamingResponse, AsyncRolesResourceWithStreamingResponse, ) +from .tokens import ( + TokensResource, + AsyncTokensResource, + TokensResourceWithRawResponse, + AsyncTokensResourceWithRawResponse, + TokensResourceWithStreamingResponse, + AsyncTokensResourceWithStreamingResponse, +) from .members import ( MembersResource, AsyncMembersResource, @@ -24,6 +40,14 @@ AccountsResourceWithStreamingResponse, AsyncAccountsResourceWithStreamingResponse, ) +from .subscriptions import ( + SubscriptionsResource, + AsyncSubscriptionsResource, + SubscriptionsResourceWithRawResponse, + AsyncSubscriptionsResourceWithRawResponse, + SubscriptionsResourceWithStreamingResponse, + AsyncSubscriptionsResourceWithStreamingResponse, +) __all__ = [ "MembersResource", @@ -38,6 +62,24 @@ "AsyncRolesResourceWithRawResponse", "RolesResourceWithStreamingResponse", "AsyncRolesResourceWithStreamingResponse", + "SubscriptionsResource", + "AsyncSubscriptionsResource", + "SubscriptionsResourceWithRawResponse", + "AsyncSubscriptionsResourceWithRawResponse", + "SubscriptionsResourceWithStreamingResponse", + "AsyncSubscriptionsResourceWithStreamingResponse", + "TokensResource", + "AsyncTokensResource", + "TokensResourceWithRawResponse", + "AsyncTokensResourceWithRawResponse", + "TokensResourceWithStreamingResponse", + "AsyncTokensResourceWithStreamingResponse", + "LogsResource", + "AsyncLogsResource", + "LogsResourceWithRawResponse", + "AsyncLogsResourceWithRawResponse", + "LogsResourceWithStreamingResponse", + "AsyncLogsResourceWithStreamingResponse", "AccountsResource", "AsyncAccountsResource", "AccountsResourceWithRawResponse", diff --git a/src/cloudflare/resources/accounts/accounts.py b/src/cloudflare/resources/accounts/accounts.py index 2d48d9dfe99..aedb92f84e7 100644 --- a/src/cloudflare/resources/accounts/accounts.py +++ b/src/cloudflare/resources/accounts/accounts.py @@ -23,12 +23,17 @@ MembersResourceWithStreamingResponse, AsyncMembersResourceWithStreamingResponse, ) -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property +from .logs.logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -38,8 +43,26 @@ ) from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from .subscriptions import ( + SubscriptionsResource, + AsyncSubscriptionsResource, + SubscriptionsResourceWithRawResponse, + AsyncSubscriptionsResourceWithRawResponse, + SubscriptionsResourceWithStreamingResponse, + AsyncSubscriptionsResourceWithStreamingResponse, +) +from .tokens.tokens import ( + TokensResource, + AsyncTokensResource, + TokensResourceWithRawResponse, + AsyncTokensResourceWithRawResponse, + TokensResourceWithStreamingResponse, + AsyncTokensResourceWithStreamingResponse, +) from ..._base_client import AsyncPaginator, make_request_options -from ...types.accounts import account_list_params, account_update_params +from ...types.accounts import account_list_params, account_create_params, account_update_params +from ...types.accounts.account import Account +from ...types.accounts.account_delete_response import AccountDeleteResponse __all__ = ["AccountsResource", "AsyncAccountsResource"] @@ -53,33 +76,116 @@ def members(self) -> MembersResource: def roles(self) -> RolesResource: return RolesResource(self._client) + @cached_property + def subscriptions(self) -> SubscriptionsResource: + return SubscriptionsResource(self._client) + + @cached_property + def tokens(self) -> TokensResource: + return TokensResource(self._client) + + @cached_property + def logs(self) -> LogsResource: + return LogsResource(self._client) + @cached_property def with_raw_response(self) -> AccountsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AccountsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AccountsResourceWithStreamingResponse(self) + def create( + self, + *, + name: str, + type: Literal["standard", "enterprise"] | Omit = omit, + unit: account_create_params.Unit | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: + """ + Create an account (only available for tenant admins at this time) + + Args: + name: Account name + + unit: information related to the tenant unit, and optionally, an id of the unit to + create the account on. see + https://developers.cloudflare.com/tenant/how-to/manage-accounts/ + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/accounts", + body=maybe_transform( + { + "name": name, + "type": type, + "unit": unit, + }, + account_create_params.AccountCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, + ), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), + ) + def update( self, *, - account_id: object, + account_id: str, + id: str, name: str, - settings: account_update_params.Settings | NotGiven = NOT_GIVEN, + type: Literal["standard", "enterprise"], + managed_by: account_update_params.ManagedBy | Omit = omit, + settings: account_update_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: """ Update an existing account. Args: + account_id: Account identifier tag. + + id: Identifier + name: Account name + managed_by: Parent container details + settings: Account settings extra_headers: Send extra headers @@ -90,11 +196,16 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._put( f"/accounts/{account_id}", body=maybe_transform( { + "id": id, "name": name, + "type": type, + "managed_by": managed_by, "settings": settings, }, account_update_params.AccountUpdateParams, @@ -104,25 +215,25 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), ) def list( self, *, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + name: str | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[object]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[Account]: """ List all accounts you have ownership or verified access to. @@ -145,7 +256,7 @@ def list( """ return self._get_api_list( "/accounts", - page=SyncV4PagePaginationArray[object], + page=SyncV4PagePaginationArray[Account], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -161,24 +272,68 @@ def list( account_list_params.AccountListParams, ), ), - model=object, + model=Account, + ) + + def delete( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AccountDeleteResponse]: + """Delete a specific account (only available for tenant admins at this time). + + This + is a permanent operation that will delete any zones or other resources under the + account + + Args: + account_id: The account ID of the account to be deleted + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._delete( + f"/accounts/{account_id}", + 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]), ) def get( self, *, - account_id: object, + account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: """ Get information about a specific account that you are a member of. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -187,6 +342,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get( f"/accounts/{account_id}", options=make_request_options( @@ -194,9 +351,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), ) @@ -209,33 +366,116 @@ def members(self) -> AsyncMembersResource: def roles(self) -> AsyncRolesResource: return AsyncRolesResource(self._client) + @cached_property + def subscriptions(self) -> AsyncSubscriptionsResource: + return AsyncSubscriptionsResource(self._client) + + @cached_property + def tokens(self) -> AsyncTokensResource: + return AsyncTokensResource(self._client) + + @cached_property + def logs(self) -> AsyncLogsResource: + return AsyncLogsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAccountsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAccountsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAccountsResourceWithStreamingResponse(self) + async def create( + self, + *, + name: str, + type: Literal["standard", "enterprise"] | Omit = omit, + unit: account_create_params.Unit | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: + """ + Create an account (only available for tenant admins at this time) + + Args: + name: Account name + + unit: information related to the tenant unit, and optionally, an id of the unit to + create the account on. see + https://developers.cloudflare.com/tenant/how-to/manage-accounts/ + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/accounts", + body=await async_maybe_transform( + { + "name": name, + "type": type, + "unit": unit, + }, + account_create_params.AccountCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, + ), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), + ) + async def update( self, *, - account_id: object, + account_id: str, + id: str, name: str, - settings: account_update_params.Settings | NotGiven = NOT_GIVEN, + type: Literal["standard", "enterprise"], + managed_by: account_update_params.ManagedBy | Omit = omit, + settings: account_update_params.Settings | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: """ Update an existing account. Args: + account_id: Account identifier tag. + + id: Identifier + name: Account name + managed_by: Parent container details + settings: Account settings extra_headers: Send extra headers @@ -246,11 +486,16 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._put( f"/accounts/{account_id}", body=await async_maybe_transform( { + "id": id, "name": name, + "type": type, + "managed_by": managed_by, "settings": settings, }, account_update_params.AccountUpdateParams, @@ -260,25 +505,25 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), ) def list( self, *, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + name: str | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Account, AsyncV4PagePaginationArray[Account]]: """ List all accounts you have ownership or verified access to. @@ -301,7 +546,7 @@ def list( """ return self._get_api_list( "/accounts", - page=AsyncV4PagePaginationArray[object], + page=AsyncV4PagePaginationArray[Account], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -317,24 +562,68 @@ def list( account_list_params.AccountListParams, ), ), - model=object, + model=Account, + ) + + async def delete( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AccountDeleteResponse]: + """Delete a specific account (only available for tenant admins at this time). + + This + is a permanent operation that will delete any zones or other resources under the + account + + Args: + account_id: The account ID of the account to be deleted + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._delete( + f"/accounts/{account_id}", + 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]), ) async def get( self, *, - account_id: object, + account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Account]: """ Get information about a specific account that you are a member of. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -343,6 +632,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._get( f"/accounts/{account_id}", options=make_request_options( @@ -350,9 +641,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Account]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Account]], ResultWrapper[Account]), ) @@ -360,12 +651,18 @@ class AccountsResourceWithRawResponse: def __init__(self, accounts: AccountsResource) -> None: self._accounts = accounts + self.create = to_raw_response_wrapper( + accounts.create, + ) self.update = to_raw_response_wrapper( accounts.update, ) self.list = to_raw_response_wrapper( accounts.list, ) + self.delete = to_raw_response_wrapper( + accounts.delete, + ) self.get = to_raw_response_wrapper( accounts.get, ) @@ -378,17 +675,35 @@ def members(self) -> MembersResourceWithRawResponse: def roles(self) -> RolesResourceWithRawResponse: return RolesResourceWithRawResponse(self._accounts.roles) + @cached_property + def subscriptions(self) -> SubscriptionsResourceWithRawResponse: + return SubscriptionsResourceWithRawResponse(self._accounts.subscriptions) + + @cached_property + def tokens(self) -> TokensResourceWithRawResponse: + return TokensResourceWithRawResponse(self._accounts.tokens) + + @cached_property + def logs(self) -> LogsResourceWithRawResponse: + return LogsResourceWithRawResponse(self._accounts.logs) + class AsyncAccountsResourceWithRawResponse: def __init__(self, accounts: AsyncAccountsResource) -> None: self._accounts = accounts + self.create = async_to_raw_response_wrapper( + accounts.create, + ) self.update = async_to_raw_response_wrapper( accounts.update, ) self.list = async_to_raw_response_wrapper( accounts.list, ) + self.delete = async_to_raw_response_wrapper( + accounts.delete, + ) self.get = async_to_raw_response_wrapper( accounts.get, ) @@ -401,17 +716,35 @@ def members(self) -> AsyncMembersResourceWithRawResponse: def roles(self) -> AsyncRolesResourceWithRawResponse: return AsyncRolesResourceWithRawResponse(self._accounts.roles) + @cached_property + def subscriptions(self) -> AsyncSubscriptionsResourceWithRawResponse: + return AsyncSubscriptionsResourceWithRawResponse(self._accounts.subscriptions) + + @cached_property + def tokens(self) -> AsyncTokensResourceWithRawResponse: + return AsyncTokensResourceWithRawResponse(self._accounts.tokens) + + @cached_property + def logs(self) -> AsyncLogsResourceWithRawResponse: + return AsyncLogsResourceWithRawResponse(self._accounts.logs) + class AccountsResourceWithStreamingResponse: def __init__(self, accounts: AccountsResource) -> None: self._accounts = accounts + self.create = to_streamed_response_wrapper( + accounts.create, + ) self.update = to_streamed_response_wrapper( accounts.update, ) self.list = to_streamed_response_wrapper( accounts.list, ) + self.delete = to_streamed_response_wrapper( + accounts.delete, + ) self.get = to_streamed_response_wrapper( accounts.get, ) @@ -424,17 +757,35 @@ def members(self) -> MembersResourceWithStreamingResponse: def roles(self) -> RolesResourceWithStreamingResponse: return RolesResourceWithStreamingResponse(self._accounts.roles) + @cached_property + def subscriptions(self) -> SubscriptionsResourceWithStreamingResponse: + return SubscriptionsResourceWithStreamingResponse(self._accounts.subscriptions) + + @cached_property + def tokens(self) -> TokensResourceWithStreamingResponse: + return TokensResourceWithStreamingResponse(self._accounts.tokens) + + @cached_property + def logs(self) -> LogsResourceWithStreamingResponse: + return LogsResourceWithStreamingResponse(self._accounts.logs) + class AsyncAccountsResourceWithStreamingResponse: def __init__(self, accounts: AsyncAccountsResource) -> None: self._accounts = accounts + self.create = async_to_streamed_response_wrapper( + accounts.create, + ) self.update = async_to_streamed_response_wrapper( accounts.update, ) self.list = async_to_streamed_response_wrapper( accounts.list, ) + self.delete = async_to_streamed_response_wrapper( + accounts.delete, + ) self.get = async_to_streamed_response_wrapper( accounts.get, ) @@ -446,3 +797,15 @@ def members(self) -> AsyncMembersResourceWithStreamingResponse: @cached_property def roles(self) -> AsyncRolesResourceWithStreamingResponse: return AsyncRolesResourceWithStreamingResponse(self._accounts.roles) + + @cached_property + def subscriptions(self) -> AsyncSubscriptionsResourceWithStreamingResponse: + return AsyncSubscriptionsResourceWithStreamingResponse(self._accounts.subscriptions) + + @cached_property + def tokens(self) -> AsyncTokensResourceWithStreamingResponse: + return AsyncTokensResourceWithStreamingResponse(self._accounts.tokens) + + @cached_property + def logs(self) -> AsyncLogsResourceWithStreamingResponse: + return AsyncLogsResourceWithStreamingResponse(self._accounts.logs) diff --git a/src/cloudflare/resources/accounts/logs/__init__.py b/src/cloudflare/resources/accounts/logs/__init__.py new file mode 100644 index 00000000000..5d5ddcdb7e2 --- /dev/null +++ b/src/cloudflare/resources/accounts/logs/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) +from .audit import ( + AuditResource, + AsyncAuditResource, + AuditResourceWithRawResponse, + AsyncAuditResourceWithRawResponse, + AuditResourceWithStreamingResponse, + AsyncAuditResourceWithStreamingResponse, +) + +__all__ = [ + "AuditResource", + "AsyncAuditResource", + "AuditResourceWithRawResponse", + "AsyncAuditResourceWithRawResponse", + "AuditResourceWithStreamingResponse", + "AsyncAuditResourceWithStreamingResponse", + "LogsResource", + "AsyncLogsResource", + "LogsResourceWithRawResponse", + "AsyncLogsResourceWithRawResponse", + "LogsResourceWithStreamingResponse", + "AsyncLogsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/accounts/logs/audit.py b/src/cloudflare/resources/accounts/logs/audit.py new file mode 100644 index 00000000000..fd663c7cc68 --- /dev/null +++ b/src/cloudflare/resources/accounts/logs/audit.py @@ -0,0 +1,346 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import date +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from ...._base_client import AsyncPaginator, make_request_options +from ....types.accounts.logs import audit_list_params +from ....types.accounts.logs.audit_list_response import AuditListResponse + +__all__ = ["AuditResource", "AsyncAuditResource"] + + +class AuditResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AuditResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AuditResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AuditResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AuditResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + before: Union[str, date], + since: Union[str, date], + id: audit_list_params.ID | Omit = omit, + account_name: audit_list_params.AccountName | Omit = omit, + action_result: audit_list_params.ActionResult | Omit = omit, + action_type: audit_list_params.ActionType | Omit = omit, + actor_context: audit_list_params.ActorContext | Omit = omit, + actor_email: audit_list_params.ActorEmail | Omit = omit, + actor_id: audit_list_params.ActorID | Omit = omit, + actor_ip_address: audit_list_params.ActorIPAddress | Omit = omit, + actor_token_id: audit_list_params.ActorTokenID | Omit = omit, + actor_token_name: audit_list_params.ActorTokenName | Omit = omit, + actor_type: audit_list_params.ActorType | Omit = omit, + audit_log_id: audit_list_params.AuditLogID | Omit = omit, + cursor: str | Omit = omit, + direction: Literal["desc", "asc"] | Omit = omit, + limit: float | Omit = omit, + raw_cf_rayid: audit_list_params.RawCfRayID | Omit = omit, + raw_method: audit_list_params.RawMethod | Omit = omit, + raw_status_code: audit_list_params.RawStatusCode | Omit = omit, + raw_uri: audit_list_params.RawURI | Omit = omit, + resource_id: audit_list_params.ResourceID | Omit = omit, + resource_product: audit_list_params.ResourceProduct | Omit = omit, + resource_scope: audit_list_params.ResourceScope | Omit = omit, + resource_type: audit_list_params.ResourceType | Omit = omit, + zone_id: audit_list_params.ZoneID | Omit = omit, + zone_name: audit_list_params.ZoneName | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncCursorPaginationAfter[AuditListResponse]: + """Gets a list of audit logs for an account. + +

This is the beta release + of Audit Logs Version 2. Since this is a beta version, there may be gaps or + missing entries in the available audit logs. Be aware of the following + limitations.
  • Audit logs are available only for the past 30 days. +
  • Error handling is not yet implemented.
+ + Args: + account_id: The unique id that identifies the account. + + before: Limits the returned results to logs older than the specified date. This can be a + date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + conforms to RFC3339. + + since: Limits the returned results to logs newer than the specified date. This can be a + date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + conforms to RFC3339. + + cursor: The cursor is an opaque token used to paginate through large sets of records. It + indicates the position from which to continue when requesting the next set of + records. A valid cursor value can be obtained from the cursor object in the + result_info structure of a previous response. + + direction: Sets sorting order. + + limit: The number limits the objects to return. The cursor attribute may be used to + iterate over the next batch of objects if there are more than the limit. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/logs/audit", + page=SyncCursorPaginationAfter[AuditListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "before": before, + "since": since, + "id": id, + "account_name": account_name, + "action_result": action_result, + "action_type": action_type, + "actor_context": actor_context, + "actor_email": actor_email, + "actor_id": actor_id, + "actor_ip_address": actor_ip_address, + "actor_token_id": actor_token_id, + "actor_token_name": actor_token_name, + "actor_type": actor_type, + "audit_log_id": audit_log_id, + "cursor": cursor, + "direction": direction, + "limit": limit, + "raw_cf_rayid": raw_cf_rayid, + "raw_method": raw_method, + "raw_status_code": raw_status_code, + "raw_uri": raw_uri, + "resource_id": resource_id, + "resource_product": resource_product, + "resource_scope": resource_scope, + "resource_type": resource_type, + "zone_id": zone_id, + "zone_name": zone_name, + }, + audit_list_params.AuditListParams, + ), + ), + model=AuditListResponse, + ) + + +class AsyncAuditResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAuditResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAuditResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAuditResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAuditResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + before: Union[str, date], + since: Union[str, date], + id: audit_list_params.ID | Omit = omit, + account_name: audit_list_params.AccountName | Omit = omit, + action_result: audit_list_params.ActionResult | Omit = omit, + action_type: audit_list_params.ActionType | Omit = omit, + actor_context: audit_list_params.ActorContext | Omit = omit, + actor_email: audit_list_params.ActorEmail | Omit = omit, + actor_id: audit_list_params.ActorID | Omit = omit, + actor_ip_address: audit_list_params.ActorIPAddress | Omit = omit, + actor_token_id: audit_list_params.ActorTokenID | Omit = omit, + actor_token_name: audit_list_params.ActorTokenName | Omit = omit, + actor_type: audit_list_params.ActorType | Omit = omit, + audit_log_id: audit_list_params.AuditLogID | Omit = omit, + cursor: str | Omit = omit, + direction: Literal["desc", "asc"] | Omit = omit, + limit: float | Omit = omit, + raw_cf_rayid: audit_list_params.RawCfRayID | Omit = omit, + raw_method: audit_list_params.RawMethod | Omit = omit, + raw_status_code: audit_list_params.RawStatusCode | Omit = omit, + raw_uri: audit_list_params.RawURI | Omit = omit, + resource_id: audit_list_params.ResourceID | Omit = omit, + resource_product: audit_list_params.ResourceProduct | Omit = omit, + resource_scope: audit_list_params.ResourceScope | Omit = omit, + resource_type: audit_list_params.ResourceType | Omit = omit, + zone_id: audit_list_params.ZoneID | Omit = omit, + zone_name: audit_list_params.ZoneName | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[AuditListResponse, AsyncCursorPaginationAfter[AuditListResponse]]: + """Gets a list of audit logs for an account. + +

This is the beta release + of Audit Logs Version 2. Since this is a beta version, there may be gaps or + missing entries in the available audit logs. Be aware of the following + limitations.
  • Audit logs are available only for the past 30 days. +
  • Error handling is not yet implemented.
+ + Args: + account_id: The unique id that identifies the account. + + before: Limits the returned results to logs older than the specified date. This can be a + date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + conforms to RFC3339. + + since: Limits the returned results to logs newer than the specified date. This can be a + date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + conforms to RFC3339. + + cursor: The cursor is an opaque token used to paginate through large sets of records. It + indicates the position from which to continue when requesting the next set of + records. A valid cursor value can be obtained from the cursor object in the + result_info structure of a previous response. + + direction: Sets sorting order. + + limit: The number limits the objects to return. The cursor attribute may be used to + iterate over the next batch of objects if there are more than the limit. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/logs/audit", + page=AsyncCursorPaginationAfter[AuditListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "before": before, + "since": since, + "id": id, + "account_name": account_name, + "action_result": action_result, + "action_type": action_type, + "actor_context": actor_context, + "actor_email": actor_email, + "actor_id": actor_id, + "actor_ip_address": actor_ip_address, + "actor_token_id": actor_token_id, + "actor_token_name": actor_token_name, + "actor_type": actor_type, + "audit_log_id": audit_log_id, + "cursor": cursor, + "direction": direction, + "limit": limit, + "raw_cf_rayid": raw_cf_rayid, + "raw_method": raw_method, + "raw_status_code": raw_status_code, + "raw_uri": raw_uri, + "resource_id": resource_id, + "resource_product": resource_product, + "resource_scope": resource_scope, + "resource_type": resource_type, + "zone_id": zone_id, + "zone_name": zone_name, + }, + audit_list_params.AuditListParams, + ), + ), + model=AuditListResponse, + ) + + +class AuditResourceWithRawResponse: + def __init__(self, audit: AuditResource) -> None: + self._audit = audit + + self.list = to_raw_response_wrapper( + audit.list, + ) + + +class AsyncAuditResourceWithRawResponse: + def __init__(self, audit: AsyncAuditResource) -> None: + self._audit = audit + + self.list = async_to_raw_response_wrapper( + audit.list, + ) + + +class AuditResourceWithStreamingResponse: + def __init__(self, audit: AuditResource) -> None: + self._audit = audit + + self.list = to_streamed_response_wrapper( + audit.list, + ) + + +class AsyncAuditResourceWithStreamingResponse: + def __init__(self, audit: AsyncAuditResource) -> None: + self._audit = audit + + self.list = async_to_streamed_response_wrapper( + audit.list, + ) diff --git a/src/cloudflare/resources/accounts/logs/logs.py b/src/cloudflare/resources/accounts/logs/logs.py new file mode 100644 index 00000000000..69595caf7a3 --- /dev/null +++ b/src/cloudflare/resources/accounts/logs/logs.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .audit import ( + AuditResource, + AsyncAuditResource, + AuditResourceWithRawResponse, + AsyncAuditResourceWithRawResponse, + AuditResourceWithStreamingResponse, + AsyncAuditResourceWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["LogsResource", "AsyncLogsResource"] + + +class LogsResource(SyncAPIResource): + @cached_property + def audit(self) -> AuditResource: + return AuditResource(self._client) + + @cached_property + def with_raw_response(self) -> LogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LogsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LogsResourceWithStreamingResponse(self) + + +class AsyncLogsResource(AsyncAPIResource): + @cached_property + def audit(self) -> AsyncAuditResource: + return AsyncAuditResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLogsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLogsResourceWithStreamingResponse(self) + + +class LogsResourceWithRawResponse: + def __init__(self, logs: LogsResource) -> None: + self._logs = logs + + @cached_property + def audit(self) -> AuditResourceWithRawResponse: + return AuditResourceWithRawResponse(self._logs.audit) + + +class AsyncLogsResourceWithRawResponse: + def __init__(self, logs: AsyncLogsResource) -> None: + self._logs = logs + + @cached_property + def audit(self) -> AsyncAuditResourceWithRawResponse: + return AsyncAuditResourceWithRawResponse(self._logs.audit) + + +class LogsResourceWithStreamingResponse: + def __init__(self, logs: LogsResource) -> None: + self._logs = logs + + @cached_property + def audit(self) -> AuditResourceWithStreamingResponse: + return AuditResourceWithStreamingResponse(self._logs.audit) + + +class AsyncLogsResourceWithStreamingResponse: + def __init__(self, logs: AsyncLogsResource) -> None: + self._logs = logs + + @cached_property + def audit(self) -> AsyncAuditResourceWithStreamingResponse: + return AsyncAuditResourceWithStreamingResponse(self._logs.audit) diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 97716de0279..61eb3ff9fc2 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -2,17 +2,13 @@ from __future__ import annotations -from typing import List, Type, Iterable, Optional, cast, overload -from typing_extensions import Literal +from typing import Type, Iterable, Optional, cast +from typing_extensions import Literal, overload import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - required_args, - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -25,11 +21,9 @@ from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options from ...types.accounts import member_list_params, member_create_params, member_update_params -from ...types.accounts.member_get_response import MemberGetResponse -from ...types.accounts.member_list_response import MemberListResponse -from ...types.accounts.member_create_response import MemberCreateResponse +from ...types.shared.member import Member +from ...types.shared_params.role import Role from ...types.accounts.member_delete_response import MemberDeleteResponse -from ...types.accounts.member_update_response import MemberUpdateResponse __all__ = ["MembersResource", "AsyncMembersResource"] @@ -37,10 +31,21 @@ class MembersResource(SyncAPIResource): @cached_property def with_raw_response(self) -> MembersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return MembersResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> MembersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return MembersResourceWithStreamingResponse(self) @overload @@ -49,15 +54,15 @@ def create( *, account_id: str, email: str, - roles: List[str], - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + roles: SequenceNotStr[str], + status: Literal["accepted", "pending"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Add a user to the list of members for this account. @@ -85,14 +90,14 @@ def create( account_id: str, email: str, policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Add a user to the list of members for this account. @@ -119,16 +124,16 @@ def create( *, account_id: str, email: str, - roles: List[str] | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + roles: SequenceNotStr[str] | Omit = omit, + status: Literal["accepted", "pending"] | Omit = omit, + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._post( @@ -147,9 +152,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) @overload @@ -158,14 +163,14 @@ def update( member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + roles: Iterable[Role] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Modify an account member. @@ -198,8 +203,8 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Modify an account member. @@ -226,15 +231,15 @@ def update( member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + roles: Iterable[Role] | Omit = omit, + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: @@ -253,27 +258,27 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) def list( self, *, account_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - order: Literal["user.first_name", "user.last_name", "user.email", "status"] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending", "rejected"] | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + order: Literal["user.first_name", "user.last_name", "user.email", "status"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + status: Literal["accepted", "pending", "rejected"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[MemberListResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[Member]: """ List all members of an account. @@ -302,7 +307,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/members", - page=SyncV4PagePaginationArray[MemberListResponse], + page=SyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -319,7 +324,7 @@ def list( member_list_params.MemberListParams, ), ), - model=MemberListResponse, + model=Member, ) def delete( @@ -332,7 +337,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[MemberDeleteResponse]: """ Remove a member from an account. @@ -376,8 +381,8 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberGetResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Get information about a specific member of an account. @@ -405,19 +410,30 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) class AsyncMembersResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncMembersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncMembersResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncMembersResourceWithStreamingResponse(self) @overload @@ -426,15 +442,15 @@ async def create( *, account_id: str, email: str, - roles: List[str], - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + roles: SequenceNotStr[str], + status: Literal["accepted", "pending"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Add a user to the list of members for this account. @@ -462,14 +478,14 @@ async def create( account_id: str, email: str, policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Add a user to the list of members for this account. @@ -496,16 +512,16 @@ async def create( *, account_id: str, email: str, - roles: List[str] | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + roles: SequenceNotStr[str] | Omit = omit, + status: Literal["accepted", "pending"] | Omit = omit, + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._post( @@ -524,9 +540,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) @overload @@ -535,14 +551,14 @@ async def update( member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + roles: Iterable[Role] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Modify an account member. @@ -575,8 +591,8 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Modify an account member. @@ -603,15 +619,15 @@ async def update( member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + roles: Iterable[Role] | Omit = omit, + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: @@ -630,27 +646,27 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) def list( self, *, account_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - order: Literal["user.first_name", "user.last_name", "user.email", "status"] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending", "rejected"] | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + order: Literal["user.first_name", "user.last_name", "user.email", "status"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + status: Literal["accepted", "pending", "rejected"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[MemberListResponse, AsyncV4PagePaginationArray[MemberListResponse]]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Member, AsyncV4PagePaginationArray[Member]]: """ List all members of an account. @@ -679,7 +695,7 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/members", - page=AsyncV4PagePaginationArray[MemberListResponse], + page=AsyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -696,7 +712,7 @@ def list( member_list_params.MemberListParams, ), ), - model=MemberListResponse, + model=Member, ) async def delete( @@ -709,7 +725,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[MemberDeleteResponse]: """ Remove a member from an account. @@ -753,8 +769,8 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MemberGetResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Member]: """ Get information about a specific member of an account. @@ -782,9 +798,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Member]]._unwrapper, ), - cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), + cast_to=cast(Type[Optional[Member]], ResultWrapper[Member]), ) diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index f23d3aa498c..399ad9f9449 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -6,7 +6,8 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -16,8 +17,9 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper -from ...pagination import SyncSinglePage, AsyncSinglePage +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options +from ...types.accounts import role_list_params from ...types.shared.role import Role __all__ = ["RolesResource", "AsyncRolesResource"] @@ -26,29 +28,46 @@ class RolesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> RolesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return RolesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> RolesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return RolesResourceWithStreamingResponse(self) def list( self, *, account_id: str, + page: float | Omit = omit, + per_page: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Role]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[Role]: """ Get all available roles for an account. Args: account_id: Account identifier tag. + page: Page number of paginated results. + + per_page: Number of roles per page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -61,16 +80,26 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/roles", - page=SyncSinglePage[Role], + page=SyncV4PagePaginationArray[Role], options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + role_list_params.RoleListParams, + ), ), model=Role, ) def get( self, - role_id: object, + role_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -78,14 +107,16 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Role]: """ Get information about a specific role for an account. Args: account_id: Account identifier tag. + role_id: Role identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -96,6 +127,8 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not role_id: + raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._get( f"/accounts/{account_id}/roles/{role_id}", options=make_request_options( @@ -103,38 +136,55 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Role]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Role]], ResultWrapper[Role]), ) class AsyncRolesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncRolesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncRolesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncRolesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncRolesResourceWithStreamingResponse(self) def list( self, *, account_id: str, + page: float | Omit = omit, + per_page: float | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Role, AsyncSinglePage[Role]]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Role, AsyncV4PagePaginationArray[Role]]: """ Get all available roles for an account. Args: account_id: Account identifier tag. + page: Page number of paginated results. + + per_page: Number of roles per page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -147,16 +197,26 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/roles", - page=AsyncSinglePage[Role], + page=AsyncV4PagePaginationArray[Role], options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + role_list_params.RoleListParams, + ), ), model=Role, ) async def get( self, - role_id: object, + role_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -164,14 +224,16 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Role]: """ Get information about a specific role for an account. Args: account_id: Account identifier tag. + role_id: Role identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -182,6 +244,8 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not role_id: + raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._get( f"/accounts/{account_id}/roles/{role_id}", options=make_request_options( @@ -189,9 +253,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[object]]._unwrapper, + post_parser=ResultWrapper[Optional[Role]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[Role]], ResultWrapper[Role]), ) diff --git a/src/cloudflare/resources/accounts/subscriptions.py b/src/cloudflare/resources/accounts/subscriptions.py new file mode 100644 index 00000000000..7209c025dfa --- /dev/null +++ b/src/cloudflare/resources/accounts/subscriptions.py @@ -0,0 +1,528 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options +from ...types.accounts import subscription_create_params, subscription_update_params +from ...types.shared.subscription import Subscription +from ...types.shared_params.rate_plan import RatePlan +from ...types.accounts.subscription_delete_response import SubscriptionDeleteResponse + +__all__ = ["SubscriptionsResource", "AsyncSubscriptionsResource"] + + +class SubscriptionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SubscriptionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return SubscriptionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SubscriptionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return SubscriptionsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + frequency: Literal["weekly", "monthly", "quarterly", "yearly"] | Omit = omit, + rate_plan: RatePlan | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Subscription: + """ + Creates an account subscription. + + Args: + account_id: Identifier + + frequency: How often the subscription is renewed automatically. + + rate_plan: The rate plan applied to the subscription. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/subscriptions", + body=maybe_transform( + { + "frequency": frequency, + "rate_plan": rate_plan, + }, + subscription_create_params.SubscriptionCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Subscription]._unwrapper, + ), + cast_to=cast(Type[Subscription], ResultWrapper[Subscription]), + ) + + def update( + self, + subscription_identifier: str, + *, + account_id: str, + frequency: Literal["weekly", "monthly", "quarterly", "yearly"] | Omit = omit, + rate_plan: RatePlan | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Subscription: + """ + Updates an account subscription. + + Args: + account_id: Identifier + + subscription_identifier: Subscription identifier tag. + + frequency: How often the subscription is renewed automatically. + + rate_plan: The rate plan applied to the subscription. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not subscription_identifier: + raise ValueError( + f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" + ) + return self._put( + f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + body=maybe_transform( + { + "frequency": frequency, + "rate_plan": rate_plan, + }, + subscription_update_params.SubscriptionUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Subscription]._unwrapper, + ), + cast_to=cast(Type[Subscription], ResultWrapper[Subscription]), + ) + + def delete( + self, + subscription_identifier: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SubscriptionDeleteResponse: + """ + Deletes an account's subscription. + + Args: + account_id: Identifier + + subscription_identifier: Subscription identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not subscription_identifier: + raise ValueError( + f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" + ) + return self._delete( + f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SubscriptionDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[SubscriptionDeleteResponse], ResultWrapper[SubscriptionDeleteResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[Subscription]: + """ + Lists all of an account's subscriptions. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/subscriptions", + page=SyncSinglePage[Subscription], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Subscription, + ) + + +class AsyncSubscriptionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSubscriptionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncSubscriptionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSubscriptionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncSubscriptionsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + frequency: Literal["weekly", "monthly", "quarterly", "yearly"] | Omit = omit, + rate_plan: RatePlan | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Subscription: + """ + Creates an account subscription. + + Args: + account_id: Identifier + + frequency: How often the subscription is renewed automatically. + + rate_plan: The rate plan applied to the subscription. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/subscriptions", + body=await async_maybe_transform( + { + "frequency": frequency, + "rate_plan": rate_plan, + }, + subscription_create_params.SubscriptionCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Subscription]._unwrapper, + ), + cast_to=cast(Type[Subscription], ResultWrapper[Subscription]), + ) + + async def update( + self, + subscription_identifier: str, + *, + account_id: str, + frequency: Literal["weekly", "monthly", "quarterly", "yearly"] | Omit = omit, + rate_plan: RatePlan | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Subscription: + """ + Updates an account subscription. + + Args: + account_id: Identifier + + subscription_identifier: Subscription identifier tag. + + frequency: How often the subscription is renewed automatically. + + rate_plan: The rate plan applied to the subscription. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not subscription_identifier: + raise ValueError( + f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" + ) + return await self._put( + f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + body=await async_maybe_transform( + { + "frequency": frequency, + "rate_plan": rate_plan, + }, + subscription_update_params.SubscriptionUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Subscription]._unwrapper, + ), + cast_to=cast(Type[Subscription], ResultWrapper[Subscription]), + ) + + async def delete( + self, + subscription_identifier: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SubscriptionDeleteResponse: + """ + Deletes an account's subscription. + + Args: + account_id: Identifier + + subscription_identifier: Subscription identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not subscription_identifier: + raise ValueError( + f"Expected a non-empty value for `subscription_identifier` but received {subscription_identifier!r}" + ) + return await self._delete( + f"/accounts/{account_id}/subscriptions/{subscription_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SubscriptionDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[SubscriptionDeleteResponse], ResultWrapper[SubscriptionDeleteResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Subscription, AsyncSinglePage[Subscription]]: + """ + Lists all of an account's subscriptions. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/subscriptions", + page=AsyncSinglePage[Subscription], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Subscription, + ) + + +class SubscriptionsResourceWithRawResponse: + def __init__(self, subscriptions: SubscriptionsResource) -> None: + self._subscriptions = subscriptions + + self.create = to_raw_response_wrapper( + subscriptions.create, + ) + self.update = to_raw_response_wrapper( + subscriptions.update, + ) + self.delete = to_raw_response_wrapper( + subscriptions.delete, + ) + self.get = to_raw_response_wrapper( + subscriptions.get, + ) + + +class AsyncSubscriptionsResourceWithRawResponse: + def __init__(self, subscriptions: AsyncSubscriptionsResource) -> None: + self._subscriptions = subscriptions + + self.create = async_to_raw_response_wrapper( + subscriptions.create, + ) + self.update = async_to_raw_response_wrapper( + subscriptions.update, + ) + self.delete = async_to_raw_response_wrapper( + subscriptions.delete, + ) + self.get = async_to_raw_response_wrapper( + subscriptions.get, + ) + + +class SubscriptionsResourceWithStreamingResponse: + def __init__(self, subscriptions: SubscriptionsResource) -> None: + self._subscriptions = subscriptions + + self.create = to_streamed_response_wrapper( + subscriptions.create, + ) + self.update = to_streamed_response_wrapper( + subscriptions.update, + ) + self.delete = to_streamed_response_wrapper( + subscriptions.delete, + ) + self.get = to_streamed_response_wrapper( + subscriptions.get, + ) + + +class AsyncSubscriptionsResourceWithStreamingResponse: + def __init__(self, subscriptions: AsyncSubscriptionsResource) -> None: + self._subscriptions = subscriptions + + self.create = async_to_streamed_response_wrapper( + subscriptions.create, + ) + self.update = async_to_streamed_response_wrapper( + subscriptions.update, + ) + self.delete = async_to_streamed_response_wrapper( + subscriptions.delete, + ) + self.get = async_to_streamed_response_wrapper( + subscriptions.get, + ) diff --git a/src/cloudflare/resources/accounts/tokens/__init__.py b/src/cloudflare/resources/accounts/tokens/__init__.py new file mode 100644 index 00000000000..f42f0970969 --- /dev/null +++ b/src/cloudflare/resources/accounts/tokens/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .value import ( + ValueResource, + AsyncValueResource, + ValueResourceWithRawResponse, + AsyncValueResourceWithRawResponse, + ValueResourceWithStreamingResponse, + AsyncValueResourceWithStreamingResponse, +) +from .tokens import ( + TokensResource, + AsyncTokensResource, + TokensResourceWithRawResponse, + AsyncTokensResourceWithRawResponse, + TokensResourceWithStreamingResponse, + AsyncTokensResourceWithStreamingResponse, +) +from .permission_groups import ( + PermissionGroupsResource, + AsyncPermissionGroupsResource, + PermissionGroupsResourceWithRawResponse, + AsyncPermissionGroupsResourceWithRawResponse, + PermissionGroupsResourceWithStreamingResponse, + AsyncPermissionGroupsResourceWithStreamingResponse, +) + +__all__ = [ + "PermissionGroupsResource", + "AsyncPermissionGroupsResource", + "PermissionGroupsResourceWithRawResponse", + "AsyncPermissionGroupsResourceWithRawResponse", + "PermissionGroupsResourceWithStreamingResponse", + "AsyncPermissionGroupsResourceWithStreamingResponse", + "ValueResource", + "AsyncValueResource", + "ValueResourceWithRawResponse", + "AsyncValueResourceWithRawResponse", + "ValueResourceWithStreamingResponse", + "AsyncValueResourceWithStreamingResponse", + "TokensResource", + "AsyncTokensResource", + "TokensResourceWithRawResponse", + "AsyncTokensResourceWithRawResponse", + "TokensResourceWithStreamingResponse", + "AsyncTokensResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/accounts/tokens/permission_groups.py b/src/cloudflare/resources/accounts/tokens/permission_groups.py new file mode 100644 index 00000000000..2efe092f8ec --- /dev/null +++ b/src/cloudflare/resources/accounts/tokens/permission_groups.py @@ -0,0 +1,324 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.accounts.tokens import permission_group_get_params, permission_group_list_params +from ....types.accounts.tokens.permission_group_get_response import PermissionGroupGetResponse +from ....types.accounts.tokens.permission_group_list_response import PermissionGroupListResponse + +__all__ = ["PermissionGroupsResource", "AsyncPermissionGroupsResource"] + + +class PermissionGroupsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PermissionGroupsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return PermissionGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PermissionGroupsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return PermissionGroupsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + name: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[PermissionGroupListResponse]: + """ + Find all available permission groups for Account Owned API Tokens + + Args: + account_id: Account identifier tag. + + name: Filter by the name of the permission group. The value must be URL-encoded. + + scope: Filter by the scope of the permission group. The value must be URL-encoded. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/tokens/permission_groups", + page=SyncSinglePage[PermissionGroupListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "name": name, + "scope": scope, + }, + permission_group_list_params.PermissionGroupListParams, + ), + ), + model=PermissionGroupListResponse, + ) + + def get( + self, + *, + account_id: str, + name: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[PermissionGroupGetResponse]: + """ + Find all available permission groups for Account Owned API Tokens + + Args: + account_id: Account identifier tag. + + name: Filter by the name of the permission group. The value must be URL-encoded. + + scope: Filter by the scope of the permission group. The value must be URL-encoded. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/tokens/permission_groups", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "name": name, + "scope": scope, + }, + permission_group_get_params.PermissionGroupGetParams, + ), + post_parser=ResultWrapper[Optional[PermissionGroupGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PermissionGroupGetResponse]], ResultWrapper[PermissionGroupGetResponse]), + ) + + +class AsyncPermissionGroupsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPermissionGroupsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncPermissionGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPermissionGroupsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncPermissionGroupsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + name: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[PermissionGroupListResponse, AsyncSinglePage[PermissionGroupListResponse]]: + """ + Find all available permission groups for Account Owned API Tokens + + Args: + account_id: Account identifier tag. + + name: Filter by the name of the permission group. The value must be URL-encoded. + + scope: Filter by the scope of the permission group. The value must be URL-encoded. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/tokens/permission_groups", + page=AsyncSinglePage[PermissionGroupListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "name": name, + "scope": scope, + }, + permission_group_list_params.PermissionGroupListParams, + ), + ), + model=PermissionGroupListResponse, + ) + + async def get( + self, + *, + account_id: str, + name: str | Omit = omit, + scope: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[PermissionGroupGetResponse]: + """ + Find all available permission groups for Account Owned API Tokens + + Args: + account_id: Account identifier tag. + + name: Filter by the name of the permission group. The value must be URL-encoded. + + scope: Filter by the scope of the permission group. The value must be URL-encoded. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/tokens/permission_groups", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "name": name, + "scope": scope, + }, + permission_group_get_params.PermissionGroupGetParams, + ), + post_parser=ResultWrapper[Optional[PermissionGroupGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PermissionGroupGetResponse]], ResultWrapper[PermissionGroupGetResponse]), + ) + + +class PermissionGroupsResourceWithRawResponse: + def __init__(self, permission_groups: PermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = to_raw_response_wrapper( + permission_groups.list, + ) + self.get = to_raw_response_wrapper( + permission_groups.get, + ) + + +class AsyncPermissionGroupsResourceWithRawResponse: + def __init__(self, permission_groups: AsyncPermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = async_to_raw_response_wrapper( + permission_groups.list, + ) + self.get = async_to_raw_response_wrapper( + permission_groups.get, + ) + + +class PermissionGroupsResourceWithStreamingResponse: + def __init__(self, permission_groups: PermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = to_streamed_response_wrapper( + permission_groups.list, + ) + self.get = to_streamed_response_wrapper( + permission_groups.get, + ) + + +class AsyncPermissionGroupsResourceWithStreamingResponse: + def __init__(self, permission_groups: AsyncPermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = async_to_streamed_response_wrapper( + permission_groups.list, + ) + self.get = async_to_streamed_response_wrapper( + permission_groups.get, + ) diff --git a/src/cloudflare/resources/accounts/tokens/tokens.py b/src/cloudflare/resources/accounts/tokens/tokens.py new file mode 100644 index 00000000000..eb6d7826528 --- /dev/null +++ b/src/cloudflare/resources/accounts/tokens/tokens.py @@ -0,0 +1,869 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, Iterable, Optional, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from .value import ( + ValueResource, + AsyncValueResource, + ValueResourceWithRawResponse, + AsyncValueResourceWithRawResponse, + ValueResourceWithStreamingResponse, + AsyncValueResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options +from ....types.accounts import token_list_params, token_create_params, token_update_params +from .permission_groups import ( + PermissionGroupsResource, + AsyncPermissionGroupsResource, + PermissionGroupsResourceWithRawResponse, + AsyncPermissionGroupsResourceWithRawResponse, + PermissionGroupsResourceWithStreamingResponse, + AsyncPermissionGroupsResourceWithStreamingResponse, +) +from ....types.shared.token import Token +from ....types.shared_params.token_policy import TokenPolicy +from ....types.accounts.token_create_response import TokenCreateResponse +from ....types.accounts.token_delete_response import TokenDeleteResponse +from ....types.accounts.token_verify_response import TokenVerifyResponse + +__all__ = ["TokensResource", "AsyncTokensResource"] + + +class TokensResource(SyncAPIResource): + @cached_property + def permission_groups(self) -> PermissionGroupsResource: + return PermissionGroupsResource(self._client) + + @cached_property + def value(self) -> ValueResource: + return ValueResource(self._client) + + @cached_property + def with_raw_response(self) -> TokensResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return TokensResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TokensResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return TokensResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + name: str, + policies: Iterable[TokenPolicy], + condition: token_create_params.Condition | Omit = omit, + expires_on: Union[str, datetime] | Omit = omit, + not_before: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenCreateResponse]: + """ + Create a new Account Owned API token. + + Args: + account_id: Account identifier tag. + + name: Token name. + + policies: List of access policies assigned to the token. + + expires_on: The expiration time on or after which the JWT MUST NOT be accepted for + processing. + + not_before: The time before which the token MUST NOT be accepted for processing. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/tokens", + body=maybe_transform( + { + "name": name, + "policies": policies, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + }, + token_create_params.TokenCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenCreateResponse]], ResultWrapper[TokenCreateResponse]), + ) + + def update( + self, + token_id: str, + *, + account_id: str, + name: str, + policies: Iterable[TokenPolicy], + condition: token_update_params.Condition | Omit = omit, + expires_on: Union[str, datetime] | Omit = omit, + not_before: Union[str, datetime] | Omit = omit, + status: Literal["active", "disabled", "expired"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Token]: + """ + Update an existing token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + name: Token name. + + policies: List of access policies assigned to the token. + + expires_on: The expiration time on or after which the JWT MUST NOT be accepted for + processing. + + not_before: The time before which the token MUST NOT be accepted for processing. + + status: Status of the token. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return self._put( + f"/accounts/{account_id}/tokens/{token_id}", + body=maybe_transform( + { + "name": name, + "policies": policies, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + "status": status, + }, + token_update_params.TokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, + ), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), + ) + + def list( + self, + *, + account_id: str, + direction: Literal["asc", "desc"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[Token]: + """ + List all Account Owned API tokens created for this account. + + Args: + account_id: Account identifier tag. + + direction: Direction to order results. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/tokens", + page=SyncV4PagePaginationArray[Token], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "page": page, + "per_page": per_page, + }, + token_list_params.TokenListParams, + ), + ), + model=Token, + ) + + def delete( + self, + token_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenDeleteResponse]: + """ + Destroy an Account Owned API token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return self._delete( + f"/accounts/{account_id}/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenDeleteResponse]], ResultWrapper[TokenDeleteResponse]), + ) + + def get( + self, + token_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Token]: + """ + Get information about a specific Account Owned API token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return self._get( + f"/accounts/{account_id}/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, + ), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), + ) + + def verify( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenVerifyResponse]: + """ + Test whether a token works. + + Args: + account_id: Account identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/tokens/verify", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenVerifyResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenVerifyResponse]], ResultWrapper[TokenVerifyResponse]), + ) + + +class AsyncTokensResource(AsyncAPIResource): + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResource: + return AsyncPermissionGroupsResource(self._client) + + @cached_property + def value(self) -> AsyncValueResource: + return AsyncValueResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncTokensResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncTokensResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncTokensResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + name: str, + policies: Iterable[TokenPolicy], + condition: token_create_params.Condition | Omit = omit, + expires_on: Union[str, datetime] | Omit = omit, + not_before: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenCreateResponse]: + """ + Create a new Account Owned API token. + + Args: + account_id: Account identifier tag. + + name: Token name. + + policies: List of access policies assigned to the token. + + expires_on: The expiration time on or after which the JWT MUST NOT be accepted for + processing. + + not_before: The time before which the token MUST NOT be accepted for processing. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/tokens", + body=await async_maybe_transform( + { + "name": name, + "policies": policies, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + }, + token_create_params.TokenCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenCreateResponse]], ResultWrapper[TokenCreateResponse]), + ) + + async def update( + self, + token_id: str, + *, + account_id: str, + name: str, + policies: Iterable[TokenPolicy], + condition: token_update_params.Condition | Omit = omit, + expires_on: Union[str, datetime] | Omit = omit, + not_before: Union[str, datetime] | Omit = omit, + status: Literal["active", "disabled", "expired"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Token]: + """ + Update an existing token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + name: Token name. + + policies: List of access policies assigned to the token. + + expires_on: The expiration time on or after which the JWT MUST NOT be accepted for + processing. + + not_before: The time before which the token MUST NOT be accepted for processing. + + status: Status of the token. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return await self._put( + f"/accounts/{account_id}/tokens/{token_id}", + body=await async_maybe_transform( + { + "name": name, + "policies": policies, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + "status": status, + }, + token_update_params.TokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, + ), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), + ) + + def list( + self, + *, + account_id: str, + direction: Literal["asc", "desc"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Token, AsyncV4PagePaginationArray[Token]]: + """ + List all Account Owned API tokens created for this account. + + Args: + account_id: Account identifier tag. + + direction: Direction to order results. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/tokens", + page=AsyncV4PagePaginationArray[Token], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "page": page, + "per_page": per_page, + }, + token_list_params.TokenListParams, + ), + ), + model=Token, + ) + + async def delete( + self, + token_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenDeleteResponse]: + """ + Destroy an Account Owned API token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return await self._delete( + f"/accounts/{account_id}/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenDeleteResponse]], ResultWrapper[TokenDeleteResponse]), + ) + + async def get( + self, + token_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[Token]: + """ + Get information about a specific Account Owned API token. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return await self._get( + f"/accounts/{account_id}/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Token]]._unwrapper, + ), + cast_to=cast(Type[Optional[Token]], ResultWrapper[Token]), + ) + + async def verify( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TokenVerifyResponse]: + """ + Test whether a token works. + + Args: + account_id: Account identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/tokens/verify", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenVerifyResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TokenVerifyResponse]], ResultWrapper[TokenVerifyResponse]), + ) + + +class TokensResourceWithRawResponse: + def __init__(self, tokens: TokensResource) -> None: + self._tokens = tokens + + self.create = to_raw_response_wrapper( + tokens.create, + ) + self.update = to_raw_response_wrapper( + tokens.update, + ) + self.list = to_raw_response_wrapper( + tokens.list, + ) + self.delete = to_raw_response_wrapper( + tokens.delete, + ) + self.get = to_raw_response_wrapper( + tokens.get, + ) + self.verify = to_raw_response_wrapper( + tokens.verify, + ) + + @cached_property + def permission_groups(self) -> PermissionGroupsResourceWithRawResponse: + return PermissionGroupsResourceWithRawResponse(self._tokens.permission_groups) + + @cached_property + def value(self) -> ValueResourceWithRawResponse: + return ValueResourceWithRawResponse(self._tokens.value) + + +class AsyncTokensResourceWithRawResponse: + def __init__(self, tokens: AsyncTokensResource) -> None: + self._tokens = tokens + + self.create = async_to_raw_response_wrapper( + tokens.create, + ) + self.update = async_to_raw_response_wrapper( + tokens.update, + ) + self.list = async_to_raw_response_wrapper( + tokens.list, + ) + self.delete = async_to_raw_response_wrapper( + tokens.delete, + ) + self.get = async_to_raw_response_wrapper( + tokens.get, + ) + self.verify = async_to_raw_response_wrapper( + tokens.verify, + ) + + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResourceWithRawResponse: + return AsyncPermissionGroupsResourceWithRawResponse(self._tokens.permission_groups) + + @cached_property + def value(self) -> AsyncValueResourceWithRawResponse: + return AsyncValueResourceWithRawResponse(self._tokens.value) + + +class TokensResourceWithStreamingResponse: + def __init__(self, tokens: TokensResource) -> None: + self._tokens = tokens + + self.create = to_streamed_response_wrapper( + tokens.create, + ) + self.update = to_streamed_response_wrapper( + tokens.update, + ) + self.list = to_streamed_response_wrapper( + tokens.list, + ) + self.delete = to_streamed_response_wrapper( + tokens.delete, + ) + self.get = to_streamed_response_wrapper( + tokens.get, + ) + self.verify = to_streamed_response_wrapper( + tokens.verify, + ) + + @cached_property + def permission_groups(self) -> PermissionGroupsResourceWithStreamingResponse: + return PermissionGroupsResourceWithStreamingResponse(self._tokens.permission_groups) + + @cached_property + def value(self) -> ValueResourceWithStreamingResponse: + return ValueResourceWithStreamingResponse(self._tokens.value) + + +class AsyncTokensResourceWithStreamingResponse: + def __init__(self, tokens: AsyncTokensResource) -> None: + self._tokens = tokens + + self.create = async_to_streamed_response_wrapper( + tokens.create, + ) + self.update = async_to_streamed_response_wrapper( + tokens.update, + ) + self.list = async_to_streamed_response_wrapper( + tokens.list, + ) + self.delete = async_to_streamed_response_wrapper( + tokens.delete, + ) + self.get = async_to_streamed_response_wrapper( + tokens.get, + ) + self.verify = async_to_streamed_response_wrapper( + tokens.verify, + ) + + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResourceWithStreamingResponse: + return AsyncPermissionGroupsResourceWithStreamingResponse(self._tokens.permission_groups) + + @cached_property + def value(self) -> AsyncValueResourceWithStreamingResponse: + return AsyncValueResourceWithStreamingResponse(self._tokens.value) diff --git a/src/cloudflare/resources/accounts/tokens/value.py b/src/cloudflare/resources/accounts/tokens/value.py new file mode 100644 index 00000000000..5e76bc54948 --- /dev/null +++ b/src/cloudflare/resources/accounts/tokens/value.py @@ -0,0 +1,194 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.accounts.tokens import value_update_params +from ....types.shared.token_value import TokenValue + +__all__ = ["ValueResource", "AsyncValueResource"] + + +class ValueResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ValueResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ValueResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ValueResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ValueResourceWithStreamingResponse(self) + + def update( + self, + token_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Roll the Account Owned API token secret. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return self._put( + f"/accounts/{account_id}/tokens/{token_id}/value", + body=maybe_transform(body, value_update_params.ValueUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenValue]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class AsyncValueResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncValueResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncValueResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncValueResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncValueResourceWithStreamingResponse(self) + + async def update( + self, + token_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Roll the Account Owned API token secret. + + Args: + account_id: Account identifier tag. + + token_id: Token identifier tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not token_id: + raise ValueError(f"Expected a non-empty value for `token_id` but received {token_id!r}") + return await self._put( + f"/accounts/{account_id}/tokens/{token_id}/value", + body=await async_maybe_transform(body, value_update_params.ValueUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TokenValue]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class ValueResourceWithRawResponse: + def __init__(self, value: ValueResource) -> None: + self._value = value + + self.update = to_raw_response_wrapper( + value.update, + ) + + +class AsyncValueResourceWithRawResponse: + def __init__(self, value: AsyncValueResource) -> None: + self._value = value + + self.update = async_to_raw_response_wrapper( + value.update, + ) + + +class ValueResourceWithStreamingResponse: + def __init__(self, value: ValueResource) -> None: + self._value = value + + self.update = to_streamed_response_wrapper( + value.update, + ) + + +class AsyncValueResourceWithStreamingResponse: + def __init__(self, value: AsyncValueResource) -> None: + self._value = value + + self.update = async_to_streamed_response_wrapper( + value.update, + ) diff --git a/src/cloudflare/resources/acm/acm.py b/src/cloudflare/resources/acm/acm.py index ad401c45360..4d576c8fa13 100644 --- a/src/cloudflare/resources/acm/acm.py +++ b/src/cloudflare/resources/acm/acm.py @@ -23,10 +23,21 @@ def total_tls(self) -> TotalTLSResource: @cached_property def with_raw_response(self) -> ACMResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ACMResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ACMResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ACMResourceWithStreamingResponse(self) @@ -37,10 +48,21 @@ def total_tls(self) -> AsyncTotalTLSResource: @cached_property def with_raw_response(self) -> AsyncACMResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncACMResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncACMResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncACMResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/acm/total_tls.py b/src/cloudflare/resources/acm/total_tls.py index 22877d9f1a8..ed1c54d9f7e 100644 --- a/src/cloudflare/resources/acm/total_tls.py +++ b/src/cloudflare/resources/acm/total_tls.py @@ -6,11 +6,8 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -20,11 +17,12 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper -from ...types.acm import CertificateAuthority, total_tls_create_params +from ...types.acm import CertificateAuthority, total_tls_edit_params, total_tls_update_params from ..._base_client import make_request_options from ...types.acm.certificate_authority import CertificateAuthority from ...types.acm.total_tls_get_response import TotalTLSGetResponse -from ...types.acm.total_tls_create_response import TotalTLSCreateResponse +from ...types.acm.total_tls_edit_response import TotalTLSEditResponse +from ...types.acm.total_tls_update_response import TotalTLSUpdateResponse __all__ = ["TotalTLSResource", "AsyncTotalTLSResource"] @@ -32,30 +30,94 @@ class TotalTLSResource(SyncAPIResource): @cached_property def with_raw_response(self) -> TotalTLSResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return TotalTLSResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> TotalTLSResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return TotalTLSResourceWithStreamingResponse(self) - def create( + def update( + self, + *, + zone_id: str, + enabled: bool, + certificate_authority: CertificateAuthority | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TotalTLSUpdateResponse]: + """ + Set Total TLS Settings or disable the feature for a Zone. + + Args: + zone_id: Identifier. + + enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any + proxied A, AAAA, or CNAME record in your zone. + + certificate_authority: The Certificate Authority that Total TLS certificates will be issued through. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/acm/total_tls", + body=maybe_transform( + { + "enabled": enabled, + "certificate_authority": certificate_authority, + }, + total_tls_update_params.TotalTLSUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TotalTLSUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TotalTLSUpdateResponse]], ResultWrapper[TotalTLSUpdateResponse]), + ) + + def edit( self, *, zone_id: str, enabled: bool, - certificate_authority: CertificateAuthority | NotGiven = NOT_GIVEN, + certificate_authority: CertificateAuthority | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TotalTLSCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TotalTLSEditResponse]: """ Set Total TLS Settings or disable the feature for a Zone. Args: - zone_id: Identifier + zone_id: Identifier. enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any proxied A, AAAA, or CNAME record in your zone. @@ -79,16 +141,16 @@ def create( "enabled": enabled, "certificate_authority": certificate_authority, }, - total_tls_create_params.TotalTLSCreateParams, + total_tls_edit_params.TotalTLSEditParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TotalTLSCreateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[TotalTLSEditResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[TotalTLSCreateResponse]], ResultWrapper[TotalTLSCreateResponse]), + cast_to=cast(Type[Optional[TotalTLSEditResponse]], ResultWrapper[TotalTLSEditResponse]), ) def get( @@ -100,13 +162,13 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[TotalTLSGetResponse]: """ Get Total TLS Settings for a Zone. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -134,30 +196,41 @@ def get( class AsyncTotalTLSResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncTotalTLSResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncTotalTLSResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncTotalTLSResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncTotalTLSResourceWithStreamingResponse(self) - async def create( + async def update( self, *, zone_id: str, enabled: bool, - certificate_authority: CertificateAuthority | NotGiven = NOT_GIVEN, + certificate_authority: CertificateAuthority | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[TotalTLSCreateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TotalTLSUpdateResponse]: """ Set Total TLS Settings or disable the feature for a Zone. Args: - zone_id: Identifier + zone_id: Identifier. enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any proxied A, AAAA, or CNAME record in your zone. @@ -181,16 +254,69 @@ async def create( "enabled": enabled, "certificate_authority": certificate_authority, }, - total_tls_create_params.TotalTLSCreateParams, + total_tls_update_params.TotalTLSUpdateParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[TotalTLSCreateResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[TotalTLSUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[TotalTLSCreateResponse]], ResultWrapper[TotalTLSCreateResponse]), + cast_to=cast(Type[Optional[TotalTLSUpdateResponse]], ResultWrapper[TotalTLSUpdateResponse]), + ) + + async def edit( + self, + *, + zone_id: str, + enabled: bool, + certificate_authority: CertificateAuthority | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TotalTLSEditResponse]: + """ + Set Total TLS Settings or disable the feature for a Zone. + + Args: + zone_id: Identifier. + + enabled: If enabled, Total TLS will order a hostname specific TLS certificate for any + proxied A, AAAA, or CNAME record in your zone. + + certificate_authority: The Certificate Authority that Total TLS certificates will be issued through. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/acm/total_tls", + body=await async_maybe_transform( + { + "enabled": enabled, + "certificate_authority": certificate_authority, + }, + total_tls_edit_params.TotalTLSEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TotalTLSEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TotalTLSEditResponse]], ResultWrapper[TotalTLSEditResponse]), ) async def get( @@ -202,13 +328,13 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[TotalTLSGetResponse]: """ Get Total TLS Settings for a Zone. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -237,8 +363,11 @@ class TotalTLSResourceWithRawResponse: def __init__(self, total_tls: TotalTLSResource) -> None: self._total_tls = total_tls - self.create = to_raw_response_wrapper( - total_tls.create, + self.update = to_raw_response_wrapper( + total_tls.update, + ) + self.edit = to_raw_response_wrapper( + total_tls.edit, ) self.get = to_raw_response_wrapper( total_tls.get, @@ -249,8 +378,11 @@ class AsyncTotalTLSResourceWithRawResponse: def __init__(self, total_tls: AsyncTotalTLSResource) -> None: self._total_tls = total_tls - self.create = async_to_raw_response_wrapper( - total_tls.create, + self.update = async_to_raw_response_wrapper( + total_tls.update, + ) + self.edit = async_to_raw_response_wrapper( + total_tls.edit, ) self.get = async_to_raw_response_wrapper( total_tls.get, @@ -261,8 +393,11 @@ class TotalTLSResourceWithStreamingResponse: def __init__(self, total_tls: TotalTLSResource) -> None: self._total_tls = total_tls - self.create = to_streamed_response_wrapper( - total_tls.create, + self.update = to_streamed_response_wrapper( + total_tls.update, + ) + self.edit = to_streamed_response_wrapper( + total_tls.edit, ) self.get = to_streamed_response_wrapper( total_tls.get, @@ -273,8 +408,11 @@ class AsyncTotalTLSResourceWithStreamingResponse: def __init__(self, total_tls: AsyncTotalTLSResource) -> None: self._total_tls = total_tls - self.create = async_to_streamed_response_wrapper( - total_tls.create, + self.update = async_to_streamed_response_wrapper( + total_tls.update, + ) + self.edit = async_to_streamed_response_wrapper( + total_tls.edit, ) self.get = async_to_streamed_response_wrapper( total_tls.get, diff --git a/src/cloudflare/resources/addressing/address_maps/accounts.py b/src/cloudflare/resources/addressing/address_maps/accounts.py index a7a4e27322c..9d839d4a42d 100644 --- a/src/cloudflare/resources/addressing/address_maps/accounts.py +++ b/src/cloudflare/resources/addressing/address_maps/accounts.py @@ -2,15 +2,10 @@ from __future__ import annotations -from typing import Type, Optional, cast - import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -19,7 +14,6 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...._wrappers import ResultWrapper from ...._base_client import make_request_options from ....types.addressing.address_maps import account_update_params from ....types.addressing.address_maps.account_delete_response import AccountDeleteResponse @@ -31,10 +25,21 @@ class AccountsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> AccountsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AccountsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AccountsResourceWithStreamingResponse(self) def update( @@ -48,15 +53,15 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccountUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AccountUpdateResponse: """ Add an account as a member of a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -74,13 +79,9 @@ def update( 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, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AccountUpdateResponse]], ResultWrapper[AccountUpdateResponse]), + cast_to=AccountUpdateResponse, ) def delete( @@ -93,15 +94,15 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccountDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AccountDeleteResponse: """ Remove an account as a member of a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -118,23 +119,30 @@ def delete( return self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AccountDeleteResponse]], ResultWrapper[AccountDeleteResponse]), + cast_to=AccountDeleteResponse, ) class AsyncAccountsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAccountsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAccountsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAccountsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAccountsResourceWithStreamingResponse(self) async def update( @@ -148,15 +156,15 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccountUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AccountUpdateResponse: """ Add an account as a member of a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -174,13 +182,9 @@ async def update( 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, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AccountUpdateResponse]], ResultWrapper[AccountUpdateResponse]), + cast_to=AccountUpdateResponse, ) async def delete( @@ -193,15 +197,15 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccountDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AccountDeleteResponse: """ Remove an account as a member of a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -218,13 +222,9 @@ async def delete( return await self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/accounts/{account_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccountDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AccountDeleteResponse]], ResultWrapper[AccountDeleteResponse]), + cast_to=AccountDeleteResponse, ) diff --git a/src/cloudflare/resources/addressing/address_maps/address_maps.py b/src/cloudflare/resources/addressing/address_maps/address_maps.py index 755134df84f..af03cd6994b 100644 --- a/src/cloudflare/resources/addressing/address_maps/address_maps.py +++ b/src/cloudflare/resources/addressing/address_maps/address_maps.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Iterable, Optional, cast +from typing import Type, Iterable, Optional, cast import httpx @@ -30,11 +30,8 @@ AccountsResourceWithStreamingResponse, AsyncAccountsResourceWithStreamingResponse, ) -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -70,32 +67,43 @@ def zones(self) -> ZonesResource: @cached_property def with_raw_response(self) -> AddressMapsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AddressMapsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AddressMapsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AddressMapsResourceWithStreamingResponse(self) def create( self, *, account_id: str, - description: Optional[str] | NotGiven = NOT_GIVEN, - enabled: Optional[bool] | NotGiven = NOT_GIVEN, - ips: List[str] | NotGiven = NOT_GIVEN, - memberships: Iterable[address_map_create_params.Membership] | NotGiven = NOT_GIVEN, + description: Optional[str] | Omit = omit, + enabled: Optional[bool] | Omit = omit, + ips: SequenceNotStr[str] | Omit = omit, + memberships: Iterable[address_map_create_params.Membership] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMapCreateResponse]: """ Create a new address map under the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. description: An optional description field which may be used to describe the types of IPs or zones on the map. @@ -146,13 +154,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[AddressMap]: """ List all address maps owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers @@ -183,17 +191,17 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AddressMapDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressMapDeleteResponse: """Delete a particular address map owned by the account. An Address Map must be disabled before it can be deleted. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -210,13 +218,9 @@ def delete( return self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AddressMapDeleteResponse]], ResultWrapper[AddressMapDeleteResponse]), + cast_to=AddressMapDeleteResponse, ) def edit( @@ -224,23 +228,23 @@ def edit( address_map_id: str, *, account_id: str, - default_sni: Optional[str] | NotGiven = NOT_GIVEN, - description: Optional[str] | NotGiven = NOT_GIVEN, - enabled: Optional[bool] | NotGiven = NOT_GIVEN, + default_sni: Optional[str] | Omit = omit, + description: Optional[str] | Omit = omit, + enabled: Optional[bool] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMap]: """ Modify properties of an address map owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. default_sni: If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS @@ -296,15 +300,15 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMapGetResponse]: """ Show a particular address map owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -346,32 +350,43 @@ def zones(self) -> AsyncZonesResource: @cached_property def with_raw_response(self) -> AsyncAddressMapsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAddressMapsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAddressMapsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAddressMapsResourceWithStreamingResponse(self) async def create( self, *, account_id: str, - description: Optional[str] | NotGiven = NOT_GIVEN, - enabled: Optional[bool] | NotGiven = NOT_GIVEN, - ips: List[str] | NotGiven = NOT_GIVEN, - memberships: Iterable[address_map_create_params.Membership] | NotGiven = NOT_GIVEN, + description: Optional[str] | Omit = omit, + enabled: Optional[bool] | Omit = omit, + ips: SequenceNotStr[str] | Omit = omit, + memberships: Iterable[address_map_create_params.Membership] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMapCreateResponse]: """ Create a new address map under the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. description: An optional description field which may be used to describe the types of IPs or zones on the map. @@ -422,13 +437,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AddressMap, AsyncSinglePage[AddressMap]]: """ List all address maps owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers @@ -459,17 +474,17 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AddressMapDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressMapDeleteResponse: """Delete a particular address map owned by the account. An Address Map must be disabled before it can be deleted. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -486,13 +501,9 @@ async def delete( return await self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AddressMapDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[AddressMapDeleteResponse]], ResultWrapper[AddressMapDeleteResponse]), + cast_to=AddressMapDeleteResponse, ) async def edit( @@ -500,23 +511,23 @@ async def edit( address_map_id: str, *, account_id: str, - default_sni: Optional[str] | NotGiven = NOT_GIVEN, - description: Optional[str] | NotGiven = NOT_GIVEN, - enabled: Optional[bool] | NotGiven = NOT_GIVEN, + default_sni: Optional[str] | Omit = omit, + description: Optional[str] | Omit = omit, + enabled: Optional[bool] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMap]: """ Modify properties of an address map owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. default_sni: If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS @@ -572,15 +583,15 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AddressMapGetResponse]: """ Show a particular address map owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/addressing/address_maps/ips.py b/src/cloudflare/resources/addressing/address_maps/ips.py index e9edf9881fe..78313356374 100644 --- a/src/cloudflare/resources/addressing/address_maps/ips.py +++ b/src/cloudflare/resources/addressing/address_maps/ips.py @@ -2,15 +2,10 @@ from __future__ import annotations -from typing import Type, Optional, cast - import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -19,7 +14,6 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...._wrappers import ResultWrapper from ...._base_client import make_request_options from ....types.addressing.address_maps import ip_update_params from ....types.addressing.address_maps.ip_delete_response import IPDeleteResponse @@ -31,10 +25,21 @@ class IPsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> IPsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return IPsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> IPsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return IPsResourceWithStreamingResponse(self) def update( @@ -49,15 +54,15 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IPUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IPUpdateResponse: """ Add an IP from a prefix owned by the account to a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. ip_address: An IPv4 or IPv6 address. @@ -79,13 +84,9 @@ def update( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", body=maybe_transform(body, ip_update_params.IPUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IPUpdateResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[IPUpdateResponse]], ResultWrapper[IPUpdateResponse]), + cast_to=IPUpdateResponse, ) def delete( @@ -99,15 +100,15 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IPDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IPDeleteResponse: """ Remove an IP from a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. ip_address: An IPv4 or IPv6 address. @@ -128,23 +129,30 @@ def delete( return self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IPDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[IPDeleteResponse]], ResultWrapper[IPDeleteResponse]), + cast_to=IPDeleteResponse, ) class AsyncIPsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncIPsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncIPsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncIPsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncIPsResourceWithStreamingResponse(self) async def update( @@ -159,15 +167,15 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IPUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IPUpdateResponse: """ Add an IP from a prefix owned by the account to a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. ip_address: An IPv4 or IPv6 address. @@ -189,13 +197,9 @@ async def update( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", body=await async_maybe_transform(body, ip_update_params.IPUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IPUpdateResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[IPUpdateResponse]], ResultWrapper[IPUpdateResponse]), + cast_to=IPUpdateResponse, ) async def delete( @@ -209,15 +213,15 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IPDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IPDeleteResponse: """ Remove an IP from a particular address map. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. ip_address: An IPv4 or IPv6 address. @@ -238,13 +242,9 @@ async def delete( return await self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/ips/{ip_address}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IPDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[IPDeleteResponse]], ResultWrapper[IPDeleteResponse]), + cast_to=IPDeleteResponse, ) diff --git a/src/cloudflare/resources/addressing/address_maps/zones.py b/src/cloudflare/resources/addressing/address_maps/zones.py index cf592d92645..e6ac1d4e043 100644 --- a/src/cloudflare/resources/addressing/address_maps/zones.py +++ b/src/cloudflare/resources/addressing/address_maps/zones.py @@ -2,15 +2,10 @@ from __future__ import annotations -from typing import Type, Optional, cast - import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -19,7 +14,6 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...._wrappers import ResultWrapper from ...._base_client import make_request_options from ....types.addressing.address_maps import zone_update_params from ....types.addressing.address_maps.zone_delete_response import ZoneDeleteResponse @@ -31,10 +25,21 @@ class ZonesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ZonesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ZonesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ZonesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ZonesResourceWithStreamingResponse(self) def update( @@ -49,17 +54,17 @@ def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZoneUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ZoneUpdateResponse: """ Add a zone as a member of a particular address map. Args: - zone_id: Identifier + zone_id: Identifier of a zone. - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -79,13 +84,9 @@ def update( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", body=maybe_transform(body, zone_update_params.ZoneUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZoneUpdateResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[ZoneUpdateResponse]], ResultWrapper[ZoneUpdateResponse]), + cast_to=ZoneUpdateResponse, ) def delete( @@ -99,17 +100,17 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZoneDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ZoneDeleteResponse: """ Remove a zone as a member of a particular address map. Args: - zone_id: Identifier + zone_id: Identifier of a zone. - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -128,23 +129,30 @@ def delete( return self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZoneDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), + cast_to=ZoneDeleteResponse, ) class AsyncZonesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncZonesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncZonesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncZonesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncZonesResourceWithStreamingResponse(self) async def update( @@ -159,17 +167,17 @@ async def update( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZoneUpdateResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ZoneUpdateResponse: """ Add a zone as a member of a particular address map. Args: - zone_id: Identifier + zone_id: Identifier of a zone. - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -189,13 +197,9 @@ async def update( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", body=await async_maybe_transform(body, zone_update_params.ZoneUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZoneUpdateResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[ZoneUpdateResponse]], ResultWrapper[ZoneUpdateResponse]), + cast_to=ZoneUpdateResponse, ) async def delete( @@ -209,17 +213,17 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZoneDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ZoneDeleteResponse: """ Remove a zone as a member of a particular address map. Args: - zone_id: Identifier + zone_id: Identifier of a zone. - account_id: Identifier + account_id: Identifier of a Cloudflare account. - address_map_id: Identifier + address_map_id: Identifier of an Address Map. extra_headers: Send extra headers @@ -238,13 +242,9 @@ async def delete( return await self._delete( f"/accounts/{account_id}/addressing/address_maps/{address_map_id}/zones/{zone_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZoneDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), + cast_to=ZoneDeleteResponse, ) diff --git a/src/cloudflare/resources/addressing/addressing.py b/src/cloudflare/resources/addressing/addressing.py index 8157035d32f..2ddc2d78362 100644 --- a/src/cloudflare/resources/addressing/addressing.py +++ b/src/cloudflare/resources/addressing/addressing.py @@ -2,14 +2,6 @@ from __future__ import annotations -from .prefixes import ( - PrefixesResource, - AsyncPrefixesResource, - PrefixesResourceWithRawResponse, - AsyncPrefixesResourceWithRawResponse, - PrefixesResourceWithStreamingResponse, - AsyncPrefixesResourceWithStreamingResponse, -) from .services import ( ServicesResource, AsyncServicesResource, @@ -20,14 +12,6 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource -from .address_maps import ( - AddressMapsResource, - AsyncAddressMapsResource, - AddressMapsResourceWithRawResponse, - AsyncAddressMapsResourceWithRawResponse, - AddressMapsResourceWithStreamingResponse, - AsyncAddressMapsResourceWithStreamingResponse, -) from .loa_documents import ( LOADocumentsResource, AsyncLOADocumentsResource, @@ -36,8 +20,23 @@ LOADocumentsResourceWithStreamingResponse, AsyncLOADocumentsResourceWithStreamingResponse, ) -from .prefixes.prefixes import PrefixesResource, AsyncPrefixesResource -from .regional_hostnames import ( +from .prefixes.prefixes import ( + PrefixesResource, + AsyncPrefixesResource, + PrefixesResourceWithRawResponse, + AsyncPrefixesResourceWithRawResponse, + PrefixesResourceWithStreamingResponse, + AsyncPrefixesResourceWithStreamingResponse, +) +from .address_maps.address_maps import ( + AddressMapsResource, + AsyncAddressMapsResource, + AddressMapsResourceWithRawResponse, + AsyncAddressMapsResourceWithRawResponse, + AddressMapsResourceWithStreamingResponse, + AsyncAddressMapsResourceWithStreamingResponse, +) +from .regional_hostnames.regional_hostnames import ( RegionalHostnamesResource, AsyncRegionalHostnamesResource, RegionalHostnamesResourceWithRawResponse, @@ -45,9 +44,6 @@ RegionalHostnamesResourceWithStreamingResponse, AsyncRegionalHostnamesResourceWithStreamingResponse, ) -from .address_maps.address_maps import AddressMapsResource, AsyncAddressMapsResource -from .loa_documents.loa_documents import LOADocumentsResource, AsyncLOADocumentsResource -from .regional_hostnames.regional_hostnames import RegionalHostnamesResource, AsyncRegionalHostnamesResource __all__ = ["AddressingResource", "AsyncAddressingResource"] @@ -75,10 +71,21 @@ def prefixes(self) -> PrefixesResource: @cached_property def with_raw_response(self) -> AddressingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AddressingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AddressingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AddressingResourceWithStreamingResponse(self) @@ -105,10 +112,21 @@ def prefixes(self) -> AsyncPrefixesResource: @cached_property def with_raw_response(self) -> AsyncAddressingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAddressingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAddressingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAddressingResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/addressing/loa_documents.py b/src/cloudflare/resources/addressing/loa_documents.py new file mode 100644 index 00000000000..a1765c32f97 --- /dev/null +++ b/src/cloudflare/resources/addressing/loa_documents.py @@ -0,0 +1,304 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + to_custom_raw_response_wrapper, + async_to_streamed_response_wrapper, + to_custom_streamed_response_wrapper, + async_to_custom_raw_response_wrapper, + async_to_custom_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.addressing import loa_document_create_params +from ...types.addressing.loa_document_create_response import LOADocumentCreateResponse + +__all__ = ["LOADocumentsResource", "AsyncLOADocumentsResource"] + + +class LOADocumentsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LOADocumentsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LOADocumentsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LOADocumentsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LOADocumentsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + loa_document: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[LOADocumentCreateResponse]: + """ + Submit LOA document (pdf format) under the account. + + Args: + account_id: Identifier of a Cloudflare account. + + loa_document: LOA document to upload. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return self._post( + f"/accounts/{account_id}/addressing/loa_documents", + body=maybe_transform({"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[LOADocumentCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]), + ) + + def get( + self, + loa_document_id: Optional[str], + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BinaryAPIResponse: + """ + Download specified LOA document under the account. + + Args: + account_id: Identifier of a Cloudflare account. + + loa_document_id: Identifier for the uploaded LOA document. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not loa_document_id: + raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") + extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} + return self._get( + f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BinaryAPIResponse, + ) + + +class AsyncLOADocumentsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLOADocumentsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLOADocumentsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLOADocumentsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLOADocumentsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + loa_document: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[LOADocumentCreateResponse]: + """ + Submit LOA document (pdf format) under the account. + + Args: + account_id: Identifier of a Cloudflare account. + + loa_document: LOA document to upload. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return await self._post( + f"/accounts/{account_id}/addressing/loa_documents", + body=await async_maybe_transform( + {"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[LOADocumentCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]), + ) + + async def get( + self, + loa_document_id: Optional[str], + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncBinaryAPIResponse: + """ + Download specified LOA document under the account. + + Args: + account_id: Identifier of a Cloudflare account. + + loa_document_id: Identifier for the uploaded LOA document. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not loa_document_id: + raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") + extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} + return await self._get( + f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AsyncBinaryAPIResponse, + ) + + +class LOADocumentsResourceWithRawResponse: + def __init__(self, loa_documents: LOADocumentsResource) -> None: + self._loa_documents = loa_documents + + self.create = to_raw_response_wrapper( + loa_documents.create, + ) + self.get = to_custom_raw_response_wrapper( + loa_documents.get, + BinaryAPIResponse, + ) + + +class AsyncLOADocumentsResourceWithRawResponse: + def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None: + self._loa_documents = loa_documents + + self.create = async_to_raw_response_wrapper( + loa_documents.create, + ) + self.get = async_to_custom_raw_response_wrapper( + loa_documents.get, + AsyncBinaryAPIResponse, + ) + + +class LOADocumentsResourceWithStreamingResponse: + def __init__(self, loa_documents: LOADocumentsResource) -> None: + self._loa_documents = loa_documents + + self.create = to_streamed_response_wrapper( + loa_documents.create, + ) + self.get = to_custom_streamed_response_wrapper( + loa_documents.get, + StreamedBinaryAPIResponse, + ) + + +class AsyncLOADocumentsResourceWithStreamingResponse: + def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None: + self._loa_documents = loa_documents + + self.create = async_to_streamed_response_wrapper( + loa_documents.create, + ) + self.get = async_to_custom_streamed_response_wrapper( + loa_documents.get, + AsyncStreamedBinaryAPIResponse, + ) diff --git a/src/cloudflare/resources/addressing/loa_documents/__init__.py b/src/cloudflare/resources/addressing/loa_documents/__init__.py deleted file mode 100644 index 72f6dbba90c..00000000000 --- a/src/cloudflare/resources/addressing/loa_documents/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .downloads import ( - DownloadsResource, - AsyncDownloadsResource, - DownloadsResourceWithRawResponse, - AsyncDownloadsResourceWithRawResponse, - DownloadsResourceWithStreamingResponse, - AsyncDownloadsResourceWithStreamingResponse, -) -from .loa_documents import ( - LOADocumentsResource, - AsyncLOADocumentsResource, - LOADocumentsResourceWithRawResponse, - AsyncLOADocumentsResourceWithRawResponse, - LOADocumentsResourceWithStreamingResponse, - AsyncLOADocumentsResourceWithStreamingResponse, -) - -__all__ = [ - "DownloadsResource", - "AsyncDownloadsResource", - "DownloadsResourceWithRawResponse", - "AsyncDownloadsResourceWithRawResponse", - "DownloadsResourceWithStreamingResponse", - "AsyncDownloadsResourceWithStreamingResponse", - "LOADocumentsResource", - "AsyncLOADocumentsResource", - "LOADocumentsResourceWithRawResponse", - "AsyncLOADocumentsResourceWithRawResponse", - "LOADocumentsResourceWithStreamingResponse", - "AsyncLOADocumentsResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/addressing/loa_documents/downloads.py b/src/cloudflare/resources/addressing/loa_documents/downloads.py deleted file mode 100644 index 5540d005306..00000000000 --- a/src/cloudflare/resources/addressing/loa_documents/downloads.py +++ /dev/null @@ -1,166 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Optional - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - BinaryAPIResponse, - AsyncBinaryAPIResponse, - StreamedBinaryAPIResponse, - AsyncStreamedBinaryAPIResponse, - to_custom_raw_response_wrapper, - to_custom_streamed_response_wrapper, - async_to_custom_raw_response_wrapper, - async_to_custom_streamed_response_wrapper, -) -from ...._base_client import make_request_options - -__all__ = ["DownloadsResource", "AsyncDownloadsResource"] - - -class DownloadsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> DownloadsResourceWithRawResponse: - return DownloadsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> DownloadsResourceWithStreamingResponse: - return DownloadsResourceWithStreamingResponse(self) - - def get( - self, - loa_document_id: Optional[str], - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BinaryAPIResponse: - """ - Download specified LOA document under the account. - - Args: - account_id: Identifier - - loa_document_id: Identifier for the uploaded LOA document. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not loa_document_id: - raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") - extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} - return self._get( - f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BinaryAPIResponse, - ) - - -class AsyncDownloadsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncDownloadsResourceWithRawResponse: - return AsyncDownloadsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncDownloadsResourceWithStreamingResponse: - return AsyncDownloadsResourceWithStreamingResponse(self) - - async def get( - self, - loa_document_id: Optional[str], - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncBinaryAPIResponse: - """ - Download specified LOA document under the account. - - Args: - account_id: Identifier - - loa_document_id: Identifier for the uploaded LOA document. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not loa_document_id: - raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") - extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} - return await self._get( - f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=AsyncBinaryAPIResponse, - ) - - -class DownloadsResourceWithRawResponse: - def __init__(self, downloads: DownloadsResource) -> None: - self._downloads = downloads - - self.get = to_custom_raw_response_wrapper( - downloads.get, - BinaryAPIResponse, - ) - - -class AsyncDownloadsResourceWithRawResponse: - def __init__(self, downloads: AsyncDownloadsResource) -> None: - self._downloads = downloads - - self.get = async_to_custom_raw_response_wrapper( - downloads.get, - AsyncBinaryAPIResponse, - ) - - -class DownloadsResourceWithStreamingResponse: - def __init__(self, downloads: DownloadsResource) -> None: - self._downloads = downloads - - self.get = to_custom_streamed_response_wrapper( - downloads.get, - StreamedBinaryAPIResponse, - ) - - -class AsyncDownloadsResourceWithStreamingResponse: - def __init__(self, downloads: AsyncDownloadsResource) -> None: - self._downloads = downloads - - self.get = async_to_custom_streamed_response_wrapper( - downloads.get, - AsyncStreamedBinaryAPIResponse, - ) diff --git a/src/cloudflare/resources/addressing/loa_documents/loa_documents.py b/src/cloudflare/resources/addressing/loa_documents/loa_documents.py deleted file mode 100644 index a783c0551a0..00000000000 --- a/src/cloudflare/resources/addressing/loa_documents/loa_documents.py +++ /dev/null @@ -1,211 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) -from .downloads import ( - DownloadsResource, - AsyncDownloadsResource, - DownloadsResourceWithRawResponse, - AsyncDownloadsResourceWithRawResponse, - DownloadsResourceWithStreamingResponse, - AsyncDownloadsResourceWithStreamingResponse, -) -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...._wrappers import ResultWrapper -from ...._base_client import make_request_options -from ....types.addressing import loa_document_create_params -from ....types.addressing.loa_document_create_response import LOADocumentCreateResponse - -__all__ = ["LOADocumentsResource", "AsyncLOADocumentsResource"] - - -class LOADocumentsResource(SyncAPIResource): - @cached_property - def downloads(self) -> DownloadsResource: - return DownloadsResource(self._client) - - @cached_property - def with_raw_response(self) -> LOADocumentsResourceWithRawResponse: - return LOADocumentsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> LOADocumentsResourceWithStreamingResponse: - return LOADocumentsResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - loa_document: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[LOADocumentCreateResponse]: - """ - Submit LOA document (pdf format) under the account. - - Args: - account_id: Identifier - - loa_document: LOA document to upload. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - # It should be noted that the actual Content-Type header that will be - # sent to the server will contain a `boundary` parameter, e.g. - # multipart/form-data; boundary=---abc-- - extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return self._post( - f"/accounts/{account_id}/addressing/loa_documents", - body=maybe_transform({"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[LOADocumentCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]), - ) - - -class AsyncLOADocumentsResource(AsyncAPIResource): - @cached_property - def downloads(self) -> AsyncDownloadsResource: - return AsyncDownloadsResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncLOADocumentsResourceWithRawResponse: - return AsyncLOADocumentsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncLOADocumentsResourceWithStreamingResponse: - return AsyncLOADocumentsResourceWithStreamingResponse(self) - - async def create( - self, - *, - account_id: str, - loa_document: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[LOADocumentCreateResponse]: - """ - Submit LOA document (pdf format) under the account. - - Args: - account_id: Identifier - - loa_document: LOA document to upload. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - # It should be noted that the actual Content-Type header that will be - # sent to the server will contain a `boundary` parameter, e.g. - # multipart/form-data; boundary=---abc-- - extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} - return await self._post( - f"/accounts/{account_id}/addressing/loa_documents", - body=await async_maybe_transform( - {"loa_document": loa_document}, loa_document_create_params.LOADocumentCreateParams - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[LOADocumentCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[LOADocumentCreateResponse]], ResultWrapper[LOADocumentCreateResponse]), - ) - - -class LOADocumentsResourceWithRawResponse: - def __init__(self, loa_documents: LOADocumentsResource) -> None: - self._loa_documents = loa_documents - - self.create = to_raw_response_wrapper( - loa_documents.create, - ) - - @cached_property - def downloads(self) -> DownloadsResourceWithRawResponse: - return DownloadsResourceWithRawResponse(self._loa_documents.downloads) - - -class AsyncLOADocumentsResourceWithRawResponse: - def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None: - self._loa_documents = loa_documents - - self.create = async_to_raw_response_wrapper( - loa_documents.create, - ) - - @cached_property - def downloads(self) -> AsyncDownloadsResourceWithRawResponse: - return AsyncDownloadsResourceWithRawResponse(self._loa_documents.downloads) - - -class LOADocumentsResourceWithStreamingResponse: - def __init__(self, loa_documents: LOADocumentsResource) -> None: - self._loa_documents = loa_documents - - self.create = to_streamed_response_wrapper( - loa_documents.create, - ) - - @cached_property - def downloads(self) -> DownloadsResourceWithStreamingResponse: - return DownloadsResourceWithStreamingResponse(self._loa_documents.downloads) - - -class AsyncLOADocumentsResourceWithStreamingResponse: - def __init__(self, loa_documents: AsyncLOADocumentsResource) -> None: - self._loa_documents = loa_documents - - self.create = async_to_streamed_response_wrapper( - loa_documents.create, - ) - - @cached_property - def downloads(self) -> AsyncDownloadsResourceWithStreamingResponse: - return AsyncDownloadsResourceWithStreamingResponse(self._loa_documents.downloads) diff --git a/src/cloudflare/resources/addressing/prefixes/__init__.py b/src/cloudflare/resources/addressing/prefixes/__init__.py index baf5dcefd16..89ce6e1fa39 100644 --- a/src/cloudflare/resources/addressing/prefixes/__init__.py +++ b/src/cloudflare/resources/addressing/prefixes/__init__.py @@ -1,13 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .bgp import ( - BGPResource, - AsyncBGPResource, - BGPResourceWithRawResponse, - AsyncBGPResourceWithRawResponse, - BGPResourceWithStreamingResponse, - AsyncBGPResourceWithStreamingResponse, -) from .prefixes import ( PrefixesResource, AsyncPrefixesResource, @@ -24,14 +16,50 @@ DelegationsResourceWithStreamingResponse, AsyncDelegationsResourceWithStreamingResponse, ) +from .bgp_prefixes import ( + BGPPrefixesResource, + AsyncBGPPrefixesResource, + BGPPrefixesResourceWithRawResponse, + AsyncBGPPrefixesResourceWithRawResponse, + BGPPrefixesResourceWithStreamingResponse, + AsyncBGPPrefixesResourceWithStreamingResponse, +) +from .service_bindings import ( + ServiceBindingsResource, + AsyncServiceBindingsResource, + ServiceBindingsResourceWithRawResponse, + AsyncServiceBindingsResourceWithRawResponse, + ServiceBindingsResourceWithStreamingResponse, + AsyncServiceBindingsResourceWithStreamingResponse, +) +from .advertisement_status import ( + AdvertisementStatusResource, + AsyncAdvertisementStatusResource, + AdvertisementStatusResourceWithRawResponse, + AsyncAdvertisementStatusResourceWithRawResponse, + AdvertisementStatusResourceWithStreamingResponse, + AsyncAdvertisementStatusResourceWithStreamingResponse, +) __all__ = [ - "BGPResource", - "AsyncBGPResource", - "BGPResourceWithRawResponse", - "AsyncBGPResourceWithRawResponse", - "BGPResourceWithStreamingResponse", - "AsyncBGPResourceWithStreamingResponse", + "ServiceBindingsResource", + "AsyncServiceBindingsResource", + "ServiceBindingsResourceWithRawResponse", + "AsyncServiceBindingsResourceWithRawResponse", + "ServiceBindingsResourceWithStreamingResponse", + "AsyncServiceBindingsResourceWithStreamingResponse", + "BGPPrefixesResource", + "AsyncBGPPrefixesResource", + "BGPPrefixesResourceWithRawResponse", + "AsyncBGPPrefixesResourceWithRawResponse", + "BGPPrefixesResourceWithStreamingResponse", + "AsyncBGPPrefixesResourceWithStreamingResponse", + "AdvertisementStatusResource", + "AsyncAdvertisementStatusResource", + "AdvertisementStatusResourceWithRawResponse", + "AsyncAdvertisementStatusResourceWithRawResponse", + "AdvertisementStatusResourceWithStreamingResponse", + "AsyncAdvertisementStatusResourceWithStreamingResponse", "DelegationsResource", "AsyncDelegationsResource", "DelegationsResourceWithRawResponse", diff --git a/src/cloudflare/resources/addressing/prefixes/advertisement_status.py b/src/cloudflare/resources/addressing/prefixes/advertisement_status.py new file mode 100644 index 00000000000..7b71630f5b2 --- /dev/null +++ b/src/cloudflare/resources/addressing/prefixes/advertisement_status.py @@ -0,0 +1,342 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import typing_extensions +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.addressing.prefixes import advertisement_status_edit_params +from ....types.addressing.prefixes.advertisement_status_get_response import AdvertisementStatusGetResponse +from ....types.addressing.prefixes.advertisement_status_edit_response import AdvertisementStatusEditResponse + +__all__ = ["AdvertisementStatusResource", "AsyncAdvertisementStatusResource"] + + +class AdvertisementStatusResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AdvertisementStatusResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AdvertisementStatusResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AdvertisementStatusResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AdvertisementStatusResourceWithStreamingResponse(self) + + @typing_extensions.deprecated("deprecated") + def edit( + self, + prefix_id: str, + *, + account_id: str, + advertised: bool, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AdvertisementStatusEditResponse]: + """ + Advertise or withdraw the BGP route for a prefix. + + **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for + advertising and withdrawing subnets of an IP prefix. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + advertised: Advertisement status of the prefix. If `true`, the BGP route for the prefix is + advertised to the Internet. If `false`, the BGP route is withdrawn. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._patch( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + body=maybe_transform( + {"advertised": advertised}, advertisement_status_edit_params.AdvertisementStatusEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AdvertisementStatusEditResponse]]._unwrapper, + ), + cast_to=cast( + Type[Optional[AdvertisementStatusEditResponse]], ResultWrapper[AdvertisementStatusEditResponse] + ), + ) + + @typing_extensions.deprecated("deprecated") + def get( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AdvertisementStatusGetResponse]: + """ + View the current advertisement state for a prefix. + + **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for + advertising and withdrawing subnets of an IP prefix. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AdvertisementStatusGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AdvertisementStatusGetResponse]], ResultWrapper[AdvertisementStatusGetResponse]), + ) + + +class AsyncAdvertisementStatusResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAdvertisementStatusResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAdvertisementStatusResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAdvertisementStatusResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAdvertisementStatusResourceWithStreamingResponse(self) + + @typing_extensions.deprecated("deprecated") + async def edit( + self, + prefix_id: str, + *, + account_id: str, + advertised: bool, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AdvertisementStatusEditResponse]: + """ + Advertise or withdraw the BGP route for a prefix. + + **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for + advertising and withdrawing subnets of an IP prefix. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + advertised: Advertisement status of the prefix. If `true`, the BGP route for the prefix is + advertised to the Internet. If `false`, the BGP route is withdrawn. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return await self._patch( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + body=await async_maybe_transform( + {"advertised": advertised}, advertisement_status_edit_params.AdvertisementStatusEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AdvertisementStatusEditResponse]]._unwrapper, + ), + cast_to=cast( + Type[Optional[AdvertisementStatusEditResponse]], ResultWrapper[AdvertisementStatusEditResponse] + ), + ) + + @typing_extensions.deprecated("deprecated") + async def get( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AdvertisementStatusGetResponse]: + """ + View the current advertisement state for a prefix. + + **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for + advertising and withdrawing subnets of an IP prefix. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return await self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AdvertisementStatusGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AdvertisementStatusGetResponse]], ResultWrapper[AdvertisementStatusGetResponse]), + ) + + +class AdvertisementStatusResourceWithRawResponse: + def __init__(self, advertisement_status: AdvertisementStatusResource) -> None: + self._advertisement_status = advertisement_status + + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + advertisement_status.edit, # pyright: ignore[reportDeprecated], + ) + ) + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + advertisement_status.get, # pyright: ignore[reportDeprecated], + ) + ) + + +class AsyncAdvertisementStatusResourceWithRawResponse: + def __init__(self, advertisement_status: AsyncAdvertisementStatusResource) -> None: + self._advertisement_status = advertisement_status + + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + advertisement_status.edit, # pyright: ignore[reportDeprecated], + ) + ) + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + advertisement_status.get, # pyright: ignore[reportDeprecated], + ) + ) + + +class AdvertisementStatusResourceWithStreamingResponse: + def __init__(self, advertisement_status: AdvertisementStatusResource) -> None: + self._advertisement_status = advertisement_status + + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + advertisement_status.edit, # pyright: ignore[reportDeprecated], + ) + ) + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + advertisement_status.get, # pyright: ignore[reportDeprecated], + ) + ) + + +class AsyncAdvertisementStatusResourceWithStreamingResponse: + def __init__(self, advertisement_status: AsyncAdvertisementStatusResource) -> None: + self._advertisement_status = advertisement_status + + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + advertisement_status.edit, # pyright: ignore[reportDeprecated], + ) + ) + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + advertisement_status.get, # pyright: ignore[reportDeprecated], + ) + ) diff --git a/src/cloudflare/resources/addressing/prefixes/bgp/__init__.py b/src/cloudflare/resources/addressing/prefixes/bgp/__init__.py deleted file mode 100644 index 8c3709d72cc..00000000000 --- a/src/cloudflare/resources/addressing/prefixes/bgp/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .bgp import ( - BGPResource, - AsyncBGPResource, - BGPResourceWithRawResponse, - AsyncBGPResourceWithRawResponse, - BGPResourceWithStreamingResponse, - AsyncBGPResourceWithStreamingResponse, -) -from .bindings import ( - BindingsResource, - AsyncBindingsResource, - BindingsResourceWithRawResponse, - AsyncBindingsResourceWithRawResponse, - BindingsResourceWithStreamingResponse, - AsyncBindingsResourceWithStreamingResponse, -) -from .prefixes import ( - PrefixesResource, - AsyncPrefixesResource, - PrefixesResourceWithRawResponse, - AsyncPrefixesResourceWithRawResponse, - PrefixesResourceWithStreamingResponse, - AsyncPrefixesResourceWithStreamingResponse, -) -from .statuses import ( - StatusesResource, - AsyncStatusesResource, - StatusesResourceWithRawResponse, - AsyncStatusesResourceWithRawResponse, - StatusesResourceWithStreamingResponse, - AsyncStatusesResourceWithStreamingResponse, -) - -__all__ = [ - "BindingsResource", - "AsyncBindingsResource", - "BindingsResourceWithRawResponse", - "AsyncBindingsResourceWithRawResponse", - "BindingsResourceWithStreamingResponse", - "AsyncBindingsResourceWithStreamingResponse", - "PrefixesResource", - "AsyncPrefixesResource", - "PrefixesResourceWithRawResponse", - "AsyncPrefixesResourceWithRawResponse", - "PrefixesResourceWithStreamingResponse", - "AsyncPrefixesResourceWithStreamingResponse", - "StatusesResource", - "AsyncStatusesResource", - "StatusesResourceWithRawResponse", - "AsyncStatusesResourceWithRawResponse", - "StatusesResourceWithStreamingResponse", - "AsyncStatusesResourceWithStreamingResponse", - "BGPResource", - "AsyncBGPResource", - "BGPResourceWithRawResponse", - "AsyncBGPResourceWithRawResponse", - "BGPResourceWithStreamingResponse", - "AsyncBGPResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/addressing/prefixes/bgp/bgp.py b/src/cloudflare/resources/addressing/prefixes/bgp/bgp.py deleted file mode 100644 index 4b5ec4fa6d6..00000000000 --- a/src/cloudflare/resources/addressing/prefixes/bgp/bgp.py +++ /dev/null @@ -1,144 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .bindings import ( - BindingsResource, - AsyncBindingsResource, - BindingsResourceWithRawResponse, - AsyncBindingsResourceWithRawResponse, - BindingsResourceWithStreamingResponse, - AsyncBindingsResourceWithStreamingResponse, -) -from .prefixes import ( - PrefixesResource, - AsyncPrefixesResource, - PrefixesResourceWithRawResponse, - AsyncPrefixesResourceWithRawResponse, - PrefixesResourceWithStreamingResponse, - AsyncPrefixesResourceWithStreamingResponse, -) -from .statuses import ( - StatusesResource, - AsyncStatusesResource, - StatusesResourceWithRawResponse, - AsyncStatusesResourceWithRawResponse, - StatusesResourceWithStreamingResponse, - AsyncStatusesResourceWithStreamingResponse, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource - -__all__ = ["BGPResource", "AsyncBGPResource"] - - -class BGPResource(SyncAPIResource): - @cached_property - def bindings(self) -> BindingsResource: - return BindingsResource(self._client) - - @cached_property - def prefixes(self) -> PrefixesResource: - return PrefixesResource(self._client) - - @cached_property - def statuses(self) -> StatusesResource: - return StatusesResource(self._client) - - @cached_property - def with_raw_response(self) -> BGPResourceWithRawResponse: - return BGPResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> BGPResourceWithStreamingResponse: - return BGPResourceWithStreamingResponse(self) - - -class AsyncBGPResource(AsyncAPIResource): - @cached_property - def bindings(self) -> AsyncBindingsResource: - return AsyncBindingsResource(self._client) - - @cached_property - def prefixes(self) -> AsyncPrefixesResource: - return AsyncPrefixesResource(self._client) - - @cached_property - def statuses(self) -> AsyncStatusesResource: - return AsyncStatusesResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncBGPResourceWithRawResponse: - return AsyncBGPResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncBGPResourceWithStreamingResponse: - return AsyncBGPResourceWithStreamingResponse(self) - - -class BGPResourceWithRawResponse: - def __init__(self, bgp: BGPResource) -> None: - self._bgp = bgp - - @cached_property - def bindings(self) -> BindingsResourceWithRawResponse: - return BindingsResourceWithRawResponse(self._bgp.bindings) - - @cached_property - def prefixes(self) -> PrefixesResourceWithRawResponse: - return PrefixesResourceWithRawResponse(self._bgp.prefixes) - - @cached_property - def statuses(self) -> StatusesResourceWithRawResponse: - return StatusesResourceWithRawResponse(self._bgp.statuses) - - -class AsyncBGPResourceWithRawResponse: - def __init__(self, bgp: AsyncBGPResource) -> None: - self._bgp = bgp - - @cached_property - def bindings(self) -> AsyncBindingsResourceWithRawResponse: - return AsyncBindingsResourceWithRawResponse(self._bgp.bindings) - - @cached_property - def prefixes(self) -> AsyncPrefixesResourceWithRawResponse: - return AsyncPrefixesResourceWithRawResponse(self._bgp.prefixes) - - @cached_property - def statuses(self) -> AsyncStatusesResourceWithRawResponse: - return AsyncStatusesResourceWithRawResponse(self._bgp.statuses) - - -class BGPResourceWithStreamingResponse: - def __init__(self, bgp: BGPResource) -> None: - self._bgp = bgp - - @cached_property - def bindings(self) -> BindingsResourceWithStreamingResponse: - return BindingsResourceWithStreamingResponse(self._bgp.bindings) - - @cached_property - def prefixes(self) -> PrefixesResourceWithStreamingResponse: - return PrefixesResourceWithStreamingResponse(self._bgp.prefixes) - - @cached_property - def statuses(self) -> StatusesResourceWithStreamingResponse: - return StatusesResourceWithStreamingResponse(self._bgp.statuses) - - -class AsyncBGPResourceWithStreamingResponse: - def __init__(self, bgp: AsyncBGPResource) -> None: - self._bgp = bgp - - @cached_property - def bindings(self) -> AsyncBindingsResourceWithStreamingResponse: - return AsyncBindingsResourceWithStreamingResponse(self._bgp.bindings) - - @cached_property - def prefixes(self) -> AsyncPrefixesResourceWithStreamingResponse: - return AsyncPrefixesResourceWithStreamingResponse(self._bgp.prefixes) - - @cached_property - def statuses(self) -> AsyncStatusesResourceWithStreamingResponse: - return AsyncStatusesResourceWithStreamingResponse(self._bgp.statuses) diff --git a/src/cloudflare/resources/addressing/prefixes/bgp/bindings.py b/src/cloudflare/resources/addressing/prefixes/bgp/bindings.py deleted file mode 100644 index a2c7b0f566e..00000000000 --- a/src/cloudflare/resources/addressing/prefixes/bgp/bindings.py +++ /dev/null @@ -1,523 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( - maybe_transform, - async_maybe_transform, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.addressing.prefixes.bgp import binding_create_params -from .....types.addressing.prefixes.bgp.service_binding import ServiceBinding -from .....types.addressing.prefixes.bgp.binding_delete_response import BindingDeleteResponse - -__all__ = ["BindingsResource", "AsyncBindingsResource"] - - -class BindingsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> BindingsResourceWithRawResponse: - return BindingsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> BindingsResourceWithStreamingResponse: - return BindingsResourceWithStreamingResponse(self) - - def create( - self, - prefix_id: str, - *, - account_id: str, - cidr: str | NotGiven = NOT_GIVEN, - service_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceBinding]: - """ - Creates a new Service Binding, routing traffic to IPs within the given CIDR to a - service running on Cloudflare's network. **Note:** This API may only be used on - prefixes currently configured with a Magic Transit service binding, and only - allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. - - Args: - account_id: Identifier - - prefix_id: Identifier - - cidr: IP Prefix in Classless Inter-Domain Routing format. - - service_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._post( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", - body=maybe_transform( - { - "cidr": cidr, - "service_id": service_id, - }, - binding_create_params.BindingCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), - ) - - def list( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[ServiceBinding]: - """List the Cloudflare services this prefix is currently bound to. - - Traffic sent to - an address within an IP prefix will be routed to the Cloudflare service of the - most-specific Service Binding matching the address. **Example:** binding - `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare - CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other - IPs in the prefix to Cloudflare Magic Transit. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", - page=SyncSinglePage[ServiceBinding], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ServiceBinding, - ) - - def delete( - self, - binding_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BindingDeleteResponse: - """ - Delete a Service Binding - - Args: - account_id: Identifier - - prefix_id: Identifier - - binding_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not binding_id: - raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") - return self._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BindingDeleteResponse, - ) - - def get( - self, - binding_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceBinding]: - """ - Fetch a single Service Binding - - Args: - account_id: Identifier - - prefix_id: Identifier - - binding_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not binding_id: - raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") - return self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), - ) - - -class AsyncBindingsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncBindingsResourceWithRawResponse: - return AsyncBindingsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncBindingsResourceWithStreamingResponse: - return AsyncBindingsResourceWithStreamingResponse(self) - - async def create( - self, - prefix_id: str, - *, - account_id: str, - cidr: str | NotGiven = NOT_GIVEN, - service_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceBinding]: - """ - Creates a new Service Binding, routing traffic to IPs within the given CIDR to a - service running on Cloudflare's network. **Note:** This API may only be used on - prefixes currently configured with a Magic Transit service binding, and only - allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. - - Args: - account_id: Identifier - - prefix_id: Identifier - - cidr: IP Prefix in Classless Inter-Domain Routing format. - - service_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return await self._post( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", - body=await async_maybe_transform( - { - "cidr": cidr, - "service_id": service_id, - }, - binding_create_params.BindingCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), - ) - - def list( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[ServiceBinding, AsyncSinglePage[ServiceBinding]]: - """List the Cloudflare services this prefix is currently bound to. - - Traffic sent to - an address within an IP prefix will be routed to the Cloudflare service of the - most-specific Service Binding matching the address. **Example:** binding - `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare - CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other - IPs in the prefix to Cloudflare Magic Transit. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", - page=AsyncSinglePage[ServiceBinding], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ServiceBinding, - ) - - async def delete( - self, - binding_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BindingDeleteResponse: - """ - Delete a Service Binding - - Args: - account_id: Identifier - - prefix_id: Identifier - - binding_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not binding_id: - raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") - return await self._delete( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BindingDeleteResponse, - ) - - async def get( - self, - binding_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceBinding]: - """ - Fetch a single Service Binding - - Args: - account_id: Identifier - - prefix_id: Identifier - - binding_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not binding_id: - raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") - return await self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), - ) - - -class BindingsResourceWithRawResponse: - def __init__(self, bindings: BindingsResource) -> None: - self._bindings = bindings - - self.create = to_raw_response_wrapper( - bindings.create, - ) - self.list = to_raw_response_wrapper( - bindings.list, - ) - self.delete = to_raw_response_wrapper( - bindings.delete, - ) - self.get = to_raw_response_wrapper( - bindings.get, - ) - - -class AsyncBindingsResourceWithRawResponse: - def __init__(self, bindings: AsyncBindingsResource) -> None: - self._bindings = bindings - - self.create = async_to_raw_response_wrapper( - bindings.create, - ) - self.list = async_to_raw_response_wrapper( - bindings.list, - ) - self.delete = async_to_raw_response_wrapper( - bindings.delete, - ) - self.get = async_to_raw_response_wrapper( - bindings.get, - ) - - -class BindingsResourceWithStreamingResponse: - def __init__(self, bindings: BindingsResource) -> None: - self._bindings = bindings - - self.create = to_streamed_response_wrapper( - bindings.create, - ) - self.list = to_streamed_response_wrapper( - bindings.list, - ) - self.delete = to_streamed_response_wrapper( - bindings.delete, - ) - self.get = to_streamed_response_wrapper( - bindings.get, - ) - - -class AsyncBindingsResourceWithStreamingResponse: - def __init__(self, bindings: AsyncBindingsResource) -> None: - self._bindings = bindings - - self.create = async_to_streamed_response_wrapper( - bindings.create, - ) - self.list = async_to_streamed_response_wrapper( - bindings.list, - ) - self.delete = async_to_streamed_response_wrapper( - bindings.delete, - ) - self.get = async_to_streamed_response_wrapper( - bindings.get, - ) diff --git a/src/cloudflare/resources/addressing/prefixes/bgp/prefixes.py b/src/cloudflare/resources/addressing/prefixes/bgp/prefixes.py deleted file mode 100644 index a2a444a4c68..00000000000 --- a/src/cloudflare/resources/addressing/prefixes/bgp/prefixes.py +++ /dev/null @@ -1,400 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( - maybe_transform, - async_maybe_transform, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.addressing.prefixes.bgp import prefix_edit_params -from .....types.addressing.prefixes.bgp.bgp_prefix import BGPPrefix - -__all__ = ["PrefixesResource", "AsyncPrefixesResource"] - - -class PrefixesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> PrefixesResourceWithRawResponse: - return PrefixesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> PrefixesResourceWithStreamingResponse: - return PrefixesResourceWithStreamingResponse(self) - - def list( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[BGPPrefix]: - """List all BGP Prefixes within the specified IP Prefix. - - BGP Prefixes are used to - control which specific subnets are advertised to the Internet. It is possible to - advertise subnets more specific than an IP Prefix by creating more specific BGP - Prefixes. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", - page=SyncSinglePage[BGPPrefix], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=BGPPrefix, - ) - - def edit( - self, - bgp_prefix_id: str, - *, - account_id: str, - prefix_id: str, - on_demand: prefix_edit_params.OnDemand | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BGPPrefix]: - """ - Update the properties of a BGP Prefix, such as the on demand advertisement - status (advertised or withdrawn). - - Args: - account_id: Identifier - - prefix_id: Identifier - - bgp_prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not bgp_prefix_id: - raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") - return self._patch( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", - body=maybe_transform({"on_demand": on_demand}, prefix_edit_params.PrefixEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, - ), - cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), - ) - - def get( - self, - bgp_prefix_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BGPPrefix]: - """ - Retrieve a single BGP Prefix according to its identifier - - Args: - account_id: Identifier - - prefix_id: Identifier - - bgp_prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not bgp_prefix_id: - raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") - return self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, - ), - cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), - ) - - -class AsyncPrefixesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncPrefixesResourceWithRawResponse: - return AsyncPrefixesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncPrefixesResourceWithStreamingResponse: - return AsyncPrefixesResourceWithStreamingResponse(self) - - def list( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[BGPPrefix, AsyncSinglePage[BGPPrefix]]: - """List all BGP Prefixes within the specified IP Prefix. - - BGP Prefixes are used to - control which specific subnets are advertised to the Internet. It is possible to - advertise subnets more specific than an IP Prefix by creating more specific BGP - Prefixes. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", - page=AsyncSinglePage[BGPPrefix], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=BGPPrefix, - ) - - async def edit( - self, - bgp_prefix_id: str, - *, - account_id: str, - prefix_id: str, - on_demand: prefix_edit_params.OnDemand | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BGPPrefix]: - """ - Update the properties of a BGP Prefix, such as the on demand advertisement - status (advertised or withdrawn). - - Args: - account_id: Identifier - - prefix_id: Identifier - - bgp_prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not bgp_prefix_id: - raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") - return await self._patch( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", - body=await async_maybe_transform({"on_demand": on_demand}, prefix_edit_params.PrefixEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, - ), - cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), - ) - - async def get( - self, - bgp_prefix_id: str, - *, - account_id: str, - prefix_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BGPPrefix]: - """ - Retrieve a single BGP Prefix according to its identifier - - Args: - account_id: Identifier - - prefix_id: Identifier - - bgp_prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - if not bgp_prefix_id: - raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") - return await self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, - ), - cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), - ) - - -class PrefixesResourceWithRawResponse: - def __init__(self, prefixes: PrefixesResource) -> None: - self._prefixes = prefixes - - self.list = to_raw_response_wrapper( - prefixes.list, - ) - self.edit = to_raw_response_wrapper( - prefixes.edit, - ) - self.get = to_raw_response_wrapper( - prefixes.get, - ) - - -class AsyncPrefixesResourceWithRawResponse: - def __init__(self, prefixes: AsyncPrefixesResource) -> None: - self._prefixes = prefixes - - self.list = async_to_raw_response_wrapper( - prefixes.list, - ) - self.edit = async_to_raw_response_wrapper( - prefixes.edit, - ) - self.get = async_to_raw_response_wrapper( - prefixes.get, - ) - - -class PrefixesResourceWithStreamingResponse: - def __init__(self, prefixes: PrefixesResource) -> None: - self._prefixes = prefixes - - self.list = to_streamed_response_wrapper( - prefixes.list, - ) - self.edit = to_streamed_response_wrapper( - prefixes.edit, - ) - self.get = to_streamed_response_wrapper( - prefixes.get, - ) - - -class AsyncPrefixesResourceWithStreamingResponse: - def __init__(self, prefixes: AsyncPrefixesResource) -> None: - self._prefixes = prefixes - - self.list = async_to_streamed_response_wrapper( - prefixes.list, - ) - self.edit = async_to_streamed_response_wrapper( - prefixes.edit, - ) - self.get = async_to_streamed_response_wrapper( - prefixes.get, - ) diff --git a/src/cloudflare/resources/addressing/prefixes/bgp/statuses.py b/src/cloudflare/resources/addressing/prefixes/bgp/statuses.py deleted file mode 100644 index 065c28d426e..00000000000 --- a/src/cloudflare/resources/addressing/prefixes/bgp/statuses.py +++ /dev/null @@ -1,280 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( - maybe_transform, - async_maybe_transform, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from ....._base_client import make_request_options -from .....types.addressing.prefixes.bgp import status_edit_params -from .....types.addressing.prefixes.bgp.status_get_response import StatusGetResponse -from .....types.addressing.prefixes.bgp.status_edit_response import StatusEditResponse - -__all__ = ["StatusesResource", "AsyncStatusesResource"] - - -class StatusesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> StatusesResourceWithRawResponse: - return StatusesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> StatusesResourceWithStreamingResponse: - return StatusesResourceWithStreamingResponse(self) - - def edit( - self, - prefix_id: str, - *, - account_id: str, - advertised: bool, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[StatusEditResponse]: - """ - Advertise or withdraw BGP route for a prefix. - - Args: - account_id: Identifier - - prefix_id: Identifier - - advertised: Enablement of prefix advertisement to the Internet. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._patch( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", - body=maybe_transform({"advertised": advertised}, status_edit_params.StatusEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[StatusEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[StatusEditResponse]], ResultWrapper[StatusEditResponse]), - ) - - def get( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[StatusGetResponse]: - """ - List the current advertisement state for a prefix. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[StatusGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[StatusGetResponse]], ResultWrapper[StatusGetResponse]), - ) - - -class AsyncStatusesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncStatusesResourceWithRawResponse: - return AsyncStatusesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncStatusesResourceWithStreamingResponse: - return AsyncStatusesResourceWithStreamingResponse(self) - - async def edit( - self, - prefix_id: str, - *, - account_id: str, - advertised: bool, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[StatusEditResponse]: - """ - Advertise or withdraw BGP route for a prefix. - - Args: - account_id: Identifier - - prefix_id: Identifier - - advertised: Enablement of prefix advertisement to the Internet. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return await self._patch( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", - body=await async_maybe_transform({"advertised": advertised}, status_edit_params.StatusEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[StatusEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[StatusEditResponse]], ResultWrapper[StatusEditResponse]), - ) - - async def get( - self, - prefix_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[StatusGetResponse]: - """ - List the current advertisement state for a prefix. - - Args: - account_id: Identifier - - prefix_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not prefix_id: - raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") - return await self._get( - f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/status", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[StatusGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[StatusGetResponse]], ResultWrapper[StatusGetResponse]), - ) - - -class StatusesResourceWithRawResponse: - def __init__(self, statuses: StatusesResource) -> None: - self._statuses = statuses - - self.edit = to_raw_response_wrapper( - statuses.edit, - ) - self.get = to_raw_response_wrapper( - statuses.get, - ) - - -class AsyncStatusesResourceWithRawResponse: - def __init__(self, statuses: AsyncStatusesResource) -> None: - self._statuses = statuses - - self.edit = async_to_raw_response_wrapper( - statuses.edit, - ) - self.get = async_to_raw_response_wrapper( - statuses.get, - ) - - -class StatusesResourceWithStreamingResponse: - def __init__(self, statuses: StatusesResource) -> None: - self._statuses = statuses - - self.edit = to_streamed_response_wrapper( - statuses.edit, - ) - self.get = to_streamed_response_wrapper( - statuses.get, - ) - - -class AsyncStatusesResourceWithStreamingResponse: - def __init__(self, statuses: AsyncStatusesResource) -> None: - self._statuses = statuses - - self.edit = async_to_streamed_response_wrapper( - statuses.edit, - ) - self.get = async_to_streamed_response_wrapper( - statuses.get, - ) diff --git a/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py b/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py new file mode 100644 index 00000000000..2f997e3a34f --- /dev/null +++ b/src/cloudflare/resources/addressing/prefixes/bgp_prefixes.py @@ -0,0 +1,563 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.addressing.prefixes import bgp_prefix_edit_params, bgp_prefix_create_params +from ....types.addressing.prefixes.bgp_prefix import BGPPrefix + +__all__ = ["BGPPrefixesResource", "AsyncBGPPrefixesResource"] + + +class BGPPrefixesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BGPPrefixesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return BGPPrefixesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BGPPrefixesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return BGPPrefixesResourceWithStreamingResponse(self) + + def create( + self, + prefix_id: str, + *, + account_id: str, + cidr: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Create a BGP prefix, controlling the BGP advertisement status of a specific + subnet. When created, BGP prefixes are initially withdrawn, and can be + advertised with the Update BGP Prefix API. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + cidr: IP Prefix in Classless Inter-Domain Routing format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._post( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + body=maybe_transform({"cidr": cidr}, bgp_prefix_create_params.BGPPrefixCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + def list( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[BGPPrefix]: + """List all BGP Prefixes within the specified IP Prefix. + + BGP Prefixes are used to + control which specific subnets are advertised to the Internet. It is possible to + advertise subnets more specific than an IP Prefix by creating more specific BGP + Prefixes. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + page=SyncSinglePage[BGPPrefix], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=BGPPrefix, + ) + + def edit( + self, + bgp_prefix_id: str, + *, + account_id: str, + prefix_id: str, + asn_prepend_count: int | Omit = omit, + auto_advertise_withdraw: bool | Omit = omit, + on_demand: bgp_prefix_edit_params.OnDemand | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Update the properties of a BGP Prefix, such as the on demand advertisement + status (advertised or withdrawn). + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + bgp_prefix_id: Identifier of BGP Prefix. + + asn_prepend_count: Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute + + auto_advertise_withdraw: Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no + matching BGP prefix in the Magic routing table. When true, Cloudflare will + automatically withdraw the BGP prefix when there are no matching BGP routes, and + will resume advertising when there is at least one matching BGP route. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not bgp_prefix_id: + raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") + return self._patch( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + body=maybe_transform( + { + "asn_prepend_count": asn_prepend_count, + "auto_advertise_withdraw": auto_advertise_withdraw, + "on_demand": on_demand, + }, + bgp_prefix_edit_params.BGPPrefixEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + def get( + self, + bgp_prefix_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Retrieve a single BGP Prefix according to its identifier + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + bgp_prefix_id: Identifier of BGP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not bgp_prefix_id: + raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") + return self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + +class AsyncBGPPrefixesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBGPPrefixesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncBGPPrefixesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBGPPrefixesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncBGPPrefixesResourceWithStreamingResponse(self) + + async def create( + self, + prefix_id: str, + *, + account_id: str, + cidr: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Create a BGP prefix, controlling the BGP advertisement status of a specific + subnet. When created, BGP prefixes are initially withdrawn, and can be + advertised with the Update BGP Prefix API. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + cidr: IP Prefix in Classless Inter-Domain Routing format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return await self._post( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + body=await async_maybe_transform({"cidr": cidr}, bgp_prefix_create_params.BGPPrefixCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + def list( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[BGPPrefix, AsyncSinglePage[BGPPrefix]]: + """List all BGP Prefixes within the specified IP Prefix. + + BGP Prefixes are used to + control which specific subnets are advertised to the Internet. It is possible to + advertise subnets more specific than an IP Prefix by creating more specific BGP + Prefixes. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes", + page=AsyncSinglePage[BGPPrefix], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=BGPPrefix, + ) + + async def edit( + self, + bgp_prefix_id: str, + *, + account_id: str, + prefix_id: str, + asn_prepend_count: int | Omit = omit, + auto_advertise_withdraw: bool | Omit = omit, + on_demand: bgp_prefix_edit_params.OnDemand | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Update the properties of a BGP Prefix, such as the on demand advertisement + status (advertised or withdrawn). + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + bgp_prefix_id: Identifier of BGP Prefix. + + asn_prepend_count: Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute + + auto_advertise_withdraw: Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no + matching BGP prefix in the Magic routing table. When true, Cloudflare will + automatically withdraw the BGP prefix when there are no matching BGP routes, and + will resume advertising when there is at least one matching BGP route. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not bgp_prefix_id: + raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") + return await self._patch( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + body=await async_maybe_transform( + { + "asn_prepend_count": asn_prepend_count, + "auto_advertise_withdraw": auto_advertise_withdraw, + "on_demand": on_demand, + }, + bgp_prefix_edit_params.BGPPrefixEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + async def get( + self, + bgp_prefix_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[BGPPrefix]: + """ + Retrieve a single BGP Prefix according to its identifier + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + bgp_prefix_id: Identifier of BGP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not bgp_prefix_id: + raise ValueError(f"Expected a non-empty value for `bgp_prefix_id` but received {bgp_prefix_id!r}") + return await self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bgp/prefixes/{bgp_prefix_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BGPPrefix]]._unwrapper, + ), + cast_to=cast(Type[Optional[BGPPrefix]], ResultWrapper[BGPPrefix]), + ) + + +class BGPPrefixesResourceWithRawResponse: + def __init__(self, bgp_prefixes: BGPPrefixesResource) -> None: + self._bgp_prefixes = bgp_prefixes + + self.create = to_raw_response_wrapper( + bgp_prefixes.create, + ) + self.list = to_raw_response_wrapper( + bgp_prefixes.list, + ) + self.edit = to_raw_response_wrapper( + bgp_prefixes.edit, + ) + self.get = to_raw_response_wrapper( + bgp_prefixes.get, + ) + + +class AsyncBGPPrefixesResourceWithRawResponse: + def __init__(self, bgp_prefixes: AsyncBGPPrefixesResource) -> None: + self._bgp_prefixes = bgp_prefixes + + self.create = async_to_raw_response_wrapper( + bgp_prefixes.create, + ) + self.list = async_to_raw_response_wrapper( + bgp_prefixes.list, + ) + self.edit = async_to_raw_response_wrapper( + bgp_prefixes.edit, + ) + self.get = async_to_raw_response_wrapper( + bgp_prefixes.get, + ) + + +class BGPPrefixesResourceWithStreamingResponse: + def __init__(self, bgp_prefixes: BGPPrefixesResource) -> None: + self._bgp_prefixes = bgp_prefixes + + self.create = to_streamed_response_wrapper( + bgp_prefixes.create, + ) + self.list = to_streamed_response_wrapper( + bgp_prefixes.list, + ) + self.edit = to_streamed_response_wrapper( + bgp_prefixes.edit, + ) + self.get = to_streamed_response_wrapper( + bgp_prefixes.get, + ) + + +class AsyncBGPPrefixesResourceWithStreamingResponse: + def __init__(self, bgp_prefixes: AsyncBGPPrefixesResource) -> None: + self._bgp_prefixes = bgp_prefixes + + self.create = async_to_streamed_response_wrapper( + bgp_prefixes.create, + ) + self.list = async_to_streamed_response_wrapper( + bgp_prefixes.list, + ) + self.edit = async_to_streamed_response_wrapper( + bgp_prefixes.edit, + ) + self.get = async_to_streamed_response_wrapper( + bgp_prefixes.get, + ) diff --git a/src/cloudflare/resources/addressing/prefixes/delegations.py b/src/cloudflare/resources/addressing/prefixes/delegations.py index 1fed5c0a3ba..cdc8824f1d3 100644 --- a/src/cloudflare/resources/addressing/prefixes/delegations.py +++ b/src/cloudflare/resources/addressing/prefixes/delegations.py @@ -6,11 +6,8 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -32,10 +29,21 @@ class DelegationsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> DelegationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return DelegationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> DelegationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return DelegationsResourceWithStreamingResponse(self) def create( @@ -50,15 +58,15 @@ def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Delegations]: """ Create a new account delegation for a given IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. cidr: IP Prefix in Classless Inter-Domain Routing format. @@ -105,15 +113,15 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[Delegations]: """ List all delegations for a given account IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -147,17 +155,17 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[DelegationDeleteResponse]: """ Delete an account delegation for a given IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. - delegation_id: Delegation identifier tag. + delegation_id: Identifier of a Delegation. extra_headers: Send extra headers @@ -189,10 +197,21 @@ def delete( class AsyncDelegationsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncDelegationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncDelegationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncDelegationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncDelegationsResourceWithStreamingResponse(self) async def create( @@ -207,15 +226,15 @@ async def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Delegations]: """ Create a new account delegation for a given IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. cidr: IP Prefix in Classless Inter-Domain Routing format. @@ -262,15 +281,15 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[Delegations, AsyncSinglePage[Delegations]]: """ List all delegations for a given account IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -304,17 +323,17 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[DelegationDeleteResponse]: """ Delete an account delegation for a given IP prefix. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. - delegation_id: Delegation identifier tag. + delegation_id: Identifier of a Delegation. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/addressing/prefixes/prefixes.py b/src/cloudflare/resources/addressing/prefixes/prefixes.py index ee43ea753db..6c9785fa6cf 100644 --- a/src/cloudflare/resources/addressing/prefixes/prefixes.py +++ b/src/cloudflare/resources/addressing/prefixes/prefixes.py @@ -6,20 +6,8 @@ import httpx -from .bgp import ( - BGPResource, - AsyncBGPResource, - BGPResourceWithRawResponse, - AsyncBGPResourceWithRawResponse, - BGPResourceWithStreamingResponse, - AsyncBGPResourceWithStreamingResponse, -) -from .bgp.bgp import BGPResource, AsyncBGPResource -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from .delegations import ( DelegationsResource, @@ -37,9 +25,33 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from .bgp_prefixes import ( + BGPPrefixesResource, + AsyncBGPPrefixesResource, + BGPPrefixesResourceWithRawResponse, + AsyncBGPPrefixesResourceWithRawResponse, + BGPPrefixesResourceWithStreamingResponse, + AsyncBGPPrefixesResourceWithStreamingResponse, +) from ....pagination import SyncSinglePage, AsyncSinglePage from ...._base_client import AsyncPaginator, make_request_options +from .service_bindings import ( + ServiceBindingsResource, + AsyncServiceBindingsResource, + ServiceBindingsResourceWithRawResponse, + AsyncServiceBindingsResourceWithRawResponse, + ServiceBindingsResourceWithStreamingResponse, + AsyncServiceBindingsResourceWithStreamingResponse, +) from ....types.addressing import prefix_edit_params, prefix_create_params +from .advertisement_status import ( + AdvertisementStatusResource, + AsyncAdvertisementStatusResource, + AdvertisementStatusResourceWithRawResponse, + AsyncAdvertisementStatusResourceWithRawResponse, + AdvertisementStatusResourceWithStreamingResponse, + AsyncAdvertisementStatusResourceWithStreamingResponse, +) from ....types.addressing.prefix import Prefix from ....types.addressing.prefix_delete_response import PrefixDeleteResponse @@ -48,8 +60,16 @@ class PrefixesResource(SyncAPIResource): @cached_property - def bgp(self) -> BGPResource: - return BGPResource(self._client) + def service_bindings(self) -> ServiceBindingsResource: + return ServiceBindingsResource(self._client) + + @cached_property + def bgp_prefixes(self) -> BGPPrefixesResource: + return BGPPrefixesResource(self._client) + + @cached_property + def advertisement_status(self) -> AdvertisementStatusResource: + return AdvertisementStatusResource(self._client) @cached_property def delegations(self) -> DelegationsResource: @@ -57,36 +77,54 @@ def delegations(self) -> DelegationsResource: @cached_property def with_raw_response(self) -> PrefixesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return PrefixesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> PrefixesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return PrefixesResourceWithStreamingResponse(self) def create( self, *, account_id: str, - asn: Optional[int], + asn: int, cidr: str, - loa_document_id: Optional[str], + delegate_loa_creation: bool | Omit = omit, + description: str | Omit = omit, + loa_document_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ Add a new prefix under the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. asn: Autonomous System Number (ASN) the prefix will be advertised under. cidr: IP Prefix in Classless Inter-Domain Routing format. + delegate_loa_creation: Whether Cloudflare is allowed to generate the LOA document on behalf of the + prefix owner. + + description: Description of the prefix. + loa_document_id: Identifier for the uploaded LOA document. extra_headers: Send extra headers @@ -105,6 +143,8 @@ def create( { "asn": asn, "cidr": cidr, + "delegate_loa_creation": delegate_loa_creation, + "description": description, "loa_document_id": loa_document_id, }, prefix_create_params.PrefixCreateParams, @@ -128,13 +168,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[Prefix]: """ List all prefixes owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers @@ -165,15 +205,15 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PrefixDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PrefixDeleteResponse: """ Delete an unapproved prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -190,13 +230,9 @@ def delete( return self._delete( f"/accounts/{account_id}/addressing/prefixes/{prefix_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PrefixDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[PrefixDeleteResponse]], ResultWrapper[PrefixDeleteResponse]), + cast_to=PrefixDeleteResponse, ) def edit( @@ -210,15 +246,15 @@ def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ Modify the description for a prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. description: Description of the prefix. @@ -257,15 +293,15 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ List a particular prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -294,8 +330,16 @@ def get( class AsyncPrefixesResource(AsyncAPIResource): @cached_property - def bgp(self) -> AsyncBGPResource: - return AsyncBGPResource(self._client) + def service_bindings(self) -> AsyncServiceBindingsResource: + return AsyncServiceBindingsResource(self._client) + + @cached_property + def bgp_prefixes(self) -> AsyncBGPPrefixesResource: + return AsyncBGPPrefixesResource(self._client) + + @cached_property + def advertisement_status(self) -> AsyncAdvertisementStatusResource: + return AsyncAdvertisementStatusResource(self._client) @cached_property def delegations(self) -> AsyncDelegationsResource: @@ -303,36 +347,54 @@ def delegations(self) -> AsyncDelegationsResource: @cached_property def with_raw_response(self) -> AsyncPrefixesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncPrefixesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncPrefixesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncPrefixesResourceWithStreamingResponse(self) async def create( self, *, account_id: str, - asn: Optional[int], + asn: int, cidr: str, - loa_document_id: Optional[str], + delegate_loa_creation: bool | Omit = omit, + description: str | Omit = omit, + loa_document_id: Optional[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ Add a new prefix under the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. asn: Autonomous System Number (ASN) the prefix will be advertised under. cidr: IP Prefix in Classless Inter-Domain Routing format. + delegate_loa_creation: Whether Cloudflare is allowed to generate the LOA document on behalf of the + prefix owner. + + description: Description of the prefix. + loa_document_id: Identifier for the uploaded LOA document. extra_headers: Send extra headers @@ -351,6 +413,8 @@ async def create( { "asn": asn, "cidr": cidr, + "delegate_loa_creation": delegate_loa_creation, + "description": description, "loa_document_id": loa_document_id, }, prefix_create_params.PrefixCreateParams, @@ -374,13 +438,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[Prefix, AsyncSinglePage[Prefix]]: """ List all prefixes owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers @@ -411,15 +475,15 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PrefixDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> PrefixDeleteResponse: """ Delete an unapproved prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -436,13 +500,9 @@ async def delete( return await self._delete( f"/accounts/{account_id}/addressing/prefixes/{prefix_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PrefixDeleteResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[PrefixDeleteResponse]], ResultWrapper[PrefixDeleteResponse]), + cast_to=PrefixDeleteResponse, ) async def edit( @@ -456,15 +516,15 @@ async def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ Modify the description for a prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. description: Description of the prefix. @@ -503,15 +563,15 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Prefix]: """ List a particular prefix owned by the account. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. - prefix_id: Identifier + prefix_id: Identifier of an IP Prefix. extra_headers: Send extra headers @@ -559,8 +619,16 @@ def __init__(self, prefixes: PrefixesResource) -> None: ) @cached_property - def bgp(self) -> BGPResourceWithRawResponse: - return BGPResourceWithRawResponse(self._prefixes.bgp) + def service_bindings(self) -> ServiceBindingsResourceWithRawResponse: + return ServiceBindingsResourceWithRawResponse(self._prefixes.service_bindings) + + @cached_property + def bgp_prefixes(self) -> BGPPrefixesResourceWithRawResponse: + return BGPPrefixesResourceWithRawResponse(self._prefixes.bgp_prefixes) + + @cached_property + def advertisement_status(self) -> AdvertisementStatusResourceWithRawResponse: + return AdvertisementStatusResourceWithRawResponse(self._prefixes.advertisement_status) @cached_property def delegations(self) -> DelegationsResourceWithRawResponse: @@ -588,8 +656,16 @@ def __init__(self, prefixes: AsyncPrefixesResource) -> None: ) @cached_property - def bgp(self) -> AsyncBGPResourceWithRawResponse: - return AsyncBGPResourceWithRawResponse(self._prefixes.bgp) + def service_bindings(self) -> AsyncServiceBindingsResourceWithRawResponse: + return AsyncServiceBindingsResourceWithRawResponse(self._prefixes.service_bindings) + + @cached_property + def bgp_prefixes(self) -> AsyncBGPPrefixesResourceWithRawResponse: + return AsyncBGPPrefixesResourceWithRawResponse(self._prefixes.bgp_prefixes) + + @cached_property + def advertisement_status(self) -> AsyncAdvertisementStatusResourceWithRawResponse: + return AsyncAdvertisementStatusResourceWithRawResponse(self._prefixes.advertisement_status) @cached_property def delegations(self) -> AsyncDelegationsResourceWithRawResponse: @@ -617,8 +693,16 @@ def __init__(self, prefixes: PrefixesResource) -> None: ) @cached_property - def bgp(self) -> BGPResourceWithStreamingResponse: - return BGPResourceWithStreamingResponse(self._prefixes.bgp) + def service_bindings(self) -> ServiceBindingsResourceWithStreamingResponse: + return ServiceBindingsResourceWithStreamingResponse(self._prefixes.service_bindings) + + @cached_property + def bgp_prefixes(self) -> BGPPrefixesResourceWithStreamingResponse: + return BGPPrefixesResourceWithStreamingResponse(self._prefixes.bgp_prefixes) + + @cached_property + def advertisement_status(self) -> AdvertisementStatusResourceWithStreamingResponse: + return AdvertisementStatusResourceWithStreamingResponse(self._prefixes.advertisement_status) @cached_property def delegations(self) -> DelegationsResourceWithStreamingResponse: @@ -646,8 +730,16 @@ def __init__(self, prefixes: AsyncPrefixesResource) -> None: ) @cached_property - def bgp(self) -> AsyncBGPResourceWithStreamingResponse: - return AsyncBGPResourceWithStreamingResponse(self._prefixes.bgp) + def service_bindings(self) -> AsyncServiceBindingsResourceWithStreamingResponse: + return AsyncServiceBindingsResourceWithStreamingResponse(self._prefixes.service_bindings) + + @cached_property + def bgp_prefixes(self) -> AsyncBGPPrefixesResourceWithStreamingResponse: + return AsyncBGPPrefixesResourceWithStreamingResponse(self._prefixes.bgp_prefixes) + + @cached_property + def advertisement_status(self) -> AsyncAdvertisementStatusResourceWithStreamingResponse: + return AsyncAdvertisementStatusResourceWithStreamingResponse(self._prefixes.advertisement_status) @cached_property def delegations(self) -> AsyncDelegationsResourceWithStreamingResponse: diff --git a/src/cloudflare/resources/addressing/prefixes/service_bindings.py b/src/cloudflare/resources/addressing/prefixes/service_bindings.py new file mode 100644 index 00000000000..163f77b5a40 --- /dev/null +++ b/src/cloudflare/resources/addressing/prefixes/service_bindings.py @@ -0,0 +1,548 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.addressing.prefixes import service_binding_create_params +from ....types.addressing.prefixes.service_binding import ServiceBinding +from ....types.addressing.prefixes.service_binding_delete_response import ServiceBindingDeleteResponse + +__all__ = ["ServiceBindingsResource", "AsyncServiceBindingsResource"] + + +class ServiceBindingsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ServiceBindingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ServiceBindingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ServiceBindingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ServiceBindingsResourceWithStreamingResponse(self) + + def create( + self, + prefix_id: str, + *, + account_id: str, + cidr: str, + service_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ServiceBinding]: + """ + Creates a new Service Binding, routing traffic to IPs within the given CIDR to a + service running on Cloudflare's network. **NOTE:** The first Service Binding + created for an IP Prefix must exactly match the IP Prefix's CIDR. Subsequent + Service Bindings may be created with a more-specific CIDR. Refer to the + [Service Bindings Documentation](https://developers.cloudflare.com/byoip/service-bindings/) + for compatibility details. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + cidr: IP Prefix in Classless Inter-Domain Routing format. + + service_id: Identifier of a Service on the Cloudflare network. Available services and their + IDs may be found in the **List Services** endpoint. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._post( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + body=maybe_transform( + { + "cidr": cidr, + "service_id": service_id, + }, + service_binding_create_params.ServiceBindingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), + ) + + def list( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[ServiceBinding]: + """List the Cloudflare services this prefix is currently bound to. + + Traffic sent to + an address within an IP prefix will be routed to the Cloudflare service of the + most-specific Service Binding matching the address. **Example:** binding + `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare + CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other + IPs in the prefix to Cloudflare Magic Transit. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + page=SyncSinglePage[ServiceBinding], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ServiceBinding, + ) + + def delete( + self, + binding_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ServiceBindingDeleteResponse: + """ + Delete a Service Binding + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + binding_id: Identifier of a Service Binding. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not binding_id: + raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") + return self._delete( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ServiceBindingDeleteResponse, + ) + + def get( + self, + binding_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ServiceBinding]: + """ + Fetch a single Service Binding + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + binding_id: Identifier of a Service Binding. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not binding_id: + raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") + return self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), + ) + + +class AsyncServiceBindingsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncServiceBindingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncServiceBindingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncServiceBindingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncServiceBindingsResourceWithStreamingResponse(self) + + async def create( + self, + prefix_id: str, + *, + account_id: str, + cidr: str, + service_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ServiceBinding]: + """ + Creates a new Service Binding, routing traffic to IPs within the given CIDR to a + service running on Cloudflare's network. **NOTE:** The first Service Binding + created for an IP Prefix must exactly match the IP Prefix's CIDR. Subsequent + Service Bindings may be created with a more-specific CIDR. Refer to the + [Service Bindings Documentation](https://developers.cloudflare.com/byoip/service-bindings/) + for compatibility details. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + cidr: IP Prefix in Classless Inter-Domain Routing format. + + service_id: Identifier of a Service on the Cloudflare network. Available services and their + IDs may be found in the **List Services** endpoint. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return await self._post( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + body=await async_maybe_transform( + { + "cidr": cidr, + "service_id": service_id, + }, + service_binding_create_params.ServiceBindingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), + ) + + def list( + self, + prefix_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ServiceBinding, AsyncSinglePage[ServiceBinding]]: + """List the Cloudflare services this prefix is currently bound to. + + Traffic sent to + an address within an IP prefix will be routed to the Cloudflare service of the + most-specific Service Binding matching the address. **Example:** binding + `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare + CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other + IPs in the prefix to Cloudflare Magic Transit. + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings", + page=AsyncSinglePage[ServiceBinding], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ServiceBinding, + ) + + async def delete( + self, + binding_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ServiceBindingDeleteResponse: + """ + Delete a Service Binding + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + binding_id: Identifier of a Service Binding. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not binding_id: + raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") + return await self._delete( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ServiceBindingDeleteResponse, + ) + + async def get( + self, + binding_id: str, + *, + account_id: str, + prefix_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ServiceBinding]: + """ + Fetch a single Service Binding + + Args: + account_id: Identifier of a Cloudflare account. + + prefix_id: Identifier of an IP Prefix. + + binding_id: Identifier of a Service Binding. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not prefix_id: + raise ValueError(f"Expected a non-empty value for `prefix_id` but received {prefix_id!r}") + if not binding_id: + raise ValueError(f"Expected a non-empty value for `binding_id` but received {binding_id!r}") + return await self._get( + f"/accounts/{account_id}/addressing/prefixes/{prefix_id}/bindings/{binding_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceBinding]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceBinding]], ResultWrapper[ServiceBinding]), + ) + + +class ServiceBindingsResourceWithRawResponse: + def __init__(self, service_bindings: ServiceBindingsResource) -> None: + self._service_bindings = service_bindings + + self.create = to_raw_response_wrapper( + service_bindings.create, + ) + self.list = to_raw_response_wrapper( + service_bindings.list, + ) + self.delete = to_raw_response_wrapper( + service_bindings.delete, + ) + self.get = to_raw_response_wrapper( + service_bindings.get, + ) + + +class AsyncServiceBindingsResourceWithRawResponse: + def __init__(self, service_bindings: AsyncServiceBindingsResource) -> None: + self._service_bindings = service_bindings + + self.create = async_to_raw_response_wrapper( + service_bindings.create, + ) + self.list = async_to_raw_response_wrapper( + service_bindings.list, + ) + self.delete = async_to_raw_response_wrapper( + service_bindings.delete, + ) + self.get = async_to_raw_response_wrapper( + service_bindings.get, + ) + + +class ServiceBindingsResourceWithStreamingResponse: + def __init__(self, service_bindings: ServiceBindingsResource) -> None: + self._service_bindings = service_bindings + + self.create = to_streamed_response_wrapper( + service_bindings.create, + ) + self.list = to_streamed_response_wrapper( + service_bindings.list, + ) + self.delete = to_streamed_response_wrapper( + service_bindings.delete, + ) + self.get = to_streamed_response_wrapper( + service_bindings.get, + ) + + +class AsyncServiceBindingsResourceWithStreamingResponse: + def __init__(self, service_bindings: AsyncServiceBindingsResource) -> None: + self._service_bindings = service_bindings + + self.create = async_to_streamed_response_wrapper( + service_bindings.create, + ) + self.list = async_to_streamed_response_wrapper( + service_bindings.list, + ) + self.delete = async_to_streamed_response_wrapper( + service_bindings.delete, + ) + self.get = async_to_streamed_response_wrapper( + service_bindings.get, + ) diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py index 1c719b3da72..e404f48a4d1 100644 --- a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py +++ b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py @@ -14,11 +14,8 @@ RegionsResourceWithStreamingResponse, AsyncRegionsResourceWithStreamingResponse, ) -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -47,10 +44,21 @@ def regions(self) -> RegionsResource: @cached_property def with_raw_response(self) -> RegionalHostnamesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return RegionalHostnamesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> RegionalHostnamesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return RegionalHostnamesResourceWithStreamingResponse(self) def create( @@ -59,12 +67,13 @@ def create( zone_id: str, hostname: str, region_key: str, + routing: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameCreateResponse]: """Create a new Regional Hostname entry. @@ -74,13 +83,15 @@ def create( [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` region_key: Identifying key for the region + routing: Configure which routing method to use for the regional hostname + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -97,6 +108,7 @@ def create( { "hostname": hostname, "region_key": region_key, + "routing": routing, }, regional_hostname_create_params.RegionalHostnameCreateParams, ), @@ -119,13 +131,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[RegionalHostnameListResponse]: """ List all Regional Hostnames within a zone. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -156,13 +168,13 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RegionalHostnameDeleteResponse: """ Delete the region configuration for a specific Regional Hostname. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` @@ -198,7 +210,7 @@ def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameEditResponse]: """Update the configuration for a specific Regional Hostname. @@ -206,7 +218,7 @@ def edit( of a hostname is mutable. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` @@ -248,13 +260,13 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameGetResponse]: """ Fetch the configuration for a specific Regional Hostname, within a zone. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` @@ -291,10 +303,21 @@ def regions(self) -> AsyncRegionsResource: @cached_property def with_raw_response(self) -> AsyncRegionalHostnamesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncRegionalHostnamesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncRegionalHostnamesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncRegionalHostnamesResourceWithStreamingResponse(self) async def create( @@ -303,12 +326,13 @@ async def create( zone_id: str, hostname: str, region_key: str, + routing: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameCreateResponse]: """Create a new Regional Hostname entry. @@ -318,13 +342,15 @@ async def create( [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` region_key: Identifying key for the region + routing: Configure which routing method to use for the regional hostname + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -341,6 +367,7 @@ async def create( { "hostname": hostname, "region_key": region_key, + "routing": routing, }, regional_hostname_create_params.RegionalHostnameCreateParams, ), @@ -363,13 +390,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[RegionalHostnameListResponse, AsyncSinglePage[RegionalHostnameListResponse]]: """ List all Regional Hostnames within a zone. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -400,13 +427,13 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> RegionalHostnameDeleteResponse: """ Delete the region configuration for a specific Regional Hostname. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` @@ -442,7 +469,7 @@ async def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameEditResponse]: """Update the configuration for a specific Regional Hostname. @@ -450,7 +477,7 @@ async def edit( of a hostname is mutable. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` @@ -494,13 +521,13 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[RegionalHostnameGetResponse]: """ Fetch the configuration for a specific Regional Hostname, within a zone. Args: - zone_id: Identifier + zone_id: Identifier. hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com` diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regions.py b/src/cloudflare/resources/addressing/regional_hostnames/regions.py index c3432d5cb2b..e94af76ff04 100644 --- a/src/cloudflare/resources/addressing/regional_hostnames/regions.py +++ b/src/cloudflare/resources/addressing/regional_hostnames/regions.py @@ -4,7 +4,7 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -23,10 +23,21 @@ class RegionsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> RegionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return RegionsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> RegionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return RegionsResourceWithStreamingResponse(self) def list( @@ -38,13 +49,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[RegionListResponse]: """ List all Regional Services regions available for use by this account. Args: - account_id: Identifier + account_id: Identifier. extra_headers: Send extra headers @@ -69,10 +80,21 @@ def list( class AsyncRegionsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncRegionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncRegionsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncRegionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncRegionsResourceWithStreamingResponse(self) def list( @@ -84,13 +106,13 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[RegionListResponse, AsyncSinglePage[RegionListResponse]]: """ List all Regional Services regions available for use by this account. Args: - account_id: Identifier + account_id: Identifier. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/addressing/services.py b/src/cloudflare/resources/addressing/services.py index ff6ef55cfa2..959ced7ff44 100644 --- a/src/cloudflare/resources/addressing/services.py +++ b/src/cloudflare/resources/addressing/services.py @@ -4,7 +4,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Query, Headers, NotGiven, not_given from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -23,10 +23,21 @@ class ServicesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ServicesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ServicesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ServicesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ServicesResourceWithStreamingResponse(self) def list( @@ -38,7 +49,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ServiceListResponse]: """ Bring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a @@ -47,7 +58,7 @@ def list( the Cloudflare network, and their service IDs. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers @@ -72,10 +83,21 @@ def list( class AsyncServicesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncServicesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncServicesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncServicesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncServicesResourceWithStreamingResponse(self) def list( @@ -87,7 +109,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ServiceListResponse, AsyncSinglePage[ServiceListResponse]]: """ Bring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a @@ -96,7 +118,7 @@ def list( the Cloudflare network, and their service IDs. Args: - account_id: Identifier + account_id: Identifier of a Cloudflare account. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai/__init__.py b/src/cloudflare/resources/ai/__init__.py new file mode 100644 index 00000000000..ccf8b736c39 --- /dev/null +++ b/src/cloudflare/resources/ai/__init__.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .ai import ( + AIResource, + AsyncAIResource, + AIResourceWithRawResponse, + AsyncAIResourceWithRawResponse, + AIResourceWithStreamingResponse, + AsyncAIResourceWithStreamingResponse, +) +from .tasks import ( + TasksResource, + AsyncTasksResource, + TasksResourceWithRawResponse, + AsyncTasksResourceWithRawResponse, + TasksResourceWithStreamingResponse, + AsyncTasksResourceWithStreamingResponse, +) +from .models import ( + ModelsResource, + AsyncModelsResource, + ModelsResourceWithRawResponse, + AsyncModelsResourceWithRawResponse, + ModelsResourceWithStreamingResponse, + AsyncModelsResourceWithStreamingResponse, +) +from .authors import ( + AuthorsResource, + AsyncAuthorsResource, + AuthorsResourceWithRawResponse, + AsyncAuthorsResourceWithRawResponse, + AuthorsResourceWithStreamingResponse, + AsyncAuthorsResourceWithStreamingResponse, +) +from .finetunes import ( + FinetunesResource, + AsyncFinetunesResource, + FinetunesResourceWithRawResponse, + AsyncFinetunesResourceWithRawResponse, + FinetunesResourceWithStreamingResponse, + AsyncFinetunesResourceWithStreamingResponse, +) +from .to_markdown import ( + ToMarkdownResource, + AsyncToMarkdownResource, + ToMarkdownResourceWithRawResponse, + AsyncToMarkdownResourceWithRawResponse, + ToMarkdownResourceWithStreamingResponse, + AsyncToMarkdownResourceWithStreamingResponse, +) + +__all__ = [ + "FinetunesResource", + "AsyncFinetunesResource", + "FinetunesResourceWithRawResponse", + "AsyncFinetunesResourceWithRawResponse", + "FinetunesResourceWithStreamingResponse", + "AsyncFinetunesResourceWithStreamingResponse", + "AuthorsResource", + "AsyncAuthorsResource", + "AuthorsResourceWithRawResponse", + "AsyncAuthorsResourceWithRawResponse", + "AuthorsResourceWithStreamingResponse", + "AsyncAuthorsResourceWithStreamingResponse", + "TasksResource", + "AsyncTasksResource", + "TasksResourceWithRawResponse", + "AsyncTasksResourceWithRawResponse", + "TasksResourceWithStreamingResponse", + "AsyncTasksResourceWithStreamingResponse", + "ModelsResource", + "AsyncModelsResource", + "ModelsResourceWithRawResponse", + "AsyncModelsResourceWithRawResponse", + "ModelsResourceWithStreamingResponse", + "AsyncModelsResourceWithStreamingResponse", + "ToMarkdownResource", + "AsyncToMarkdownResource", + "ToMarkdownResourceWithRawResponse", + "AsyncToMarkdownResourceWithRawResponse", + "ToMarkdownResourceWithStreamingResponse", + "AsyncToMarkdownResourceWithStreamingResponse", + "AIResource", + "AsyncAIResource", + "AIResourceWithRawResponse", + "AsyncAIResourceWithRawResponse", + "AIResourceWithStreamingResponse", + "AsyncAIResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/ai/ai.py b/src/cloudflare/resources/ai/ai.py new file mode 100644 index 00000000000..9a53d1b3df5 --- /dev/null +++ b/src/cloudflare/resources/ai/ai.py @@ -0,0 +1,2137 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Union, Iterable, Optional, cast +from typing_extensions import overload + +import httpx + +from .tasks import ( + TasksResource, + AsyncTasksResource, + TasksResourceWithRawResponse, + AsyncTasksResourceWithRawResponse, + TasksResourceWithStreamingResponse, + AsyncTasksResourceWithStreamingResponse, +) +from .authors import ( + AuthorsResource, + AsyncAuthorsResource, + AuthorsResourceWithRawResponse, + AsyncAuthorsResourceWithRawResponse, + AuthorsResourceWithStreamingResponse, + AsyncAuthorsResourceWithStreamingResponse, +) +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ...types.ai import ai_run_params +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from .to_markdown import ( + ToMarkdownResource, + AsyncToMarkdownResource, + ToMarkdownResourceWithRawResponse, + AsyncToMarkdownResourceWithRawResponse, + ToMarkdownResourceWithStreamingResponse, + AsyncToMarkdownResourceWithStreamingResponse, +) +from .models.models import ( + ModelsResource, + AsyncModelsResource, + ModelsResourceWithRawResponse, + AsyncModelsResourceWithRawResponse, + ModelsResourceWithStreamingResponse, + AsyncModelsResourceWithStreamingResponse, +) +from ..._base_client import make_request_options +from .finetunes.finetunes import ( + FinetunesResource, + AsyncFinetunesResource, + FinetunesResourceWithRawResponse, + AsyncFinetunesResourceWithRawResponse, + FinetunesResourceWithStreamingResponse, + AsyncFinetunesResourceWithStreamingResponse, +) +from ...types.ai.ai_run_response import AIRunResponse + +__all__ = ["AIResource", "AsyncAIResource"] + + +class AIResource(SyncAPIResource): + @cached_property + def finetunes(self) -> FinetunesResource: + return FinetunesResource(self._client) + + @cached_property + def authors(self) -> AuthorsResource: + return AuthorsResource(self._client) + + @cached_property + def tasks(self) -> TasksResource: + return TasksResource(self._client) + + @cached_property + def models(self) -> ModelsResource: + return ModelsResource(self._client) + + @cached_property + def to_markdown(self) -> ToMarkdownResource: + return ToMarkdownResource(self._client) + + @cached_property + def with_raw_response(self) -> AIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AIResourceWithStreamingResponse(self) + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + text: The text that you want to classify + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + guidance: float | Omit = omit, + height: int | Omit = omit, + image: Iterable[float] | Omit = omit, + image_b64: str | Omit = omit, + mask: Iterable[float] | Omit = omit, + negative_prompt: str | Omit = omit, + num_steps: int | Omit = omit, + seed: int | Omit = omit, + strength: float | Omit = omit, + width: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: A text description of the image you want to generate + + guidance: Controls how closely the generated image should adhere to the prompt; higher + values make the image more aligned with the prompt + + height: The height of the generated image in pixels + + image: For use with img2img tasks. An array of integers that represent the image data + constrained to 8-bit unsigned integer values + + image_b64: For use with img2img tasks. A base64-encoded string of the input image + + mask: An array representing An array of integers that represent mask image data for + inpainting constrained to 8-bit unsigned integer values + + negative_prompt: Text describing elements to avoid in the generated image + + num_steps: The number of diffusion steps; higher values can improve quality but take longer + + seed: Random seed for reproducibility of the image generation + + strength: A value between 0 and 1 indicating how strongly to apply the transformation + during img2img tasks; lower values make the output closer to the input image + + width: The width of the generated image in pixels + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: A text description of the audio you want to generate + + lang: The speech language (e.g., 'en' for English, 'fr' for French). Defaults to 'en' + if not specified + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + text: Union[str, SequenceNotStr[str]], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + text: The text to embed + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + audio: Iterable[float], + source_lang: str | Omit = omit, + target_lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + audio: An array of integers that represent the audio data constrained to 8-bit unsigned + integer values + + source_lang: The language of the recorded audio + + target_lang: The language to translate the transcription into. Currently only English is + supported. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + frequency_penalty: float | Omit = omit, + lora: str | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.PromptResponseFormat | Omit = omit, + seed: int | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + top_k: int | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + lora: Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Adjusts the creativity of the AI's responses by controlling how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + messages: Iterable[ai_run_params.MessagesMessage], + frequency_penalty: float | Omit = omit, + functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.MessagesResponseFormat | Omit = omit, + seed: int | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + tools: Iterable[ai_run_params.MessagesTool] | Omit = omit, + top_k: int | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + tools: A list of tools available for the assistant to use. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Adjusts the creativity of the AI's responses by controlling how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + target_lang: str, + text: str, + source_lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + target_lang: The language code to translate the text into (e.g., 'es' for Spanish) + + text: The text to be translated + + source_lang: The language code of the source text (e.g., 'en' for English). Defaults to 'en' + if not specified + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + input_text: str, + max_length: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + input_text: The text that you want the model to summarize + + max_length: The maximum length of the generated summary in tokens + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float], + frequency_penalty: float | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + prompt: str | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + prompt: The input text prompt for the model to generate a response. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: str, + prompt: str, + frequency_penalty: float | Omit = omit, + ignore_eos: bool | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: str, + messages: Iterable[ai_run_params.Variant13Message], + frequency_penalty: float | Omit = omit, + ignore_eos: bool | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def run( + self, + model_name: str, + *, + account_id: str, + image: str | Omit = omit, + text: SequenceNotStr[str] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["account_id", "text"], + ["account_id", "prompt"], + ["account_id", "audio"], + ["account_id", "image"], + ["account_id"], + ["account_id", "messages"], + ["account_id", "target_lang", "text"], + ["account_id", "input_text"], + ["account_id", "image", "prompt"], + ["account_id", "image", "messages"], + ) + def run( + self, + model_name: str, + *, + account_id: str, + text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, + prompt: str | Omit = omit, + guidance: float | Omit = omit, + height: int | Omit = omit, + image: Iterable[float] | str | Omit = omit, + image_b64: str | Omit = omit, + mask: Iterable[float] | Omit = omit, + negative_prompt: str | Omit = omit, + num_steps: int | Omit = omit, + seed: int | float | Omit = omit, + strength: float | Omit = omit, + width: int | Omit = omit, + lang: str | Omit = omit, + audio: Iterable[float] | Omit = omit, + source_lang: str | Omit = omit, + target_lang: str | Omit = omit, + frequency_penalty: float | Omit = omit, + lora: str | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.PromptResponseFormat | ai_run_params.MessagesResponseFormat | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + top_k: int | float | Omit = omit, + top_p: float | Omit = omit, + messages: Iterable[ai_run_params.MessagesMessage] | Iterable[ai_run_params.Variant13Message] | Omit = omit, + functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, + tools: Iterable[ai_run_params.MessagesTool] | Omit = omit, + input_text: str | Omit = omit, + max_length: int | Omit = omit, + ignore_eos: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not model_name: + raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") + return cast( + Optional[AIRunResponse], + self._post( + f"/accounts/{account_id}/ai/run/{model_name}", + body=maybe_transform( + { + "text": text, + "prompt": prompt, + "guidance": guidance, + "height": height, + "image": image, + "image_b64": image_b64, + "mask": mask, + "negative_prompt": negative_prompt, + "num_steps": num_steps, + "seed": seed, + "strength": strength, + "width": width, + "lang": lang, + "audio": audio, + "source_lang": source_lang, + "target_lang": target_lang, + "frequency_penalty": frequency_penalty, + "lora": lora, + "max_tokens": max_tokens, + "presence_penalty": presence_penalty, + "raw": raw, + "repetition_penalty": repetition_penalty, + "response_format": response_format, + "stream": stream, + "temperature": temperature, + "top_k": top_k, + "top_p": top_p, + "messages": messages, + "functions": functions, + "tools": tools, + "input_text": input_text, + "max_length": max_length, + "ignore_eos": ignore_eos, + }, + ai_run_params.AIRunParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AIRunResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AIRunResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncAIResource(AsyncAPIResource): + @cached_property + def finetunes(self) -> AsyncFinetunesResource: + return AsyncFinetunesResource(self._client) + + @cached_property + def authors(self) -> AsyncAuthorsResource: + return AsyncAuthorsResource(self._client) + + @cached_property + def tasks(self) -> AsyncTasksResource: + return AsyncTasksResource(self._client) + + @cached_property + def models(self) -> AsyncModelsResource: + return AsyncModelsResource(self._client) + + @cached_property + def to_markdown(self) -> AsyncToMarkdownResource: + return AsyncToMarkdownResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAIResourceWithStreamingResponse(self) + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + text: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + text: The text that you want to classify + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + guidance: float | Omit = omit, + height: int | Omit = omit, + image: Iterable[float] | Omit = omit, + image_b64: str | Omit = omit, + mask: Iterable[float] | Omit = omit, + negative_prompt: str | Omit = omit, + num_steps: int | Omit = omit, + seed: int | Omit = omit, + strength: float | Omit = omit, + width: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: A text description of the image you want to generate + + guidance: Controls how closely the generated image should adhere to the prompt; higher + values make the image more aligned with the prompt + + height: The height of the generated image in pixels + + image: For use with img2img tasks. An array of integers that represent the image data + constrained to 8-bit unsigned integer values + + image_b64: For use with img2img tasks. A base64-encoded string of the input image + + mask: An array representing An array of integers that represent mask image data for + inpainting constrained to 8-bit unsigned integer values + + negative_prompt: Text describing elements to avoid in the generated image + + num_steps: The number of diffusion steps; higher values can improve quality but take longer + + seed: Random seed for reproducibility of the image generation + + strength: A value between 0 and 1 indicating how strongly to apply the transformation + during img2img tasks; lower values make the output closer to the input image + + width: The width of the generated image in pixels + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: A text description of the audio you want to generate + + lang: The speech language (e.g., 'en' for English, 'fr' for French). Defaults to 'en' + if not specified + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + text: Union[str, SequenceNotStr[str]], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + text: The text to embed + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + audio: Iterable[float], + source_lang: str | Omit = omit, + target_lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + audio: An array of integers that represent the audio data constrained to 8-bit unsigned + integer values + + source_lang: The language of the recorded audio + + target_lang: The language to translate the transcription into. Currently only English is + supported. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + prompt: str, + frequency_penalty: float | Omit = omit, + lora: str | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.PromptResponseFormat | Omit = omit, + seed: int | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + top_k: int | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + lora: Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Adjusts the creativity of the AI's responses by controlling how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + messages: Iterable[ai_run_params.MessagesMessage], + frequency_penalty: float | Omit = omit, + functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.MessagesResponseFormat | Omit = omit, + seed: int | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + tools: Iterable[ai_run_params.MessagesTool] | Omit = omit, + top_k: int | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + stream: If true, the response will be streamed back incrementally using SSE, Server Sent + Events. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + tools: A list of tools available for the assistant to use. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Adjusts the creativity of the AI's responses by controlling how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + target_lang: str, + text: str, + source_lang: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + target_lang: The language code to translate the text into (e.g., 'es' for Spanish) + + text: The text to be translated + + source_lang: The language code of the source text (e.g., 'en' for English). Defaults to 'en' + if not specified + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + input_text: str, + max_length: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + input_text: The text that you want the model to summarize + + max_length: The maximum length of the generated summary in tokens + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: Iterable[float], + frequency_penalty: float | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + prompt: str | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: An array of integers that represent the image data constrained to 8-bit unsigned + integer values + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + prompt: The input text prompt for the model to generate a response. + + raw: If true, a chat template is not applied and you must adhere to the specific + model's expected formatting. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: str, + prompt: str, + frequency_penalty: float | Omit = omit, + ignore_eos: bool | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + prompt: The input text prompt for the model to generate a response. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: str, + messages: Iterable[ai_run_params.Variant13Message], + frequency_penalty: float | Omit = omit, + ignore_eos: bool | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + repetition_penalty: float | Omit = omit, + seed: float | Omit = omit, + temperature: float | Omit = omit, + top_k: float | Omit = omit, + top_p: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + messages: An array of message objects representing the conversation history. + + frequency_penalty: Decreases the likelihood of the model repeating the same lines verbatim. + + ignore_eos: Whether to ignore the EOS token and continue generating tokens after the EOS + token is generated. + + max_tokens: The maximum number of tokens to generate in the response. + + presence_penalty: Increases the likelihood of the model introducing new topics. + + repetition_penalty: Penalty for repeated tokens; higher values discourage repetition. + + seed: Random seed for reproducibility of the generation. + + temperature: Controls the randomness of the output; higher values produce more random + results. + + top_k: Limits the AI to choose from the top 'k' most probable words. Lower values make + responses more focused; higher values introduce more variety and potential + surprises. + + top_p: Controls the creativity of the AI's responses by adjusting how many possible + words it considers. Lower values make outputs more predictable; higher values + allow for more varied and creative responses. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def run( + self, + model_name: str, + *, + account_id: str, + image: str | Omit = omit, + text: SequenceNotStr[str] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + """ + This endpoint provides users with the capability to run specific AI models + on-demand. + + By submitting the required input data, users can receive real-time predictions + or results generated by the chosen AI model. The endpoint supports various AI + model types, ensuring flexibility and adaptability for diverse use cases. + + Model specific inputs available in + [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). + + Args: + image: Image in base64 encoded format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["account_id", "text"], + ["account_id", "prompt"], + ["account_id", "audio"], + ["account_id", "image"], + ["account_id"], + ["account_id", "messages"], + ["account_id", "target_lang", "text"], + ["account_id", "input_text"], + ["account_id", "image", "prompt"], + ["account_id", "image", "messages"], + ) + async def run( + self, + model_name: str, + *, + account_id: str, + text: str | Union[str, SequenceNotStr[str]] | SequenceNotStr[str] | Omit = omit, + prompt: str | Omit = omit, + guidance: float | Omit = omit, + height: int | Omit = omit, + image: Iterable[float] | str | Omit = omit, + image_b64: str | Omit = omit, + mask: Iterable[float] | Omit = omit, + negative_prompt: str | Omit = omit, + num_steps: int | Omit = omit, + seed: int | float | Omit = omit, + strength: float | Omit = omit, + width: int | Omit = omit, + lang: str | Omit = omit, + audio: Iterable[float] | Omit = omit, + source_lang: str | Omit = omit, + target_lang: str | Omit = omit, + frequency_penalty: float | Omit = omit, + lora: str | Omit = omit, + max_tokens: int | Omit = omit, + presence_penalty: float | Omit = omit, + raw: bool | Omit = omit, + repetition_penalty: float | Omit = omit, + response_format: ai_run_params.PromptResponseFormat | ai_run_params.MessagesResponseFormat | Omit = omit, + stream: bool | Omit = omit, + temperature: float | Omit = omit, + top_k: int | float | Omit = omit, + top_p: float | Omit = omit, + messages: Iterable[ai_run_params.MessagesMessage] | Iterable[ai_run_params.Variant13Message] | Omit = omit, + functions: Iterable[ai_run_params.MessagesFunction] | Omit = omit, + tools: Iterable[ai_run_params.MessagesTool] | Omit = omit, + input_text: str | Omit = omit, + max_length: int | Omit = omit, + ignore_eos: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[AIRunResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not model_name: + raise ValueError(f"Expected a non-empty value for `model_name` but received {model_name!r}") + return cast( + Optional[AIRunResponse], + await self._post( + f"/accounts/{account_id}/ai/run/{model_name}", + body=await async_maybe_transform( + { + "text": text, + "prompt": prompt, + "guidance": guidance, + "height": height, + "image": image, + "image_b64": image_b64, + "mask": mask, + "negative_prompt": negative_prompt, + "num_steps": num_steps, + "seed": seed, + "strength": strength, + "width": width, + "lang": lang, + "audio": audio, + "source_lang": source_lang, + "target_lang": target_lang, + "frequency_penalty": frequency_penalty, + "lora": lora, + "max_tokens": max_tokens, + "presence_penalty": presence_penalty, + "raw": raw, + "repetition_penalty": repetition_penalty, + "response_format": response_format, + "stream": stream, + "temperature": temperature, + "top_k": top_k, + "top_p": top_p, + "messages": messages, + "functions": functions, + "tools": tools, + "input_text": input_text, + "max_length": max_length, + "ignore_eos": ignore_eos, + }, + ai_run_params.AIRunParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AIRunResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AIRunResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AIResourceWithRawResponse: + def __init__(self, ai: AIResource) -> None: + self._ai = ai + + self.run = to_raw_response_wrapper( + ai.run, + ) + + @cached_property + def finetunes(self) -> FinetunesResourceWithRawResponse: + return FinetunesResourceWithRawResponse(self._ai.finetunes) + + @cached_property + def authors(self) -> AuthorsResourceWithRawResponse: + return AuthorsResourceWithRawResponse(self._ai.authors) + + @cached_property + def tasks(self) -> TasksResourceWithRawResponse: + return TasksResourceWithRawResponse(self._ai.tasks) + + @cached_property + def models(self) -> ModelsResourceWithRawResponse: + return ModelsResourceWithRawResponse(self._ai.models) + + @cached_property + def to_markdown(self) -> ToMarkdownResourceWithRawResponse: + return ToMarkdownResourceWithRawResponse(self._ai.to_markdown) + + +class AsyncAIResourceWithRawResponse: + def __init__(self, ai: AsyncAIResource) -> None: + self._ai = ai + + self.run = async_to_raw_response_wrapper( + ai.run, + ) + + @cached_property + def finetunes(self) -> AsyncFinetunesResourceWithRawResponse: + return AsyncFinetunesResourceWithRawResponse(self._ai.finetunes) + + @cached_property + def authors(self) -> AsyncAuthorsResourceWithRawResponse: + return AsyncAuthorsResourceWithRawResponse(self._ai.authors) + + @cached_property + def tasks(self) -> AsyncTasksResourceWithRawResponse: + return AsyncTasksResourceWithRawResponse(self._ai.tasks) + + @cached_property + def models(self) -> AsyncModelsResourceWithRawResponse: + return AsyncModelsResourceWithRawResponse(self._ai.models) + + @cached_property + def to_markdown(self) -> AsyncToMarkdownResourceWithRawResponse: + return AsyncToMarkdownResourceWithRawResponse(self._ai.to_markdown) + + +class AIResourceWithStreamingResponse: + def __init__(self, ai: AIResource) -> None: + self._ai = ai + + self.run = to_streamed_response_wrapper( + ai.run, + ) + + @cached_property + def finetunes(self) -> FinetunesResourceWithStreamingResponse: + return FinetunesResourceWithStreamingResponse(self._ai.finetunes) + + @cached_property + def authors(self) -> AuthorsResourceWithStreamingResponse: + return AuthorsResourceWithStreamingResponse(self._ai.authors) + + @cached_property + def tasks(self) -> TasksResourceWithStreamingResponse: + return TasksResourceWithStreamingResponse(self._ai.tasks) + + @cached_property + def models(self) -> ModelsResourceWithStreamingResponse: + return ModelsResourceWithStreamingResponse(self._ai.models) + + @cached_property + def to_markdown(self) -> ToMarkdownResourceWithStreamingResponse: + return ToMarkdownResourceWithStreamingResponse(self._ai.to_markdown) + + +class AsyncAIResourceWithStreamingResponse: + def __init__(self, ai: AsyncAIResource) -> None: + self._ai = ai + + self.run = async_to_streamed_response_wrapper( + ai.run, + ) + + @cached_property + def finetunes(self) -> AsyncFinetunesResourceWithStreamingResponse: + return AsyncFinetunesResourceWithStreamingResponse(self._ai.finetunes) + + @cached_property + def authors(self) -> AsyncAuthorsResourceWithStreamingResponse: + return AsyncAuthorsResourceWithStreamingResponse(self._ai.authors) + + @cached_property + def tasks(self) -> AsyncTasksResourceWithStreamingResponse: + return AsyncTasksResourceWithStreamingResponse(self._ai.tasks) + + @cached_property + def models(self) -> AsyncModelsResourceWithStreamingResponse: + return AsyncModelsResourceWithStreamingResponse(self._ai.models) + + @cached_property + def to_markdown(self) -> AsyncToMarkdownResourceWithStreamingResponse: + return AsyncToMarkdownResourceWithStreamingResponse(self._ai.to_markdown) diff --git a/src/cloudflare/resources/ai/authors.py b/src/cloudflare/resources/ai/authors.py new file mode 100644 index 00000000000..8f3ceeb8486 --- /dev/null +++ b/src/cloudflare/resources/ai/authors.py @@ -0,0 +1,165 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options + +__all__ = ["AuthorsResource", "AsyncAuthorsResource"] + + +class AuthorsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AuthorsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AuthorsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AuthorsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AuthorsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[object]: + """ + Author Search + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/authors/search", + page=SyncSinglePage[object], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=object, + ) + + +class AsyncAuthorsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAuthorsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAuthorsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAuthorsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAuthorsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[object, AsyncSinglePage[object]]: + """ + Author Search + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/authors/search", + page=AsyncSinglePage[object], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=object, + ) + + +class AuthorsResourceWithRawResponse: + def __init__(self, authors: AuthorsResource) -> None: + self._authors = authors + + self.list = to_raw_response_wrapper( + authors.list, + ) + + +class AsyncAuthorsResourceWithRawResponse: + def __init__(self, authors: AsyncAuthorsResource) -> None: + self._authors = authors + + self.list = async_to_raw_response_wrapper( + authors.list, + ) + + +class AuthorsResourceWithStreamingResponse: + def __init__(self, authors: AuthorsResource) -> None: + self._authors = authors + + self.list = to_streamed_response_wrapper( + authors.list, + ) + + +class AsyncAuthorsResourceWithStreamingResponse: + def __init__(self, authors: AsyncAuthorsResource) -> None: + self._authors = authors + + self.list = async_to_streamed_response_wrapper( + authors.list, + ) diff --git a/src/cloudflare/resources/ai/finetunes/__init__.py b/src/cloudflare/resources/ai/finetunes/__init__.py new file mode 100644 index 00000000000..57d977a86f3 --- /dev/null +++ b/src/cloudflare/resources/ai/finetunes/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .assets import ( + AssetsResource, + AsyncAssetsResource, + AssetsResourceWithRawResponse, + AsyncAssetsResourceWithRawResponse, + AssetsResourceWithStreamingResponse, + AsyncAssetsResourceWithStreamingResponse, +) +from .public import ( + PublicResource, + AsyncPublicResource, + PublicResourceWithRawResponse, + AsyncPublicResourceWithRawResponse, + PublicResourceWithStreamingResponse, + AsyncPublicResourceWithStreamingResponse, +) +from .finetunes import ( + FinetunesResource, + AsyncFinetunesResource, + FinetunesResourceWithRawResponse, + AsyncFinetunesResourceWithRawResponse, + FinetunesResourceWithStreamingResponse, + AsyncFinetunesResourceWithStreamingResponse, +) + +__all__ = [ + "AssetsResource", + "AsyncAssetsResource", + "AssetsResourceWithRawResponse", + "AsyncAssetsResourceWithRawResponse", + "AssetsResourceWithStreamingResponse", + "AsyncAssetsResourceWithStreamingResponse", + "PublicResource", + "AsyncPublicResource", + "PublicResourceWithRawResponse", + "AsyncPublicResourceWithRawResponse", + "PublicResourceWithStreamingResponse", + "AsyncPublicResourceWithStreamingResponse", + "FinetunesResource", + "AsyncFinetunesResource", + "FinetunesResourceWithRawResponse", + "AsyncFinetunesResourceWithRawResponse", + "FinetunesResourceWithStreamingResponse", + "AsyncFinetunesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/ai/finetunes/assets.py b/src/cloudflare/resources/ai/finetunes/assets.py new file mode 100644 index 00000000000..50ce6bb6cae --- /dev/null +++ b/src/cloudflare/resources/ai/finetunes/assets.py @@ -0,0 +1,203 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Mapping, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given +from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.ai.finetunes import asset_create_params +from ....types.ai.finetunes.asset_create_response import AssetCreateResponse + +__all__ = ["AssetsResource", "AsyncAssetsResource"] + + +class AssetsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AssetsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AssetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AssetsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AssetsResourceWithStreamingResponse(self) + + def create( + self, + finetune_id: str, + *, + account_id: str, + file: FileTypes | Omit = omit, + file_name: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AssetCreateResponse: + """ + Upload a Finetune Asset + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not finetune_id: + raise ValueError(f"Expected a non-empty value for `finetune_id` but received {finetune_id!r}") + body = deepcopy_minimal( + { + "file": file, + "file_name": file_name, + } + ) + files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return self._post( + f"/accounts/{account_id}/ai/finetunes/{finetune_id}/finetune-assets", + body=maybe_transform(body, asset_create_params.AssetCreateParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AssetCreateResponse, + ) + + +class AsyncAssetsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAssetsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAssetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAssetsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAssetsResourceWithStreamingResponse(self) + + async def create( + self, + finetune_id: str, + *, + account_id: str, + file: FileTypes | Omit = omit, + file_name: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AssetCreateResponse: + """ + Upload a Finetune Asset + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not finetune_id: + raise ValueError(f"Expected a non-empty value for `finetune_id` but received {finetune_id!r}") + body = deepcopy_minimal( + { + "file": file, + "file_name": file_name, + } + ) + files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return await self._post( + f"/accounts/{account_id}/ai/finetunes/{finetune_id}/finetune-assets", + body=await async_maybe_transform(body, asset_create_params.AssetCreateParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AssetCreateResponse, + ) + + +class AssetsResourceWithRawResponse: + def __init__(self, assets: AssetsResource) -> None: + self._assets = assets + + self.create = to_raw_response_wrapper( + assets.create, + ) + + +class AsyncAssetsResourceWithRawResponse: + def __init__(self, assets: AsyncAssetsResource) -> None: + self._assets = assets + + self.create = async_to_raw_response_wrapper( + assets.create, + ) + + +class AssetsResourceWithStreamingResponse: + def __init__(self, assets: AssetsResource) -> None: + self._assets = assets + + self.create = to_streamed_response_wrapper( + assets.create, + ) + + +class AsyncAssetsResourceWithStreamingResponse: + def __init__(self, assets: AsyncAssetsResource) -> None: + self._assets = assets + + self.create = async_to_streamed_response_wrapper( + assets.create, + ) diff --git a/src/cloudflare/resources/ai/finetunes/finetunes.py b/src/cloudflare/resources/ai/finetunes/finetunes.py new file mode 100644 index 00000000000..e998763b6f2 --- /dev/null +++ b/src/cloudflare/resources/ai/finetunes/finetunes.py @@ -0,0 +1,353 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from .assets import ( + AssetsResource, + AsyncAssetsResource, + AssetsResourceWithRawResponse, + AsyncAssetsResourceWithRawResponse, + AssetsResourceWithStreamingResponse, + AsyncAssetsResourceWithStreamingResponse, +) +from .public import ( + PublicResource, + AsyncPublicResource, + PublicResourceWithRawResponse, + AsyncPublicResourceWithRawResponse, + PublicResourceWithStreamingResponse, + AsyncPublicResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ....types.ai import finetune_create_params +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.ai.finetune_list_response import FinetuneListResponse +from ....types.ai.finetune_create_response import FinetuneCreateResponse + +__all__ = ["FinetunesResource", "AsyncFinetunesResource"] + + +class FinetunesResource(SyncAPIResource): + @cached_property + def assets(self) -> AssetsResource: + return AssetsResource(self._client) + + @cached_property + def public(self) -> PublicResource: + return PublicResource(self._client) + + @cached_property + def with_raw_response(self) -> FinetunesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return FinetunesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FinetunesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return FinetunesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + model: str, + name: str, + description: str | Omit = omit, + public: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FinetuneCreateResponse: + """ + Create a new Finetune + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/ai/finetunes", + body=maybe_transform( + { + "model": model, + "name": name, + "description": description, + "public": public, + }, + finetune_create_params.FinetuneCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FinetuneCreateResponse]._unwrapper, + ), + cast_to=cast(Type[FinetuneCreateResponse], ResultWrapper[FinetuneCreateResponse]), + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FinetuneListResponse: + """ + List Finetunes + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/ai/finetunes", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FinetuneListResponse]._unwrapper, + ), + cast_to=cast(Type[FinetuneListResponse], ResultWrapper[FinetuneListResponse]), + ) + + +class AsyncFinetunesResource(AsyncAPIResource): + @cached_property + def assets(self) -> AsyncAssetsResource: + return AsyncAssetsResource(self._client) + + @cached_property + def public(self) -> AsyncPublicResource: + return AsyncPublicResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncFinetunesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncFinetunesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFinetunesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncFinetunesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + model: str, + name: str, + description: str | Omit = omit, + public: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FinetuneCreateResponse: + """ + Create a new Finetune + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/ai/finetunes", + body=await async_maybe_transform( + { + "model": model, + "name": name, + "description": description, + "public": public, + }, + finetune_create_params.FinetuneCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FinetuneCreateResponse]._unwrapper, + ), + cast_to=cast(Type[FinetuneCreateResponse], ResultWrapper[FinetuneCreateResponse]), + ) + + async def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FinetuneListResponse: + """ + List Finetunes + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/ai/finetunes", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FinetuneListResponse]._unwrapper, + ), + cast_to=cast(Type[FinetuneListResponse], ResultWrapper[FinetuneListResponse]), + ) + + +class FinetunesResourceWithRawResponse: + def __init__(self, finetunes: FinetunesResource) -> None: + self._finetunes = finetunes + + self.create = to_raw_response_wrapper( + finetunes.create, + ) + self.list = to_raw_response_wrapper( + finetunes.list, + ) + + @cached_property + def assets(self) -> AssetsResourceWithRawResponse: + return AssetsResourceWithRawResponse(self._finetunes.assets) + + @cached_property + def public(self) -> PublicResourceWithRawResponse: + return PublicResourceWithRawResponse(self._finetunes.public) + + +class AsyncFinetunesResourceWithRawResponse: + def __init__(self, finetunes: AsyncFinetunesResource) -> None: + self._finetunes = finetunes + + self.create = async_to_raw_response_wrapper( + finetunes.create, + ) + self.list = async_to_raw_response_wrapper( + finetunes.list, + ) + + @cached_property + def assets(self) -> AsyncAssetsResourceWithRawResponse: + return AsyncAssetsResourceWithRawResponse(self._finetunes.assets) + + @cached_property + def public(self) -> AsyncPublicResourceWithRawResponse: + return AsyncPublicResourceWithRawResponse(self._finetunes.public) + + +class FinetunesResourceWithStreamingResponse: + def __init__(self, finetunes: FinetunesResource) -> None: + self._finetunes = finetunes + + self.create = to_streamed_response_wrapper( + finetunes.create, + ) + self.list = to_streamed_response_wrapper( + finetunes.list, + ) + + @cached_property + def assets(self) -> AssetsResourceWithStreamingResponse: + return AssetsResourceWithStreamingResponse(self._finetunes.assets) + + @cached_property + def public(self) -> PublicResourceWithStreamingResponse: + return PublicResourceWithStreamingResponse(self._finetunes.public) + + +class AsyncFinetunesResourceWithStreamingResponse: + def __init__(self, finetunes: AsyncFinetunesResource) -> None: + self._finetunes = finetunes + + self.create = async_to_streamed_response_wrapper( + finetunes.create, + ) + self.list = async_to_streamed_response_wrapper( + finetunes.list, + ) + + @cached_property + def assets(self) -> AsyncAssetsResourceWithStreamingResponse: + return AsyncAssetsResourceWithStreamingResponse(self._finetunes.assets) + + @cached_property + def public(self) -> AsyncPublicResourceWithStreamingResponse: + return AsyncPublicResourceWithStreamingResponse(self._finetunes.public) diff --git a/src/cloudflare/resources/ai/finetunes/public.py b/src/cloudflare/resources/ai/finetunes/public.py new file mode 100644 index 00000000000..0e8f9e74988 --- /dev/null +++ b/src/cloudflare/resources/ai/finetunes/public.py @@ -0,0 +1,208 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.ai.finetunes import public_list_params +from ....types.ai.finetunes.public_list_response import PublicListResponse + +__all__ = ["PublicResource", "AsyncPublicResource"] + + +class PublicResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PublicResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return PublicResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PublicResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return PublicResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + limit: float | Omit = omit, + offset: float | Omit = omit, + order_by: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[PublicListResponse]: + """ + List Public Finetunes + + Args: + limit: Pagination Limit + + offset: Pagination Offset + + order_by: Order By Column Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/finetunes/public", + page=SyncSinglePage[PublicListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "offset": offset, + "order_by": order_by, + }, + public_list_params.PublicListParams, + ), + ), + model=PublicListResponse, + ) + + +class AsyncPublicResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPublicResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncPublicResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPublicResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncPublicResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + limit: float | Omit = omit, + offset: float | Omit = omit, + order_by: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[PublicListResponse, AsyncSinglePage[PublicListResponse]]: + """ + List Public Finetunes + + Args: + limit: Pagination Limit + + offset: Pagination Offset + + order_by: Order By Column Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/finetunes/public", + page=AsyncSinglePage[PublicListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "offset": offset, + "order_by": order_by, + }, + public_list_params.PublicListParams, + ), + ), + model=PublicListResponse, + ) + + +class PublicResourceWithRawResponse: + def __init__(self, public: PublicResource) -> None: + self._public = public + + self.list = to_raw_response_wrapper( + public.list, + ) + + +class AsyncPublicResourceWithRawResponse: + def __init__(self, public: AsyncPublicResource) -> None: + self._public = public + + self.list = async_to_raw_response_wrapper( + public.list, + ) + + +class PublicResourceWithStreamingResponse: + def __init__(self, public: PublicResource) -> None: + self._public = public + + self.list = to_streamed_response_wrapper( + public.list, + ) + + +class AsyncPublicResourceWithStreamingResponse: + def __init__(self, public: AsyncPublicResource) -> None: + self._public = public + + self.list = async_to_streamed_response_wrapper( + public.list, + ) diff --git a/src/cloudflare/resources/workers/ai/models/__init__.py b/src/cloudflare/resources/ai/models/__init__.py similarity index 100% rename from src/cloudflare/resources/workers/ai/models/__init__.py rename to src/cloudflare/resources/ai/models/__init__.py diff --git a/src/cloudflare/resources/ai/models/models.py b/src/cloudflare/resources/ai/models/models.py new file mode 100644 index 00000000000..9d6d4f9c83d --- /dev/null +++ b/src/cloudflare/resources/ai/models/models.py @@ -0,0 +1,263 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .schema import ( + SchemaResource, + AsyncSchemaResource, + SchemaResourceWithRawResponse, + AsyncSchemaResourceWithRawResponse, + SchemaResourceWithStreamingResponse, + AsyncSchemaResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from ...._compat import cached_property +from ....types.ai import model_list_params +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options + +__all__ = ["ModelsResource", "AsyncModelsResource"] + + +class ModelsResource(SyncAPIResource): + @cached_property + def schema(self) -> SchemaResource: + return SchemaResource(self._client) + + @cached_property + def with_raw_response(self) -> ModelsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ModelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ModelsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ModelsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + author: str | Omit = omit, + hide_experimental: bool | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + source: float | Omit = omit, + task: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[object]: + """ + Model Search + + Args: + author: Filter by Author + + hide_experimental: Filter to hide experimental models + + search: Search + + source: Filter by Source Id + + task: Filter by Task Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/models/search", + page=SyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "author": author, + "hide_experimental": hide_experimental, + "page": page, + "per_page": per_page, + "search": search, + "source": source, + "task": task, + }, + model_list_params.ModelListParams, + ), + ), + model=object, + ) + + +class AsyncModelsResource(AsyncAPIResource): + @cached_property + def schema(self) -> AsyncSchemaResource: + return AsyncSchemaResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncModelsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncModelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncModelsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncModelsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + author: str | Omit = omit, + hide_experimental: bool | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + source: float | Omit = omit, + task: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: + """ + Model Search + + Args: + author: Filter by Author + + hide_experimental: Filter to hide experimental models + + search: Search + + source: Filter by Source Id + + task: Filter by Task Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/models/search", + page=AsyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "author": author, + "hide_experimental": hide_experimental, + "page": page, + "per_page": per_page, + "search": search, + "source": source, + "task": task, + }, + model_list_params.ModelListParams, + ), + ), + model=object, + ) + + +class ModelsResourceWithRawResponse: + def __init__(self, models: ModelsResource) -> None: + self._models = models + + self.list = to_raw_response_wrapper( + models.list, + ) + + @cached_property + def schema(self) -> SchemaResourceWithRawResponse: + return SchemaResourceWithRawResponse(self._models.schema) + + +class AsyncModelsResourceWithRawResponse: + def __init__(self, models: AsyncModelsResource) -> None: + self._models = models + + self.list = async_to_raw_response_wrapper( + models.list, + ) + + @cached_property + def schema(self) -> AsyncSchemaResourceWithRawResponse: + return AsyncSchemaResourceWithRawResponse(self._models.schema) + + +class ModelsResourceWithStreamingResponse: + def __init__(self, models: ModelsResource) -> None: + self._models = models + + self.list = to_streamed_response_wrapper( + models.list, + ) + + @cached_property + def schema(self) -> SchemaResourceWithStreamingResponse: + return SchemaResourceWithStreamingResponse(self._models.schema) + + +class AsyncModelsResourceWithStreamingResponse: + def __init__(self, models: AsyncModelsResource) -> None: + self._models = models + + self.list = async_to_streamed_response_wrapper( + models.list, + ) + + @cached_property + def schema(self) -> AsyncSchemaResourceWithStreamingResponse: + return AsyncSchemaResourceWithStreamingResponse(self._models.schema) diff --git a/src/cloudflare/resources/ai/models/schema.py b/src/cloudflare/resources/ai/models/schema.py new file mode 100644 index 00000000000..2f12236dd38 --- /dev/null +++ b/src/cloudflare/resources/ai/models/schema.py @@ -0,0 +1,183 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.ai.models import schema_get_params + +__all__ = ["SchemaResource", "AsyncSchemaResource"] + + +class SchemaResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemaResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return SchemaResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemaResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return SchemaResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + model: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Model Schema + + Args: + model: Model Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/ai/models/schema", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"model": model}, schema_get_params.SchemaGetParams), + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + +class AsyncSchemaResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemaResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncSchemaResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemaResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncSchemaResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + model: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Model Schema + + Args: + model: Model Name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/ai/models/schema", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"model": model}, schema_get_params.SchemaGetParams), + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + +class SchemaResourceWithRawResponse: + def __init__(self, schema: SchemaResource) -> None: + self._schema = schema + + self.get = to_raw_response_wrapper( + schema.get, + ) + + +class AsyncSchemaResourceWithRawResponse: + def __init__(self, schema: AsyncSchemaResource) -> None: + self._schema = schema + + self.get = async_to_raw_response_wrapper( + schema.get, + ) + + +class SchemaResourceWithStreamingResponse: + def __init__(self, schema: SchemaResource) -> None: + self._schema = schema + + self.get = to_streamed_response_wrapper( + schema.get, + ) + + +class AsyncSchemaResourceWithStreamingResponse: + def __init__(self, schema: AsyncSchemaResource) -> None: + self._schema = schema + + self.get = async_to_streamed_response_wrapper( + schema.get, + ) diff --git a/src/cloudflare/resources/ai/tasks.py b/src/cloudflare/resources/ai/tasks.py new file mode 100644 index 00000000000..26fcd51f8b0 --- /dev/null +++ b/src/cloudflare/resources/ai/tasks.py @@ -0,0 +1,165 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options + +__all__ = ["TasksResource", "AsyncTasksResource"] + + +class TasksResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TasksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return TasksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TasksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return TasksResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[object]: + """ + Task Search + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/tasks/search", + page=SyncSinglePage[object], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=object, + ) + + +class AsyncTasksResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTasksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncTasksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTasksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncTasksResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[object, AsyncSinglePage[object]]: + """ + Task Search + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/tasks/search", + page=AsyncSinglePage[object], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=object, + ) + + +class TasksResourceWithRawResponse: + def __init__(self, tasks: TasksResource) -> None: + self._tasks = tasks + + self.list = to_raw_response_wrapper( + tasks.list, + ) + + +class AsyncTasksResourceWithRawResponse: + def __init__(self, tasks: AsyncTasksResource) -> None: + self._tasks = tasks + + self.list = async_to_raw_response_wrapper( + tasks.list, + ) + + +class TasksResourceWithStreamingResponse: + def __init__(self, tasks: TasksResource) -> None: + self._tasks = tasks + + self.list = to_streamed_response_wrapper( + tasks.list, + ) + + +class AsyncTasksResourceWithStreamingResponse: + def __init__(self, tasks: AsyncTasksResource) -> None: + self._tasks = tasks + + self.list = async_to_streamed_response_wrapper( + tasks.list, + ) diff --git a/src/cloudflare/resources/ai/to_markdown.py b/src/cloudflare/resources/ai/to_markdown.py new file mode 100644 index 00000000000..15cab8aa9e4 --- /dev/null +++ b/src/cloudflare/resources/ai/to_markdown.py @@ -0,0 +1,271 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Mapping, cast + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import extract_files, maybe_transform, deepcopy_minimal +from ..._compat import cached_property +from ...types.ai import to_markdown_transform_params +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ai.to_markdown_supported_response import ToMarkdownSupportedResponse +from ...types.ai.to_markdown_transform_response import ToMarkdownTransformResponse + +__all__ = ["ToMarkdownResource", "AsyncToMarkdownResource"] + + +class ToMarkdownResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ToMarkdownResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ToMarkdownResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ToMarkdownResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ToMarkdownResourceWithStreamingResponse(self) + + def supported( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[ToMarkdownSupportedResponse]: + """ + Get all converted formats supported + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/tomarkdown/supported", + page=SyncSinglePage[ToMarkdownSupportedResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ToMarkdownSupportedResponse, + ) + + def transform( + self, + *, + account_id: str, + file: to_markdown_transform_params.File, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[ToMarkdownTransformResponse]: + """ + Convert Files into Markdown + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + body = deepcopy_minimal(file) + files = extract_files(cast(Mapping[str, object], body), paths=[["files", ""]]) + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return self._get_api_list( # type: ignore[call-arg] # pyright: ignore[reportUnknownVariableType, reportCallIssue] + f"/accounts/{account_id}/ai/tomarkdown", + page=SyncSinglePage[ToMarkdownTransformResponse], + body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams), + files=files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ToMarkdownTransformResponse, + method="post", + ) + + +class AsyncToMarkdownResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncToMarkdownResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncToMarkdownResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncToMarkdownResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncToMarkdownResourceWithStreamingResponse(self) + + def supported( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ToMarkdownSupportedResponse, AsyncSinglePage[ToMarkdownSupportedResponse]]: + """ + Get all converted formats supported + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai/tomarkdown/supported", + page=AsyncSinglePage[ToMarkdownSupportedResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ToMarkdownSupportedResponse, + ) + + def transform( + self, + *, + account_id: str, + file: to_markdown_transform_params.File, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ToMarkdownTransformResponse, AsyncSinglePage[ToMarkdownTransformResponse]]: + """ + Convert Files into Markdown + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + body = deepcopy_minimal(file) + files = extract_files(cast(Mapping[str, object], body), paths=[["files", ""]]) + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return self._get_api_list( # type: ignore[call-arg] # pyright: ignore[reportUnknownVariableType, reportCallIssue] + f"/accounts/{account_id}/ai/tomarkdown", + page=AsyncSinglePage[ToMarkdownTransformResponse], + body=maybe_transform(body, to_markdown_transform_params.ToMarkdownTransformParams), + files=files, # pyright: ignore[reportCallIssue] # type: ignore[call-arg] + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ToMarkdownTransformResponse, + method="post", + ) + + +class ToMarkdownResourceWithRawResponse: + def __init__(self, to_markdown: ToMarkdownResource) -> None: + self._to_markdown = to_markdown + + self.supported = to_raw_response_wrapper( + to_markdown.supported, + ) + self.transform = to_raw_response_wrapper( + to_markdown.transform, + ) + + +class AsyncToMarkdownResourceWithRawResponse: + def __init__(self, to_markdown: AsyncToMarkdownResource) -> None: + self._to_markdown = to_markdown + + self.supported = async_to_raw_response_wrapper( + to_markdown.supported, + ) + self.transform = async_to_raw_response_wrapper( + to_markdown.transform, + ) + + +class ToMarkdownResourceWithStreamingResponse: + def __init__(self, to_markdown: ToMarkdownResource) -> None: + self._to_markdown = to_markdown + + self.supported = to_streamed_response_wrapper( + to_markdown.supported, + ) + self.transform = to_streamed_response_wrapper( + to_markdown.transform, + ) + + +class AsyncToMarkdownResourceWithStreamingResponse: + def __init__(self, to_markdown: AsyncToMarkdownResource) -> None: + self._to_markdown = to_markdown + + self.supported = async_to_streamed_response_wrapper( + to_markdown.supported, + ) + self.transform = async_to_streamed_response_wrapper( + to_markdown.transform, + ) diff --git a/src/cloudflare/resources/ai_gateway/__init__.py b/src/cloudflare/resources/ai_gateway/__init__.py index 95883733129..d149a1d44cb 100644 --- a/src/cloudflare/resources/ai_gateway/__init__.py +++ b/src/cloudflare/resources/ai_gateway/__init__.py @@ -8,6 +8,22 @@ LogsResourceWithStreamingResponse, AsyncLogsResourceWithStreamingResponse, ) +from .urls import ( + URLsResource, + AsyncURLsResource, + URLsResourceWithRawResponse, + AsyncURLsResourceWithRawResponse, + URLsResourceWithStreamingResponse, + AsyncURLsResourceWithStreamingResponse, +) +from .datasets import ( + DatasetsResource, + AsyncDatasetsResource, + DatasetsResourceWithRawResponse, + AsyncDatasetsResourceWithRawResponse, + DatasetsResourceWithStreamingResponse, + AsyncDatasetsResourceWithStreamingResponse, +) from .ai_gateway import ( AIGatewayResource, AsyncAIGatewayResource, @@ -16,14 +32,82 @@ AIGatewayResourceWithStreamingResponse, AsyncAIGatewayResourceWithStreamingResponse, ) +from .evaluations import ( + EvaluationsResource, + AsyncEvaluationsResource, + EvaluationsResourceWithRawResponse, + AsyncEvaluationsResourceWithRawResponse, + EvaluationsResourceWithStreamingResponse, + AsyncEvaluationsResourceWithStreamingResponse, +) +from .dynamic_routing import ( + DynamicRoutingResource, + AsyncDynamicRoutingResource, + DynamicRoutingResourceWithRawResponse, + AsyncDynamicRoutingResourceWithRawResponse, + DynamicRoutingResourceWithStreamingResponse, + AsyncDynamicRoutingResourceWithStreamingResponse, +) +from .evaluation_types import ( + EvaluationTypesResource, + AsyncEvaluationTypesResource, + EvaluationTypesResourceWithRawResponse, + AsyncEvaluationTypesResourceWithRawResponse, + EvaluationTypesResourceWithStreamingResponse, + AsyncEvaluationTypesResourceWithStreamingResponse, +) +from .provider_configs import ( + ProviderConfigsResource, + AsyncProviderConfigsResource, + ProviderConfigsResourceWithRawResponse, + AsyncProviderConfigsResourceWithRawResponse, + ProviderConfigsResourceWithStreamingResponse, + AsyncProviderConfigsResourceWithStreamingResponse, +) __all__ = [ + "EvaluationTypesResource", + "AsyncEvaluationTypesResource", + "EvaluationTypesResourceWithRawResponse", + "AsyncEvaluationTypesResourceWithRawResponse", + "EvaluationTypesResourceWithStreamingResponse", + "AsyncEvaluationTypesResourceWithStreamingResponse", "LogsResource", "AsyncLogsResource", "LogsResourceWithRawResponse", "AsyncLogsResourceWithRawResponse", "LogsResourceWithStreamingResponse", "AsyncLogsResourceWithStreamingResponse", + "DatasetsResource", + "AsyncDatasetsResource", + "DatasetsResourceWithRawResponse", + "AsyncDatasetsResourceWithRawResponse", + "DatasetsResourceWithStreamingResponse", + "AsyncDatasetsResourceWithStreamingResponse", + "EvaluationsResource", + "AsyncEvaluationsResource", + "EvaluationsResourceWithRawResponse", + "AsyncEvaluationsResourceWithRawResponse", + "EvaluationsResourceWithStreamingResponse", + "AsyncEvaluationsResourceWithStreamingResponse", + "DynamicRoutingResource", + "AsyncDynamicRoutingResource", + "DynamicRoutingResourceWithRawResponse", + "AsyncDynamicRoutingResourceWithRawResponse", + "DynamicRoutingResourceWithStreamingResponse", + "AsyncDynamicRoutingResourceWithStreamingResponse", + "ProviderConfigsResource", + "AsyncProviderConfigsResource", + "ProviderConfigsResourceWithRawResponse", + "AsyncProviderConfigsResourceWithRawResponse", + "ProviderConfigsResourceWithStreamingResponse", + "AsyncProviderConfigsResourceWithStreamingResponse", + "URLsResource", + "AsyncURLsResource", + "URLsResourceWithRawResponse", + "AsyncURLsResourceWithRawResponse", + "URLsResourceWithStreamingResponse", + "AsyncURLsResourceWithStreamingResponse", "AIGatewayResource", "AsyncAIGatewayResource", "AIGatewayResourceWithRawResponse", diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 6d75bfb8ba3..545ad9b28e6 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, Iterable, Optional, cast from typing_extensions import Literal import httpx @@ -15,10 +15,23 @@ LogsResourceWithStreamingResponse, AsyncLogsResourceWithStreamingResponse, ) -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, +from .urls import ( + URLsResource, + AsyncURLsResource, + URLsResourceWithRawResponse, + AsyncURLsResourceWithRawResponse, + URLsResourceWithStreamingResponse, + AsyncURLsResourceWithStreamingResponse, +) +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from .datasets import ( + DatasetsResource, + AsyncDatasetsResource, + DatasetsResourceWithRawResponse, + AsyncDatasetsResourceWithRawResponse, + DatasetsResourceWithStreamingResponse, + AsyncDatasetsResourceWithStreamingResponse, ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -29,8 +42,40 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper +from .evaluations import ( + EvaluationsResource, + AsyncEvaluationsResource, + EvaluationsResourceWithRawResponse, + AsyncEvaluationsResourceWithRawResponse, + EvaluationsResourceWithStreamingResponse, + AsyncEvaluationsResourceWithStreamingResponse, +) from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options +from .dynamic_routing import ( + DynamicRoutingResource, + AsyncDynamicRoutingResource, + DynamicRoutingResourceWithRawResponse, + AsyncDynamicRoutingResourceWithRawResponse, + DynamicRoutingResourceWithStreamingResponse, + AsyncDynamicRoutingResourceWithStreamingResponse, +) +from .evaluation_types import ( + EvaluationTypesResource, + AsyncEvaluationTypesResource, + EvaluationTypesResourceWithRawResponse, + AsyncEvaluationTypesResourceWithRawResponse, + EvaluationTypesResourceWithStreamingResponse, + AsyncEvaluationTypesResourceWithStreamingResponse, +) +from .provider_configs import ( + ProviderConfigsResource, + AsyncProviderConfigsResource, + ProviderConfigsResourceWithRawResponse, + AsyncProviderConfigsResourceWithRawResponse, + ProviderConfigsResourceWithStreamingResponse, + AsyncProviderConfigsResourceWithStreamingResponse, +) from ...types.ai_gateway import ai_gateway_list_params, ai_gateway_create_params, ai_gateway_update_params from ...types.ai_gateway.ai_gateway_get_response import AIGatewayGetResponse from ...types.ai_gateway.ai_gateway_list_response import AIGatewayListResponse @@ -42,16 +87,51 @@ class AIGatewayResource(SyncAPIResource): + @cached_property + def evaluation_types(self) -> EvaluationTypesResource: + return EvaluationTypesResource(self._client) + @cached_property def logs(self) -> LogsResource: return LogsResource(self._client) + @cached_property + def datasets(self) -> DatasetsResource: + return DatasetsResource(self._client) + + @cached_property + def evaluations(self) -> EvaluationsResource: + return EvaluationsResource(self._client) + + @cached_property + def dynamic_routing(self) -> DynamicRoutingResource: + return DynamicRoutingResource(self._client) + + @cached_property + def provider_configs(self) -> ProviderConfigsResource: + return ProviderConfigsResource(self._client) + + @cached_property + def urls(self) -> URLsResource: + return URLsResource(self._client) + @cached_property def with_raw_response(self) -> AIGatewayResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AIGatewayResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AIGatewayResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AIGatewayResourceWithStreamingResponse(self) def create( @@ -65,12 +145,19 @@ def create( rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], + authentication: bool | Omit = omit, + is_default: bool | Omit = omit, + log_management: Optional[int] | Omit = omit, + log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, + logpush: bool | Omit = omit, + logpush_public_key: Optional[str] | Omit = omit, + zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ Create a new Gateway @@ -99,6 +186,13 @@ def create( "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, + "authentication": authentication, + "is_default": is_default, + "log_management": log_management, + "log_management_strategy": log_management_strategy, + "logpush": logpush, + "logpush_public_key": logpush_public_key, + "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, ), @@ -123,12 +217,23 @@ def update( rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], + authentication: bool | Omit = omit, + dlp: ai_gateway_update_params.DLP | Omit = omit, + is_default: bool | Omit = omit, + log_management: Optional[int] | Omit = omit, + log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, + logpush: bool | Omit = omit, + logpush_public_key: Optional[str] | Omit = omit, + otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, + store_id: Optional[str] | Omit = omit, + stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ Update a Gateway @@ -158,6 +263,17 @@ def update( "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, + "authentication": authentication, + "dlp": dlp, + "is_default": is_default, + "log_management": log_management, + "log_management_strategy": log_management_strategy, + "logpush": logpush, + "logpush_public_key": logpush_public_key, + "otel": otel, + "store_id": store_id, + "stripe": stripe, + "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, ), @@ -175,24 +291,21 @@ def list( self, *, account_id: str, - id: str | NotGiven = NOT_GIVEN, - order_by: str | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[AIGatewayListResponse]: """ List Gateways Args: - id: gateway id - - order_by: Order By Column Name + search: Search by id extra_headers: Send extra headers @@ -214,10 +327,9 @@ def list( timeout=timeout, query=maybe_transform( { - "id": id, - "order_by": order_by, "page": page, "per_page": per_page, + "search": search, }, ai_gateway_list_params.AIGatewayListParams, ), @@ -235,12 +347,14 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ Delete a Gateway Args: + id: gateway id + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -275,7 +389,7 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ Fetch a Gateway @@ -309,16 +423,51 @@ def get( class AsyncAIGatewayResource(AsyncAPIResource): + @cached_property + def evaluation_types(self) -> AsyncEvaluationTypesResource: + return AsyncEvaluationTypesResource(self._client) + @cached_property def logs(self) -> AsyncLogsResource: return AsyncLogsResource(self._client) + @cached_property + def datasets(self) -> AsyncDatasetsResource: + return AsyncDatasetsResource(self._client) + + @cached_property + def evaluations(self) -> AsyncEvaluationsResource: + return AsyncEvaluationsResource(self._client) + + @cached_property + def dynamic_routing(self) -> AsyncDynamicRoutingResource: + return AsyncDynamicRoutingResource(self._client) + + @cached_property + def provider_configs(self) -> AsyncProviderConfigsResource: + return AsyncProviderConfigsResource(self._client) + + @cached_property + def urls(self) -> AsyncURLsResource: + return AsyncURLsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAIGatewayResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAIGatewayResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAIGatewayResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAIGatewayResourceWithStreamingResponse(self) async def create( @@ -332,12 +481,19 @@ async def create( rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], + authentication: bool | Omit = omit, + is_default: bool | Omit = omit, + log_management: Optional[int] | Omit = omit, + log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, + logpush: bool | Omit = omit, + logpush_public_key: Optional[str] | Omit = omit, + zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ Create a new Gateway @@ -366,6 +522,13 @@ async def create( "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, + "authentication": authentication, + "is_default": is_default, + "log_management": log_management, + "log_management_strategy": log_management_strategy, + "logpush": logpush, + "logpush_public_key": logpush_public_key, + "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, ), @@ -390,12 +553,23 @@ async def update( rate_limiting_interval: Optional[int], rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], + authentication: bool | Omit = omit, + dlp: ai_gateway_update_params.DLP | Omit = omit, + is_default: bool | Omit = omit, + log_management: Optional[int] | Omit = omit, + log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, + logpush: bool | Omit = omit, + logpush_public_key: Optional[str] | Omit = omit, + otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, + store_id: Optional[str] | Omit = omit, + stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + zdr: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ Update a Gateway @@ -425,6 +599,17 @@ async def update( "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, + "authentication": authentication, + "dlp": dlp, + "is_default": is_default, + "log_management": log_management, + "log_management_strategy": log_management_strategy, + "logpush": logpush, + "logpush_public_key": logpush_public_key, + "otel": otel, + "store_id": store_id, + "stripe": stripe, + "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, ), @@ -442,24 +627,21 @@ def list( self, *, account_id: str, - id: str | NotGiven = NOT_GIVEN, - order_by: str | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AIGatewayListResponse, AsyncV4PagePaginationArray[AIGatewayListResponse]]: """ List Gateways Args: - id: gateway id - - order_by: Order By Column Name + search: Search by id extra_headers: Send extra headers @@ -481,10 +663,9 @@ def list( timeout=timeout, query=maybe_transform( { - "id": id, - "order_by": order_by, "page": page, "per_page": per_page, + "search": search, }, ai_gateway_list_params.AIGatewayListParams, ), @@ -502,12 +683,14 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ Delete a Gateway Args: + id: gateway id + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -542,7 +725,7 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ Fetch a Gateway @@ -595,10 +778,34 @@ def __init__(self, ai_gateway: AIGatewayResource) -> None: ai_gateway.get, ) + @cached_property + def evaluation_types(self) -> EvaluationTypesResourceWithRawResponse: + return EvaluationTypesResourceWithRawResponse(self._ai_gateway.evaluation_types) + @cached_property def logs(self) -> LogsResourceWithRawResponse: return LogsResourceWithRawResponse(self._ai_gateway.logs) + @cached_property + def datasets(self) -> DatasetsResourceWithRawResponse: + return DatasetsResourceWithRawResponse(self._ai_gateway.datasets) + + @cached_property + def evaluations(self) -> EvaluationsResourceWithRawResponse: + return EvaluationsResourceWithRawResponse(self._ai_gateway.evaluations) + + @cached_property + def dynamic_routing(self) -> DynamicRoutingResourceWithRawResponse: + return DynamicRoutingResourceWithRawResponse(self._ai_gateway.dynamic_routing) + + @cached_property + def provider_configs(self) -> ProviderConfigsResourceWithRawResponse: + return ProviderConfigsResourceWithRawResponse(self._ai_gateway.provider_configs) + + @cached_property + def urls(self) -> URLsResourceWithRawResponse: + return URLsResourceWithRawResponse(self._ai_gateway.urls) + class AsyncAIGatewayResourceWithRawResponse: def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None: @@ -620,10 +827,34 @@ def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None: ai_gateway.get, ) + @cached_property + def evaluation_types(self) -> AsyncEvaluationTypesResourceWithRawResponse: + return AsyncEvaluationTypesResourceWithRawResponse(self._ai_gateway.evaluation_types) + @cached_property def logs(self) -> AsyncLogsResourceWithRawResponse: return AsyncLogsResourceWithRawResponse(self._ai_gateway.logs) + @cached_property + def datasets(self) -> AsyncDatasetsResourceWithRawResponse: + return AsyncDatasetsResourceWithRawResponse(self._ai_gateway.datasets) + + @cached_property + def evaluations(self) -> AsyncEvaluationsResourceWithRawResponse: + return AsyncEvaluationsResourceWithRawResponse(self._ai_gateway.evaluations) + + @cached_property + def dynamic_routing(self) -> AsyncDynamicRoutingResourceWithRawResponse: + return AsyncDynamicRoutingResourceWithRawResponse(self._ai_gateway.dynamic_routing) + + @cached_property + def provider_configs(self) -> AsyncProviderConfigsResourceWithRawResponse: + return AsyncProviderConfigsResourceWithRawResponse(self._ai_gateway.provider_configs) + + @cached_property + def urls(self) -> AsyncURLsResourceWithRawResponse: + return AsyncURLsResourceWithRawResponse(self._ai_gateway.urls) + class AIGatewayResourceWithStreamingResponse: def __init__(self, ai_gateway: AIGatewayResource) -> None: @@ -645,10 +876,34 @@ def __init__(self, ai_gateway: AIGatewayResource) -> None: ai_gateway.get, ) + @cached_property + def evaluation_types(self) -> EvaluationTypesResourceWithStreamingResponse: + return EvaluationTypesResourceWithStreamingResponse(self._ai_gateway.evaluation_types) + @cached_property def logs(self) -> LogsResourceWithStreamingResponse: return LogsResourceWithStreamingResponse(self._ai_gateway.logs) + @cached_property + def datasets(self) -> DatasetsResourceWithStreamingResponse: + return DatasetsResourceWithStreamingResponse(self._ai_gateway.datasets) + + @cached_property + def evaluations(self) -> EvaluationsResourceWithStreamingResponse: + return EvaluationsResourceWithStreamingResponse(self._ai_gateway.evaluations) + + @cached_property + def dynamic_routing(self) -> DynamicRoutingResourceWithStreamingResponse: + return DynamicRoutingResourceWithStreamingResponse(self._ai_gateway.dynamic_routing) + + @cached_property + def provider_configs(self) -> ProviderConfigsResourceWithStreamingResponse: + return ProviderConfigsResourceWithStreamingResponse(self._ai_gateway.provider_configs) + + @cached_property + def urls(self) -> URLsResourceWithStreamingResponse: + return URLsResourceWithStreamingResponse(self._ai_gateway.urls) + class AsyncAIGatewayResourceWithStreamingResponse: def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None: @@ -670,6 +925,30 @@ def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None: ai_gateway.get, ) + @cached_property + def evaluation_types(self) -> AsyncEvaluationTypesResourceWithStreamingResponse: + return AsyncEvaluationTypesResourceWithStreamingResponse(self._ai_gateway.evaluation_types) + @cached_property def logs(self) -> AsyncLogsResourceWithStreamingResponse: return AsyncLogsResourceWithStreamingResponse(self._ai_gateway.logs) + + @cached_property + def datasets(self) -> AsyncDatasetsResourceWithStreamingResponse: + return AsyncDatasetsResourceWithStreamingResponse(self._ai_gateway.datasets) + + @cached_property + def evaluations(self) -> AsyncEvaluationsResourceWithStreamingResponse: + return AsyncEvaluationsResourceWithStreamingResponse(self._ai_gateway.evaluations) + + @cached_property + def dynamic_routing(self) -> AsyncDynamicRoutingResourceWithStreamingResponse: + return AsyncDynamicRoutingResourceWithStreamingResponse(self._ai_gateway.dynamic_routing) + + @cached_property + def provider_configs(self) -> AsyncProviderConfigsResourceWithStreamingResponse: + return AsyncProviderConfigsResourceWithStreamingResponse(self._ai_gateway.provider_configs) + + @cached_property + def urls(self) -> AsyncURLsResourceWithStreamingResponse: + return AsyncURLsResourceWithStreamingResponse(self._ai_gateway.urls) diff --git a/src/cloudflare/resources/ai_gateway/datasets.py b/src/cloudflare/resources/ai_gateway/datasets.py new file mode 100644 index 00000000000..bb256a33205 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/datasets.py @@ -0,0 +1,671 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, cast + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ai_gateway import dataset_list_params, dataset_create_params, dataset_update_params +from ...types.ai_gateway.dataset_get_response import DatasetGetResponse +from ...types.ai_gateway.dataset_list_response import DatasetListResponse +from ...types.ai_gateway.dataset_create_response import DatasetCreateResponse +from ...types.ai_gateway.dataset_delete_response import DatasetDeleteResponse +from ...types.ai_gateway.dataset_update_response import DatasetUpdateResponse + +__all__ = ["DatasetsResource", "AsyncDatasetsResource"] + + +class DatasetsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DatasetsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return DatasetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return DatasetsResourceWithStreamingResponse(self) + + def create( + self, + gateway_id: str, + *, + account_id: str, + enable: bool, + filters: Iterable[dataset_create_params.Filter], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetCreateResponse: + """ + Create a new Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + body=maybe_transform( + { + "enable": enable, + "filters": filters, + "name": name, + }, + dataset_create_params.DatasetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetCreateResponse], ResultWrapper[DatasetCreateResponse]), + ) + + def update( + self, + id: str, + *, + account_id: str, + gateway_id: str, + enable: bool, + filters: Iterable[dataset_update_params.Filter], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetUpdateResponse: + """ + Update a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + body=maybe_transform( + { + "enable": enable, + "filters": filters, + "name": name, + }, + dataset_update_params.DatasetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetUpdateResponse], ResultWrapper[DatasetUpdateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + enable: bool | Omit = omit, + name: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[DatasetListResponse]: + """ + List Datasets + + Args: + gateway_id: gateway id + + search: Search by id, name, filters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + page=SyncV4PagePaginationArray[DatasetListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "enable": enable, + "name": name, + "page": page, + "per_page": per_page, + "search": search, + }, + dataset_list_params.DatasetListParams, + ), + ), + model=DatasetListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetDeleteResponse: + """ + Delete a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetDeleteResponse], ResultWrapper[DatasetDeleteResponse]), + ) + + def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetGetResponse: + """ + Fetch a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetGetResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetGetResponse], ResultWrapper[DatasetGetResponse]), + ) + + +class AsyncDatasetsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDatasetsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncDatasetsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDatasetsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncDatasetsResourceWithStreamingResponse(self) + + async def create( + self, + gateway_id: str, + *, + account_id: str, + enable: bool, + filters: Iterable[dataset_create_params.Filter], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetCreateResponse: + """ + Create a new Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + body=await async_maybe_transform( + { + "enable": enable, + "filters": filters, + "name": name, + }, + dataset_create_params.DatasetCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetCreateResponse], ResultWrapper[DatasetCreateResponse]), + ) + + async def update( + self, + id: str, + *, + account_id: str, + gateway_id: str, + enable: bool, + filters: Iterable[dataset_update_params.Filter], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetUpdateResponse: + """ + Update a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + body=await async_maybe_transform( + { + "enable": enable, + "filters": filters, + "name": name, + }, + dataset_update_params.DatasetUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetUpdateResponse], ResultWrapper[DatasetUpdateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + enable: bool | Omit = omit, + name: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[DatasetListResponse, AsyncV4PagePaginationArray[DatasetListResponse]]: + """ + List Datasets + + Args: + gateway_id: gateway id + + search: Search by id, name, filters + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets", + page=AsyncV4PagePaginationArray[DatasetListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "enable": enable, + "name": name, + "page": page, + "per_page": per_page, + "search": search, + }, + dataset_list_params.DatasetListParams, + ), + ), + model=DatasetListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetDeleteResponse: + """ + Delete a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetDeleteResponse], ResultWrapper[DatasetDeleteResponse]), + ) + + async def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DatasetGetResponse: + """ + Fetch a Dataset + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatasetGetResponse]._unwrapper, + ), + cast_to=cast(Type[DatasetGetResponse], ResultWrapper[DatasetGetResponse]), + ) + + +class DatasetsResourceWithRawResponse: + def __init__(self, datasets: DatasetsResource) -> None: + self._datasets = datasets + + self.create = to_raw_response_wrapper( + datasets.create, + ) + self.update = to_raw_response_wrapper( + datasets.update, + ) + self.list = to_raw_response_wrapper( + datasets.list, + ) + self.delete = to_raw_response_wrapper( + datasets.delete, + ) + self.get = to_raw_response_wrapper( + datasets.get, + ) + + +class AsyncDatasetsResourceWithRawResponse: + def __init__(self, datasets: AsyncDatasetsResource) -> None: + self._datasets = datasets + + self.create = async_to_raw_response_wrapper( + datasets.create, + ) + self.update = async_to_raw_response_wrapper( + datasets.update, + ) + self.list = async_to_raw_response_wrapper( + datasets.list, + ) + self.delete = async_to_raw_response_wrapper( + datasets.delete, + ) + self.get = async_to_raw_response_wrapper( + datasets.get, + ) + + +class DatasetsResourceWithStreamingResponse: + def __init__(self, datasets: DatasetsResource) -> None: + self._datasets = datasets + + self.create = to_streamed_response_wrapper( + datasets.create, + ) + self.update = to_streamed_response_wrapper( + datasets.update, + ) + self.list = to_streamed_response_wrapper( + datasets.list, + ) + self.delete = to_streamed_response_wrapper( + datasets.delete, + ) + self.get = to_streamed_response_wrapper( + datasets.get, + ) + + +class AsyncDatasetsResourceWithStreamingResponse: + def __init__(self, datasets: AsyncDatasetsResource) -> None: + self._datasets = datasets + + self.create = async_to_streamed_response_wrapper( + datasets.create, + ) + self.update = async_to_streamed_response_wrapper( + datasets.update, + ) + self.list = async_to_streamed_response_wrapper( + datasets.list, + ) + self.delete = async_to_streamed_response_wrapper( + datasets.delete, + ) + self.get = async_to_streamed_response_wrapper( + datasets.get, + ) diff --git a/src/cloudflare/resources/ai_gateway/dynamic_routing.py b/src/cloudflare/resources/ai_gateway/dynamic_routing.py new file mode 100644 index 00000000000..719f7e12ff7 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/dynamic_routing.py @@ -0,0 +1,1108 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, cast + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.ai_gateway import ( + dynamic_routing_create_params, + dynamic_routing_update_params, + dynamic_routing_create_version_params, + dynamic_routing_create_deployment_params, +) +from ...types.ai_gateway.dynamic_routing_get_response import DynamicRoutingGetResponse +from ...types.ai_gateway.dynamic_routing_list_response import DynamicRoutingListResponse +from ...types.ai_gateway.dynamic_routing_create_response import DynamicRoutingCreateResponse +from ...types.ai_gateway.dynamic_routing_delete_response import DynamicRoutingDeleteResponse +from ...types.ai_gateway.dynamic_routing_update_response import DynamicRoutingUpdateResponse +from ...types.ai_gateway.dynamic_routing_get_version_response import DynamicRoutingGetVersionResponse +from ...types.ai_gateway.dynamic_routing_list_versions_response import DynamicRoutingListVersionsResponse +from ...types.ai_gateway.dynamic_routing_create_version_response import DynamicRoutingCreateVersionResponse +from ...types.ai_gateway.dynamic_routing_list_deployments_response import DynamicRoutingListDeploymentsResponse +from ...types.ai_gateway.dynamic_routing_create_deployment_response import DynamicRoutingCreateDeploymentResponse + +__all__ = ["DynamicRoutingResource", "AsyncDynamicRoutingResource"] + + +class DynamicRoutingResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DynamicRoutingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return DynamicRoutingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DynamicRoutingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return DynamicRoutingResourceWithStreamingResponse(self) + + def create( + self, + gateway_id: str, + *, + account_id: str, + elements: Iterable[dynamic_routing_create_params.Element], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateResponse: + """ + Create a new AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + body=maybe_transform( + { + "elements": elements, + "name": name, + }, + dynamic_routing_create_params.DynamicRoutingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingCreateResponse], ResultWrapper[DynamicRoutingCreateResponse]), + ) + + def update( + self, + id: str, + *, + account_id: str, + gateway_id: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingUpdateResponse: + """ + Update an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._patch( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + body=maybe_transform({"name": name}, dynamic_routing_update_params.DynamicRoutingUpdateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingUpdateResponse, + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListResponse: + """ + List all AI Gateway Dynamic Routes. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingDeleteResponse: + """ + Delete an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingDeleteResponse], ResultWrapper[DynamicRoutingDeleteResponse]), + ) + + def create_deployment( + self, + id: str, + *, + account_id: str, + gateway_id: str, + comment: str, + version_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateDeploymentResponse: + """ + Create a new AI Gateway Dynamic Route Deployment. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + body=maybe_transform( + { + "comment": comment, + "version_id": version_id, + }, + dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateDeploymentResponse]._unwrapper, + ), + cast_to=cast( + Type[DynamicRoutingCreateDeploymentResponse], ResultWrapper[DynamicRoutingCreateDeploymentResponse] + ), + ) + + def create_version( + self, + id: str, + *, + account_id: str, + gateway_id: str, + comment: str, + elements: Iterable[dynamic_routing_create_version_params.Element], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateVersionResponse: + """ + Create a new AI Gateway Dynamic Route Version. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + body=maybe_transform( + { + "comment": comment, + "elements": elements, + }, + dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateVersionResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingCreateVersionResponse], ResultWrapper[DynamicRoutingCreateVersionResponse]), + ) + + def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingGetResponse: + """ + Get an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingGetResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingGetResponse], ResultWrapper[DynamicRoutingGetResponse]), + ) + + def get_version( + self, + version_id: str, + *, + account_id: str, + gateway_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingGetVersionResponse: + """ + Get an AI Gateway Dynamic Route Version. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not version_id: + raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions/{version_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingGetVersionResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingGetVersionResponse], ResultWrapper[DynamicRoutingGetVersionResponse]), + ) + + def list_deployments( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListDeploymentsResponse: + """ + List all AI Gateway Dynamic Route Deployments. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListDeploymentsResponse, + ) + + def list_versions( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListVersionsResponse: + """ + List all AI Gateway Dynamic Route Versions. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListVersionsResponse, + ) + + +class AsyncDynamicRoutingResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDynamicRoutingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncDynamicRoutingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDynamicRoutingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncDynamicRoutingResourceWithStreamingResponse(self) + + async def create( + self, + gateway_id: str, + *, + account_id: str, + elements: Iterable[dynamic_routing_create_params.Element], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateResponse: + """ + Create a new AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + body=await async_maybe_transform( + { + "elements": elements, + "name": name, + }, + dynamic_routing_create_params.DynamicRoutingCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingCreateResponse], ResultWrapper[DynamicRoutingCreateResponse]), + ) + + async def update( + self, + id: str, + *, + account_id: str, + gateway_id: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingUpdateResponse: + """ + Update an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._patch( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + body=await async_maybe_transform({"name": name}, dynamic_routing_update_params.DynamicRoutingUpdateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingUpdateResponse, + ) + + async def list( + self, + gateway_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListResponse: + """ + List all AI Gateway Dynamic Routes. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingDeleteResponse: + """ + Delete an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingDeleteResponse], ResultWrapper[DynamicRoutingDeleteResponse]), + ) + + async def create_deployment( + self, + id: str, + *, + account_id: str, + gateway_id: str, + comment: str, + version_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateDeploymentResponse: + """ + Create a new AI Gateway Dynamic Route Deployment. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + body=await async_maybe_transform( + { + "comment": comment, + "version_id": version_id, + }, + dynamic_routing_create_deployment_params.DynamicRoutingCreateDeploymentParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateDeploymentResponse]._unwrapper, + ), + cast_to=cast( + Type[DynamicRoutingCreateDeploymentResponse], ResultWrapper[DynamicRoutingCreateDeploymentResponse] + ), + ) + + async def create_version( + self, + id: str, + *, + account_id: str, + gateway_id: str, + comment: str, + elements: Iterable[dynamic_routing_create_version_params.Element], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingCreateVersionResponse: + """ + Create a new AI Gateway Dynamic Route Version. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + body=await async_maybe_transform( + { + "comment": comment, + "elements": elements, + }, + dynamic_routing_create_version_params.DynamicRoutingCreateVersionParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingCreateVersionResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingCreateVersionResponse], ResultWrapper[DynamicRoutingCreateVersionResponse]), + ) + + async def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingGetResponse: + """ + Get an AI Gateway Dynamic Route. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingGetResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingGetResponse], ResultWrapper[DynamicRoutingGetResponse]), + ) + + async def get_version( + self, + version_id: str, + *, + account_id: str, + gateway_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingGetVersionResponse: + """ + Get an AI Gateway Dynamic Route Version. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not version_id: + raise ValueError(f"Expected a non-empty value for `version_id` but received {version_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions/{version_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DynamicRoutingGetVersionResponse]._unwrapper, + ), + cast_to=cast(Type[DynamicRoutingGetVersionResponse], ResultWrapper[DynamicRoutingGetVersionResponse]), + ) + + async def list_deployments( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListDeploymentsResponse: + """ + List all AI Gateway Dynamic Route Deployments. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListDeploymentsResponse, + ) + + async def list_versions( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> DynamicRoutingListVersionsResponse: + """ + List all AI Gateway Dynamic Route Versions. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DynamicRoutingListVersionsResponse, + ) + + +class DynamicRoutingResourceWithRawResponse: + def __init__(self, dynamic_routing: DynamicRoutingResource) -> None: + self._dynamic_routing = dynamic_routing + + self.create = to_raw_response_wrapper( + dynamic_routing.create, + ) + self.update = to_raw_response_wrapper( + dynamic_routing.update, + ) + self.list = to_raw_response_wrapper( + dynamic_routing.list, + ) + self.delete = to_raw_response_wrapper( + dynamic_routing.delete, + ) + self.create_deployment = to_raw_response_wrapper( + dynamic_routing.create_deployment, + ) + self.create_version = to_raw_response_wrapper( + dynamic_routing.create_version, + ) + self.get = to_raw_response_wrapper( + dynamic_routing.get, + ) + self.get_version = to_raw_response_wrapper( + dynamic_routing.get_version, + ) + self.list_deployments = to_raw_response_wrapper( + dynamic_routing.list_deployments, + ) + self.list_versions = to_raw_response_wrapper( + dynamic_routing.list_versions, + ) + + +class AsyncDynamicRoutingResourceWithRawResponse: + def __init__(self, dynamic_routing: AsyncDynamicRoutingResource) -> None: + self._dynamic_routing = dynamic_routing + + self.create = async_to_raw_response_wrapper( + dynamic_routing.create, + ) + self.update = async_to_raw_response_wrapper( + dynamic_routing.update, + ) + self.list = async_to_raw_response_wrapper( + dynamic_routing.list, + ) + self.delete = async_to_raw_response_wrapper( + dynamic_routing.delete, + ) + self.create_deployment = async_to_raw_response_wrapper( + dynamic_routing.create_deployment, + ) + self.create_version = async_to_raw_response_wrapper( + dynamic_routing.create_version, + ) + self.get = async_to_raw_response_wrapper( + dynamic_routing.get, + ) + self.get_version = async_to_raw_response_wrapper( + dynamic_routing.get_version, + ) + self.list_deployments = async_to_raw_response_wrapper( + dynamic_routing.list_deployments, + ) + self.list_versions = async_to_raw_response_wrapper( + dynamic_routing.list_versions, + ) + + +class DynamicRoutingResourceWithStreamingResponse: + def __init__(self, dynamic_routing: DynamicRoutingResource) -> None: + self._dynamic_routing = dynamic_routing + + self.create = to_streamed_response_wrapper( + dynamic_routing.create, + ) + self.update = to_streamed_response_wrapper( + dynamic_routing.update, + ) + self.list = to_streamed_response_wrapper( + dynamic_routing.list, + ) + self.delete = to_streamed_response_wrapper( + dynamic_routing.delete, + ) + self.create_deployment = to_streamed_response_wrapper( + dynamic_routing.create_deployment, + ) + self.create_version = to_streamed_response_wrapper( + dynamic_routing.create_version, + ) + self.get = to_streamed_response_wrapper( + dynamic_routing.get, + ) + self.get_version = to_streamed_response_wrapper( + dynamic_routing.get_version, + ) + self.list_deployments = to_streamed_response_wrapper( + dynamic_routing.list_deployments, + ) + self.list_versions = to_streamed_response_wrapper( + dynamic_routing.list_versions, + ) + + +class AsyncDynamicRoutingResourceWithStreamingResponse: + def __init__(self, dynamic_routing: AsyncDynamicRoutingResource) -> None: + self._dynamic_routing = dynamic_routing + + self.create = async_to_streamed_response_wrapper( + dynamic_routing.create, + ) + self.update = async_to_streamed_response_wrapper( + dynamic_routing.update, + ) + self.list = async_to_streamed_response_wrapper( + dynamic_routing.list, + ) + self.delete = async_to_streamed_response_wrapper( + dynamic_routing.delete, + ) + self.create_deployment = async_to_streamed_response_wrapper( + dynamic_routing.create_deployment, + ) + self.create_version = async_to_streamed_response_wrapper( + dynamic_routing.create_version, + ) + self.get = async_to_streamed_response_wrapper( + dynamic_routing.get, + ) + self.get_version = async_to_streamed_response_wrapper( + dynamic_routing.get_version, + ) + self.list_deployments = async_to_streamed_response_wrapper( + dynamic_routing.list_deployments, + ) + self.list_versions = async_to_streamed_response_wrapper( + dynamic_routing.list_versions, + ) diff --git a/src/cloudflare/resources/ai_gateway/evaluation_types.py b/src/cloudflare/resources/ai_gateway/evaluation_types.py new file mode 100644 index 00000000000..ed06314835d --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/evaluation_types.py @@ -0,0 +1,202 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ai_gateway import evaluation_type_list_params +from ...types.ai_gateway.evaluation_type_list_response import EvaluationTypeListResponse + +__all__ = ["EvaluationTypesResource", "AsyncEvaluationTypesResource"] + + +class EvaluationTypesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> EvaluationTypesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return EvaluationTypesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> EvaluationTypesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return EvaluationTypesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + order_by: str | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[EvaluationTypeListResponse]: + """ + List Evaluators + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/evaluation-types", + page=SyncV4PagePaginationArray[EvaluationTypeListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "order_by": order_by, + "order_by_direction": order_by_direction, + "page": page, + "per_page": per_page, + }, + evaluation_type_list_params.EvaluationTypeListParams, + ), + ), + model=EvaluationTypeListResponse, + ) + + +class AsyncEvaluationTypesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncEvaluationTypesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncEvaluationTypesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncEvaluationTypesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncEvaluationTypesResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + order_by: str | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[EvaluationTypeListResponse, AsyncV4PagePaginationArray[EvaluationTypeListResponse]]: + """ + List Evaluators + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/evaluation-types", + page=AsyncV4PagePaginationArray[EvaluationTypeListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "order_by": order_by, + "order_by_direction": order_by_direction, + "page": page, + "per_page": per_page, + }, + evaluation_type_list_params.EvaluationTypeListParams, + ), + ), + model=EvaluationTypeListResponse, + ) + + +class EvaluationTypesResourceWithRawResponse: + def __init__(self, evaluation_types: EvaluationTypesResource) -> None: + self._evaluation_types = evaluation_types + + self.list = to_raw_response_wrapper( + evaluation_types.list, + ) + + +class AsyncEvaluationTypesResourceWithRawResponse: + def __init__(self, evaluation_types: AsyncEvaluationTypesResource) -> None: + self._evaluation_types = evaluation_types + + self.list = async_to_raw_response_wrapper( + evaluation_types.list, + ) + + +class EvaluationTypesResourceWithStreamingResponse: + def __init__(self, evaluation_types: EvaluationTypesResource) -> None: + self._evaluation_types = evaluation_types + + self.list = to_streamed_response_wrapper( + evaluation_types.list, + ) + + +class AsyncEvaluationTypesResourceWithStreamingResponse: + def __init__(self, evaluation_types: AsyncEvaluationTypesResource) -> None: + self._evaluation_types = evaluation_types + + self.list = async_to_streamed_response_wrapper( + evaluation_types.list, + ) diff --git a/src/cloudflare/resources/ai_gateway/evaluations.py b/src/cloudflare/resources/ai_gateway/evaluations.py new file mode 100644 index 00000000000..e3d9fd87309 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/evaluations.py @@ -0,0 +1,546 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ai_gateway import evaluation_list_params, evaluation_create_params +from ...types.ai_gateway.evaluation_get_response import EvaluationGetResponse +from ...types.ai_gateway.evaluation_list_response import EvaluationListResponse +from ...types.ai_gateway.evaluation_create_response import EvaluationCreateResponse +from ...types.ai_gateway.evaluation_delete_response import EvaluationDeleteResponse + +__all__ = ["EvaluationsResource", "AsyncEvaluationsResource"] + + +class EvaluationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> EvaluationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return EvaluationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> EvaluationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return EvaluationsResourceWithStreamingResponse(self) + + def create( + self, + gateway_id: str, + *, + account_id: str, + dataset_ids: SequenceNotStr[str], + evaluation_type_ids: SequenceNotStr[str], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationCreateResponse: + """ + Create a new Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + body=maybe_transform( + { + "dataset_ids": dataset_ids, + "evaluation_type_ids": evaluation_type_ids, + "name": name, + }, + evaluation_create_params.EvaluationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationCreateResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationCreateResponse], ResultWrapper[EvaluationCreateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + name: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + processed: bool | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[EvaluationListResponse]: + """ + List Evaluations + + Args: + gateway_id: gateway id + + search: Search by id, name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + page=SyncV4PagePaginationArray[EvaluationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "name": name, + "page": page, + "per_page": per_page, + "processed": processed, + "search": search, + }, + evaluation_list_params.EvaluationListParams, + ), + ), + model=EvaluationListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationDeleteResponse: + """ + Delete a Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationDeleteResponse], ResultWrapper[EvaluationDeleteResponse]), + ) + + def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationGetResponse: + """ + Fetch a Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationGetResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationGetResponse], ResultWrapper[EvaluationGetResponse]), + ) + + +class AsyncEvaluationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncEvaluationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncEvaluationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncEvaluationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncEvaluationsResourceWithStreamingResponse(self) + + async def create( + self, + gateway_id: str, + *, + account_id: str, + dataset_ids: SequenceNotStr[str], + evaluation_type_ids: SequenceNotStr[str], + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationCreateResponse: + """ + Create a new Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + body=await async_maybe_transform( + { + "dataset_ids": dataset_ids, + "evaluation_type_ids": evaluation_type_ids, + "name": name, + }, + evaluation_create_params.EvaluationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationCreateResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationCreateResponse], ResultWrapper[EvaluationCreateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + name: str | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + processed: bool | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[EvaluationListResponse, AsyncV4PagePaginationArray[EvaluationListResponse]]: + """ + List Evaluations + + Args: + gateway_id: gateway id + + search: Search by id, name + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations", + page=AsyncV4PagePaginationArray[EvaluationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "name": name, + "page": page, + "per_page": per_page, + "processed": processed, + "search": search, + }, + evaluation_list_params.EvaluationListParams, + ), + ), + model=EvaluationListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationDeleteResponse: + """ + Delete a Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationDeleteResponse], ResultWrapper[EvaluationDeleteResponse]), + ) + + async def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> EvaluationGetResponse: + """ + Fetch a Evaluation + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[EvaluationGetResponse]._unwrapper, + ), + cast_to=cast(Type[EvaluationGetResponse], ResultWrapper[EvaluationGetResponse]), + ) + + +class EvaluationsResourceWithRawResponse: + def __init__(self, evaluations: EvaluationsResource) -> None: + self._evaluations = evaluations + + self.create = to_raw_response_wrapper( + evaluations.create, + ) + self.list = to_raw_response_wrapper( + evaluations.list, + ) + self.delete = to_raw_response_wrapper( + evaluations.delete, + ) + self.get = to_raw_response_wrapper( + evaluations.get, + ) + + +class AsyncEvaluationsResourceWithRawResponse: + def __init__(self, evaluations: AsyncEvaluationsResource) -> None: + self._evaluations = evaluations + + self.create = async_to_raw_response_wrapper( + evaluations.create, + ) + self.list = async_to_raw_response_wrapper( + evaluations.list, + ) + self.delete = async_to_raw_response_wrapper( + evaluations.delete, + ) + self.get = async_to_raw_response_wrapper( + evaluations.get, + ) + + +class EvaluationsResourceWithStreamingResponse: + def __init__(self, evaluations: EvaluationsResource) -> None: + self._evaluations = evaluations + + self.create = to_streamed_response_wrapper( + evaluations.create, + ) + self.list = to_streamed_response_wrapper( + evaluations.list, + ) + self.delete = to_streamed_response_wrapper( + evaluations.delete, + ) + self.get = to_streamed_response_wrapper( + evaluations.get, + ) + + +class AsyncEvaluationsResourceWithStreamingResponse: + def __init__(self, evaluations: AsyncEvaluationsResource) -> None: + self._evaluations = evaluations + + self.create = async_to_streamed_response_wrapper( + evaluations.create, + ) + self.list = async_to_streamed_response_wrapper( + evaluations.list, + ) + self.delete = async_to_streamed_response_wrapper( + evaluations.delete, + ) + self.get = async_to_streamed_response_wrapper( + evaluations.get, + ) diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 4ddf4d28468..8518d36781c 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -2,14 +2,14 @@ from __future__ import annotations -from typing import Union +from typing import Dict, Type, Union, Iterable, Optional, cast from datetime import datetime from typing_extensions import Literal import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import maybe_transform +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -18,10 +18,13 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) +from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options -from ...types.ai_gateway import log_list_params +from ...types.ai_gateway import log_edit_params, log_list_params, log_delete_params +from ...types.ai_gateway.log_get_response import LogGetResponse from ...types.ai_gateway.log_list_response import LogListResponse +from ...types.ai_gateway.log_delete_response import LogDeleteResponse __all__ = ["LogsResource", "AsyncLogsResource"] @@ -29,38 +32,68 @@ class LogsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> LogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return LogsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> LogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return LogsResourceWithStreamingResponse(self) def list( self, - id: str, + gateway_id: str, *, account_id: str, - cached: bool | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - end_date: Union[str, datetime] | NotGiven = NOT_GIVEN, - order_by: Literal["created_at", "provider"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, - start_date: Union[str, datetime] | NotGiven = NOT_GIVEN, - success: bool | NotGiven = NOT_GIVEN, + cached: bool | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + end_date: Union[str, datetime] | Omit = omit, + feedback: Literal[0, 1] | Omit = omit, + filters: Iterable[log_list_params.Filter] | Omit = omit, + max_cost: float | Omit = omit, + max_duration: float | Omit = omit, + max_tokens_in: float | Omit = omit, + max_tokens_out: float | Omit = omit, + max_total_tokens: float | Omit = omit, + meta_info: bool | Omit = omit, + min_cost: float | Omit = omit, + min_duration: float | Omit = omit, + min_tokens_in: float | Omit = omit, + min_tokens_out: float | Omit = omit, + min_total_tokens: float | Omit = omit, + model: str | Omit = omit, + model_type: str | Omit = omit, + order_by: Literal["created_at", "provider", "model", "model_type", "success", "cached"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + provider: str | Omit = omit, + request_content_type: str | Omit = omit, + response_content_type: str | Omit = omit, + search: str | Omit = omit, + start_date: Union[str, datetime] | Omit = omit, + success: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[LogListResponse]: """ List Gateway Logs Args: - id: gateway id + gateway_id: gateway id extra_headers: Send extra headers @@ -72,10 +105,10 @@ def list( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") return self._get_api_list( - f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs", + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", page=SyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, @@ -87,9 +120,28 @@ def list( "cached": cached, "direction": direction, "end_date": end_date, + "feedback": feedback, + "filters": filters, + "max_cost": max_cost, + "max_duration": max_duration, + "max_tokens_in": max_tokens_in, + "max_tokens_out": max_tokens_out, + "max_total_tokens": max_total_tokens, + "meta_info": meta_info, + "min_cost": min_cost, + "min_duration": min_duration, + "min_tokens_in": min_tokens_in, + "min_tokens_out": min_tokens_out, + "min_total_tokens": min_total_tokens, + "model": model, + "model_type": model_type, "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, + "provider": provider, + "request_content_type": request_content_type, + "response_content_type": response_content_type, "search": search, "start_date": start_date, "success": success, @@ -100,42 +152,322 @@ def list( model=LogListResponse, ) + def delete( + self, + gateway_id: str, + *, + account_id: str, + filters: Iterable[log_delete_params.Filter] | Omit = omit, + limit: int | Omit = omit, + order_by: Literal[ + "created_at", + "provider", + "model", + "model_type", + "success", + "cached", + "cost", + "tokens_in", + "tokens_out", + "duration", + "feedback", + ] + | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogDeleteResponse: + """ + Delete Gateway Logs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "filters": filters, + "limit": limit, + "order_by": order_by, + "order_by_direction": order_by_direction, + }, + log_delete_params.LogDeleteParams, + ), + ), + cast_to=LogDeleteResponse, + ) + + def edit( + self, + id: str, + *, + account_id: str, + gateway_id: str, + feedback: Optional[float] | Omit = omit, + metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit, + score: Optional[float] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Patch Gateway Log + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._patch( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + body=maybe_transform( + { + "feedback": feedback, + "metadata": metadata, + "score": score, + }, + log_edit_params.LogEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogGetResponse: + """ + Get Gateway Log Detail + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LogGetResponse]._unwrapper, + ), + cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]), + ) + + def request( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Gateway Log Request + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + def response( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Gateway Log Response + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + class AsyncLogsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncLogsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncLogsResourceWithStreamingResponse(self) def list( self, - id: str, + gateway_id: str, *, account_id: str, - cached: bool | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - end_date: Union[str, datetime] | NotGiven = NOT_GIVEN, - order_by: Literal["created_at", "provider"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, - start_date: Union[str, datetime] | NotGiven = NOT_GIVEN, - success: bool | NotGiven = NOT_GIVEN, + cached: bool | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + end_date: Union[str, datetime] | Omit = omit, + feedback: Literal[0, 1] | Omit = omit, + filters: Iterable[log_list_params.Filter] | Omit = omit, + max_cost: float | Omit = omit, + max_duration: float | Omit = omit, + max_tokens_in: float | Omit = omit, + max_tokens_out: float | Omit = omit, + max_total_tokens: float | Omit = omit, + meta_info: bool | Omit = omit, + min_cost: float | Omit = omit, + min_duration: float | Omit = omit, + min_tokens_in: float | Omit = omit, + min_tokens_out: float | Omit = omit, + min_total_tokens: float | Omit = omit, + model: str | Omit = omit, + model_type: str | Omit = omit, + order_by: Literal["created_at", "provider", "model", "model_type", "success", "cached"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + provider: str | Omit = omit, + request_content_type: str | Omit = omit, + response_content_type: str | Omit = omit, + search: str | Omit = omit, + start_date: Union[str, datetime] | Omit = omit, + success: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[LogListResponse, AsyncV4PagePaginationArray[LogListResponse]]: """ List Gateway Logs Args: - id: gateway id + gateway_id: gateway id extra_headers: Send extra headers @@ -147,10 +479,10 @@ def list( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") return self._get_api_list( - f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs", + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", page=AsyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, @@ -162,9 +494,28 @@ def list( "cached": cached, "direction": direction, "end_date": end_date, + "feedback": feedback, + "filters": filters, + "max_cost": max_cost, + "max_duration": max_duration, + "max_tokens_in": max_tokens_in, + "max_tokens_out": max_tokens_out, + "max_total_tokens": max_total_tokens, + "meta_info": meta_info, + "min_cost": min_cost, + "min_duration": min_duration, + "min_tokens_in": min_tokens_in, + "min_tokens_out": min_tokens_out, + "min_total_tokens": min_total_tokens, + "model": model, + "model_type": model_type, "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, + "provider": provider, + "request_content_type": request_content_type, + "response_content_type": response_content_type, "search": search, "start_date": start_date, "success": success, @@ -175,6 +526,256 @@ def list( model=LogListResponse, ) + async def delete( + self, + gateway_id: str, + *, + account_id: str, + filters: Iterable[log_delete_params.Filter] | Omit = omit, + limit: int | Omit = omit, + order_by: Literal[ + "created_at", + "provider", + "model", + "model_type", + "success", + "cached", + "cost", + "tokens_in", + "tokens_out", + "duration", + "feedback", + ] + | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogDeleteResponse: + """ + Delete Gateway Logs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "filters": filters, + "limit": limit, + "order_by": order_by, + "order_by_direction": order_by_direction, + }, + log_delete_params.LogDeleteParams, + ), + ), + cast_to=LogDeleteResponse, + ) + + async def edit( + self, + id: str, + *, + account_id: str, + gateway_id: str, + feedback: Optional[float] | Omit = omit, + metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit, + score: Optional[float] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Patch Gateway Log + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._patch( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + body=await async_maybe_transform( + { + "feedback": feedback, + "metadata": metadata, + "score": score, + }, + log_edit_params.LogEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + async def get( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogGetResponse: + """ + Get Gateway Log Detail + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LogGetResponse]._unwrapper, + ), + cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]), + ) + + async def request( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Gateway Log Request + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + async def response( + self, + id: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> object: + """ + Get Gateway Log Response + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + class LogsResourceWithRawResponse: def __init__(self, logs: LogsResource) -> None: @@ -183,6 +784,21 @@ def __init__(self, logs: LogsResource) -> None: self.list = to_raw_response_wrapper( logs.list, ) + self.delete = to_raw_response_wrapper( + logs.delete, + ) + self.edit = to_raw_response_wrapper( + logs.edit, + ) + self.get = to_raw_response_wrapper( + logs.get, + ) + self.request = to_raw_response_wrapper( + logs.request, + ) + self.response = to_raw_response_wrapper( + logs.response, + ) class AsyncLogsResourceWithRawResponse: @@ -192,6 +808,21 @@ def __init__(self, logs: AsyncLogsResource) -> None: self.list = async_to_raw_response_wrapper( logs.list, ) + self.delete = async_to_raw_response_wrapper( + logs.delete, + ) + self.edit = async_to_raw_response_wrapper( + logs.edit, + ) + self.get = async_to_raw_response_wrapper( + logs.get, + ) + self.request = async_to_raw_response_wrapper( + logs.request, + ) + self.response = async_to_raw_response_wrapper( + logs.response, + ) class LogsResourceWithStreamingResponse: @@ -201,6 +832,21 @@ def __init__(self, logs: LogsResource) -> None: self.list = to_streamed_response_wrapper( logs.list, ) + self.delete = to_streamed_response_wrapper( + logs.delete, + ) + self.edit = to_streamed_response_wrapper( + logs.edit, + ) + self.get = to_streamed_response_wrapper( + logs.get, + ) + self.request = to_streamed_response_wrapper( + logs.request, + ) + self.response = to_streamed_response_wrapper( + logs.response, + ) class AsyncLogsResourceWithStreamingResponse: @@ -210,3 +856,18 @@ def __init__(self, logs: AsyncLogsResource) -> None: self.list = async_to_streamed_response_wrapper( logs.list, ) + self.delete = async_to_streamed_response_wrapper( + logs.delete, + ) + self.edit = async_to_streamed_response_wrapper( + logs.edit, + ) + self.get = async_to_streamed_response_wrapper( + logs.get, + ) + self.request = async_to_streamed_response_wrapper( + logs.request, + ) + self.response = async_to_streamed_response_wrapper( + logs.response, + ) diff --git a/src/cloudflare/resources/ai_gateway/provider_configs.py b/src/cloudflare/resources/ai_gateway/provider_configs.py new file mode 100644 index 00000000000..60c7fc5f891 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/provider_configs.py @@ -0,0 +1,340 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.ai_gateway import provider_config_list_params, provider_config_create_params +from ...types.ai_gateway.provider_config_list_response import ProviderConfigListResponse +from ...types.ai_gateway.provider_config_create_response import ProviderConfigCreateResponse + +__all__ = ["ProviderConfigsResource", "AsyncProviderConfigsResource"] + + +class ProviderConfigsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ProviderConfigsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ProviderConfigsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ProviderConfigsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ProviderConfigsResourceWithStreamingResponse(self) + + def create( + self, + gateway_id: str, + *, + account_id: str, + alias: str, + default_config: bool, + provider_slug: str, + secret: str, + secret_id: str, + rate_limit: float | Omit = omit, + rate_limit_period: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ProviderConfigCreateResponse: + """ + Create a new Provider Configs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + body=maybe_transform( + { + "alias": alias, + "default_config": default_config, + "provider_slug": provider_slug, + "secret": secret, + "secret_id": secret_id, + "rate_limit": rate_limit, + "rate_limit_period": rate_limit_period, + }, + provider_config_create_params.ProviderConfigCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ProviderConfigCreateResponse]._unwrapper, + ), + cast_to=cast(Type[ProviderConfigCreateResponse], ResultWrapper[ProviderConfigCreateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[ProviderConfigListResponse]: + """ + List Provider Configs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + page=SyncV4PagePaginationArray[ProviderConfigListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + provider_config_list_params.ProviderConfigListParams, + ), + ), + model=ProviderConfigListResponse, + ) + + +class AsyncProviderConfigsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncProviderConfigsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncProviderConfigsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncProviderConfigsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncProviderConfigsResourceWithStreamingResponse(self) + + async def create( + self, + gateway_id: str, + *, + account_id: str, + alias: str, + default_config: bool, + provider_slug: str, + secret: str, + secret_id: str, + rate_limit: float | Omit = omit, + rate_limit_period: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ProviderConfigCreateResponse: + """ + Create a new Provider Configs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + body=await async_maybe_transform( + { + "alias": alias, + "default_config": default_config, + "provider_slug": provider_slug, + "secret": secret, + "secret_id": secret_id, + "rate_limit": rate_limit, + "rate_limit_period": rate_limit_period, + }, + provider_config_create_params.ProviderConfigCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ProviderConfigCreateResponse]._unwrapper, + ), + cast_to=cast(Type[ProviderConfigCreateResponse], ResultWrapper[ProviderConfigCreateResponse]), + ) + + def list( + self, + gateway_id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ProviderConfigListResponse, AsyncV4PagePaginationArray[ProviderConfigListResponse]]: + """ + List Provider Configs + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs", + page=AsyncV4PagePaginationArray[ProviderConfigListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + provider_config_list_params.ProviderConfigListParams, + ), + ), + model=ProviderConfigListResponse, + ) + + +class ProviderConfigsResourceWithRawResponse: + def __init__(self, provider_configs: ProviderConfigsResource) -> None: + self._provider_configs = provider_configs + + self.create = to_raw_response_wrapper( + provider_configs.create, + ) + self.list = to_raw_response_wrapper( + provider_configs.list, + ) + + +class AsyncProviderConfigsResourceWithRawResponse: + def __init__(self, provider_configs: AsyncProviderConfigsResource) -> None: + self._provider_configs = provider_configs + + self.create = async_to_raw_response_wrapper( + provider_configs.create, + ) + self.list = async_to_raw_response_wrapper( + provider_configs.list, + ) + + +class ProviderConfigsResourceWithStreamingResponse: + def __init__(self, provider_configs: ProviderConfigsResource) -> None: + self._provider_configs = provider_configs + + self.create = to_streamed_response_wrapper( + provider_configs.create, + ) + self.list = to_streamed_response_wrapper( + provider_configs.list, + ) + + +class AsyncProviderConfigsResourceWithStreamingResponse: + def __init__(self, provider_configs: AsyncProviderConfigsResource) -> None: + self._provider_configs = provider_configs + + self.create = async_to_streamed_response_wrapper( + provider_configs.create, + ) + self.list = async_to_streamed_response_wrapper( + provider_configs.list, + ) diff --git a/src/cloudflare/resources/ai_gateway/urls.py b/src/cloudflare/resources/ai_gateway/urls.py new file mode 100644 index 00000000000..8f660faa164 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/urls.py @@ -0,0 +1,190 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.ai_gateway.url_get_response import URLGetResponse + +__all__ = ["URLsResource", "AsyncURLsResource"] + + +class URLsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> URLsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return URLsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> URLsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return URLsResourceWithStreamingResponse(self) + + def get( + self, + provider: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Get Gateway URL + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not provider: + raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[URLGetResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class AsyncURLsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncURLsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncURLsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncURLsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncURLsResourceWithStreamingResponse(self) + + async def get( + self, + provider: str, + *, + account_id: str, + gateway_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """ + Get Gateway URL + + Args: + gateway_id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not gateway_id: + raise ValueError(f"Expected a non-empty value for `gateway_id` but received {gateway_id!r}") + if not provider: + raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[URLGetResponse]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class URLsResourceWithRawResponse: + def __init__(self, urls: URLsResource) -> None: + self._urls = urls + + self.get = to_raw_response_wrapper( + urls.get, + ) + + +class AsyncURLsResourceWithRawResponse: + def __init__(self, urls: AsyncURLsResource) -> None: + self._urls = urls + + self.get = async_to_raw_response_wrapper( + urls.get, + ) + + +class URLsResourceWithStreamingResponse: + def __init__(self, urls: URLsResource) -> None: + self._urls = urls + + self.get = to_streamed_response_wrapper( + urls.get, + ) + + +class AsyncURLsResourceWithStreamingResponse: + def __init__(self, urls: AsyncURLsResource) -> None: + self._urls = urls + + self.get = async_to_streamed_response_wrapper( + urls.get, + ) diff --git a/src/cloudflare/resources/aisearch/__init__.py b/src/cloudflare/resources/aisearch/__init__.py new file mode 100644 index 00000000000..e7d15dd59ad --- /dev/null +++ b/src/cloudflare/resources/aisearch/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .tokens import ( + TokensResource, + AsyncTokensResource, + TokensResourceWithRawResponse, + AsyncTokensResourceWithRawResponse, + TokensResourceWithStreamingResponse, + AsyncTokensResourceWithStreamingResponse, +) +from .aisearch import ( + AISearchResource, + AsyncAISearchResource, + AISearchResourceWithRawResponse, + AsyncAISearchResourceWithRawResponse, + AISearchResourceWithStreamingResponse, + AsyncAISearchResourceWithStreamingResponse, +) +from .instances import ( + InstancesResource, + AsyncInstancesResource, + InstancesResourceWithRawResponse, + AsyncInstancesResourceWithRawResponse, + InstancesResourceWithStreamingResponse, + AsyncInstancesResourceWithStreamingResponse, +) + +__all__ = [ + "InstancesResource", + "AsyncInstancesResource", + "InstancesResourceWithRawResponse", + "AsyncInstancesResourceWithRawResponse", + "InstancesResourceWithStreamingResponse", + "AsyncInstancesResourceWithStreamingResponse", + "TokensResource", + "AsyncTokensResource", + "TokensResourceWithRawResponse", + "AsyncTokensResourceWithRawResponse", + "TokensResourceWithStreamingResponse", + "AsyncTokensResourceWithStreamingResponse", + "AISearchResource", + "AsyncAISearchResource", + "AISearchResourceWithRawResponse", + "AsyncAISearchResourceWithRawResponse", + "AISearchResourceWithStreamingResponse", + "AsyncAISearchResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/aisearch/aisearch.py b/src/cloudflare/resources/aisearch/aisearch.py new file mode 100644 index 00000000000..483739a1224 --- /dev/null +++ b/src/cloudflare/resources/aisearch/aisearch.py @@ -0,0 +1,134 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .tokens import ( + TokensResource, + AsyncTokensResource, + TokensResourceWithRawResponse, + AsyncTokensResourceWithRawResponse, + TokensResourceWithStreamingResponse, + AsyncTokensResourceWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .instances.instances import ( + InstancesResource, + AsyncInstancesResource, + InstancesResourceWithRawResponse, + AsyncInstancesResourceWithRawResponse, + InstancesResourceWithStreamingResponse, + AsyncInstancesResourceWithStreamingResponse, +) + +__all__ = ["AISearchResource", "AsyncAISearchResource"] + + +class AISearchResource(SyncAPIResource): + @cached_property + def instances(self) -> InstancesResource: + return InstancesResource(self._client) + + @cached_property + def tokens(self) -> TokensResource: + return TokensResource(self._client) + + @cached_property + def with_raw_response(self) -> AISearchResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AISearchResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AISearchResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AISearchResourceWithStreamingResponse(self) + + +class AsyncAISearchResource(AsyncAPIResource): + @cached_property + def instances(self) -> AsyncInstancesResource: + return AsyncInstancesResource(self._client) + + @cached_property + def tokens(self) -> AsyncTokensResource: + return AsyncTokensResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAISearchResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAISearchResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAISearchResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAISearchResourceWithStreamingResponse(self) + + +class AISearchResourceWithRawResponse: + def __init__(self, aisearch: AISearchResource) -> None: + self._aisearch = aisearch + + @cached_property + def instances(self) -> InstancesResourceWithRawResponse: + return InstancesResourceWithRawResponse(self._aisearch.instances) + + @cached_property + def tokens(self) -> TokensResourceWithRawResponse: + return TokensResourceWithRawResponse(self._aisearch.tokens) + + +class AsyncAISearchResourceWithRawResponse: + def __init__(self, aisearch: AsyncAISearchResource) -> None: + self._aisearch = aisearch + + @cached_property + def instances(self) -> AsyncInstancesResourceWithRawResponse: + return AsyncInstancesResourceWithRawResponse(self._aisearch.instances) + + @cached_property + def tokens(self) -> AsyncTokensResourceWithRawResponse: + return AsyncTokensResourceWithRawResponse(self._aisearch.tokens) + + +class AISearchResourceWithStreamingResponse: + def __init__(self, aisearch: AISearchResource) -> None: + self._aisearch = aisearch + + @cached_property + def instances(self) -> InstancesResourceWithStreamingResponse: + return InstancesResourceWithStreamingResponse(self._aisearch.instances) + + @cached_property + def tokens(self) -> TokensResourceWithStreamingResponse: + return TokensResourceWithStreamingResponse(self._aisearch.tokens) + + +class AsyncAISearchResourceWithStreamingResponse: + def __init__(self, aisearch: AsyncAISearchResource) -> None: + self._aisearch = aisearch + + @cached_property + def instances(self) -> AsyncInstancesResourceWithStreamingResponse: + return AsyncInstancesResourceWithStreamingResponse(self._aisearch.instances) + + @cached_property + def tokens(self) -> AsyncTokensResourceWithStreamingResponse: + return AsyncTokensResourceWithStreamingResponse(self._aisearch.tokens) diff --git a/src/cloudflare/resources/aisearch/instances/__init__.py b/src/cloudflare/resources/aisearch/instances/__init__.py new file mode 100644 index 00000000000..bcd3fe82f43 --- /dev/null +++ b/src/cloudflare/resources/aisearch/instances/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .jobs import ( + JobsResource, + AsyncJobsResource, + JobsResourceWithRawResponse, + AsyncJobsResourceWithRawResponse, + JobsResourceWithStreamingResponse, + AsyncJobsResourceWithStreamingResponse, +) +from .items import ( + ItemsResource, + AsyncItemsResource, + ItemsResourceWithRawResponse, + AsyncItemsResourceWithRawResponse, + ItemsResourceWithStreamingResponse, + AsyncItemsResourceWithStreamingResponse, +) +from .instances import ( + InstancesResource, + AsyncInstancesResource, + InstancesResourceWithRawResponse, + AsyncInstancesResourceWithRawResponse, + InstancesResourceWithStreamingResponse, + AsyncInstancesResourceWithStreamingResponse, +) + +__all__ = [ + "ItemsResource", + "AsyncItemsResource", + "ItemsResourceWithRawResponse", + "AsyncItemsResourceWithRawResponse", + "ItemsResourceWithStreamingResponse", + "AsyncItemsResourceWithStreamingResponse", + "JobsResource", + "AsyncJobsResource", + "JobsResourceWithRawResponse", + "AsyncJobsResourceWithRawResponse", + "JobsResourceWithStreamingResponse", + "AsyncJobsResourceWithStreamingResponse", + "InstancesResource", + "AsyncInstancesResource", + "InstancesResourceWithRawResponse", + "AsyncInstancesResourceWithRawResponse", + "InstancesResourceWithStreamingResponse", + "AsyncInstancesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/aisearch/instances/instances.py b/src/cloudflare/resources/aisearch/instances/instances.py new file mode 100644 index 00000000000..44984f27f89 --- /dev/null +++ b/src/cloudflare/resources/aisearch/instances/instances.py @@ -0,0 +1,1569 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, cast +from typing_extensions import Literal + +import httpx + +from .jobs import ( + JobsResource, + AsyncJobsResource, + JobsResourceWithRawResponse, + AsyncJobsResourceWithRawResponse, + JobsResourceWithStreamingResponse, + AsyncJobsResourceWithStreamingResponse, +) +from .items import ( + ItemsResource, + AsyncItemsResource, + ItemsResourceWithRawResponse, + AsyncItemsResourceWithRawResponse, + ItemsResourceWithStreamingResponse, + AsyncItemsResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options +from ....types.aisearch import ( + instance_list_params, + instance_create_params, + instance_search_params, + instance_update_params, + instance_chat_completions_params, +) +from ....types.aisearch.instance_list_response import InstanceListResponse +from ....types.aisearch.instance_read_response import InstanceReadResponse +from ....types.aisearch.instance_stats_response import InstanceStatsResponse +from ....types.aisearch.instance_create_response import InstanceCreateResponse +from ....types.aisearch.instance_delete_response import InstanceDeleteResponse +from ....types.aisearch.instance_search_response import InstanceSearchResponse +from ....types.aisearch.instance_update_response import InstanceUpdateResponse +from ....types.aisearch.instance_chat_completions_response import InstanceChatCompletionsResponse + +__all__ = ["InstancesResource", "AsyncInstancesResource"] + + +class InstancesResource(SyncAPIResource): + @cached_property + def items(self) -> ItemsResource: + return ItemsResource(self._client) + + @cached_property + def jobs(self) -> JobsResource: + return JobsResource(self._client) + + @cached_property + def with_raw_response(self) -> InstancesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return InstancesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> InstancesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return InstancesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + id: str, + source: str, + type: Literal["r2", "web-crawler"], + ai_gateway_id: str | Omit = omit, + aisearch_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + chunk: bool | Omit = omit, + chunk_overlap: int | Omit = omit, + chunk_size: int | Omit = omit, + custom_metadata: Iterable[instance_create_params.CustomMetadata] | Omit = omit, + embedding_model: Literal[ + "@cf/qwen/qwen3-embedding-0.6b", + "@cf/baai/bge-m3", + "@cf/baai/bge-large-en-v1.5", + "@cf/google/embeddinggemma-300m", + "google-ai-studio/gemini-embedding-001", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + max_num_results: int | Omit = omit, + metadata: instance_create_params.Metadata | Omit = omit, + public_endpoint_params: instance_create_params.PublicEndpointParams | Omit = omit, + reranking: bool | Omit = omit, + reranking_model: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + rewrite_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + rewrite_query: bool | Omit = omit, + score_threshold: float | Omit = omit, + source_params: instance_create_params.SourceParams | Omit = omit, + token_id: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceCreateResponse: + """ + Create new instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/ai-search/instances", + body=maybe_transform( + { + "id": id, + "source": source, + "type": type, + "ai_gateway_id": ai_gateway_id, + "aisearch_model": aisearch_model, + "chunk": chunk, + "chunk_overlap": chunk_overlap, + "chunk_size": chunk_size, + "custom_metadata": custom_metadata, + "embedding_model": embedding_model, + "hybrid_search_enabled": hybrid_search_enabled, + "max_num_results": max_num_results, + "metadata": metadata, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "token_id": token_id, + }, + instance_create_params.InstanceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceCreateResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceCreateResponse], ResultWrapper[InstanceCreateResponse]), + ) + + def update( + self, + id: str, + *, + account_id: str, + ai_gateway_id: str | Omit = omit, + aisearch_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + cache: bool | Omit = omit, + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + | Omit = omit, + chunk: bool | Omit = omit, + chunk_overlap: int | Omit = omit, + chunk_size: int | Omit = omit, + custom_metadata: Iterable[instance_update_params.CustomMetadata] | Omit = omit, + embedding_model: Literal[ + "@cf/qwen/qwen3-embedding-0.6b", + "@cf/baai/bge-m3", + "@cf/baai/bge-large-en-v1.5", + "@cf/google/embeddinggemma-300m", + "google-ai-studio/gemini-embedding-001", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + max_num_results: int | Omit = omit, + metadata: instance_update_params.Metadata | Omit = omit, + paused: bool | Omit = omit, + public_endpoint_params: instance_update_params.PublicEndpointParams | Omit = omit, + reranking: bool | Omit = omit, + reranking_model: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + rewrite_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + rewrite_query: bool | Omit = omit, + score_threshold: float | Omit = omit, + source_params: instance_update_params.SourceParams | Omit = omit, + summarization: bool | Omit = omit, + summarization_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + system_prompt_aisearch: str | Omit = omit, + system_prompt_index_summarization: str | Omit = omit, + system_prompt_rewrite_query: str | Omit = omit, + token_id: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceUpdateResponse: + """ + Update instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + f"/accounts/{account_id}/ai-search/instances/{id}", + body=maybe_transform( + { + "ai_gateway_id": ai_gateway_id, + "aisearch_model": aisearch_model, + "cache": cache, + "cache_threshold": cache_threshold, + "chunk": chunk, + "chunk_overlap": chunk_overlap, + "chunk_size": chunk_size, + "custom_metadata": custom_metadata, + "embedding_model": embedding_model, + "hybrid_search_enabled": hybrid_search_enabled, + "max_num_results": max_num_results, + "metadata": metadata, + "paused": paused, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "summarization": summarization, + "summarization_model": summarization_model, + "system_prompt_aisearch": system_prompt_aisearch, + "system_prompt_index_summarization": system_prompt_index_summarization, + "system_prompt_rewrite_query": system_prompt_rewrite_query, + "token_id": token_id, + }, + instance_update_params.InstanceUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceUpdateResponse], ResultWrapper[InstanceUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[InstanceListResponse]: + """ + List instances. + + Args: + search: Search by id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances", + page=SyncV4PagePaginationArray[InstanceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + }, + instance_list_params.InstanceListParams, + ), + ), + model=InstanceListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceDeleteResponse: + """ + Delete instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/accounts/{account_id}/ai-search/instances/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceDeleteResponse], ResultWrapper[InstanceDeleteResponse]), + ) + + def chat_completions( + self, + id: str, + *, + account_id: str, + messages: Iterable[instance_chat_completions_params.Message], + aisearch_options: instance_chat_completions_params.AISearchOptions | Omit = omit, + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + stream: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceChatCompletionsResponse: + """ + Chat Completions + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/chat/completions", + body=maybe_transform( + { + "messages": messages, + "aisearch_options": aisearch_options, + "model": model, + "stream": stream, + }, + instance_chat_completions_params.InstanceChatCompletionsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=InstanceChatCompletionsResponse, + ) + + def read( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceReadResponse: + """ + Read instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/instances/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceReadResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceReadResponse], ResultWrapper[InstanceReadResponse]), + ) + + def search( + self, + id: str, + *, + account_id: str, + messages: Iterable[instance_search_params.Message], + aisearch_options: instance_search_params.AISearchOptions | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceSearchResponse: + """ + Search + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/search", + body=maybe_transform( + { + "messages": messages, + "aisearch_options": aisearch_options, + }, + instance_search_params.InstanceSearchParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceSearchResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceSearchResponse], ResultWrapper[InstanceSearchResponse]), + ) + + def stats( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceStatsResponse: + """ + Stats + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/stats", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceStatsResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceStatsResponse], ResultWrapper[InstanceStatsResponse]), + ) + + +class AsyncInstancesResource(AsyncAPIResource): + @cached_property + def items(self) -> AsyncItemsResource: + return AsyncItemsResource(self._client) + + @cached_property + def jobs(self) -> AsyncJobsResource: + return AsyncJobsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncInstancesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncInstancesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncInstancesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncInstancesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + id: str, + source: str, + type: Literal["r2", "web-crawler"], + ai_gateway_id: str | Omit = omit, + aisearch_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + chunk: bool | Omit = omit, + chunk_overlap: int | Omit = omit, + chunk_size: int | Omit = omit, + custom_metadata: Iterable[instance_create_params.CustomMetadata] | Omit = omit, + embedding_model: Literal[ + "@cf/qwen/qwen3-embedding-0.6b", + "@cf/baai/bge-m3", + "@cf/baai/bge-large-en-v1.5", + "@cf/google/embeddinggemma-300m", + "google-ai-studio/gemini-embedding-001", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + max_num_results: int | Omit = omit, + metadata: instance_create_params.Metadata | Omit = omit, + public_endpoint_params: instance_create_params.PublicEndpointParams | Omit = omit, + reranking: bool | Omit = omit, + reranking_model: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + rewrite_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + rewrite_query: bool | Omit = omit, + score_threshold: float | Omit = omit, + source_params: instance_create_params.SourceParams | Omit = omit, + token_id: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceCreateResponse: + """ + Create new instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-search/instances", + body=await async_maybe_transform( + { + "id": id, + "source": source, + "type": type, + "ai_gateway_id": ai_gateway_id, + "aisearch_model": aisearch_model, + "chunk": chunk, + "chunk_overlap": chunk_overlap, + "chunk_size": chunk_size, + "custom_metadata": custom_metadata, + "embedding_model": embedding_model, + "hybrid_search_enabled": hybrid_search_enabled, + "max_num_results": max_num_results, + "metadata": metadata, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "token_id": token_id, + }, + instance_create_params.InstanceCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceCreateResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceCreateResponse], ResultWrapper[InstanceCreateResponse]), + ) + + async def update( + self, + id: str, + *, + account_id: str, + ai_gateway_id: str | Omit = omit, + aisearch_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + cache: bool | Omit = omit, + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + | Omit = omit, + chunk: bool | Omit = omit, + chunk_overlap: int | Omit = omit, + chunk_size: int | Omit = omit, + custom_metadata: Iterable[instance_update_params.CustomMetadata] | Omit = omit, + embedding_model: Literal[ + "@cf/qwen/qwen3-embedding-0.6b", + "@cf/baai/bge-m3", + "@cf/baai/bge-large-en-v1.5", + "@cf/google/embeddinggemma-300m", + "google-ai-studio/gemini-embedding-001", + "openai/text-embedding-3-small", + "openai/text-embedding-3-large", + "", + ] + | Omit = omit, + hybrid_search_enabled: bool | Omit = omit, + max_num_results: int | Omit = omit, + metadata: instance_update_params.Metadata | Omit = omit, + paused: bool | Omit = omit, + public_endpoint_params: instance_update_params.PublicEndpointParams | Omit = omit, + reranking: bool | Omit = omit, + reranking_model: Literal["@cf/baai/bge-reranker-base", ""] | Omit = omit, + rewrite_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + rewrite_query: bool | Omit = omit, + score_threshold: float | Omit = omit, + source_params: instance_update_params.SourceParams | Omit = omit, + summarization: bool | Omit = omit, + summarization_model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + system_prompt_aisearch: str | Omit = omit, + system_prompt_index_summarization: str | Omit = omit, + system_prompt_rewrite_query: str | Omit = omit, + token_id: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceUpdateResponse: + """ + Update instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + f"/accounts/{account_id}/ai-search/instances/{id}", + body=await async_maybe_transform( + { + "ai_gateway_id": ai_gateway_id, + "aisearch_model": aisearch_model, + "cache": cache, + "cache_threshold": cache_threshold, + "chunk": chunk, + "chunk_overlap": chunk_overlap, + "chunk_size": chunk_size, + "custom_metadata": custom_metadata, + "embedding_model": embedding_model, + "hybrid_search_enabled": hybrid_search_enabled, + "max_num_results": max_num_results, + "metadata": metadata, + "paused": paused, + "public_endpoint_params": public_endpoint_params, + "reranking": reranking, + "reranking_model": reranking_model, + "rewrite_model": rewrite_model, + "rewrite_query": rewrite_query, + "score_threshold": score_threshold, + "source_params": source_params, + "summarization": summarization, + "summarization_model": summarization_model, + "system_prompt_aisearch": system_prompt_aisearch, + "system_prompt_index_summarization": system_prompt_index_summarization, + "system_prompt_rewrite_query": system_prompt_rewrite_query, + "token_id": token_id, + }, + instance_update_params.InstanceUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceUpdateResponse], ResultWrapper[InstanceUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[InstanceListResponse, AsyncV4PagePaginationArray[InstanceListResponse]]: + """ + List instances. + + Args: + search: Search by id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances", + page=AsyncV4PagePaginationArray[InstanceListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + }, + instance_list_params.InstanceListParams, + ), + ), + model=InstanceListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceDeleteResponse: + """ + Delete instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-search/instances/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceDeleteResponse], ResultWrapper[InstanceDeleteResponse]), + ) + + async def chat_completions( + self, + id: str, + *, + account_id: str, + messages: Iterable[instance_chat_completions_params.Message], + aisearch_options: instance_chat_completions_params.AISearchOptions | Omit = omit, + model: Literal[ + "@cf/meta/llama-3.3-70b-instruct-fp8-fast", + "@cf/meta/llama-3.1-8b-instruct-fast", + "@cf/meta/llama-3.1-8b-instruct-fp8", + "@cf/meta/llama-4-scout-17b-16e-instruct", + "@cf/qwen/qwen3-30b-a3b-fp8", + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", + "@cf/moonshotai/kimi-k2-instruct", + "anthropic/claude-3-7-sonnet", + "anthropic/claude-sonnet-4", + "anthropic/claude-opus-4", + "anthropic/claude-3-5-haiku", + "cerebras/qwen-3-235b-a22b-instruct", + "cerebras/qwen-3-235b-a22b-thinking", + "cerebras/llama-3.3-70b", + "cerebras/llama-4-maverick-17b-128e-instruct", + "cerebras/llama-4-scout-17b-16e-instruct", + "cerebras/gpt-oss-120b", + "google-ai-studio/gemini-2.5-flash", + "google-ai-studio/gemini-2.5-pro", + "grok/grok-4", + "groq/llama-3.3-70b-versatile", + "groq/llama-3.1-8b-instant", + "openai/gpt-5", + "openai/gpt-5-mini", + "openai/gpt-5-nano", + "", + ] + | Omit = omit, + stream: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceChatCompletionsResponse: + """ + Chat Completions + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/chat/completions", + body=await async_maybe_transform( + { + "messages": messages, + "aisearch_options": aisearch_options, + "model": model, + "stream": stream, + }, + instance_chat_completions_params.InstanceChatCompletionsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=InstanceChatCompletionsResponse, + ) + + async def read( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceReadResponse: + """ + Read instances. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/instances/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceReadResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceReadResponse], ResultWrapper[InstanceReadResponse]), + ) + + async def search( + self, + id: str, + *, + account_id: str, + messages: Iterable[instance_search_params.Message], + aisearch_options: instance_search_params.AISearchOptions | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceSearchResponse: + """ + Search + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/search", + body=await async_maybe_transform( + { + "messages": messages, + "aisearch_options": aisearch_options, + }, + instance_search_params.InstanceSearchParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceSearchResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceSearchResponse], ResultWrapper[InstanceSearchResponse]), + ) + + async def stats( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> InstanceStatsResponse: + """ + Stats + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/stats", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[InstanceStatsResponse]._unwrapper, + ), + cast_to=cast(Type[InstanceStatsResponse], ResultWrapper[InstanceStatsResponse]), + ) + + +class InstancesResourceWithRawResponse: + def __init__(self, instances: InstancesResource) -> None: + self._instances = instances + + self.create = to_raw_response_wrapper( + instances.create, + ) + self.update = to_raw_response_wrapper( + instances.update, + ) + self.list = to_raw_response_wrapper( + instances.list, + ) + self.delete = to_raw_response_wrapper( + instances.delete, + ) + self.chat_completions = to_raw_response_wrapper( + instances.chat_completions, + ) + self.read = to_raw_response_wrapper( + instances.read, + ) + self.search = to_raw_response_wrapper( + instances.search, + ) + self.stats = to_raw_response_wrapper( + instances.stats, + ) + + @cached_property + def items(self) -> ItemsResourceWithRawResponse: + return ItemsResourceWithRawResponse(self._instances.items) + + @cached_property + def jobs(self) -> JobsResourceWithRawResponse: + return JobsResourceWithRawResponse(self._instances.jobs) + + +class AsyncInstancesResourceWithRawResponse: + def __init__(self, instances: AsyncInstancesResource) -> None: + self._instances = instances + + self.create = async_to_raw_response_wrapper( + instances.create, + ) + self.update = async_to_raw_response_wrapper( + instances.update, + ) + self.list = async_to_raw_response_wrapper( + instances.list, + ) + self.delete = async_to_raw_response_wrapper( + instances.delete, + ) + self.chat_completions = async_to_raw_response_wrapper( + instances.chat_completions, + ) + self.read = async_to_raw_response_wrapper( + instances.read, + ) + self.search = async_to_raw_response_wrapper( + instances.search, + ) + self.stats = async_to_raw_response_wrapper( + instances.stats, + ) + + @cached_property + def items(self) -> AsyncItemsResourceWithRawResponse: + return AsyncItemsResourceWithRawResponse(self._instances.items) + + @cached_property + def jobs(self) -> AsyncJobsResourceWithRawResponse: + return AsyncJobsResourceWithRawResponse(self._instances.jobs) + + +class InstancesResourceWithStreamingResponse: + def __init__(self, instances: InstancesResource) -> None: + self._instances = instances + + self.create = to_streamed_response_wrapper( + instances.create, + ) + self.update = to_streamed_response_wrapper( + instances.update, + ) + self.list = to_streamed_response_wrapper( + instances.list, + ) + self.delete = to_streamed_response_wrapper( + instances.delete, + ) + self.chat_completions = to_streamed_response_wrapper( + instances.chat_completions, + ) + self.read = to_streamed_response_wrapper( + instances.read, + ) + self.search = to_streamed_response_wrapper( + instances.search, + ) + self.stats = to_streamed_response_wrapper( + instances.stats, + ) + + @cached_property + def items(self) -> ItemsResourceWithStreamingResponse: + return ItemsResourceWithStreamingResponse(self._instances.items) + + @cached_property + def jobs(self) -> JobsResourceWithStreamingResponse: + return JobsResourceWithStreamingResponse(self._instances.jobs) + + +class AsyncInstancesResourceWithStreamingResponse: + def __init__(self, instances: AsyncInstancesResource) -> None: + self._instances = instances + + self.create = async_to_streamed_response_wrapper( + instances.create, + ) + self.update = async_to_streamed_response_wrapper( + instances.update, + ) + self.list = async_to_streamed_response_wrapper( + instances.list, + ) + self.delete = async_to_streamed_response_wrapper( + instances.delete, + ) + self.chat_completions = async_to_streamed_response_wrapper( + instances.chat_completions, + ) + self.read = async_to_streamed_response_wrapper( + instances.read, + ) + self.search = async_to_streamed_response_wrapper( + instances.search, + ) + self.stats = async_to_streamed_response_wrapper( + instances.stats, + ) + + @cached_property + def items(self) -> AsyncItemsResourceWithStreamingResponse: + return AsyncItemsResourceWithStreamingResponse(self._instances.items) + + @cached_property + def jobs(self) -> AsyncJobsResourceWithStreamingResponse: + return AsyncJobsResourceWithStreamingResponse(self._instances.jobs) diff --git a/src/cloudflare/resources/aisearch/instances/items.py b/src/cloudflare/resources/aisearch/instances/items.py new file mode 100644 index 00000000000..7ed961721d2 --- /dev/null +++ b/src/cloudflare/resources/aisearch/instances/items.py @@ -0,0 +1,317 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options +from ....types.aisearch.instances import item_list_params +from ....types.aisearch.instances.item_get_response import ItemGetResponse +from ....types.aisearch.instances.item_list_response import ItemListResponse + +__all__ = ["ItemsResource", "AsyncItemsResource"] + + +class ItemsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ItemsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ItemsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ItemsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ItemsResourceWithStreamingResponse(self) + + def list( + self, + id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + status: Literal["queued", "running", "completed", "error", "skipped"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[ItemListResponse]: + """ + Items List. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances/{id}/items", + page=SyncV4PagePaginationArray[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + "status": status, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + def get( + self, + item_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemGetResponse: + """ + Get Item. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not item_id: + raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemGetResponse]._unwrapper, + ), + cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), + ) + + +class AsyncItemsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncItemsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncItemsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncItemsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncItemsResourceWithStreamingResponse(self) + + def list( + self, + id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + search: str | Omit = omit, + status: Literal["queued", "running", "completed", "error", "skipped"] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ItemListResponse, AsyncV4PagePaginationArray[ItemListResponse]]: + """ + Items List. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances/{id}/items", + page=AsyncV4PagePaginationArray[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + "search": search, + "status": status, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + async def get( + self, + item_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemGetResponse: + """ + Get Item. + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not item_id: + raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ItemGetResponse]._unwrapper, + ), + cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), + ) + + +class ItemsResourceWithRawResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.list = to_raw_response_wrapper( + items.list, + ) + self.get = to_raw_response_wrapper( + items.get, + ) + + +class AsyncItemsResourceWithRawResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.list = async_to_raw_response_wrapper( + items.list, + ) + self.get = async_to_raw_response_wrapper( + items.get, + ) + + +class ItemsResourceWithStreamingResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.list = to_streamed_response_wrapper( + items.list, + ) + self.get = to_streamed_response_wrapper( + items.get, + ) + + +class AsyncItemsResourceWithStreamingResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.list = async_to_streamed_response_wrapper( + items.list, + ) + self.get = async_to_streamed_response_wrapper( + items.get, + ) diff --git a/src/cloudflare/resources/aisearch/instances/jobs.py b/src/cloudflare/resources/aisearch/instances/jobs.py new file mode 100644 index 00000000000..2c6bb4226f5 --- /dev/null +++ b/src/cloudflare/resources/aisearch/instances/jobs.py @@ -0,0 +1,526 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options +from ....types.aisearch.instances import job_list_params, job_logs_params +from ....types.aisearch.instances.job_get_response import JobGetResponse +from ....types.aisearch.instances.job_list_response import JobListResponse +from ....types.aisearch.instances.job_logs_response import JobLogsResponse +from ....types.aisearch.instances.job_create_response import JobCreateResponse + +__all__ = ["JobsResource", "AsyncJobsResource"] + + +class JobsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> JobsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return JobsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> JobsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return JobsResourceWithStreamingResponse(self) + + def create( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobCreateResponse: + """ + Create new job + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobCreateResponse]._unwrapper, + ), + cast_to=cast(Type[JobCreateResponse], ResultWrapper[JobCreateResponse]), + ) + + def list( + self, + id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[JobListResponse]: + """ + List Jobs + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + page=SyncV4PagePaginationArray[JobListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + job_list_params.JobListParams, + ), + ), + model=JobListResponse, + ) + + def get( + self, + job_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobGetResponse: + """ + Get a Job Details + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobGetResponse]._unwrapper, + ), + cast_to=cast(Type[JobGetResponse], ResultWrapper[JobGetResponse]), + ) + + def logs( + self, + job_id: str, + *, + account_id: str, + id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobLogsResponse: + """ + List Job Logs + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}/logs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + job_logs_params.JobLogsParams, + ), + post_parser=ResultWrapper[JobLogsResponse]._unwrapper, + ), + cast_to=cast(Type[JobLogsResponse], ResultWrapper[JobLogsResponse]), + ) + + +class AsyncJobsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncJobsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncJobsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncJobsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncJobsResourceWithStreamingResponse(self) + + async def create( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobCreateResponse: + """ + Create new job + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobCreateResponse]._unwrapper, + ), + cast_to=cast(Type[JobCreateResponse], ResultWrapper[JobCreateResponse]), + ) + + def list( + self, + id: str, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[JobListResponse, AsyncV4PagePaginationArray[JobListResponse]]: + """ + List Jobs + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + page=AsyncV4PagePaginationArray[JobListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + job_list_params.JobListParams, + ), + ), + model=JobListResponse, + ) + + async def get( + self, + job_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobGetResponse: + """ + Get a Job Details + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[JobGetResponse]._unwrapper, + ), + cast_to=cast(Type[JobGetResponse], ResultWrapper[JobGetResponse]), + ) + + async def logs( + self, + job_id: str, + *, + account_id: str, + id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> JobLogsResponse: + """ + List Job Logs + + Args: + id: Use your AI Search ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/instances/{id}/jobs/{job_id}/logs", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "page": page, + "per_page": per_page, + }, + job_logs_params.JobLogsParams, + ), + post_parser=ResultWrapper[JobLogsResponse]._unwrapper, + ), + cast_to=cast(Type[JobLogsResponse], ResultWrapper[JobLogsResponse]), + ) + + +class JobsResourceWithRawResponse: + def __init__(self, jobs: JobsResource) -> None: + self._jobs = jobs + + self.create = to_raw_response_wrapper( + jobs.create, + ) + self.list = to_raw_response_wrapper( + jobs.list, + ) + self.get = to_raw_response_wrapper( + jobs.get, + ) + self.logs = to_raw_response_wrapper( + jobs.logs, + ) + + +class AsyncJobsResourceWithRawResponse: + def __init__(self, jobs: AsyncJobsResource) -> None: + self._jobs = jobs + + self.create = async_to_raw_response_wrapper( + jobs.create, + ) + self.list = async_to_raw_response_wrapper( + jobs.list, + ) + self.get = async_to_raw_response_wrapper( + jobs.get, + ) + self.logs = async_to_raw_response_wrapper( + jobs.logs, + ) + + +class JobsResourceWithStreamingResponse: + def __init__(self, jobs: JobsResource) -> None: + self._jobs = jobs + + self.create = to_streamed_response_wrapper( + jobs.create, + ) + self.list = to_streamed_response_wrapper( + jobs.list, + ) + self.get = to_streamed_response_wrapper( + jobs.get, + ) + self.logs = to_streamed_response_wrapper( + jobs.logs, + ) + + +class AsyncJobsResourceWithStreamingResponse: + def __init__(self, jobs: AsyncJobsResource) -> None: + self._jobs = jobs + + self.create = async_to_streamed_response_wrapper( + jobs.create, + ) + self.list = async_to_streamed_response_wrapper( + jobs.list, + ) + self.get = async_to_streamed_response_wrapper( + jobs.get, + ) + self.logs = async_to_streamed_response_wrapper( + jobs.logs, + ) diff --git a/src/cloudflare/resources/aisearch/tokens.py b/src/cloudflare/resources/aisearch/tokens.py new file mode 100644 index 00000000000..1834a9b0c6a --- /dev/null +++ b/src/cloudflare/resources/aisearch/tokens.py @@ -0,0 +1,605 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import AsyncPaginator, make_request_options +from ...types.aisearch import token_list_params, token_create_params, token_update_params +from ...types.aisearch.token_list_response import TokenListResponse +from ...types.aisearch.token_read_response import TokenReadResponse +from ...types.aisearch.token_create_response import TokenCreateResponse +from ...types.aisearch.token_delete_response import TokenDeleteResponse +from ...types.aisearch.token_update_response import TokenUpdateResponse + +__all__ = ["TokensResource", "AsyncTokensResource"] + + +class TokensResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TokensResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return TokensResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TokensResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return TokensResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + cf_api_id: str, + cf_api_key: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenCreateResponse: + """ + Create new tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/ai-search/tokens", + body=maybe_transform( + { + "cf_api_id": cf_api_id, + "cf_api_key": cf_api_key, + "name": name, + }, + token_create_params.TokenCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenCreateResponse]._unwrapper, + ), + cast_to=cast(Type[TokenCreateResponse], ResultWrapper[TokenCreateResponse]), + ) + + def update( + self, + id: str, + *, + account_id: str, + cf_api_id: str, + cf_api_key: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenUpdateResponse: + """ + Update tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._put( + f"/accounts/{account_id}/ai-search/tokens/{id}", + body=maybe_transform( + { + "cf_api_id": cf_api_id, + "cf_api_key": cf_api_key, + "name": name, + }, + token_update_params.TokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[TokenUpdateResponse], ResultWrapper[TokenUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[TokenListResponse]: + """ + List tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/tokens", + page=SyncV4PagePaginationArray[TokenListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + token_list_params.TokenListParams, + ), + ), + model=TokenListResponse, + ) + + def delete( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenDeleteResponse: + """ + Delete tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + f"/accounts/{account_id}/ai-search/tokens/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[TokenDeleteResponse], ResultWrapper[TokenDeleteResponse]), + ) + + def read( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenReadResponse: + """ + Read tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + f"/accounts/{account_id}/ai-search/tokens/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenReadResponse]._unwrapper, + ), + cast_to=cast(Type[TokenReadResponse], ResultWrapper[TokenReadResponse]), + ) + + +class AsyncTokensResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTokensResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncTokensResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncTokensResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + cf_api_id: str, + cf_api_key: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenCreateResponse: + """ + Create new tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/ai-search/tokens", + body=await async_maybe_transform( + { + "cf_api_id": cf_api_id, + "cf_api_key": cf_api_key, + "name": name, + }, + token_create_params.TokenCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenCreateResponse]._unwrapper, + ), + cast_to=cast(Type[TokenCreateResponse], ResultWrapper[TokenCreateResponse]), + ) + + async def update( + self, + id: str, + *, + account_id: str, + cf_api_id: str, + cf_api_key: str, + name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenUpdateResponse: + """ + Update tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._put( + f"/accounts/{account_id}/ai-search/tokens/{id}", + body=await async_maybe_transform( + { + "cf_api_id": cf_api_id, + "cf_api_key": cf_api_key, + "name": name, + }, + token_update_params.TokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[TokenUpdateResponse], ResultWrapper[TokenUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[TokenListResponse, AsyncV4PagePaginationArray[TokenListResponse]]: + """ + List tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/ai-search/tokens", + page=AsyncV4PagePaginationArray[TokenListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + token_list_params.TokenListParams, + ), + ), + model=TokenListResponse, + ) + + async def delete( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenDeleteResponse: + """ + Delete tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + f"/accounts/{account_id}/ai-search/tokens/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[TokenDeleteResponse], ResultWrapper[TokenDeleteResponse]), + ) + + async def read( + self, + id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TokenReadResponse: + """ + Read tokens. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + f"/accounts/{account_id}/ai-search/tokens/{id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TokenReadResponse]._unwrapper, + ), + cast_to=cast(Type[TokenReadResponse], ResultWrapper[TokenReadResponse]), + ) + + +class TokensResourceWithRawResponse: + def __init__(self, tokens: TokensResource) -> None: + self._tokens = tokens + + self.create = to_raw_response_wrapper( + tokens.create, + ) + self.update = to_raw_response_wrapper( + tokens.update, + ) + self.list = to_raw_response_wrapper( + tokens.list, + ) + self.delete = to_raw_response_wrapper( + tokens.delete, + ) + self.read = to_raw_response_wrapper( + tokens.read, + ) + + +class AsyncTokensResourceWithRawResponse: + def __init__(self, tokens: AsyncTokensResource) -> None: + self._tokens = tokens + + self.create = async_to_raw_response_wrapper( + tokens.create, + ) + self.update = async_to_raw_response_wrapper( + tokens.update, + ) + self.list = async_to_raw_response_wrapper( + tokens.list, + ) + self.delete = async_to_raw_response_wrapper( + tokens.delete, + ) + self.read = async_to_raw_response_wrapper( + tokens.read, + ) + + +class TokensResourceWithStreamingResponse: + def __init__(self, tokens: TokensResource) -> None: + self._tokens = tokens + + self.create = to_streamed_response_wrapper( + tokens.create, + ) + self.update = to_streamed_response_wrapper( + tokens.update, + ) + self.list = to_streamed_response_wrapper( + tokens.list, + ) + self.delete = to_streamed_response_wrapper( + tokens.delete, + ) + self.read = to_streamed_response_wrapper( + tokens.read, + ) + + +class AsyncTokensResourceWithStreamingResponse: + def __init__(self, tokens: AsyncTokensResource) -> None: + self._tokens = tokens + + self.create = async_to_streamed_response_wrapper( + tokens.create, + ) + self.update = async_to_streamed_response_wrapper( + tokens.update, + ) + self.list = async_to_streamed_response_wrapper( + tokens.list, + ) + self.delete = async_to_streamed_response_wrapper( + tokens.delete, + ) + self.read = async_to_streamed_response_wrapper( + tokens.read, + ) diff --git a/src/cloudflare/resources/alerting/__init__.py b/src/cloudflare/resources/alerting/__init__.py index 2bf1c17a8f3..28d682d357e 100644 --- a/src/cloudflare/resources/alerting/__init__.py +++ b/src/cloudflare/resources/alerting/__init__.py @@ -24,6 +24,14 @@ PoliciesResourceWithStreamingResponse, AsyncPoliciesResourceWithStreamingResponse, ) +from .silences import ( + SilencesResource, + AsyncSilencesResource, + SilencesResourceWithRawResponse, + AsyncSilencesResourceWithRawResponse, + SilencesResourceWithStreamingResponse, + AsyncSilencesResourceWithStreamingResponse, +) from .destinations import ( DestinationsResource, AsyncDestinationsResource, @@ -66,6 +74,12 @@ "AsyncPoliciesResourceWithRawResponse", "PoliciesResourceWithStreamingResponse", "AsyncPoliciesResourceWithStreamingResponse", + "SilencesResource", + "AsyncSilencesResource", + "SilencesResourceWithRawResponse", + "AsyncSilencesResourceWithRawResponse", + "SilencesResourceWithStreamingResponse", + "AsyncSilencesResourceWithStreamingResponse", "AlertingResource", "AsyncAlertingResource", "AlertingResourceWithRawResponse", diff --git a/src/cloudflare/resources/alerting/alerting.py b/src/cloudflare/resources/alerting/alerting.py index 05d80699a14..861ef11fc49 100644 --- a/src/cloudflare/resources/alerting/alerting.py +++ b/src/cloudflare/resources/alerting/alerting.py @@ -18,16 +18,16 @@ PoliciesResourceWithStreamingResponse, AsyncPoliciesResourceWithStreamingResponse, ) +from .silences import ( + SilencesResource, + AsyncSilencesResource, + SilencesResourceWithRawResponse, + AsyncSilencesResourceWithRawResponse, + SilencesResourceWithStreamingResponse, + AsyncSilencesResourceWithStreamingResponse, +) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource -from .destinations import ( - DestinationsResource, - AsyncDestinationsResource, - DestinationsResourceWithRawResponse, - AsyncDestinationsResourceWithRawResponse, - DestinationsResourceWithStreamingResponse, - AsyncDestinationsResourceWithStreamingResponse, -) from .available_alerts import ( AvailableAlertsResource, AsyncAvailableAlertsResource, @@ -36,7 +36,14 @@ AvailableAlertsResourceWithStreamingResponse, AsyncAvailableAlertsResourceWithStreamingResponse, ) -from .destinations.destinations import DestinationsResource, AsyncDestinationsResource +from .destinations.destinations import ( + DestinationsResource, + AsyncDestinationsResource, + DestinationsResourceWithRawResponse, + AsyncDestinationsResourceWithRawResponse, + DestinationsResourceWithStreamingResponse, + AsyncDestinationsResourceWithStreamingResponse, +) __all__ = ["AlertingResource", "AsyncAlertingResource"] @@ -58,12 +65,27 @@ def history(self) -> HistoryResource: def policies(self) -> PoliciesResource: return PoliciesResource(self._client) + @cached_property + def silences(self) -> SilencesResource: + return SilencesResource(self._client) + @cached_property def with_raw_response(self) -> AlertingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AlertingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AlertingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AlertingResourceWithStreamingResponse(self) @@ -84,12 +106,27 @@ def history(self) -> AsyncHistoryResource: def policies(self) -> AsyncPoliciesResource: return AsyncPoliciesResource(self._client) + @cached_property + def silences(self) -> AsyncSilencesResource: + return AsyncSilencesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAlertingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAlertingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAlertingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAlertingResourceWithStreamingResponse(self) @@ -113,6 +150,10 @@ def history(self) -> HistoryResourceWithRawResponse: def policies(self) -> PoliciesResourceWithRawResponse: return PoliciesResourceWithRawResponse(self._alerting.policies) + @cached_property + def silences(self) -> SilencesResourceWithRawResponse: + return SilencesResourceWithRawResponse(self._alerting.silences) + class AsyncAlertingResourceWithRawResponse: def __init__(self, alerting: AsyncAlertingResource) -> None: @@ -134,6 +175,10 @@ def history(self) -> AsyncHistoryResourceWithRawResponse: def policies(self) -> AsyncPoliciesResourceWithRawResponse: return AsyncPoliciesResourceWithRawResponse(self._alerting.policies) + @cached_property + def silences(self) -> AsyncSilencesResourceWithRawResponse: + return AsyncSilencesResourceWithRawResponse(self._alerting.silences) + class AlertingResourceWithStreamingResponse: def __init__(self, alerting: AlertingResource) -> None: @@ -155,6 +200,10 @@ def history(self) -> HistoryResourceWithStreamingResponse: def policies(self) -> PoliciesResourceWithStreamingResponse: return PoliciesResourceWithStreamingResponse(self._alerting.policies) + @cached_property + def silences(self) -> SilencesResourceWithStreamingResponse: + return SilencesResourceWithStreamingResponse(self._alerting.silences) + class AsyncAlertingResourceWithStreamingResponse: def __init__(self, alerting: AsyncAlertingResource) -> None: @@ -175,3 +224,7 @@ def history(self) -> AsyncHistoryResourceWithStreamingResponse: @cached_property def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: return AsyncPoliciesResourceWithStreamingResponse(self._alerting.policies) + + @cached_property + def silences(self) -> AsyncSilencesResourceWithStreamingResponse: + return AsyncSilencesResourceWithStreamingResponse(self._alerting.silences) diff --git a/src/cloudflare/resources/alerting/available_alerts.py b/src/cloudflare/resources/alerting/available_alerts.py index 8ededcc6759..1286d27f1e6 100644 --- a/src/cloudflare/resources/alerting/available_alerts.py +++ b/src/cloudflare/resources/alerting/available_alerts.py @@ -6,7 +6,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Query, Headers, NotGiven, not_given from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -25,10 +25,21 @@ class AvailableAlertsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> AvailableAlertsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AvailableAlertsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AvailableAlertsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AvailableAlertsResourceWithStreamingResponse(self) def list( @@ -40,7 +51,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AvailableAlertListResponse]: """ Gets a list of all alert types for which an account is eligible. @@ -74,10 +85,21 @@ def list( class AsyncAvailableAlertsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAvailableAlertsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAvailableAlertsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAvailableAlertsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAvailableAlertsResourceWithStreamingResponse(self) async def list( @@ -89,7 +111,7 @@ async def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[AvailableAlertListResponse]: """ Gets a list of all alert types for which an account is eligible. diff --git a/src/cloudflare/resources/alerting/destinations/destinations.py b/src/cloudflare/resources/alerting/destinations/destinations.py index d5e0b713d3d..8e074ffa262 100644 --- a/src/cloudflare/resources/alerting/destinations/destinations.py +++ b/src/cloudflare/resources/alerting/destinations/destinations.py @@ -47,10 +47,21 @@ def webhooks(self) -> WebhooksResource: @cached_property def with_raw_response(self) -> DestinationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return DestinationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> DestinationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return DestinationsResourceWithStreamingResponse(self) @@ -69,10 +80,21 @@ def webhooks(self) -> AsyncWebhooksResource: @cached_property def with_raw_response(self) -> AsyncDestinationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncDestinationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncDestinationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncDestinationsResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/alerting/destinations/eligible.py b/src/cloudflare/resources/alerting/destinations/eligible.py index 9f330cc89c6..76a61c05f51 100644 --- a/src/cloudflare/resources/alerting/destinations/eligible.py +++ b/src/cloudflare/resources/alerting/destinations/eligible.py @@ -6,7 +6,7 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -25,10 +25,21 @@ class EligibleResource(SyncAPIResource): @cached_property def with_raw_response(self) -> EligibleResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return EligibleResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> EligibleResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return EligibleResourceWithStreamingResponse(self) def get( @@ -40,7 +51,7 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[EligibleGetResponse]: """ Get a list of all delivery mechanism types for which an account is eligible. @@ -74,10 +85,21 @@ def get( class AsyncEligibleResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncEligibleResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncEligibleResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncEligibleResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncEligibleResourceWithStreamingResponse(self) async def get( @@ -89,7 +111,7 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[EligibleGetResponse]: """ Get a list of all delivery mechanism types for which an account is eligible. diff --git a/src/cloudflare/resources/alerting/destinations/pagerduty.py b/src/cloudflare/resources/alerting/destinations/pagerduty.py index b6e4f112a41..223dfead7a8 100644 --- a/src/cloudflare/resources/alerting/destinations/pagerduty.py +++ b/src/cloudflare/resources/alerting/destinations/pagerduty.py @@ -6,7 +6,7 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -16,8 +16,9 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper -from ...._base_client import make_request_options -from ....types.alerting.destinations.pagerduty_get_response import PagerdutyGetResponse +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.alerting.destinations.pagerduty import Pagerduty from ....types.alerting.destinations.pagerduty_link_response import PagerdutyLinkResponse from ....types.alerting.destinations.pagerduty_create_response import PagerdutyCreateResponse from ....types.alerting.destinations.pagerduty_delete_response import PagerdutyDeleteResponse @@ -28,10 +29,21 @@ class PagerdutyResource(SyncAPIResource): @cached_property def with_raw_response(self) -> PagerdutyResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return PagerdutyResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> PagerdutyResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return PagerdutyResourceWithStreamingResponse(self) def create( @@ -43,7 +55,7 @@ def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PagerdutyCreateResponse]: """ Creates a new token for integrating with PagerDuty. @@ -82,7 +94,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PagerdutyDeleteResponse: """ Deletes all the PagerDuty Services connected to the account. @@ -117,8 +129,8 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PagerdutyGetResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[Pagerduty]: """ Get a list of all configured PagerDuty services. @@ -135,16 +147,13 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get( + return self._get_api_list( f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", + page=SyncSinglePage[Pagerduty], options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PagerdutyGetResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[PagerdutyGetResponse]], ResultWrapper[PagerdutyGetResponse]), + model=Pagerduty, ) def link( @@ -157,7 +166,7 @@ def link( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PagerdutyLinkResponse]: """ Links PagerDuty with the account using the integration token. @@ -195,10 +204,21 @@ def link( class AsyncPagerdutyResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncPagerdutyResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncPagerdutyResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncPagerdutyResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncPagerdutyResourceWithStreamingResponse(self) async def create( @@ -210,7 +230,7 @@ async def create( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PagerdutyCreateResponse]: """ Creates a new token for integrating with PagerDuty. @@ -249,7 +269,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PagerdutyDeleteResponse: """ Deletes all the PagerDuty Services connected to the account. @@ -275,7 +295,7 @@ async def delete( cast_to=PagerdutyDeleteResponse, ) - async def get( + def get( self, *, account_id: str, @@ -284,8 +304,8 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PagerdutyGetResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[Pagerduty, AsyncSinglePage[Pagerduty]]: """ Get a list of all configured PagerDuty services. @@ -302,16 +322,13 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._get( + return self._get_api_list( f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", + page=AsyncSinglePage[Pagerduty], options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PagerdutyGetResponse]]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=cast(Type[Optional[PagerdutyGetResponse]], ResultWrapper[PagerdutyGetResponse]), + model=Pagerduty, ) async def link( @@ -324,7 +341,7 @@ async def link( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PagerdutyLinkResponse]: """ Links PagerDuty with the account using the integration token. diff --git a/src/cloudflare/resources/alerting/destinations/webhooks.py b/src/cloudflare/resources/alerting/destinations/webhooks.py index 038ec887425..9a83705a4fd 100644 --- a/src/cloudflare/resources/alerting/destinations/webhooks.py +++ b/src/cloudflare/resources/alerting/destinations/webhooks.py @@ -6,11 +6,8 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -34,10 +31,21 @@ class WebhooksResource(SyncAPIResource): @cached_property def with_raw_response(self) -> WebhooksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return WebhooksResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> WebhooksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return WebhooksResourceWithStreamingResponse(self) def create( @@ -46,13 +54,13 @@ def create( account_id: str, name: str, url: str, - secret: str | NotGiven = NOT_GIVEN, + secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[WebhookCreateResponse]: """ Creates a new webhook destination. @@ -106,13 +114,13 @@ def update( account_id: str, name: str, url: str, - secret: str | NotGiven = NOT_GIVEN, + secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[WebhookUpdateResponse]: """ Update a webhook destination. @@ -172,7 +180,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[Webhooks]: """ Gets a list of all configured webhook destinations. @@ -209,7 +217,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WebhookDeleteResponse: """ Delete a configured webhook destination. @@ -249,7 +257,7 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Webhooks]: """ Get details for a single webhooks destination. @@ -287,10 +295,21 @@ def get( class AsyncWebhooksResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncWebhooksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncWebhooksResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncWebhooksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncWebhooksResourceWithStreamingResponse(self) async def create( @@ -299,13 +318,13 @@ async def create( account_id: str, name: str, url: str, - secret: str | NotGiven = NOT_GIVEN, + secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[WebhookCreateResponse]: """ Creates a new webhook destination. @@ -359,13 +378,13 @@ async def update( account_id: str, name: str, url: str, - secret: str | NotGiven = NOT_GIVEN, + secret: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[WebhookUpdateResponse]: """ Update a webhook destination. @@ -425,7 +444,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[Webhooks, AsyncSinglePage[Webhooks]]: """ Gets a list of all configured webhook destinations. @@ -462,7 +481,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WebhookDeleteResponse: """ Delete a configured webhook destination. @@ -502,7 +521,7 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Webhooks]: """ Get details for a single webhooks destination. diff --git a/src/cloudflare/resources/alerting/history.py b/src/cloudflare/resources/alerting/history.py index f36f2e6927e..8eee416174e 100644 --- a/src/cloudflare/resources/alerting/history.py +++ b/src/cloudflare/resources/alerting/history.py @@ -7,7 +7,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._utils import maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource @@ -28,26 +28,37 @@ class HistoryResource(SyncAPIResource): @cached_property def with_raw_response(self) -> HistoryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return HistoryResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> HistoryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return HistoryResourceWithStreamingResponse(self) def list( self, *, account_id: str, - before: Union[str, datetime] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - since: Union[str, datetime] | NotGiven = NOT_GIVEN, + before: Union[str, datetime] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + since: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[History]: """Gets a list of history records for notifications sent to an account. @@ -103,26 +114,37 @@ def list( class AsyncHistoryResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncHistoryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncHistoryResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncHistoryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncHistoryResourceWithStreamingResponse(self) def list( self, *, account_id: str, - before: Union[str, datetime] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - since: Union[str, datetime] | NotGiven = NOT_GIVEN, + before: Union[str, datetime] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + since: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[History, AsyncV4PagePaginationArray[History]]: """Gets a list of history records for notifications sent to an account. diff --git a/src/cloudflare/resources/alerting/policies.py b/src/cloudflare/resources/alerting/policies.py index d951b329903..8f8115ecd60 100644 --- a/src/cloudflare/resources/alerting/policies.py +++ b/src/cloudflare/resources/alerting/policies.py @@ -7,11 +7,8 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -37,10 +34,21 @@ class PoliciesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> PoliciesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return PoliciesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return PoliciesResourceWithStreamingResponse(self) def create( @@ -48,6 +56,7 @@ def create( *, account_id: str, alert_type: Literal[ + "abuse_report_alert", "access_custom_certificate_expiration_type", "advanced_ddos_attack_l4_alert", "advanced_ddos_attack_l7_alert", @@ -57,12 +66,17 @@ def create( "block_notification_block_removed", "block_notification_new_block", "block_notification_review_rejected", + "bot_traffic_basic_alert", "brand_protection_alert", "brand_protection_digest", "clickhouse_alert_fw_anomaly", "clickhouse_alert_fw_ent_anomaly", + "cloudforce_one_request_notification", + "custom_analytics", + "custom_bot_detection_alert", "custom_ssl_certificate_event_type", "dedicated_ssl_certificate_event_type", + "device_connectivity_anomaly_alert", "dos_attack_l4", "dos_attack_l7", "expiring_service_token_alert", @@ -74,11 +88,14 @@ def create( "hostname_aop_custom_certificate_expiration_type", "http_alert_edge_error", "http_alert_origin_error", + "image_notification", + "image_resizing_notification", "incident_alert", "load_balancing_health_alert", "load_balancing_pool_enablement_alert", "logo_match_alert", "magic_tunnel_health_check_event", + "magic_wan_tunnel_health", "maintenance_event_notification", "mtls_certificate_store_certificate_expiration_type", "pages_event_alert", @@ -93,10 +110,14 @@ def create( "scriptmonitor_alert_new_resources", "secondary_dns_all_primaries_failing", "secondary_dns_primaries_failing", + "secondary_dns_warning", "secondary_dns_zone_successfully_updated", "secondary_dns_zone_validation_warning", + "security_insights_alert", "sentinel_alert", "stream_live_notifications", + "synthetic_test_latency_alert", + "synthetic_test_low_availability_alert", "traffic_anomalies_alert", "tunnel_health_event", "tunnel_update_event", @@ -107,14 +128,15 @@ def create( enabled: bool, mechanisms: MechanismParam, name: str, - description: str | NotGiven = NOT_GIVEN, - filters: PolicyFilterParam | NotGiven = NOT_GIVEN, + alert_interval: str | Omit = omit, + description: str | Omit = omit, + filters: PolicyFilterParam | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PolicyCreateResponse]: """ Creates a new Notification policy. @@ -133,6 +155,9 @@ def create( name: Name of the policy. + alert_interval: Optional specification of how often to re-alert from the same incident, not + support on all alert types. + description: Optional description for the Notification policy. filters: Optional filters that allow you to be alerted only on a subset of events for @@ -157,6 +182,7 @@ def create( "enabled": enabled, "mechanisms": mechanisms, "name": name, + "alert_interval": alert_interval, "description": description, "filters": filters, }, @@ -177,7 +203,9 @@ def update( policy_id: str, *, account_id: str, + alert_interval: str | Omit = omit, alert_type: Literal[ + "abuse_report_alert", "access_custom_certificate_expiration_type", "advanced_ddos_attack_l4_alert", "advanced_ddos_attack_l7_alert", @@ -187,12 +215,17 @@ def update( "block_notification_block_removed", "block_notification_new_block", "block_notification_review_rejected", + "bot_traffic_basic_alert", "brand_protection_alert", "brand_protection_digest", "clickhouse_alert_fw_anomaly", "clickhouse_alert_fw_ent_anomaly", + "cloudforce_one_request_notification", + "custom_analytics", + "custom_bot_detection_alert", "custom_ssl_certificate_event_type", "dedicated_ssl_certificate_event_type", + "device_connectivity_anomaly_alert", "dos_attack_l4", "dos_attack_l7", "expiring_service_token_alert", @@ -204,11 +237,14 @@ def update( "hostname_aop_custom_certificate_expiration_type", "http_alert_edge_error", "http_alert_origin_error", + "image_notification", + "image_resizing_notification", "incident_alert", "load_balancing_health_alert", "load_balancing_pool_enablement_alert", "logo_match_alert", "magic_tunnel_health_check_event", + "magic_wan_tunnel_health", "maintenance_event_notification", "mtls_certificate_store_certificate_expiration_type", "pages_event_alert", @@ -223,10 +259,14 @@ def update( "scriptmonitor_alert_new_resources", "secondary_dns_all_primaries_failing", "secondary_dns_primaries_failing", + "secondary_dns_warning", "secondary_dns_zone_successfully_updated", "secondary_dns_zone_validation_warning", + "security_insights_alert", "sentinel_alert", "stream_live_notifications", + "synthetic_test_latency_alert", + "synthetic_test_low_availability_alert", "traffic_anomalies_alert", "tunnel_health_event", "tunnel_update_event", @@ -234,18 +274,18 @@ def update( "web_analytics_metrics_update", "zone_aop_custom_certificate_expiration_type", ] - | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - filters: PolicyFilterParam | NotGiven = NOT_GIVEN, - mechanisms: MechanismParam | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + filters: PolicyFilterParam | Omit = omit, + mechanisms: MechanismParam | Omit = omit, + name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PolicyUpdateResponse]: """ Update a Notification policy. @@ -255,6 +295,9 @@ def update( policy_id: The unique identifier of a notification policy + alert_interval: Optional specification of how often to re-alert from the same incident, not + support on all alert types. + alert_type: Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values. @@ -288,6 +331,7 @@ def update( f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", body=maybe_transform( { + "alert_interval": alert_interval, "alert_type": alert_type, "description": description, "enabled": enabled, @@ -316,7 +360,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[Policy]: """ Get a list of all Notification policies. @@ -353,7 +397,7 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PolicyDeleteResponse: """ Delete a Notification policy. @@ -393,7 +437,7 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Policy]: """ Get details for a single policy. @@ -431,10 +475,21 @@ def get( class AsyncPoliciesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncPoliciesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncPoliciesResourceWithStreamingResponse(self) async def create( @@ -442,6 +497,7 @@ async def create( *, account_id: str, alert_type: Literal[ + "abuse_report_alert", "access_custom_certificate_expiration_type", "advanced_ddos_attack_l4_alert", "advanced_ddos_attack_l7_alert", @@ -451,12 +507,17 @@ async def create( "block_notification_block_removed", "block_notification_new_block", "block_notification_review_rejected", + "bot_traffic_basic_alert", "brand_protection_alert", "brand_protection_digest", "clickhouse_alert_fw_anomaly", "clickhouse_alert_fw_ent_anomaly", + "cloudforce_one_request_notification", + "custom_analytics", + "custom_bot_detection_alert", "custom_ssl_certificate_event_type", "dedicated_ssl_certificate_event_type", + "device_connectivity_anomaly_alert", "dos_attack_l4", "dos_attack_l7", "expiring_service_token_alert", @@ -468,11 +529,14 @@ async def create( "hostname_aop_custom_certificate_expiration_type", "http_alert_edge_error", "http_alert_origin_error", + "image_notification", + "image_resizing_notification", "incident_alert", "load_balancing_health_alert", "load_balancing_pool_enablement_alert", "logo_match_alert", "magic_tunnel_health_check_event", + "magic_wan_tunnel_health", "maintenance_event_notification", "mtls_certificate_store_certificate_expiration_type", "pages_event_alert", @@ -487,10 +551,14 @@ async def create( "scriptmonitor_alert_new_resources", "secondary_dns_all_primaries_failing", "secondary_dns_primaries_failing", + "secondary_dns_warning", "secondary_dns_zone_successfully_updated", "secondary_dns_zone_validation_warning", + "security_insights_alert", "sentinel_alert", "stream_live_notifications", + "synthetic_test_latency_alert", + "synthetic_test_low_availability_alert", "traffic_anomalies_alert", "tunnel_health_event", "tunnel_update_event", @@ -501,14 +569,15 @@ async def create( enabled: bool, mechanisms: MechanismParam, name: str, - description: str | NotGiven = NOT_GIVEN, - filters: PolicyFilterParam | NotGiven = NOT_GIVEN, + alert_interval: str | Omit = omit, + description: str | Omit = omit, + filters: PolicyFilterParam | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PolicyCreateResponse]: """ Creates a new Notification policy. @@ -527,6 +596,9 @@ async def create( name: Name of the policy. + alert_interval: Optional specification of how often to re-alert from the same incident, not + support on all alert types. + description: Optional description for the Notification policy. filters: Optional filters that allow you to be alerted only on a subset of events for @@ -551,6 +623,7 @@ async def create( "enabled": enabled, "mechanisms": mechanisms, "name": name, + "alert_interval": alert_interval, "description": description, "filters": filters, }, @@ -571,7 +644,9 @@ async def update( policy_id: str, *, account_id: str, + alert_interval: str | Omit = omit, alert_type: Literal[ + "abuse_report_alert", "access_custom_certificate_expiration_type", "advanced_ddos_attack_l4_alert", "advanced_ddos_attack_l7_alert", @@ -581,12 +656,17 @@ async def update( "block_notification_block_removed", "block_notification_new_block", "block_notification_review_rejected", + "bot_traffic_basic_alert", "brand_protection_alert", "brand_protection_digest", "clickhouse_alert_fw_anomaly", "clickhouse_alert_fw_ent_anomaly", + "cloudforce_one_request_notification", + "custom_analytics", + "custom_bot_detection_alert", "custom_ssl_certificate_event_type", "dedicated_ssl_certificate_event_type", + "device_connectivity_anomaly_alert", "dos_attack_l4", "dos_attack_l7", "expiring_service_token_alert", @@ -598,11 +678,14 @@ async def update( "hostname_aop_custom_certificate_expiration_type", "http_alert_edge_error", "http_alert_origin_error", + "image_notification", + "image_resizing_notification", "incident_alert", "load_balancing_health_alert", "load_balancing_pool_enablement_alert", "logo_match_alert", "magic_tunnel_health_check_event", + "magic_wan_tunnel_health", "maintenance_event_notification", "mtls_certificate_store_certificate_expiration_type", "pages_event_alert", @@ -617,10 +700,14 @@ async def update( "scriptmonitor_alert_new_resources", "secondary_dns_all_primaries_failing", "secondary_dns_primaries_failing", + "secondary_dns_warning", "secondary_dns_zone_successfully_updated", "secondary_dns_zone_validation_warning", + "security_insights_alert", "sentinel_alert", "stream_live_notifications", + "synthetic_test_latency_alert", + "synthetic_test_low_availability_alert", "traffic_anomalies_alert", "tunnel_health_event", "tunnel_update_event", @@ -628,18 +715,18 @@ async def update( "web_analytics_metrics_update", "zone_aop_custom_certificate_expiration_type", ] - | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - filters: PolicyFilterParam | NotGiven = NOT_GIVEN, - mechanisms: MechanismParam | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, + | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + filters: PolicyFilterParam | Omit = omit, + mechanisms: MechanismParam | Omit = omit, + name: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[PolicyUpdateResponse]: """ Update a Notification policy. @@ -649,6 +736,9 @@ async def update( policy_id: The unique identifier of a notification policy + alert_interval: Optional specification of how often to re-alert from the same incident, not + support on all alert types. + alert_type: Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values. @@ -682,6 +772,7 @@ async def update( f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", body=await async_maybe_transform( { + "alert_interval": alert_interval, "alert_type": alert_type, "description": description, "enabled": enabled, @@ -710,7 +801,7 @@ def list( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[Policy, AsyncSinglePage[Policy]]: """ Get a list of all Notification policies. @@ -747,7 +838,7 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PolicyDeleteResponse: """ Delete a Notification policy. @@ -787,7 +878,7 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[Policy]: """ Get details for a single policy. diff --git a/src/cloudflare/resources/alerting/silences.py b/src/cloudflare/resources/alerting/silences.py new file mode 100644 index 00000000000..a024012b058 --- /dev/null +++ b/src/cloudflare/resources/alerting/silences.py @@ -0,0 +1,547 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import AsyncPaginator, make_request_options +from ...types.alerting import silence_create_params, silence_update_params +from ...types.alerting.silence_get_response import SilenceGetResponse +from ...types.alerting.silence_list_response import SilenceListResponse +from ...types.alerting.silence_create_response import SilenceCreateResponse +from ...types.alerting.silence_delete_response import SilenceDeleteResponse +from ...types.alerting.silence_update_response import SilenceUpdateResponse + +__all__ = ["SilencesResource", "AsyncSilencesResource"] + + +class SilencesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SilencesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return SilencesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SilencesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return SilencesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + body: Iterable[silence_create_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SilenceCreateResponse: + """ + Creates a new silence for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/alerting/v3/silences", + body=maybe_transform(body, Iterable[silence_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SilenceCreateResponse, + ) + + def update( + self, + *, + account_id: str, + body: Iterable[silence_update_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[SilenceUpdateResponse]: + """ + Updates existing silences for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/alerting/v3/silences", + page=SyncSinglePage[SilenceUpdateResponse], + body=maybe_transform(body, Iterable[silence_update_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SilenceUpdateResponse, + method="put", + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[SilenceListResponse]: + """ + Gets a list of silences for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/alerting/v3/silences", + page=SyncSinglePage[SilenceListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SilenceListResponse, + ) + + def delete( + self, + silence_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SilenceDeleteResponse: + """ + Deletes an existing silence for an account. + + Args: + account_id: The account id + + silence_id: Silence ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not silence_id: + raise ValueError(f"Expected a non-empty value for `silence_id` but received {silence_id!r}") + return self._delete( + f"/accounts/{account_id}/alerting/v3/silences/{silence_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SilenceDeleteResponse, + ) + + def get( + self, + silence_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[SilenceGetResponse]: + """ + Gets a specific silence for an account. + + Args: + account_id: The account id + + silence_id: Silence ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not silence_id: + raise ValueError(f"Expected a non-empty value for `silence_id` but received {silence_id!r}") + return self._get( + f"/accounts/{account_id}/alerting/v3/silences/{silence_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SilenceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SilenceGetResponse]], ResultWrapper[SilenceGetResponse]), + ) + + +class AsyncSilencesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSilencesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncSilencesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSilencesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncSilencesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + body: Iterable[silence_create_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SilenceCreateResponse: + """ + Creates a new silence for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/alerting/v3/silences", + body=await async_maybe_transform(body, Iterable[silence_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SilenceCreateResponse, + ) + + def update( + self, + *, + account_id: str, + body: Iterable[silence_update_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[SilenceUpdateResponse, AsyncSinglePage[SilenceUpdateResponse]]: + """ + Updates existing silences for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/alerting/v3/silences", + page=AsyncSinglePage[SilenceUpdateResponse], + body=maybe_transform(body, Iterable[silence_update_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SilenceUpdateResponse, + method="put", + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[SilenceListResponse, AsyncSinglePage[SilenceListResponse]]: + """ + Gets a list of silences for an account. + + Args: + account_id: The account id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/alerting/v3/silences", + page=AsyncSinglePage[SilenceListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SilenceListResponse, + ) + + async def delete( + self, + silence_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SilenceDeleteResponse: + """ + Deletes an existing silence for an account. + + Args: + account_id: The account id + + silence_id: Silence ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not silence_id: + raise ValueError(f"Expected a non-empty value for `silence_id` but received {silence_id!r}") + return await self._delete( + f"/accounts/{account_id}/alerting/v3/silences/{silence_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SilenceDeleteResponse, + ) + + async def get( + self, + silence_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[SilenceGetResponse]: + """ + Gets a specific silence for an account. + + Args: + account_id: The account id + + silence_id: Silence ID + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not silence_id: + raise ValueError(f"Expected a non-empty value for `silence_id` but received {silence_id!r}") + return await self._get( + f"/accounts/{account_id}/alerting/v3/silences/{silence_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SilenceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SilenceGetResponse]], ResultWrapper[SilenceGetResponse]), + ) + + +class SilencesResourceWithRawResponse: + def __init__(self, silences: SilencesResource) -> None: + self._silences = silences + + self.create = to_raw_response_wrapper( + silences.create, + ) + self.update = to_raw_response_wrapper( + silences.update, + ) + self.list = to_raw_response_wrapper( + silences.list, + ) + self.delete = to_raw_response_wrapper( + silences.delete, + ) + self.get = to_raw_response_wrapper( + silences.get, + ) + + +class AsyncSilencesResourceWithRawResponse: + def __init__(self, silences: AsyncSilencesResource) -> None: + self._silences = silences + + self.create = async_to_raw_response_wrapper( + silences.create, + ) + self.update = async_to_raw_response_wrapper( + silences.update, + ) + self.list = async_to_raw_response_wrapper( + silences.list, + ) + self.delete = async_to_raw_response_wrapper( + silences.delete, + ) + self.get = async_to_raw_response_wrapper( + silences.get, + ) + + +class SilencesResourceWithStreamingResponse: + def __init__(self, silences: SilencesResource) -> None: + self._silences = silences + + self.create = to_streamed_response_wrapper( + silences.create, + ) + self.update = to_streamed_response_wrapper( + silences.update, + ) + self.list = to_streamed_response_wrapper( + silences.list, + ) + self.delete = to_streamed_response_wrapper( + silences.delete, + ) + self.get = to_streamed_response_wrapper( + silences.get, + ) + + +class AsyncSilencesResourceWithStreamingResponse: + def __init__(self, silences: AsyncSilencesResource) -> None: + self._silences = silences + + self.create = async_to_streamed_response_wrapper( + silences.create, + ) + self.update = async_to_streamed_response_wrapper( + silences.update, + ) + self.list = async_to_streamed_response_wrapper( + silences.list, + ) + self.delete = async_to_streamed_response_wrapper( + silences.delete, + ) + self.get = async_to_streamed_response_wrapper( + silences.get, + ) diff --git a/src/cloudflare/resources/api_gateway/__init__.py b/src/cloudflare/resources/api_gateway/__init__.py index c92d2837cfb..c93926a6412 100644 --- a/src/cloudflare/resources/api_gateway/__init__.py +++ b/src/cloudflare/resources/api_gateway/__init__.py @@ -56,6 +56,14 @@ ConfigurationsResourceWithStreamingResponse, AsyncConfigurationsResourceWithStreamingResponse, ) +from .expression_template import ( + ExpressionTemplateResource, + AsyncExpressionTemplateResource, + ExpressionTemplateResourceWithRawResponse, + AsyncExpressionTemplateResourceWithRawResponse, + ExpressionTemplateResourceWithStreamingResponse, + AsyncExpressionTemplateResourceWithStreamingResponse, +) __all__ = [ "ConfigurationsResource", @@ -94,6 +102,12 @@ "AsyncUserSchemasResourceWithRawResponse", "UserSchemasResourceWithStreamingResponse", "AsyncUserSchemasResourceWithStreamingResponse", + "ExpressionTemplateResource", + "AsyncExpressionTemplateResource", + "ExpressionTemplateResourceWithRawResponse", + "AsyncExpressionTemplateResourceWithRawResponse", + "ExpressionTemplateResourceWithStreamingResponse", + "AsyncExpressionTemplateResourceWithStreamingResponse", "APIGatewayResource", "AsyncAPIGatewayResource", "APIGatewayResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/api_gateway.py b/src/cloudflare/resources/api_gateway/api_gateway.py index 5df1917d66b..70917610f7d 100644 --- a/src/cloudflare/resources/api_gateway/api_gateway.py +++ b/src/cloudflare/resources/api_gateway/api_gateway.py @@ -10,7 +10,17 @@ SchemasResourceWithStreamingResponse, AsyncSchemasResourceWithStreamingResponse, ) -from .settings import ( +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .configurations import ( + ConfigurationsResource, + AsyncConfigurationsResource, + ConfigurationsResourceWithRawResponse, + AsyncConfigurationsResourceWithRawResponse, + ConfigurationsResourceWithStreamingResponse, + AsyncConfigurationsResourceWithStreamingResponse, +) +from .settings.settings import ( SettingsResource, AsyncSettingsResource, SettingsResourceWithRawResponse, @@ -18,8 +28,7 @@ SettingsResourceWithStreamingResponse, AsyncSettingsResourceWithStreamingResponse, ) -from ..._compat import cached_property -from .discovery import ( +from .discovery.discovery import ( DiscoveryResource, AsyncDiscoveryResource, DiscoveryResourceWithRawResponse, @@ -27,7 +36,7 @@ DiscoveryResourceWithStreamingResponse, AsyncDiscoveryResourceWithStreamingResponse, ) -from .operations import ( +from .operations.operations import ( OperationsResource, AsyncOperationsResource, OperationsResourceWithRawResponse, @@ -35,8 +44,7 @@ OperationsResourceWithStreamingResponse, AsyncOperationsResourceWithStreamingResponse, ) -from ..._resource import SyncAPIResource, AsyncAPIResource -from .user_schemas import ( +from .user_schemas.user_schemas import ( UserSchemasResource, AsyncUserSchemasResource, UserSchemasResourceWithRawResponse, @@ -44,18 +52,14 @@ UserSchemasResourceWithStreamingResponse, AsyncUserSchemasResourceWithStreamingResponse, ) -from .configurations import ( - ConfigurationsResource, - AsyncConfigurationsResource, - ConfigurationsResourceWithRawResponse, - AsyncConfigurationsResourceWithRawResponse, - ConfigurationsResourceWithStreamingResponse, - AsyncConfigurationsResourceWithStreamingResponse, +from .expression_template.expression_template import ( + ExpressionTemplateResource, + AsyncExpressionTemplateResource, + ExpressionTemplateResourceWithRawResponse, + AsyncExpressionTemplateResourceWithRawResponse, + ExpressionTemplateResourceWithStreamingResponse, + AsyncExpressionTemplateResourceWithStreamingResponse, ) -from .settings.settings import SettingsResource, AsyncSettingsResource -from .discovery.discovery import DiscoveryResource, AsyncDiscoveryResource -from .operations.operations import OperationsResource, AsyncOperationsResource -from .user_schemas.user_schemas import UserSchemasResource, AsyncUserSchemasResource __all__ = ["APIGatewayResource", "AsyncAPIGatewayResource"] @@ -85,12 +89,27 @@ def settings(self) -> SettingsResource: def user_schemas(self) -> UserSchemasResource: return UserSchemasResource(self._client) + @cached_property + def expression_template(self) -> ExpressionTemplateResource: + return ExpressionTemplateResource(self._client) + @cached_property def with_raw_response(self) -> APIGatewayResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return APIGatewayResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> APIGatewayResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return APIGatewayResourceWithStreamingResponse(self) @@ -119,12 +138,27 @@ def settings(self) -> AsyncSettingsResource: def user_schemas(self) -> AsyncUserSchemasResource: return AsyncUserSchemasResource(self._client) + @cached_property + def expression_template(self) -> AsyncExpressionTemplateResource: + return AsyncExpressionTemplateResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAPIGatewayResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAPIGatewayResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAPIGatewayResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAPIGatewayResourceWithStreamingResponse(self) @@ -156,6 +190,10 @@ def settings(self) -> SettingsResourceWithRawResponse: def user_schemas(self) -> UserSchemasResourceWithRawResponse: return UserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) + @cached_property + def expression_template(self) -> ExpressionTemplateResourceWithRawResponse: + return ExpressionTemplateResourceWithRawResponse(self._api_gateway.expression_template) + class AsyncAPIGatewayResourceWithRawResponse: def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: @@ -185,6 +223,10 @@ def settings(self) -> AsyncSettingsResourceWithRawResponse: def user_schemas(self) -> AsyncUserSchemasResourceWithRawResponse: return AsyncUserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) + @cached_property + def expression_template(self) -> AsyncExpressionTemplateResourceWithRawResponse: + return AsyncExpressionTemplateResourceWithRawResponse(self._api_gateway.expression_template) + class APIGatewayResourceWithStreamingResponse: def __init__(self, api_gateway: APIGatewayResource) -> None: @@ -214,6 +256,10 @@ def settings(self) -> SettingsResourceWithStreamingResponse: def user_schemas(self) -> UserSchemasResourceWithStreamingResponse: return UserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) + @cached_property + def expression_template(self) -> ExpressionTemplateResourceWithStreamingResponse: + return ExpressionTemplateResourceWithStreamingResponse(self._api_gateway.expression_template) + class AsyncAPIGatewayResourceWithStreamingResponse: def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: @@ -242,3 +288,7 @@ def settings(self) -> AsyncSettingsResourceWithStreamingResponse: @cached_property def user_schemas(self) -> AsyncUserSchemasResourceWithStreamingResponse: return AsyncUserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) + + @cached_property + def expression_template(self) -> AsyncExpressionTemplateResourceWithStreamingResponse: + return AsyncExpressionTemplateResourceWithStreamingResponse(self._api_gateway.expression_template) diff --git a/src/cloudflare/resources/api_gateway/configurations.py b/src/cloudflare/resources/api_gateway/configurations.py index efa78c99742..96cebe13223 100644 --- a/src/cloudflare/resources/api_gateway/configurations.py +++ b/src/cloudflare/resources/api_gateway/configurations.py @@ -2,16 +2,12 @@ from __future__ import annotations -from typing import List, Type, Iterable, cast -from typing_extensions import Literal +from typing import Type, Iterable, cast import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -24,7 +20,6 @@ from ..._base_client import make_request_options from ...types.api_gateway import configuration_get_params, configuration_update_params from ...types.api_gateway.configuration import Configuration -from ...types.api_gateway.configuration_update_response import ConfigurationUpdateResponse __all__ = ["ConfigurationsResource", "AsyncConfigurationsResource"] @@ -32,10 +27,21 @@ class ConfigurationsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ConfigurationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ConfigurationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ConfigurationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ConfigurationsResourceWithStreamingResponse(self) def update( @@ -43,18 +49,21 @@ def update( *, zone_id: str, auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic], + normalize: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ConfigurationUpdateResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Configuration: """ - Set configuration properties + Update configuration properties Args: - zone_id: Identifier + zone_id: Identifier. + + normalize: Ensures that the configuration is written or retrieved in normalized fashion extra_headers: Send extra headers @@ -73,30 +82,35 @@ def update( configuration_update_params.ConfigurationUpdateParams, ), options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"normalize": normalize}, configuration_update_params.ConfigurationUpdateParams), + post_parser=ResultWrapper[Configuration]._unwrapper, ), - cast_to=ConfigurationUpdateResponse, + cast_to=cast(Type[Configuration], ResultWrapper[Configuration]), ) def get( self, *, zone_id: str, - properties: List[Literal["auth_id_characteristics"]] | NotGiven = NOT_GIVEN, + normalize: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ Retrieve information about specific configuration properties Args: - zone_id: Identifier + zone_id: Identifier. - properties: Requests information about certain properties. + normalize: Ensures that the configuration is written or retrieved in normalized fashion extra_headers: Send extra headers @@ -115,7 +129,7 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform({"properties": properties}, configuration_get_params.ConfigurationGetParams), + query=maybe_transform({"normalize": normalize}, configuration_get_params.ConfigurationGetParams), post_parser=ResultWrapper[Configuration]._unwrapper, ), cast_to=cast(Type[Configuration], ResultWrapper[Configuration]), @@ -125,10 +139,21 @@ def get( class AsyncConfigurationsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncConfigurationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncConfigurationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncConfigurationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncConfigurationsResourceWithStreamingResponse(self) async def update( @@ -136,18 +161,21 @@ async def update( *, zone_id: str, auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic], + normalize: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ConfigurationUpdateResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Configuration: """ - Set configuration properties + Update configuration properties Args: - zone_id: Identifier + zone_id: Identifier. + + normalize: Ensures that the configuration is written or retrieved in normalized fashion extra_headers: Send extra headers @@ -166,30 +194,37 @@ async def update( configuration_update_params.ConfigurationUpdateParams, ), options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"normalize": normalize}, configuration_update_params.ConfigurationUpdateParams + ), + post_parser=ResultWrapper[Configuration]._unwrapper, ), - cast_to=ConfigurationUpdateResponse, + cast_to=cast(Type[Configuration], ResultWrapper[Configuration]), ) async def get( self, *, zone_id: str, - properties: List[Literal["auth_id_characteristics"]] | NotGiven = NOT_GIVEN, + normalize: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ Retrieve information about specific configuration properties Args: - zone_id: Identifier + zone_id: Identifier. - properties: Requests information about certain properties. + normalize: Ensures that the configuration is written or retrieved in normalized fashion extra_headers: Send extra headers @@ -209,7 +244,7 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( - {"properties": properties}, configuration_get_params.ConfigurationGetParams + {"normalize": normalize}, configuration_get_params.ConfigurationGetParams ), post_parser=ResultWrapper[Configuration]._unwrapper, ), diff --git a/src/cloudflare/resources/api_gateway/discovery/discovery.py b/src/cloudflare/resources/api_gateway/discovery/discovery.py index 9decd5b422c..a465c6fc4a9 100644 --- a/src/cloudflare/resources/api_gateway/discovery/discovery.py +++ b/src/cloudflare/resources/api_gateway/discovery/discovery.py @@ -6,7 +6,7 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from .operations import ( OperationsResource, @@ -37,10 +37,21 @@ def operations(self) -> OperationsResource: @cached_property def with_raw_response(self) -> DiscoveryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return DiscoveryResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> DiscoveryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return DiscoveryResourceWithStreamingResponse(self) def get( @@ -52,14 +63,14 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DiscoveryGetResponse: """ Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -91,10 +102,21 @@ def operations(self) -> AsyncOperationsResource: @cached_property def with_raw_response(self) -> AsyncDiscoveryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncDiscoveryResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncDiscoveryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncDiscoveryResourceWithStreamingResponse(self) async def get( @@ -106,14 +128,14 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DiscoveryGetResponse: """ Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/api_gateway/discovery/operations.py b/src/cloudflare/resources/api_gateway/discovery/operations.py index 4f7fb29a475..76aeb31fde9 100644 --- a/src/cloudflare/resources/api_gateway/discovery/operations.py +++ b/src/cloudflare/resources/api_gateway/discovery/operations.py @@ -2,16 +2,13 @@ from __future__ import annotations -from typing import List, Type, cast +from typing import Dict, Type, cast from typing_extensions import Literal import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -23,9 +20,10 @@ from ...._wrappers import ResultWrapper from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options -from ....types.api_gateway.discovery import operation_edit_params, operation_list_params +from ....types.api_gateway.discovery import operation_edit_params, operation_list_params, operation_bulk_edit_params from ....types.api_gateway.discovery_operation import DiscoveryOperation from ....types.api_gateway.discovery.operation_edit_response import OperationEditResponse +from ....types.api_gateway.discovery.operation_bulk_edit_response import OperationBulkEditResponse __all__ = ["OperationsResource", "AsyncOperationsResource"] @@ -33,39 +31,50 @@ class OperationsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> OperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return OperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return OperationsResourceWithStreamingResponse(self) def list( self, *, zone_id: str, - diff: bool | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - endpoint: str | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, + diff: bool | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + endpoint: str | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] - | NotGiven = NOT_GIVEN, - origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - state: Literal["review", "saved", "ignored"] | NotGiven = NOT_GIVEN, + | Omit = omit, + origin: Literal["ML", "SessionIdentifier", "LabelDiscovery"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + state: Literal["review", "saved", "ignored"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[DiscoveryOperation]: """ Retrieve the most up to date view of discovered operations Args: - zone_id: Identifier + zone_id: Identifier. diff: When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management @@ -137,26 +146,67 @@ def list( model=DiscoveryOperation, ) + def bulk_edit( + self, + *, + zone_id: str, + body: Dict[str, operation_bulk_edit_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationBulkEditResponse: + """ + Update the `state` on one or more discovered operations + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/discovery/operations", + body=maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationBulkEditResponse]._unwrapper, + ), + cast_to=cast(Type[OperationBulkEditResponse], ResultWrapper[OperationBulkEditResponse]), + ) + def edit( self, operation_id: str, *, zone_id: str, - state: Literal["review", "ignored"] | NotGiven = NOT_GIVEN, + state: Literal["review", "ignored"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationEditResponse: """ Update the `state` on a discovered operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. state: Mark state of operation in API Discovery @@ -192,39 +242,50 @@ def edit( class AsyncOperationsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncOperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncOperationsResourceWithStreamingResponse(self) def list( self, *, zone_id: str, - diff: bool | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - endpoint: str | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, + diff: bool | Omit = omit, + direction: Literal["asc", "desc"] | Omit = omit, + endpoint: str | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] - | NotGiven = NOT_GIVEN, - origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - state: Literal["review", "saved", "ignored"] | NotGiven = NOT_GIVEN, + | Omit = omit, + origin: Literal["ML", "SessionIdentifier", "LabelDiscovery"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + state: Literal["review", "saved", "ignored"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[DiscoveryOperation, AsyncV4PagePaginationArray[DiscoveryOperation]]: """ Retrieve the most up to date view of discovered operations Args: - zone_id: Identifier + zone_id: Identifier. diff: When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management @@ -296,26 +357,67 @@ def list( model=DiscoveryOperation, ) + async def bulk_edit( + self, + *, + zone_id: str, + body: Dict[str, operation_bulk_edit_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationBulkEditResponse: + """ + Update the `state` on one or more discovered operations + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/discovery/operations", + body=await async_maybe_transform(body, operation_bulk_edit_params.OperationBulkEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationBulkEditResponse]._unwrapper, + ), + cast_to=cast(Type[OperationBulkEditResponse], ResultWrapper[OperationBulkEditResponse]), + ) + async def edit( self, operation_id: str, *, zone_id: str, - state: Literal["review", "ignored"] | NotGiven = NOT_GIVEN, + state: Literal["review", "ignored"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationEditResponse: """ Update the `state` on a discovered operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. state: Mark state of operation in API Discovery @@ -355,6 +457,9 @@ def __init__(self, operations: OperationsResource) -> None: self.list = to_raw_response_wrapper( operations.list, ) + self.bulk_edit = to_raw_response_wrapper( + operations.bulk_edit, + ) self.edit = to_raw_response_wrapper( operations.edit, ) @@ -367,6 +472,9 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.list = async_to_raw_response_wrapper( operations.list, ) + self.bulk_edit = async_to_raw_response_wrapper( + operations.bulk_edit, + ) self.edit = async_to_raw_response_wrapper( operations.edit, ) @@ -379,6 +487,9 @@ def __init__(self, operations: OperationsResource) -> None: self.list = to_streamed_response_wrapper( operations.list, ) + self.bulk_edit = to_streamed_response_wrapper( + operations.bulk_edit, + ) self.edit = to_streamed_response_wrapper( operations.edit, ) @@ -391,6 +502,9 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.list = async_to_streamed_response_wrapper( operations.list, ) + self.bulk_edit = async_to_streamed_response_wrapper( + operations.bulk_edit, + ) self.edit = async_to_streamed_response_wrapper( operations.edit, ) diff --git a/src/cloudflare/resources/api_gateway/expression_template/__init__.py b/src/cloudflare/resources/api_gateway/expression_template/__init__.py new file mode 100644 index 00000000000..40499a81369 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/expression_template/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .fallthrough import ( + FallthroughResource, + AsyncFallthroughResource, + FallthroughResourceWithRawResponse, + AsyncFallthroughResourceWithRawResponse, + FallthroughResourceWithStreamingResponse, + AsyncFallthroughResourceWithStreamingResponse, +) +from .expression_template import ( + ExpressionTemplateResource, + AsyncExpressionTemplateResource, + ExpressionTemplateResourceWithRawResponse, + AsyncExpressionTemplateResourceWithRawResponse, + ExpressionTemplateResourceWithStreamingResponse, + AsyncExpressionTemplateResourceWithStreamingResponse, +) + +__all__ = [ + "FallthroughResource", + "AsyncFallthroughResource", + "FallthroughResourceWithRawResponse", + "AsyncFallthroughResourceWithRawResponse", + "FallthroughResourceWithStreamingResponse", + "AsyncFallthroughResourceWithStreamingResponse", + "ExpressionTemplateResource", + "AsyncExpressionTemplateResource", + "ExpressionTemplateResourceWithRawResponse", + "AsyncExpressionTemplateResourceWithRawResponse", + "ExpressionTemplateResourceWithStreamingResponse", + "AsyncExpressionTemplateResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/expression_template/expression_template.py b/src/cloudflare/resources/api_gateway/expression_template/expression_template.py new file mode 100644 index 00000000000..e5173f78539 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/expression_template/expression_template.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ...._compat import cached_property +from .fallthrough import ( + FallthroughResource, + AsyncFallthroughResource, + FallthroughResourceWithRawResponse, + AsyncFallthroughResourceWithRawResponse, + FallthroughResourceWithStreamingResponse, + AsyncFallthroughResourceWithStreamingResponse, +) +from ...._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["ExpressionTemplateResource", "AsyncExpressionTemplateResource"] + + +class ExpressionTemplateResource(SyncAPIResource): + @cached_property + def fallthrough(self) -> FallthroughResource: + return FallthroughResource(self._client) + + @cached_property + def with_raw_response(self) -> ExpressionTemplateResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ExpressionTemplateResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ExpressionTemplateResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ExpressionTemplateResourceWithStreamingResponse(self) + + +class AsyncExpressionTemplateResource(AsyncAPIResource): + @cached_property + def fallthrough(self) -> AsyncFallthroughResource: + return AsyncFallthroughResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncExpressionTemplateResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncExpressionTemplateResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncExpressionTemplateResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncExpressionTemplateResourceWithStreamingResponse(self) + + +class ExpressionTemplateResourceWithRawResponse: + def __init__(self, expression_template: ExpressionTemplateResource) -> None: + self._expression_template = expression_template + + @cached_property + def fallthrough(self) -> FallthroughResourceWithRawResponse: + return FallthroughResourceWithRawResponse(self._expression_template.fallthrough) + + +class AsyncExpressionTemplateResourceWithRawResponse: + def __init__(self, expression_template: AsyncExpressionTemplateResource) -> None: + self._expression_template = expression_template + + @cached_property + def fallthrough(self) -> AsyncFallthroughResourceWithRawResponse: + return AsyncFallthroughResourceWithRawResponse(self._expression_template.fallthrough) + + +class ExpressionTemplateResourceWithStreamingResponse: + def __init__(self, expression_template: ExpressionTemplateResource) -> None: + self._expression_template = expression_template + + @cached_property + def fallthrough(self) -> FallthroughResourceWithStreamingResponse: + return FallthroughResourceWithStreamingResponse(self._expression_template.fallthrough) + + +class AsyncExpressionTemplateResourceWithStreamingResponse: + def __init__(self, expression_template: AsyncExpressionTemplateResource) -> None: + self._expression_template = expression_template + + @cached_property + def fallthrough(self) -> AsyncFallthroughResourceWithStreamingResponse: + return AsyncFallthroughResourceWithStreamingResponse(self._expression_template.fallthrough) diff --git a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py new file mode 100644 index 00000000000..1434470cfad --- /dev/null +++ b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py @@ -0,0 +1,188 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.api_gateway.expression_template import fallthrough_create_params +from ....types.api_gateway.expression_template.fallthrough_create_response import FallthroughCreateResponse + +__all__ = ["FallthroughResource", "AsyncFallthroughResource"] + + +class FallthroughResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FallthroughResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return FallthroughResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FallthroughResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return FallthroughResourceWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + hosts: SequenceNotStr[str], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FallthroughCreateResponse: + """ + Generate fallthrough WAF expression template from a set of API hosts + + Args: + zone_id: Identifier. + + hosts: List of hosts to be targeted in the expression + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/api_gateway/expression-template/fallthrough", + body=maybe_transform({"hosts": hosts}, fallthrough_create_params.FallthroughCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FallthroughCreateResponse]._unwrapper, + ), + cast_to=cast(Type[FallthroughCreateResponse], ResultWrapper[FallthroughCreateResponse]), + ) + + +class AsyncFallthroughResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFallthroughResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncFallthroughResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFallthroughResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncFallthroughResourceWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + hosts: SequenceNotStr[str], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FallthroughCreateResponse: + """ + Generate fallthrough WAF expression template from a set of API hosts + + Args: + zone_id: Identifier. + + hosts: List of hosts to be targeted in the expression + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/api_gateway/expression-template/fallthrough", + body=await async_maybe_transform({"hosts": hosts}, fallthrough_create_params.FallthroughCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[FallthroughCreateResponse]._unwrapper, + ), + cast_to=cast(Type[FallthroughCreateResponse], ResultWrapper[FallthroughCreateResponse]), + ) + + +class FallthroughResourceWithRawResponse: + def __init__(self, fallthrough: FallthroughResource) -> None: + self._fallthrough = fallthrough + + self.create = to_raw_response_wrapper( + fallthrough.create, + ) + + +class AsyncFallthroughResourceWithRawResponse: + def __init__(self, fallthrough: AsyncFallthroughResource) -> None: + self._fallthrough = fallthrough + + self.create = async_to_raw_response_wrapper( + fallthrough.create, + ) + + +class FallthroughResourceWithStreamingResponse: + def __init__(self, fallthrough: FallthroughResource) -> None: + self._fallthrough = fallthrough + + self.create = to_streamed_response_wrapper( + fallthrough.create, + ) + + +class AsyncFallthroughResourceWithStreamingResponse: + def __init__(self, fallthrough: AsyncFallthroughResource) -> None: + self._fallthrough = fallthrough + + self.create = async_to_streamed_response_wrapper( + fallthrough.create, + ) diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index cb5b7673217..1a6038c3688 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -7,11 +7,8 @@ import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -21,7 +18,7 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper -from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ....pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options from .schema_validation import ( SchemaValidationResource, @@ -31,11 +28,18 @@ SchemaValidationResourceWithStreamingResponse, AsyncSchemaValidationResourceWithStreamingResponse, ) -from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params +from ....types.api_gateway import ( + operation_get_params, + operation_list_params, + operation_create_params, + operation_bulk_create_params, +) from ....types.api_gateway.operation_get_response import OperationGetResponse from ....types.api_gateway.operation_list_response import OperationListResponse from ....types.api_gateway.operation_create_response import OperationCreateResponse from ....types.api_gateway.operation_delete_response import OperationDeleteResponse +from ....types.api_gateway.operation_bulk_create_response import OperationBulkCreateResponse +from ....types.api_gateway.operation_bulk_delete_response import OperationBulkDeleteResponse __all__ = ["OperationsResource", "AsyncOperationsResource"] @@ -47,34 +51,56 @@ def schema_validation(self) -> SchemaValidationResource: @cached_property def with_raw_response(self) -> OperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return OperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return OperationsResourceWithStreamingResponse(self) def create( self, *, zone_id: str, - body: Iterable[operation_create_params.Body], + endpoint: str, + host: str, + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationCreateResponse: - """Add one or more operations to a zone. + """Add one operation to a zone. - Endpoints can contain path variables. - Host, method, endpoint will be normalized to a canoncial form when creating an - operation and must be unique on the zone. Inserting an operation that matches an - existing one will return the record of the already existing operation and update - its last_updated date. + Endpoints can contain path variables. Host, method, + endpoint will be normalized to a canoncial form when creating an operation and + must be unique on the zone. Inserting an operation that matches an existing one + will return the record of the already existing operation and update its + last_updated date. Args: - zone_id: Identifier + zone_id: Identifier. + + endpoint: The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + + host: RFC3986-compliant host. + + method: The HTTP method used to access the endpoint. extra_headers: Send extra headers @@ -87,8 +113,15 @@ def create( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._post( - f"/zones/{zone_id}/api_gateway/operations", - body=maybe_transform(body, operation_create_params.OperationCreateParams), + f"/zones/{zone_id}/api_gateway/operations/item", + body=maybe_transform( + { + "endpoint": endpoint, + "host": host, + "method": method, + }, + operation_create_params.OperationCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -103,26 +136,26 @@ def list( self, *, zone_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - endpoint: str | NotGiven = NOT_GIVEN, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, - order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + endpoint: str | Omit = omit, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, + order: Literal["method", "host", "endpoint", "thresholds.$key"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OperationListResponse]: """ Retrieve information about all operations on a zone Args: - zone_id: Identifier + zone_id: Identifier. direction: Direction to order results. @@ -188,15 +221,15 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: """ Delete an operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. extra_headers: Send extra headers @@ -218,26 +251,105 @@ def delete( cast_to=OperationDeleteResponse, ) + def bulk_create( + self, + *, + zone_id: str, + body: Iterable[operation_bulk_create_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[OperationBulkCreateResponse]: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + 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}/api_gateway/operations", + page=SyncSinglePage[OperationBulkCreateResponse], + body=maybe_transform(body, Iterable[operation_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=OperationBulkCreateResponse, + method="post", + ) + + def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationBulkDeleteResponse: + """ + Delete multiple operations + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._delete( + f"/zones/{zone_id}/api_gateway/operations", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OperationBulkDeleteResponse, + ) + def get( self, operation_id: str, *, zone_id: str, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ Retrieve information about an operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. feature: Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description @@ -276,34 +388,56 @@ def schema_validation(self) -> AsyncSchemaValidationResource: @cached_property def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncOperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncOperationsResourceWithStreamingResponse(self) async def create( self, *, zone_id: str, - body: Iterable[operation_create_params.Body], + endpoint: str, + host: str, + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationCreateResponse: - """Add one or more operations to a zone. + """Add one operation to a zone. - Endpoints can contain path variables. - Host, method, endpoint will be normalized to a canoncial form when creating an - operation and must be unique on the zone. Inserting an operation that matches an - existing one will return the record of the already existing operation and update - its last_updated date. + Endpoints can contain path variables. Host, method, + endpoint will be normalized to a canoncial form when creating an operation and + must be unique on the zone. Inserting an operation that matches an existing one + will return the record of the already existing operation and update its + last_updated date. Args: - zone_id: Identifier + zone_id: Identifier. + + endpoint: The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + + host: RFC3986-compliant host. + + method: The HTTP method used to access the endpoint. extra_headers: Send extra headers @@ -316,8 +450,15 @@ async def create( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return await self._post( - f"/zones/{zone_id}/api_gateway/operations", - body=await async_maybe_transform(body, operation_create_params.OperationCreateParams), + f"/zones/{zone_id}/api_gateway/operations/item", + body=await async_maybe_transform( + { + "endpoint": endpoint, + "host": host, + "method": method, + }, + operation_create_params.OperationCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -332,26 +473,26 @@ def list( self, *, zone_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - endpoint: str | NotGiven = NOT_GIVEN, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, - order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | Omit = omit, + endpoint: str | Omit = omit, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, + order: Literal["method", "host", "endpoint", "thresholds.$key"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]: """ Retrieve information about all operations on a zone Args: - zone_id: Identifier + zone_id: Identifier. direction: Direction to order results. @@ -417,15 +558,15 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: """ Delete an operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. extra_headers: Send extra headers @@ -447,26 +588,105 @@ async def delete( cast_to=OperationDeleteResponse, ) + def bulk_create( + self, + *, + zone_id: str, + body: Iterable[operation_bulk_create_params.Body], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[OperationBulkCreateResponse, AsyncSinglePage[OperationBulkCreateResponse]]: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + 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}/api_gateway/operations", + page=AsyncSinglePage[OperationBulkCreateResponse], + body=maybe_transform(body, Iterable[operation_bulk_create_params.Body]), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=OperationBulkCreateResponse, + method="post", + ) + + async def bulk_delete( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OperationBulkDeleteResponse: + """ + Delete multiple operations + + Args: + zone_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._delete( + f"/zones/{zone_id}/api_gateway/operations", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=OperationBulkDeleteResponse, + ) + async def get( self, operation_id: str, *, zone_id: str, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ Retrieve information about an operation Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. feature: Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description @@ -511,6 +731,12 @@ def __init__(self, operations: OperationsResource) -> None: self.delete = to_raw_response_wrapper( operations.delete, ) + self.bulk_create = to_raw_response_wrapper( + operations.bulk_create, + ) + self.bulk_delete = to_raw_response_wrapper( + operations.bulk_delete, + ) self.get = to_raw_response_wrapper( operations.get, ) @@ -533,6 +759,12 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.delete = async_to_raw_response_wrapper( operations.delete, ) + self.bulk_create = async_to_raw_response_wrapper( + operations.bulk_create, + ) + self.bulk_delete = async_to_raw_response_wrapper( + operations.bulk_delete, + ) self.get = async_to_raw_response_wrapper( operations.get, ) @@ -555,6 +787,12 @@ def __init__(self, operations: OperationsResource) -> None: self.delete = to_streamed_response_wrapper( operations.delete, ) + self.bulk_create = to_streamed_response_wrapper( + operations.bulk_create, + ) + self.bulk_delete = to_streamed_response_wrapper( + operations.bulk_delete, + ) self.get = to_streamed_response_wrapper( operations.get, ) @@ -577,6 +815,12 @@ def __init__(self, operations: AsyncOperationsResource) -> None: self.delete = async_to_streamed_response_wrapper( operations.delete, ) + self.bulk_create = async_to_streamed_response_wrapper( + operations.bulk_create, + ) + self.bulk_delete = async_to_streamed_response_wrapper( + operations.bulk_delete, + ) self.get = async_to_streamed_response_wrapper( operations.get, ) diff --git a/src/cloudflare/resources/api_gateway/operations/schema_validation.py b/src/cloudflare/resources/api_gateway/operations/schema_validation.py index 75fbceb4e40..5b526d920a8 100644 --- a/src/cloudflare/resources/api_gateway/operations/schema_validation.py +++ b/src/cloudflare/resources/api_gateway/operations/schema_validation.py @@ -2,16 +2,14 @@ from __future__ import annotations +import typing_extensions from typing import Type, Optional, cast from typing_extensions import Literal import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -38,32 +36,46 @@ class SchemaValidationResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return SchemaValidationResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return SchemaValidationResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def update( self, operation_id: str, *, zone_id: str, - mitigation_action: Optional[Literal["log", "block", "none"]] | NotGiven = NOT_GIVEN, + mitigation_action: Optional[Literal["log", "block", "none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaValidationUpdateResponse: """ Updates operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. mitigation_action: When set, this applies a mitigation action to this operation @@ -97,6 +109,9 @@ def update( cast_to=SchemaValidationUpdateResponse, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def edit( self, *, @@ -107,13 +122,13 @@ def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingsMultipleRequest: """ Updates multiple operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -138,6 +153,9 @@ def edit( cast_to=cast(Type[SettingsMultipleRequest], ResultWrapper[SettingsMultipleRequest]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def get( self, operation_id: str, @@ -148,15 +166,15 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaValidationGetResponse: """ Retrieves operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. extra_headers: Send extra headers @@ -182,32 +200,46 @@ def get( class AsyncSchemaValidationResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncSchemaValidationResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncSchemaValidationResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def update( self, operation_id: str, *, zone_id: str, - mitigation_action: Optional[Literal["log", "block", "none"]] | NotGiven = NOT_GIVEN, + mitigation_action: Optional[Literal["log", "block", "none"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaValidationUpdateResponse: """ Updates operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. mitigation_action: When set, this applies a mitigation action to this operation @@ -241,6 +273,9 @@ async def update( cast_to=SchemaValidationUpdateResponse, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def edit( self, *, @@ -251,13 +286,13 @@ async def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingsMultipleRequest: """ Updates multiple operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -284,6 +319,9 @@ async def edit( cast_to=cast(Type[SettingsMultipleRequest], ResultWrapper[SettingsMultipleRequest]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def get( self, operation_id: str, @@ -294,15 +332,15 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaValidationGetResponse: """ Retrieves operation-level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. - operation_id: UUID + operation_id: UUID. extra_headers: Send extra headers @@ -329,14 +367,20 @@ class SchemaValidationResourceWithRawResponse: def __init__(self, schema_validation: SchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = to_raw_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -344,14 +388,20 @@ class AsyncSchemaValidationResourceWithRawResponse: def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = async_to_raw_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -359,14 +409,20 @@ class SchemaValidationResourceWithStreamingResponse: def __init__(self, schema_validation: SchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = to_streamed_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -374,12 +430,18 @@ class AsyncSchemaValidationResourceWithStreamingResponse: def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = async_to_streamed_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_streamed_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/cloudflare/resources/api_gateway/schemas.py b/src/cloudflare/resources/api_gateway/schemas.py index 501680e88a3..2559e6e21c2 100644 --- a/src/cloudflare/resources/api_gateway/schemas.py +++ b/src/cloudflare/resources/api_gateway/schemas.py @@ -7,11 +7,8 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -31,30 +28,41 @@ class SchemasResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SchemasResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return SchemasResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SchemasResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return SchemasResourceWithStreamingResponse(self) def list( self, *, zone_id: str, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaListResponse: """ Retrieve operations and features as OpenAPI schemas Args: - zone_id: Identifier + zone_id: Identifier. feature: Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description @@ -95,30 +103,41 @@ def list( class AsyncSchemasResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSchemasResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncSchemasResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSchemasResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncSchemasResourceWithStreamingResponse(self) async def list( self, *, zone_id: str, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaListResponse: """ Retrieve operations and features as OpenAPI schemas Args: - zone_id: Identifier + zone_id: Identifier. feature: Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description diff --git a/src/cloudflare/resources/api_gateway/settings/schema_validation.py b/src/cloudflare/resources/api_gateway/settings/schema_validation.py index edfbacc9040..edc6f969c00 100644 --- a/src/cloudflare/resources/api_gateway/settings/schema_validation.py +++ b/src/cloudflare/resources/api_gateway/settings/schema_validation.py @@ -2,16 +2,14 @@ from __future__ import annotations +import typing_extensions from typing import Optional from typing_extensions import Literal import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( @@ -30,30 +28,44 @@ class SchemaValidationResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return SchemaValidationResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return SchemaValidationResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def update( self, *, zone_id: str, validation_default_mitigation_action: Literal["none", "log", "block"], - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Updates zone level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on the operation @@ -98,24 +110,27 @@ def update( cast_to=Settings, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def edit( self, *, zone_id: str, - validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | NotGiven = NOT_GIVEN, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | Omit = omit, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Updates zone level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on the operation Mitigation actions are as follows: @@ -161,6 +176,9 @@ def edit( cast_to=Settings, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def get( self, *, @@ -170,13 +188,13 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Retrieves zone level schema validation settings currently set on the zone Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -200,30 +218,44 @@ def get( class AsyncSchemaValidationResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncSchemaValidationResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncSchemaValidationResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def update( self, *, zone_id: str, validation_default_mitigation_action: Literal["none", "log", "block"], - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Updates zone level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on the operation @@ -268,24 +300,27 @@ async def update( cast_to=Settings, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def edit( self, *, zone_id: str, - validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | NotGiven = NOT_GIVEN, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | Omit = omit, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Updates zone level schema validation settings on the zone Args: - zone_id: Identifier + zone_id: Identifier. validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on the operation Mitigation actions are as follows: @@ -331,6 +366,9 @@ async def edit( cast_to=Settings, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def get( self, *, @@ -340,13 +378,13 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Settings: """ Retrieves zone level schema validation settings currently set on the zone Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -371,14 +409,20 @@ class SchemaValidationResourceWithRawResponse: def __init__(self, schema_validation: SchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = to_raw_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -386,14 +430,20 @@ class AsyncSchemaValidationResourceWithRawResponse: def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = async_to_raw_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -401,14 +451,20 @@ class SchemaValidationResourceWithStreamingResponse: def __init__(self, schema_validation: SchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = to_streamed_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) @@ -416,12 +472,18 @@ class AsyncSchemaValidationResourceWithStreamingResponse: def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self._schema_validation = schema_validation - self.update = async_to_streamed_response_wrapper( - schema_validation.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.update, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_streamed_response_wrapper( - schema_validation.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - schema_validation.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + schema_validation.get, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/cloudflare/resources/api_gateway/settings/settings.py b/src/cloudflare/resources/api_gateway/settings/settings.py index 867736caef9..543c2a869d1 100644 --- a/src/cloudflare/resources/api_gateway/settings/settings.py +++ b/src/cloudflare/resources/api_gateway/settings/settings.py @@ -23,10 +23,21 @@ def schema_validation(self) -> SchemaValidationResource: @cached_property def with_raw_response(self) -> SettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return SettingsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return SettingsResourceWithStreamingResponse(self) @@ -37,10 +48,21 @@ def schema_validation(self) -> AsyncSchemaValidationResource: @cached_property def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncSettingsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncSettingsResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/__init__.py b/src/cloudflare/resources/api_gateway/user_schemas/__init__.py index 40bf4737372..7c9f80a9f0a 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/__init__.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .hosts import ( + HostsResource, + AsyncHostsResource, + HostsResourceWithRawResponse, + AsyncHostsResourceWithRawResponse, + HostsResourceWithStreamingResponse, + AsyncHostsResourceWithStreamingResponse, +) from .operations import ( OperationsResource, AsyncOperationsResource, @@ -24,6 +32,12 @@ "AsyncOperationsResourceWithRawResponse", "OperationsResourceWithStreamingResponse", "AsyncOperationsResourceWithStreamingResponse", + "HostsResource", + "AsyncHostsResource", + "HostsResourceWithRawResponse", + "AsyncHostsResourceWithRawResponse", + "HostsResourceWithStreamingResponse", + "AsyncHostsResourceWithStreamingResponse", "UserSchemasResource", "AsyncUserSchemasResource", "UserSchemasResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py new file mode 100644 index 00000000000..01861b64473 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py @@ -0,0 +1,220 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import typing_extensions + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import AsyncPaginator, make_request_options +from ....types.api_gateway.user_schemas import host_list_params +from ....types.api_gateway.user_schemas.host_list_response import HostListResponse + +__all__ = ["HostsResource", "AsyncHostsResource"] + + +class HostsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> HostsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return HostsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> HostsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return HostsResourceWithStreamingResponse(self) + + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) + def list( + self, + *, + zone_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[HostListResponse]: + """ + Retrieve schema hosts in a zone + + Args: + zone_id: Identifier. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + 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}/api_gateway/user_schemas/hosts", + page=SyncV4PagePaginationArray[HostListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + host_list_params.HostListParams, + ), + ), + model=HostListResponse, + ) + + +class AsyncHostsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncHostsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncHostsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncHostsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncHostsResourceWithStreamingResponse(self) + + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) + def list( + self, + *, + zone_id: str, + page: int | Omit = omit, + per_page: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[HostListResponse, AsyncV4PagePaginationArray[HostListResponse]]: + """ + Retrieve schema hosts in a zone + + Args: + zone_id: Identifier. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + 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}/api_gateway/user_schemas/hosts", + page=AsyncV4PagePaginationArray[HostListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "page": page, + "per_page": per_page, + }, + host_list_params.HostListParams, + ), + ), + model=HostListResponse, + ) + + +class HostsResourceWithRawResponse: + def __init__(self, hosts: HostsResource) -> None: + self._hosts = hosts + + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + hosts.list, # pyright: ignore[reportDeprecated], + ) + ) + + +class AsyncHostsResourceWithRawResponse: + def __init__(self, hosts: AsyncHostsResource) -> None: + self._hosts = hosts + + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + hosts.list, # pyright: ignore[reportDeprecated], + ) + ) + + +class HostsResourceWithStreamingResponse: + def __init__(self, hosts: HostsResource) -> None: + self._hosts = hosts + + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + hosts.list, # pyright: ignore[reportDeprecated], + ) + ) + + +class AsyncHostsResourceWithStreamingResponse: + def __init__(self, hosts: AsyncHostsResource) -> None: + self._hosts = hosts + + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + hosts.list, # pyright: ignore[reportDeprecated], + ) + ) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/operations.py b/src/cloudflare/resources/api_gateway/user_schemas/operations.py index 18cb925ea95..d5a04f5f875 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/operations.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/operations.py @@ -2,12 +2,13 @@ from __future__ import annotations +import typing_extensions from typing import Any, List, cast from typing_extensions import Literal import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given from ...._utils import maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource @@ -28,30 +29,44 @@ class OperationsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> OperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return OperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return OperationsResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def list( self, schema_id: str, *, zone_id: str, - endpoint: str | NotGiven = NOT_GIVEN, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, - operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + endpoint: str | Omit = omit, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, + operation_status: Literal["new", "existing"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OperationListResponse]: """Retrieves all operations from the schema. @@ -59,7 +74,7 @@ def list( Shield Endpoint Management will be returned as full operations. Args: - zone_id: Identifier + zone_id: Identifier. endpoint: Filter results to only include endpoints containing this pattern. @@ -120,30 +135,44 @@ def list( class AsyncOperationsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncOperationsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncOperationsResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def list( self, schema_id: str, *, zone_id: str, - endpoint: str | NotGiven = NOT_GIVEN, - feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, - host: List[str] | NotGiven = NOT_GIVEN, - method: List[str] | NotGiven = NOT_GIVEN, - operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, + endpoint: str | Omit = omit, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | Omit = omit, + host: SequenceNotStr[str] | Omit = omit, + method: SequenceNotStr[str] | Omit = omit, + operation_status: Literal["new", "existing"] | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]: """Retrieves all operations from the schema. @@ -151,7 +180,7 @@ def list( Shield Endpoint Management will be returned as full operations. Args: - zone_id: Identifier + zone_id: Identifier. endpoint: Filter results to only include endpoints containing this pattern. @@ -213,8 +242,10 @@ class OperationsResourceWithRawResponse: def __init__(self, operations: OperationsResource) -> None: self._operations = operations - self.list = to_raw_response_wrapper( - operations.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + operations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -222,8 +253,10 @@ class AsyncOperationsResourceWithRawResponse: def __init__(self, operations: AsyncOperationsResource) -> None: self._operations = operations - self.list = async_to_raw_response_wrapper( - operations.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + operations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -231,8 +264,10 @@ class OperationsResourceWithStreamingResponse: def __init__(self, operations: OperationsResource) -> None: self._operations = operations - self.list = to_streamed_response_wrapper( - operations.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + operations.list, # pyright: ignore[reportDeprecated], + ) ) @@ -240,6 +275,8 @@ class AsyncOperationsResourceWithStreamingResponse: def __init__(self, operations: AsyncOperationsResource) -> None: self._operations = operations - self.list = async_to_streamed_response_wrapper( - operations.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + operations.list, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py index 267ebee4be3..e7d9626a705 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -2,18 +2,22 @@ from __future__ import annotations -from typing import Any, Type, Mapping, Optional, cast +import typing_extensions +from typing import Type, Mapping, cast from typing_extensions import Literal import httpx -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes -from ...._utils import ( - extract_files, - maybe_transform, - deepcopy_minimal, - async_maybe_transform, +from .hosts import ( + HostsResource, + AsyncHostsResource, + HostsResourceWithRawResponse, + AsyncHostsResourceWithRawResponse, + HostsResourceWithStreamingResponse, + AsyncHostsResourceWithStreamingResponse, ) +from ...._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given +from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform from ...._compat import cached_property from .operations import ( OperationsResource, @@ -39,8 +43,8 @@ user_schema_list_params, user_schema_create_params, ) -from ....types.api_gateway.public_schema import PublicSchema -from ....types.api_gateway.schema_upload import SchemaUpload +from ....types.api_gateway.old_public_schema import OldPublicSchema +from ....types.api_gateway.user_schema_create_response import UserSchemaCreateResponse from ....types.api_gateway.user_schema_delete_response import UserSchemaDeleteResponse __all__ = ["UserSchemasResource", "AsyncUserSchemasResource"] @@ -51,34 +55,52 @@ class UserSchemasResource(SyncAPIResource): def operations(self) -> OperationsResource: return OperationsResource(self._client) + @cached_property + def hosts(self) -> HostsResource: + return HostsResource(self._client) + @cached_property def with_raw_response(self) -> UserSchemasResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return UserSchemasResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> UserSchemasResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return UserSchemasResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def create( self, *, zone_id: str, file: FileTypes, kind: Literal["openapi_v3"], - name: str | NotGiven = NOT_GIVEN, - validation_enabled: Literal["true", "false"] | NotGiven = NOT_GIVEN, + name: str | Omit = omit, + validation_enabled: Literal["true", "false"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SchemaUpload: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserSchemaCreateResponse: """ Upload a schema to a zone Args: - zone_id: Identifier + zone_id: Identifier. file: Schema file bytes @@ -120,31 +142,34 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[SchemaUpload]._unwrapper, + post_parser=ResultWrapper[UserSchemaCreateResponse]._unwrapper, ), - cast_to=cast(Type[SchemaUpload], ResultWrapper[SchemaUpload]), + cast_to=cast(Type[UserSchemaCreateResponse], ResultWrapper[UserSchemaCreateResponse]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def list( self, *, zone_id: str, - omit_source: bool | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - validation_enabled: bool | NotGiven = NOT_GIVEN, + omit_source: bool | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + validation_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[PublicSchema]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncV4PagePaginationArray[OldPublicSchema]: """ Retrieve information about all schemas on a zone Args: - zone_id: Identifier + zone_id: Identifier. omit_source: Omit the source-files of schemas and only retrieve their meta-data. @@ -166,7 +191,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}/api_gateway/user_schemas", - page=SyncV4PagePaginationArray[PublicSchema], + page=SyncV4PagePaginationArray[OldPublicSchema], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -182,9 +207,12 @@ def list( user_schema_list_params.UserSchemaListParams, ), ), - model=PublicSchema, + model=OldPublicSchema, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def delete( self, schema_id: str, @@ -195,13 +223,13 @@ def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[UserSchemaDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserSchemaDeleteResponse: """ Delete a schema Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -215,41 +243,35 @@ def delete( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not schema_id: raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") - return cast( - Optional[UserSchemaDeleteResponse], - self._delete( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[UserSchemaDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserSchemaDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=UserSchemaDeleteResponse, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def edit( self, schema_id: str, *, zone_id: str, - validation_enabled: Literal[True] | NotGiven = NOT_GIVEN, + validation_enabled: Literal[True] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PublicSchema: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OldPublicSchema: """ Enable validation for a schema Args: - zone_id: Identifier + zone_id: Identifier. validation_enabled: Flag whether schema is enabled for validation. @@ -275,29 +297,32 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PublicSchema]._unwrapper, + post_parser=ResultWrapper[OldPublicSchema]._unwrapper, ), - cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + cast_to=cast(Type[OldPublicSchema], ResultWrapper[OldPublicSchema]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def get( self, schema_id: str, *, zone_id: str, - omit_source: bool | NotGiven = NOT_GIVEN, + omit_source: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PublicSchema: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OldPublicSchema: """ Retrieve information about a specific schema on a zone Args: - zone_id: Identifier + zone_id: Identifier. omit_source: Omit the source-files of schemas and only retrieve their meta-data. @@ -321,9 +346,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"omit_source": omit_source}, user_schema_get_params.UserSchemaGetParams), - post_parser=ResultWrapper[PublicSchema]._unwrapper, + post_parser=ResultWrapper[OldPublicSchema]._unwrapper, ), - cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + cast_to=cast(Type[OldPublicSchema], ResultWrapper[OldPublicSchema]), ) @@ -332,34 +357,52 @@ class AsyncUserSchemasResource(AsyncAPIResource): def operations(self) -> AsyncOperationsResource: return AsyncOperationsResource(self._client) + @cached_property + def hosts(self) -> AsyncHostsResource: + return AsyncHostsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncUserSchemasResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncUserSchemasResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncUserSchemasResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncUserSchemasResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def create( self, *, zone_id: str, file: FileTypes, kind: Literal["openapi_v3"], - name: str | NotGiven = NOT_GIVEN, - validation_enabled: Literal["true", "false"] | NotGiven = NOT_GIVEN, + name: str | Omit = omit, + validation_enabled: Literal["true", "false"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SchemaUpload: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserSchemaCreateResponse: """ Upload a schema to a zone Args: - zone_id: Identifier + zone_id: Identifier. file: Schema file bytes @@ -401,31 +444,34 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[SchemaUpload]._unwrapper, + post_parser=ResultWrapper[UserSchemaCreateResponse]._unwrapper, ), - cast_to=cast(Type[SchemaUpload], ResultWrapper[SchemaUpload]), + cast_to=cast(Type[UserSchemaCreateResponse], ResultWrapper[UserSchemaCreateResponse]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) def list( self, *, zone_id: str, - omit_source: bool | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - validation_enabled: bool | NotGiven = NOT_GIVEN, + omit_source: bool | Omit = omit, + page: int | Omit = omit, + per_page: int | Omit = omit, + validation_enabled: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[PublicSchema, AsyncV4PagePaginationArray[PublicSchema]]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[OldPublicSchema, AsyncV4PagePaginationArray[OldPublicSchema]]: """ Retrieve information about all schemas on a zone Args: - zone_id: Identifier + zone_id: Identifier. omit_source: Omit the source-files of schemas and only retrieve their meta-data. @@ -447,7 +493,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}/api_gateway/user_schemas", - page=AsyncV4PagePaginationArray[PublicSchema], + page=AsyncV4PagePaginationArray[OldPublicSchema], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -463,9 +509,12 @@ def list( user_schema_list_params.UserSchemaListParams, ), ), - model=PublicSchema, + model=OldPublicSchema, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def delete( self, schema_id: str, @@ -476,13 +525,13 @@ async def delete( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[UserSchemaDeleteResponse]: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UserSchemaDeleteResponse: """ Delete a schema Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -496,41 +545,35 @@ async def delete( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") if not schema_id: raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") - return cast( - Optional[UserSchemaDeleteResponse], - await self._delete( - f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[UserSchemaDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserSchemaDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=UserSchemaDeleteResponse, ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def edit( self, schema_id: str, *, zone_id: str, - validation_enabled: Literal[True] | NotGiven = NOT_GIVEN, + validation_enabled: Literal[True] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PublicSchema: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OldPublicSchema: """ Enable validation for a schema Args: - zone_id: Identifier + zone_id: Identifier. validation_enabled: Flag whether schema is enabled for validation. @@ -556,29 +599,32 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PublicSchema]._unwrapper, + post_parser=ResultWrapper[OldPublicSchema]._unwrapper, ), - cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + cast_to=cast(Type[OldPublicSchema], ResultWrapper[OldPublicSchema]), ) + @typing_extensions.deprecated( + "Use [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) instead." + ) async def get( self, schema_id: str, *, zone_id: str, - omit_source: bool | NotGiven = NOT_GIVEN, + omit_source: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PublicSchema: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> OldPublicSchema: """ Retrieve information about a specific schema on a zone Args: - zone_id: Identifier + zone_id: Identifier. omit_source: Omit the source-files of schemas and only retrieve their meta-data. @@ -604,9 +650,9 @@ async def get( query=await async_maybe_transform( {"omit_source": omit_source}, user_schema_get_params.UserSchemaGetParams ), - post_parser=ResultWrapper[PublicSchema]._unwrapper, + post_parser=ResultWrapper[OldPublicSchema]._unwrapper, ), - cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + cast_to=cast(Type[OldPublicSchema], ResultWrapper[OldPublicSchema]), ) @@ -614,97 +660,153 @@ class UserSchemasResourceWithRawResponse: def __init__(self, user_schemas: UserSchemasResource) -> None: self._user_schemas = user_schemas - self.create = to_raw_response_wrapper( - user_schemas.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + user_schemas.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - user_schemas.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + user_schemas.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - user_schemas.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + user_schemas.delete, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - user_schemas.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + user_schemas.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - user_schemas.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + user_schemas.get, # pyright: ignore[reportDeprecated], + ) ) @cached_property def operations(self) -> OperationsResourceWithRawResponse: return OperationsResourceWithRawResponse(self._user_schemas.operations) + @cached_property + def hosts(self) -> HostsResourceWithRawResponse: + return HostsResourceWithRawResponse(self._user_schemas.hosts) + class AsyncUserSchemasResourceWithRawResponse: def __init__(self, user_schemas: AsyncUserSchemasResource) -> None: self._user_schemas = user_schemas - self.create = async_to_raw_response_wrapper( - user_schemas.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + user_schemas.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - user_schemas.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + user_schemas.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - user_schemas.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + user_schemas.delete, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - user_schemas.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + user_schemas.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - user_schemas.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + user_schemas.get, # pyright: ignore[reportDeprecated], + ) ) @cached_property def operations(self) -> AsyncOperationsResourceWithRawResponse: return AsyncOperationsResourceWithRawResponse(self._user_schemas.operations) + @cached_property + def hosts(self) -> AsyncHostsResourceWithRawResponse: + return AsyncHostsResourceWithRawResponse(self._user_schemas.hosts) + class UserSchemasResourceWithStreamingResponse: def __init__(self, user_schemas: UserSchemasResource) -> None: self._user_schemas = user_schemas - self.create = to_streamed_response_wrapper( - user_schemas.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + user_schemas.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - user_schemas.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + user_schemas.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - user_schemas.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + user_schemas.delete, # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - user_schemas.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + user_schemas.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - user_schemas.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + user_schemas.get, # pyright: ignore[reportDeprecated], + ) ) @cached_property def operations(self) -> OperationsResourceWithStreamingResponse: return OperationsResourceWithStreamingResponse(self._user_schemas.operations) + @cached_property + def hosts(self) -> HostsResourceWithStreamingResponse: + return HostsResourceWithStreamingResponse(self._user_schemas.hosts) + class AsyncUserSchemasResourceWithStreamingResponse: def __init__(self, user_schemas: AsyncUserSchemasResource) -> None: self._user_schemas = user_schemas - self.create = async_to_streamed_response_wrapper( - user_schemas.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + user_schemas.create, # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_streamed_response_wrapper( - user_schemas.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + user_schemas.list, # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - user_schemas.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + user_schemas.delete, # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_streamed_response_wrapper( - user_schemas.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + user_schemas.edit, # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - user_schemas.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + user_schemas.get, # pyright: ignore[reportDeprecated], + ) ) @cached_property def operations(self) -> AsyncOperationsResourceWithStreamingResponse: return AsyncOperationsResourceWithStreamingResponse(self._user_schemas.operations) + + @cached_property + def hosts(self) -> AsyncHostsResourceWithStreamingResponse: + return AsyncHostsResourceWithStreamingResponse(self._user_schemas.hosts) diff --git a/src/cloudflare/resources/argo/argo.py b/src/cloudflare/resources/argo/argo.py index f9ce9f32f66..eb94300db7a 100644 --- a/src/cloudflare/resources/argo/argo.py +++ b/src/cloudflare/resources/argo/argo.py @@ -35,10 +35,21 @@ def tiered_caching(self) -> TieredCachingResource: @cached_property def with_raw_response(self) -> ArgoResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ArgoResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ArgoResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ArgoResourceWithStreamingResponse(self) @@ -53,10 +64,21 @@ def tiered_caching(self) -> AsyncTieredCachingResource: @cached_property def with_raw_response(self) -> AsyncArgoResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncArgoResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncArgoResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncArgoResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/argo/smart_routing.py b/src/cloudflare/resources/argo/smart_routing.py index 66076b40903..d45d9be9c4d 100644 --- a/src/cloudflare/resources/argo/smart_routing.py +++ b/src/cloudflare/resources/argo/smart_routing.py @@ -2,16 +2,13 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, cast from typing_extensions import Literal import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -32,10 +29,21 @@ class SmartRoutingResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SmartRoutingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return SmartRoutingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> SmartRoutingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return SmartRoutingResourceWithStreamingResponse(self) def edit( @@ -48,15 +56,15 @@ def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SmartRoutingEditResponse: """ - Updates enablement of Argo Smart Routing. + Configures the value of the Argo Smart Routing enablement setting. Args: - zone_id: Identifier + zone_id: Specifies the zone associated with the API call. - value: Enables Argo Smart Routing. + value: Specifies the enablement value of Argo Smart Routing. extra_headers: Send extra headers @@ -68,22 +76,17 @@ def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartRoutingEditResponse, - self._patch( - f"/zones/{zone_id}/argo/smart_routing", - body=maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartRoutingEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartRoutingEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._patch( + f"/zones/{zone_id}/argo/smart_routing", + body=maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartRoutingEditResponse]._unwrapper, ), + cast_to=cast(Type[SmartRoutingEditResponse], ResultWrapper[SmartRoutingEditResponse]), ) def get( @@ -95,13 +98,13 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SmartRoutingGetResponse: """ - Get Argo Smart Routing setting + Retrieves the value of Argo Smart Routing enablement setting. Args: - zone_id: Identifier + zone_id: Specifies the zone associated with the API call. extra_headers: Send extra headers @@ -113,31 +116,37 @@ def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartRoutingGetResponse, - self._get( - f"/zones/{zone_id}/argo/smart_routing", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartRoutingGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartRoutingGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/zones/{zone_id}/argo/smart_routing", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartRoutingGetResponse]._unwrapper, ), + cast_to=cast(Type[SmartRoutingGetResponse], ResultWrapper[SmartRoutingGetResponse]), ) class AsyncSmartRoutingResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSmartRoutingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncSmartRoutingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncSmartRoutingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncSmartRoutingResourceWithStreamingResponse(self) async def edit( @@ -150,15 +159,15 @@ async def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SmartRoutingEditResponse: """ - Updates enablement of Argo Smart Routing. + Configures the value of the Argo Smart Routing enablement setting. Args: - zone_id: Identifier + zone_id: Specifies the zone associated with the API call. - value: Enables Argo Smart Routing. + value: Specifies the enablement value of Argo Smart Routing. extra_headers: Send extra headers @@ -170,22 +179,17 @@ async def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartRoutingEditResponse, - await self._patch( - f"/zones/{zone_id}/argo/smart_routing", - body=await async_maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartRoutingEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartRoutingEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._patch( + f"/zones/{zone_id}/argo/smart_routing", + body=await async_maybe_transform({"value": value}, smart_routing_edit_params.SmartRoutingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartRoutingEditResponse]._unwrapper, ), + cast_to=cast(Type[SmartRoutingEditResponse], ResultWrapper[SmartRoutingEditResponse]), ) async def get( @@ -197,13 +201,13 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SmartRoutingGetResponse: """ - Get Argo Smart Routing setting + Retrieves the value of Argo Smart Routing enablement setting. Args: - zone_id: Identifier + zone_id: Specifies the zone associated with the API call. extra_headers: Send extra headers @@ -215,21 +219,16 @@ async def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartRoutingGetResponse, - await self._get( - f"/zones/{zone_id}/argo/smart_routing", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartRoutingGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartRoutingGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/zones/{zone_id}/argo/smart_routing", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartRoutingGetResponse]._unwrapper, ), + cast_to=cast(Type[SmartRoutingGetResponse], ResultWrapper[SmartRoutingGetResponse]), ) diff --git a/src/cloudflare/resources/argo/tiered_caching.py b/src/cloudflare/resources/argo/tiered_caching.py index d11257e0a6c..9662940b73c 100644 --- a/src/cloudflare/resources/argo/tiered_caching.py +++ b/src/cloudflare/resources/argo/tiered_caching.py @@ -2,16 +2,13 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -32,10 +29,21 @@ class TieredCachingResource(SyncAPIResource): @cached_property def with_raw_response(self) -> TieredCachingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return TieredCachingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> TieredCachingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return TieredCachingResourceWithStreamingResponse(self) def edit( @@ -48,13 +56,23 @@ def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TieredCachingEditResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TieredCachingEditResponse]: """ - Updates enablement of Tiered Caching + Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of + lower-tiers and upper-tiers. If content is not cached in lower-tier data centers + (generally the ones closest to a visitor), the lower-tier must ask an upper-tier + to see if it has the content. If the upper-tier does not have the content, only + the upper-tier can ask the origin for content. This practice improves bandwidth + efficiency by limiting the number of data centers that can ask the origin for + content, which reduces origin load and makes websites more cost-effective to + operate. Additionally, Tiered Cache concentrates connections to origin servers + so they come from a small number of data centers rather than the full set of + network locations. This results in fewer open connections using server + resources. Args: - zone_id: Identifier + zone_id: Identifier. value: Enables Tiered Caching. @@ -76,9 +94,9 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TieredCachingEditResponse]]._unwrapper, ), - cast_to=cast(Type[TieredCachingEditResponse], ResultWrapper[TieredCachingEditResponse]), + cast_to=cast(Type[Optional[TieredCachingEditResponse]], ResultWrapper[TieredCachingEditResponse]), ) def get( @@ -90,13 +108,23 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TieredCachingGetResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TieredCachingGetResponse]: """ - Get Tiered Caching setting + Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of + lower-tiers and upper-tiers. If content is not cached in lower-tier data centers + (generally the ones closest to a visitor), the lower-tier must ask an upper-tier + to see if it has the content. If the upper-tier does not have the content, only + the upper-tier can ask the origin for content. This practice improves bandwidth + efficiency by limiting the number of data centers that can ask the origin for + content, which reduces origin load and makes websites more cost-effective to + operate. Additionally, Tiered Cache concentrates connections to origin servers + so they come from a small number of data centers rather than the full set of + network locations. This results in fewer open connections using server + resources. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -115,19 +143,30 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TieredCachingGetResponse]]._unwrapper, ), - cast_to=cast(Type[TieredCachingGetResponse], ResultWrapper[TieredCachingGetResponse]), + cast_to=cast(Type[Optional[TieredCachingGetResponse]], ResultWrapper[TieredCachingGetResponse]), ) class AsyncTieredCachingResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncTieredCachingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncTieredCachingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncTieredCachingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncTieredCachingResourceWithStreamingResponse(self) async def edit( @@ -140,13 +179,23 @@ async def edit( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TieredCachingEditResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TieredCachingEditResponse]: """ - Updates enablement of Tiered Caching + Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of + lower-tiers and upper-tiers. If content is not cached in lower-tier data centers + (generally the ones closest to a visitor), the lower-tier must ask an upper-tier + to see if it has the content. If the upper-tier does not have the content, only + the upper-tier can ask the origin for content. This practice improves bandwidth + efficiency by limiting the number of data centers that can ask the origin for + content, which reduces origin load and makes websites more cost-effective to + operate. Additionally, Tiered Cache concentrates connections to origin servers + so they come from a small number of data centers rather than the full set of + network locations. This results in fewer open connections using server + resources. Args: - zone_id: Identifier + zone_id: Identifier. value: Enables Tiered Caching. @@ -168,9 +217,9 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TieredCachingEditResponse]]._unwrapper, ), - cast_to=cast(Type[TieredCachingEditResponse], ResultWrapper[TieredCachingEditResponse]), + cast_to=cast(Type[Optional[TieredCachingEditResponse]], ResultWrapper[TieredCachingEditResponse]), ) async def get( @@ -182,13 +231,23 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TieredCachingGetResponse: + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[TieredCachingGetResponse]: """ - Get Tiered Caching setting + Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of + lower-tiers and upper-tiers. If content is not cached in lower-tier data centers + (generally the ones closest to a visitor), the lower-tier must ask an upper-tier + to see if it has the content. If the upper-tier does not have the content, only + the upper-tier can ask the origin for content. This practice improves bandwidth + efficiency by limiting the number of data centers that can ask the origin for + content, which reduces origin load and makes websites more cost-effective to + operate. Additionally, Tiered Cache concentrates connections to origin servers + so they come from a small number of data centers rather than the full set of + network locations. This results in fewer open connections using server + resources. Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -207,9 +266,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TieredCachingGetResponse]]._unwrapper, ), - cast_to=cast(Type[TieredCachingGetResponse], ResultWrapper[TieredCachingGetResponse]), + cast_to=cast(Type[Optional[TieredCachingGetResponse]], ResultWrapper[TieredCachingGetResponse]), ) diff --git a/src/cloudflare/resources/audit_logs.py b/src/cloudflare/resources/audit_logs.py index 5958b8541e7..1a682f5ac0e 100644 --- a/src/cloudflare/resources/audit_logs.py +++ b/src/cloudflare/resources/audit_logs.py @@ -3,12 +3,12 @@ from __future__ import annotations from typing import Union -from datetime import datetime +from datetime import date, datetime from typing_extensions import Literal import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -29,33 +29,44 @@ class AuditLogsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> AuditLogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AuditLogsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AuditLogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AuditLogsResourceWithStreamingResponse(self) def list( self, *, account_id: str, - id: str | NotGiven = NOT_GIVEN, - action: audit_log_list_params.Action | NotGiven = NOT_GIVEN, - actor: audit_log_list_params.Actor | NotGiven = NOT_GIVEN, - before: Union[str, datetime] | NotGiven = NOT_GIVEN, - direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, - export: bool | NotGiven = NOT_GIVEN, - hide_user_logs: bool | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - since: Union[str, datetime] | NotGiven = NOT_GIVEN, - zone: audit_log_list_params.Zone | NotGiven = NOT_GIVEN, + id: str | Omit = omit, + action: audit_log_list_params.Action | Omit = omit, + actor: audit_log_list_params.Actor | Omit = omit, + before: Union[Union[str, date], Union[str, datetime]] | Omit = omit, + direction: Literal["desc", "asc"] | Omit = omit, + export: bool | Omit = omit, + hide_user_logs: bool | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + since: Union[Union[str, date], Union[str, datetime]] | Omit = omit, + zone: audit_log_list_params.Zone | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[AuditLog]: """Gets a list of audit logs for an account. @@ -67,8 +78,8 @@ def list( id: Finds a specific log by its ID. - before: Limits the returned results to logs older than the specified date. This can be a - date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + before: Limits the returned results to logs older than the specified date. A `full-date` + that conforms to RFC3339. direction: Changes the direction of the chronological sorting. @@ -80,8 +91,8 @@ def list( per_page: Sets the number of results to return per page. - since: Limits the returned results to logs newer than the specified date. This can be a - date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + since: Limits the returned results to logs newer than the specified date. A `full-date` + that conforms to RFC3339. extra_headers: Send extra headers @@ -125,33 +136,44 @@ def list( class AsyncAuditLogsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAuditLogsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncAuditLogsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncAuditLogsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncAuditLogsResourceWithStreamingResponse(self) def list( self, *, account_id: str, - id: str | NotGiven = NOT_GIVEN, - action: audit_log_list_params.Action | NotGiven = NOT_GIVEN, - actor: audit_log_list_params.Actor | NotGiven = NOT_GIVEN, - before: Union[str, datetime] | NotGiven = NOT_GIVEN, - direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, - export: bool | NotGiven = NOT_GIVEN, - hide_user_logs: bool | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - since: Union[str, datetime] | NotGiven = NOT_GIVEN, - zone: audit_log_list_params.Zone | NotGiven = NOT_GIVEN, + id: str | Omit = omit, + action: audit_log_list_params.Action | Omit = omit, + actor: audit_log_list_params.Actor | Omit = omit, + before: Union[Union[str, date], Union[str, datetime]] | Omit = omit, + direction: Literal["desc", "asc"] | Omit = omit, + export: bool | Omit = omit, + hide_user_logs: bool | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + since: Union[Union[str, date], Union[str, datetime]] | Omit = omit, + zone: audit_log_list_params.Zone | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AuditLog, AsyncV4PagePaginationArray[AuditLog]]: """Gets a list of audit logs for an account. @@ -163,8 +185,8 @@ def list( id: Finds a specific log by its ID. - before: Limits the returned results to logs older than the specified date. This can be a - date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + before: Limits the returned results to logs older than the specified date. A `full-date` + that conforms to RFC3339. direction: Changes the direction of the chronological sorting. @@ -176,8 +198,8 @@ def list( per_page: Sets the number of results to return per page. - since: Limits the returned results to logs newer than the specified date. This can be a - date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + since: Limits the returned results to logs newer than the specified date. A `full-date` + that conforms to RFC3339. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/billing/billing.py b/src/cloudflare/resources/billing/billing.py index 4eb4692ac3a..d57c019144e 100644 --- a/src/cloudflare/resources/billing/billing.py +++ b/src/cloudflare/resources/billing/billing.py @@ -23,10 +23,21 @@ def profiles(self) -> ProfilesResource: @cached_property def with_raw_response(self) -> BillingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return BillingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> BillingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return BillingResourceWithStreamingResponse(self) @@ -37,10 +48,21 @@ def profiles(self) -> AsyncProfilesResource: @cached_property def with_raw_response(self) -> AsyncBillingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncBillingResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncBillingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncBillingResourceWithStreamingResponse(self) diff --git a/src/cloudflare/resources/billing/profiles.py b/src/cloudflare/resources/billing/profiles.py index 4ee42cdb407..f3272600105 100644 --- a/src/cloudflare/resources/billing/profiles.py +++ b/src/cloudflare/resources/billing/profiles.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import Any, cast +import typing_extensions +from typing import Type, cast import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import Body, Query, Headers, NotGiven, not_given from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( @@ -25,27 +26,41 @@ class ProfilesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ProfilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return ProfilesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ProfilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return ProfilesResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") def get( self, - account_identifier: object, *, + account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProfileGetResponse: """ Gets the current billing profile for the account. Args: + account_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -54,48 +69,59 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - ProfileGetResponse, - self._get( - f"/accounts/{account_identifier}/billing/profile", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ProfileGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ProfileGetResponse] - ), # Union types cannot be passed in as arguments in the type system + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/billing/profile", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ProfileGetResponse]._unwrapper, ), + cast_to=cast(Type[ProfileGetResponse], ResultWrapper[ProfileGetResponse]), ) class AsyncProfilesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncProfilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncProfilesResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncProfilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncProfilesResourceWithStreamingResponse(self) + @typing_extensions.deprecated("deprecated") async def get( self, - account_identifier: object, *, + account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProfileGetResponse: """ Gets the current billing profile for the account. Args: + account_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -104,21 +130,18 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - ProfileGetResponse, - await self._get( - f"/accounts/{account_identifier}/billing/profile", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ProfileGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ProfileGetResponse] - ), # Union types cannot be passed in as arguments in the type system + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/billing/profile", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ProfileGetResponse]._unwrapper, ), + cast_to=cast(Type[ProfileGetResponse], ResultWrapper[ProfileGetResponse]), ) @@ -126,8 +149,10 @@ class ProfilesResourceWithRawResponse: def __init__(self, profiles: ProfilesResource) -> None: self._profiles = profiles - self.get = to_raw_response_wrapper( - profiles.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + profiles.get, # pyright: ignore[reportDeprecated], + ) ) @@ -135,8 +160,10 @@ class AsyncProfilesResourceWithRawResponse: def __init__(self, profiles: AsyncProfilesResource) -> None: self._profiles = profiles - self.get = async_to_raw_response_wrapper( - profiles.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + profiles.get, # pyright: ignore[reportDeprecated], + ) ) @@ -144,8 +171,10 @@ class ProfilesResourceWithStreamingResponse: def __init__(self, profiles: ProfilesResource) -> None: self._profiles = profiles - self.get = to_streamed_response_wrapper( - profiles.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + profiles.get, # pyright: ignore[reportDeprecated], + ) ) @@ -153,6 +182,8 @@ class AsyncProfilesResourceWithStreamingResponse: def __init__(self, profiles: AsyncProfilesResource) -> None: self._profiles = profiles - self.get = async_to_streamed_response_wrapper( - profiles.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + profiles.get, # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/cloudflare/resources/bot_management.py b/src/cloudflare/resources/bot_management.py index d0974c04dc4..07b76763411 100644 --- a/src/cloudflare/resources/bot_management.py +++ b/src/cloudflare/resources/bot_management.py @@ -2,17 +2,13 @@ from __future__ import annotations -from typing import Any, Optional, cast, overload -from typing_extensions import Literal +from typing import Any, Optional, cast +from typing_extensions import Literal, overload import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import ( - required_args, - maybe_transform, - async_maybe_transform, -) +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import required_args, maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -33,10 +29,21 @@ class BotManagementResource(SyncAPIResource): @cached_property def with_raw_response(self) -> BotManagementResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return BotManagementResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> BotManagementResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return BotManagementResourceWithStreamingResponse(self) @overload @@ -44,14 +51,18 @@ def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - fight_mode: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + fight_mode: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -63,16 +74,77 @@ def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). fight_mode: Whether to enable Bot Fight Mode. + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -88,17 +160,21 @@ def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -110,14 +186,75 @@ def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + optimize_wordpress: Whether to optimize Super Bot Fight Mode protections for Wordpress. sbfm_definitely_automated: Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -143,18 +280,22 @@ def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -166,14 +307,75 @@ def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + optimize_wordpress: Whether to optimize Super Bot Fight Mode protections for Wordpress. sbfm_definitely_automated: Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -201,15 +403,20 @@ def update( self, *, zone_id: str, - auto_update_model: bool | NotGiven = NOT_GIVEN, - enable_js: bool | NotGiven = NOT_GIVEN, - suppress_session_score: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + auto_update_model: bool | Omit = omit, + bm_cookie_enabled: bool | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + suppress_session_score: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -221,18 +428,82 @@ def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. auto_update_model: Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + bm_cookie_enabled: Indicates that the bot management cookie can be placed on end user devices + accessing the site. Defaults to true + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + suppress_session_score: Whether to disable tracking the highest bot score for a session in the Bot Management cookie. @@ -251,21 +522,26 @@ def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - fight_mode: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, - sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - auto_update_model: bool | NotGiven = NOT_GIVEN, - suppress_session_score: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + fight_mode: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, + sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + auto_update_model: bool | Omit = omit, + bm_cookie_enabled: bool | Omit = omit, + suppress_session_score: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") @@ -275,14 +551,19 @@ def update( f"/zones/{zone_id}/bot_management", body=maybe_transform( { + "ai_bots_protection": ai_bots_protection, + "cf_robots_variant": cf_robots_variant, + "crawler_protection": crawler_protection, "enable_js": enable_js, "fight_mode": fight_mode, + "is_robots_txt_managed": is_robots_txt_managed, "optimize_wordpress": optimize_wordpress, "sbfm_definitely_automated": sbfm_definitely_automated, "sbfm_static_resource_protection": sbfm_static_resource_protection, "sbfm_verified_bots": sbfm_verified_bots, "sbfm_likely_automated": sbfm_likely_automated, "auto_update_model": auto_update_model, + "bm_cookie_enabled": bm_cookie_enabled, "suppress_session_score": suppress_session_score, }, bot_management_update_params.BotManagementUpdateParams, @@ -309,13 +590,13 @@ def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementGetResponse]: """ Retrieve a zone's Bot Management Config Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers @@ -348,10 +629,21 @@ def get( class AsyncBotManagementResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncBotManagementResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ return AsyncBotManagementResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncBotManagementResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ return AsyncBotManagementResourceWithStreamingResponse(self) @overload @@ -359,14 +651,18 @@ async def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - fight_mode: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + fight_mode: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -378,16 +674,77 @@ async def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). fight_mode: Whether to enable Bot Fight Mode. + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -403,17 +760,21 @@ async def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -425,14 +786,75 @@ async def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + optimize_wordpress: Whether to optimize Super Bot Fight Mode protections for Wordpress. sbfm_definitely_automated: Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -458,18 +880,22 @@ async def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -481,14 +907,75 @@ async def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + optimize_wordpress: Whether to optimize Super Bot Fight Mode protections for Wordpress. sbfm_definitely_automated: Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -516,15 +1003,20 @@ async def update( self, *, zone_id: str, - auto_update_model: bool | NotGiven = NOT_GIVEN, - enable_js: bool | NotGiven = NOT_GIVEN, - suppress_session_score: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + auto_update_model: bool | Omit = omit, + bm_cookie_enabled: bool | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + suppress_session_score: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: """ Updates the Bot Management configuration for a zone. @@ -536,18 +1028,82 @@ async def update( - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more - information on the different plans + information on the different plans \\ + If you recently upgraded or downgraded your plan, refer to the following examples + to clean up old configurations. Copy and paste the example body to remove old zone + configurations based on your current plan. + + #### Clean up configuration for Bot Fight Mode plan + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "suppress_session_score": false + } + ``` + + #### Clean up configuration for SBFM Pro plan + + ```json + { + "sbfm_likely_automated": "allow", + "fight_mode": false + } + ``` + + #### Clean up configuration for SBFM Biz plan + + ```json + { + "fight_mode": false + } + ``` + + #### Clean up configuration for BM Enterprise Subscription plan + + It is strongly recommended that you ensure you have + [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to + protect your zone before disabling the SBFM rules. Without these protections, + your zone is vulnerable to attacks. + + ```json + { + "sbfm_likely_automated": "allow", + "sbfm_definitely_automated": "allow", + "sbfm_verified_bots": "allow", + "sbfm_static_resource_protection": false, + "optimize_wordpress": false, + "fight_mode": false + } + ``` Args: - zone_id: Identifier + zone_id: Identifier. + + ai_bots_protection: Enable rule to block AI Scrapers and Crawlers. Please note the value + `only_on_ad_pages` is currently not available for Enterprise customers. auto_update_model: Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + bm_cookie_enabled: Indicates that the bot management cookie can be placed on end user devices + accessing the site. Defaults to true + + cf_robots_variant: Specifies the Robots Access Control License variant to use. + + crawler_protection: Enable rule to punish AI Scrapers and Crawlers via a link maze. + enable_js: Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + is_robots_txt_managed: Enable cloudflare managed robots.txt. If an existing robots.txt is detected, + then managed robots.txt will be prepended to the existing robots.txt. + suppress_session_score: Whether to disable tracking the highest bot score for a session in the Bot Management cookie. @@ -566,21 +1122,26 @@ async def update( self, *, zone_id: str, - enable_js: bool | NotGiven = NOT_GIVEN, - fight_mode: bool | NotGiven = NOT_GIVEN, - optimize_wordpress: bool | NotGiven = NOT_GIVEN, - sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - sbfm_static_resource_protection: bool | NotGiven = NOT_GIVEN, - sbfm_verified_bots: Literal["allow", "block"] | NotGiven = NOT_GIVEN, - sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | NotGiven = NOT_GIVEN, - auto_update_model: bool | NotGiven = NOT_GIVEN, - suppress_session_score: bool | NotGiven = NOT_GIVEN, + ai_bots_protection: Literal["block", "disabled", "only_on_ad_pages"] | Omit = omit, + cf_robots_variant: Literal["off", "policy_only"] | Omit = omit, + crawler_protection: Literal["enabled", "disabled"] | Omit = omit, + enable_js: bool | Omit = omit, + fight_mode: bool | Omit = omit, + is_robots_txt_managed: bool | Omit = omit, + optimize_wordpress: bool | Omit = omit, + sbfm_definitely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + sbfm_static_resource_protection: bool | Omit = omit, + sbfm_verified_bots: Literal["allow", "block"] | Omit = omit, + sbfm_likely_automated: Literal["allow", "block", "managed_challenge"] | Omit = omit, + auto_update_model: bool | Omit = omit, + bm_cookie_enabled: bool | Omit = omit, + suppress_session_score: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementUpdateResponse]: if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") @@ -590,14 +1151,19 @@ async def update( f"/zones/{zone_id}/bot_management", body=await async_maybe_transform( { + "ai_bots_protection": ai_bots_protection, + "cf_robots_variant": cf_robots_variant, + "crawler_protection": crawler_protection, "enable_js": enable_js, "fight_mode": fight_mode, + "is_robots_txt_managed": is_robots_txt_managed, "optimize_wordpress": optimize_wordpress, "sbfm_definitely_automated": sbfm_definitely_automated, "sbfm_static_resource_protection": sbfm_static_resource_protection, "sbfm_verified_bots": sbfm_verified_bots, "sbfm_likely_automated": sbfm_likely_automated, "auto_update_model": auto_update_model, + "bm_cookie_enabled": bm_cookie_enabled, "suppress_session_score": suppress_session_score, }, bot_management_update_params.BotManagementUpdateParams, @@ -624,13 +1190,13 @@ async def get( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Optional[BotManagementGetResponse]: """ Retrieve a zone's Bot Management Config Args: - zone_id: Identifier + zone_id: Identifier. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/botnet_feed/__init__.py b/src/cloudflare/resources/botnet_feed/__init__.py new file mode 100755 index 00000000000..851d69e45a1 --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .asn import ( + ASNResource, + AsyncASNResource, + ASNResourceWithRawResponse, + AsyncASNResourceWithRawResponse, + ASNResourceWithStreamingResponse, + AsyncASNResourceWithStreamingResponse, +) +from .configs import ( + ConfigsResource, + AsyncConfigsResource, + ConfigsResourceWithRawResponse, + AsyncConfigsResourceWithRawResponse, + ConfigsResourceWithStreamingResponse, + AsyncConfigsResourceWithStreamingResponse, +) +from .botnet_feed import ( + BotnetFeedResource, + AsyncBotnetFeedResource, + BotnetFeedResourceWithRawResponse, + AsyncBotnetFeedResourceWithRawResponse, + BotnetFeedResourceWithStreamingResponse, + AsyncBotnetFeedResourceWithStreamingResponse, +) + +__all__ = [ + "ASNResource", + "AsyncASNResource", + "ASNResourceWithRawResponse", + "AsyncASNResourceWithRawResponse", + "ASNResourceWithStreamingResponse", + "AsyncASNResourceWithStreamingResponse", + "ConfigsResource", + "AsyncConfigsResource", + "ConfigsResourceWithRawResponse", + "AsyncConfigsResourceWithRawResponse", + "ConfigsResourceWithStreamingResponse", + "AsyncConfigsResourceWithStreamingResponse", + "BotnetFeedResource", + "AsyncBotnetFeedResource", + "BotnetFeedResourceWithRawResponse", + "AsyncBotnetFeedResourceWithRawResponse", + "BotnetFeedResourceWithStreamingResponse", + "AsyncBotnetFeedResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/botnet_feed/asn.py b/src/cloudflare/resources/botnet_feed/asn.py new file mode 100755 index 00000000000..285845ee622 --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/asn.py @@ -0,0 +1,286 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Union, Optional, cast +from datetime import datetime + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.botnet_feed import asn_day_report_params +from ...types.botnet_feed.asn_day_report_response import ASNDayReportResponse +from ...types.botnet_feed.asn_full_report_response import ASNFullReportResponse + +__all__ = ["ASNResource", "AsyncASNResource"] + + +class ASNResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ASNResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ASNResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ASNResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ASNResourceWithStreamingResponse(self) + + def day_report( + self, + asn_id: int, + *, + account_id: str, + date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNDayReportResponse]: + """ + Gets all the data the botnet tracking database has for a given ASN registered to + user account for given date. If no date is given, it will return results for the + previous day. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/botnet_feed/asn/{asn_id}/day_report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"date": date}, asn_day_report_params.ASNDayReportParams), + post_parser=ResultWrapper[Optional[ASNDayReportResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNDayReportResponse]], ResultWrapper[ASNDayReportResponse]), + ) + + def full_report( + self, + asn_id: int, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNFullReportResponse]: + """ + Gets all the data the botnet threat feed tracking database has for a given ASN + registered to user account. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/botnet_feed/asn/{asn_id}/full_report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNFullReportResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNFullReportResponse]], ResultWrapper[ASNFullReportResponse]), + ) + + +class AsyncASNResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncASNResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncASNResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncASNResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncASNResourceWithStreamingResponse(self) + + async def day_report( + self, + asn_id: int, + *, + account_id: str, + date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNDayReportResponse]: + """ + Gets all the data the botnet tracking database has for a given ASN registered to + user account for given date. If no date is given, it will return results for the + previous day. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/botnet_feed/asn/{asn_id}/day_report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"date": date}, asn_day_report_params.ASNDayReportParams), + post_parser=ResultWrapper[Optional[ASNDayReportResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNDayReportResponse]], ResultWrapper[ASNDayReportResponse]), + ) + + async def full_report( + self, + asn_id: int, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNFullReportResponse]: + """ + Gets all the data the botnet threat feed tracking database has for a given ASN + registered to user account. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/botnet_feed/asn/{asn_id}/full_report", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNFullReportResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNFullReportResponse]], ResultWrapper[ASNFullReportResponse]), + ) + + +class ASNResourceWithRawResponse: + def __init__(self, asn: ASNResource) -> None: + self._asn = asn + + self.day_report = to_raw_response_wrapper( + asn.day_report, + ) + self.full_report = to_raw_response_wrapper( + asn.full_report, + ) + + +class AsyncASNResourceWithRawResponse: + def __init__(self, asn: AsyncASNResource) -> None: + self._asn = asn + + self.day_report = async_to_raw_response_wrapper( + asn.day_report, + ) + self.full_report = async_to_raw_response_wrapper( + asn.full_report, + ) + + +class ASNResourceWithStreamingResponse: + def __init__(self, asn: ASNResource) -> None: + self._asn = asn + + self.day_report = to_streamed_response_wrapper( + asn.day_report, + ) + self.full_report = to_streamed_response_wrapper( + asn.full_report, + ) + + +class AsyncASNResourceWithStreamingResponse: + def __init__(self, asn: AsyncASNResource) -> None: + self._asn = asn + + self.day_report = async_to_streamed_response_wrapper( + asn.day_report, + ) + self.full_report = async_to_streamed_response_wrapper( + asn.full_report, + ) diff --git a/src/cloudflare/resources/botnet_feed/botnet_feed.py b/src/cloudflare/resources/botnet_feed/botnet_feed.py new file mode 100755 index 00000000000..5f71396a78d --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/botnet_feed.py @@ -0,0 +1,134 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .asn import ( + ASNResource, + AsyncASNResource, + ASNResourceWithRawResponse, + AsyncASNResourceWithRawResponse, + ASNResourceWithStreamingResponse, + AsyncASNResourceWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .configs.configs import ( + ConfigsResource, + AsyncConfigsResource, + ConfigsResourceWithRawResponse, + AsyncConfigsResourceWithRawResponse, + ConfigsResourceWithStreamingResponse, + AsyncConfigsResourceWithStreamingResponse, +) + +__all__ = ["BotnetFeedResource", "AsyncBotnetFeedResource"] + + +class BotnetFeedResource(SyncAPIResource): + @cached_property + def asn(self) -> ASNResource: + return ASNResource(self._client) + + @cached_property + def configs(self) -> ConfigsResource: + return ConfigsResource(self._client) + + @cached_property + def with_raw_response(self) -> BotnetFeedResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return BotnetFeedResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BotnetFeedResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return BotnetFeedResourceWithStreamingResponse(self) + + +class AsyncBotnetFeedResource(AsyncAPIResource): + @cached_property + def asn(self) -> AsyncASNResource: + return AsyncASNResource(self._client) + + @cached_property + def configs(self) -> AsyncConfigsResource: + return AsyncConfigsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBotnetFeedResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncBotnetFeedResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBotnetFeedResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncBotnetFeedResourceWithStreamingResponse(self) + + +class BotnetFeedResourceWithRawResponse: + def __init__(self, botnet_feed: BotnetFeedResource) -> None: + self._botnet_feed = botnet_feed + + @cached_property + def asn(self) -> ASNResourceWithRawResponse: + return ASNResourceWithRawResponse(self._botnet_feed.asn) + + @cached_property + def configs(self) -> ConfigsResourceWithRawResponse: + return ConfigsResourceWithRawResponse(self._botnet_feed.configs) + + +class AsyncBotnetFeedResourceWithRawResponse: + def __init__(self, botnet_feed: AsyncBotnetFeedResource) -> None: + self._botnet_feed = botnet_feed + + @cached_property + def asn(self) -> AsyncASNResourceWithRawResponse: + return AsyncASNResourceWithRawResponse(self._botnet_feed.asn) + + @cached_property + def configs(self) -> AsyncConfigsResourceWithRawResponse: + return AsyncConfigsResourceWithRawResponse(self._botnet_feed.configs) + + +class BotnetFeedResourceWithStreamingResponse: + def __init__(self, botnet_feed: BotnetFeedResource) -> None: + self._botnet_feed = botnet_feed + + @cached_property + def asn(self) -> ASNResourceWithStreamingResponse: + return ASNResourceWithStreamingResponse(self._botnet_feed.asn) + + @cached_property + def configs(self) -> ConfigsResourceWithStreamingResponse: + return ConfigsResourceWithStreamingResponse(self._botnet_feed.configs) + + +class AsyncBotnetFeedResourceWithStreamingResponse: + def __init__(self, botnet_feed: AsyncBotnetFeedResource) -> None: + self._botnet_feed = botnet_feed + + @cached_property + def asn(self) -> AsyncASNResourceWithStreamingResponse: + return AsyncASNResourceWithStreamingResponse(self._botnet_feed.asn) + + @cached_property + def configs(self) -> AsyncConfigsResourceWithStreamingResponse: + return AsyncConfigsResourceWithStreamingResponse(self._botnet_feed.configs) diff --git a/src/cloudflare/resources/botnet_feed/configs/__init__.py b/src/cloudflare/resources/botnet_feed/configs/__init__.py new file mode 100755 index 00000000000..8aa8841973c --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/configs/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .asn import ( + ASNResource, + AsyncASNResource, + ASNResourceWithRawResponse, + AsyncASNResourceWithRawResponse, + ASNResourceWithStreamingResponse, + AsyncASNResourceWithStreamingResponse, +) +from .configs import ( + ConfigsResource, + AsyncConfigsResource, + ConfigsResourceWithRawResponse, + AsyncConfigsResourceWithRawResponse, + ConfigsResourceWithStreamingResponse, + AsyncConfigsResourceWithStreamingResponse, +) + +__all__ = [ + "ASNResource", + "AsyncASNResource", + "ASNResourceWithRawResponse", + "AsyncASNResourceWithRawResponse", + "ASNResourceWithStreamingResponse", + "AsyncASNResourceWithStreamingResponse", + "ConfigsResource", + "AsyncConfigsResource", + "ConfigsResourceWithRawResponse", + "AsyncConfigsResourceWithRawResponse", + "ConfigsResourceWithStreamingResponse", + "AsyncConfigsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/botnet_feed/configs/asn.py b/src/cloudflare/resources/botnet_feed/configs/asn.py new file mode 100755 index 00000000000..e8cf0754eb4 --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/configs/asn.py @@ -0,0 +1,271 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from ...._types import Body, Query, Headers, NotGiven, not_given +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.botnet_feed.configs.asn_get_response import ASNGetResponse +from ....types.botnet_feed.configs.asn_delete_response import ASNDeleteResponse + +__all__ = ["ASNResource", "AsyncASNResource"] + + +class ASNResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ASNResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ASNResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ASNResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ASNResourceWithStreamingResponse(self) + + def delete( + self, + asn_id: int, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNDeleteResponse]: + """ + Delete an ASN from botnet threat feed for a given user. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._delete( + f"/accounts/{account_id}/botnet_feed/configs/asn/{asn_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNDeleteResponse]], ResultWrapper[ASNDeleteResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNGetResponse]: + """ + Gets a list of all ASNs registered for a user for the DDoS Botnet Feed API. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/botnet_feed/configs/asn", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNGetResponse]], ResultWrapper[ASNGetResponse]), + ) + + +class AsyncASNResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncASNResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncASNResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncASNResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncASNResourceWithStreamingResponse(self) + + async def delete( + self, + asn_id: int, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNDeleteResponse]: + """ + Delete an ASN from botnet threat feed for a given user. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._delete( + f"/accounts/{account_id}/botnet_feed/configs/asn/{asn_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNDeleteResponse]], ResultWrapper[ASNDeleteResponse]), + ) + + async def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Optional[ASNGetResponse]: + """ + Gets a list of all ASNs registered for a user for the DDoS Botnet Feed API. + + Args: + account_id: Identifier. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/botnet_feed/configs/asn", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ASNGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ASNGetResponse]], ResultWrapper[ASNGetResponse]), + ) + + +class ASNResourceWithRawResponse: + def __init__(self, asn: ASNResource) -> None: + self._asn = asn + + self.delete = to_raw_response_wrapper( + asn.delete, + ) + self.get = to_raw_response_wrapper( + asn.get, + ) + + +class AsyncASNResourceWithRawResponse: + def __init__(self, asn: AsyncASNResource) -> None: + self._asn = asn + + self.delete = async_to_raw_response_wrapper( + asn.delete, + ) + self.get = async_to_raw_response_wrapper( + asn.get, + ) + + +class ASNResourceWithStreamingResponse: + def __init__(self, asn: ASNResource) -> None: + self._asn = asn + + self.delete = to_streamed_response_wrapper( + asn.delete, + ) + self.get = to_streamed_response_wrapper( + asn.get, + ) + + +class AsyncASNResourceWithStreamingResponse: + def __init__(self, asn: AsyncASNResource) -> None: + self._asn = asn + + self.delete = async_to_streamed_response_wrapper( + asn.delete, + ) + self.get = async_to_streamed_response_wrapper( + asn.get, + ) diff --git a/src/cloudflare/resources/botnet_feed/configs/configs.py b/src/cloudflare/resources/botnet_feed/configs/configs.py new file mode 100755 index 00000000000..6fe692cec0c --- /dev/null +++ b/src/cloudflare/resources/botnet_feed/configs/configs.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .asn import ( + ASNResource, + AsyncASNResource, + ASNResourceWithRawResponse, + AsyncASNResourceWithRawResponse, + ASNResourceWithStreamingResponse, + AsyncASNResourceWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["ConfigsResource", "AsyncConfigsResource"] + + +class ConfigsResource(SyncAPIResource): + @cached_property + def asn(self) -> ASNResource: + return ASNResource(self._client) + + @cached_property + def with_raw_response(self) -> ConfigsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ConfigsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ConfigsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ConfigsResourceWithStreamingResponse(self) + + +class AsyncConfigsResource(AsyncAPIResource): + @cached_property + def asn(self) -> AsyncASNResource: + return AsyncASNResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncConfigsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncConfigsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncConfigsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncConfigsResourceWithStreamingResponse(self) + + +class ConfigsResourceWithRawResponse: + def __init__(self, configs: ConfigsResource) -> None: + self._configs = configs + + @cached_property + def asn(self) -> ASNResourceWithRawResponse: + return ASNResourceWithRawResponse(self._configs.asn) + + +class AsyncConfigsResourceWithRawResponse: + def __init__(self, configs: AsyncConfigsResource) -> None: + self._configs = configs + + @cached_property + def asn(self) -> AsyncASNResourceWithRawResponse: + return AsyncASNResourceWithRawResponse(self._configs.asn) + + +class ConfigsResourceWithStreamingResponse: + def __init__(self, configs: ConfigsResource) -> None: + self._configs = configs + + @cached_property + def asn(self) -> ASNResourceWithStreamingResponse: + return ASNResourceWithStreamingResponse(self._configs.asn) + + +class AsyncConfigsResourceWithStreamingResponse: + def __init__(self, configs: AsyncConfigsResource) -> None: + self._configs = configs + + @cached_property + def asn(self) -> AsyncASNResourceWithStreamingResponse: + return AsyncASNResourceWithStreamingResponse(self._configs.asn) diff --git a/src/cloudflare/resources/brand_protection.py b/src/cloudflare/resources/brand_protection.py deleted file mode 100644 index ce9193d61eb..00000000000 --- a/src/cloudflare/resources/brand_protection.py +++ /dev/null @@ -1,278 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import ( - maybe_transform, - async_maybe_transform, -) -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .._wrappers import ResultWrapper -from .._base_client import make_request_options -from ..types.brand_protection import brand_protection_submit_params, brand_protection_url_info_params -from ..types.brand_protection.info import Info -from ..types.brand_protection.submit import Submit - -__all__ = ["BrandProtectionResource", "AsyncBrandProtectionResource"] - - -class BrandProtectionResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> BrandProtectionResourceWithRawResponse: - return BrandProtectionResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> BrandProtectionResourceWithStreamingResponse: - return BrandProtectionResourceWithStreamingResponse(self) - - def submit( - self, - *, - account_id: str, - url: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Submit]: - """ - Submit suspicious URL for scanning - - Args: - account_id: Identifier - - url: URL(s) to filter submissions results by - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._post( - f"/accounts/{account_id}/brand-protection/submit", - body=maybe_transform({"url": url}, brand_protection_submit_params.BrandProtectionSubmitParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Submit]]._unwrapper, - ), - cast_to=cast(Type[Optional[Submit]], ResultWrapper[Submit]), - ) - - def url_info( - self, - *, - account_id: str, - url: str | NotGiven = NOT_GIVEN, - url_id_param: brand_protection_url_info_params.URLIDParam | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Info]: - """ - Get results for a URL scan - - Args: - account_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get( - f"/accounts/{account_id}/brand-protection/url-info", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "url": url, - "url_id_param": url_id_param, - }, - brand_protection_url_info_params.BrandProtectionURLInfoParams, - ), - post_parser=ResultWrapper[Optional[Info]]._unwrapper, - ), - cast_to=cast(Type[Optional[Info]], ResultWrapper[Info]), - ) - - -class AsyncBrandProtectionResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncBrandProtectionResourceWithRawResponse: - return AsyncBrandProtectionResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncBrandProtectionResourceWithStreamingResponse: - return AsyncBrandProtectionResourceWithStreamingResponse(self) - - async def submit( - self, - *, - account_id: str, - url: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Submit]: - """ - Submit suspicious URL for scanning - - Args: - account_id: Identifier - - url: URL(s) to filter submissions results by - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._post( - f"/accounts/{account_id}/brand-protection/submit", - body=await async_maybe_transform({"url": url}, brand_protection_submit_params.BrandProtectionSubmitParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Submit]]._unwrapper, - ), - cast_to=cast(Type[Optional[Submit]], ResultWrapper[Submit]), - ) - - async def url_info( - self, - *, - account_id: str, - url: str | NotGiven = NOT_GIVEN, - url_id_param: brand_protection_url_info_params.URLIDParam | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Info]: - """ - Get results for a URL scan - - Args: - account_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._get( - f"/accounts/{account_id}/brand-protection/url-info", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "url": url, - "url_id_param": url_id_param, - }, - brand_protection_url_info_params.BrandProtectionURLInfoParams, - ), - post_parser=ResultWrapper[Optional[Info]]._unwrapper, - ), - cast_to=cast(Type[Optional[Info]], ResultWrapper[Info]), - ) - - -class BrandProtectionResourceWithRawResponse: - def __init__(self, brand_protection: BrandProtectionResource) -> None: - self._brand_protection = brand_protection - - self.submit = to_raw_response_wrapper( - brand_protection.submit, - ) - self.url_info = to_raw_response_wrapper( - brand_protection.url_info, - ) - - -class AsyncBrandProtectionResourceWithRawResponse: - def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: - self._brand_protection = brand_protection - - self.submit = async_to_raw_response_wrapper( - brand_protection.submit, - ) - self.url_info = async_to_raw_response_wrapper( - brand_protection.url_info, - ) - - -class BrandProtectionResourceWithStreamingResponse: - def __init__(self, brand_protection: BrandProtectionResource) -> None: - self._brand_protection = brand_protection - - self.submit = to_streamed_response_wrapper( - brand_protection.submit, - ) - self.url_info = to_streamed_response_wrapper( - brand_protection.url_info, - ) - - -class AsyncBrandProtectionResourceWithStreamingResponse: - def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: - self._brand_protection = brand_protection - - self.submit = async_to_streamed_response_wrapper( - brand_protection.submit, - ) - self.url_info = async_to_streamed_response_wrapper( - brand_protection.url_info, - ) diff --git a/src/cloudflare/resources/brand_protection/__init__.py b/src/cloudflare/resources/brand_protection/__init__.py new file mode 100644 index 00000000000..1660f110c9b --- /dev/null +++ b/src/cloudflare/resources/brand_protection/__init__.py @@ -0,0 +1,75 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .logos import ( + LogosResource, + AsyncLogosResource, + LogosResourceWithRawResponse, + AsyncLogosResourceWithRawResponse, + LogosResourceWithStreamingResponse, + AsyncLogosResourceWithStreamingResponse, +) +from .matches import ( + MatchesResource, + AsyncMatchesResource, + MatchesResourceWithRawResponse, + AsyncMatchesResourceWithRawResponse, + MatchesResourceWithStreamingResponse, + AsyncMatchesResourceWithStreamingResponse, +) +from .queries import ( + QueriesResource, + AsyncQueriesResource, + QueriesResourceWithRawResponse, + AsyncQueriesResourceWithRawResponse, + QueriesResourceWithStreamingResponse, + AsyncQueriesResourceWithStreamingResponse, +) +from .logo_matches import ( + LogoMatchesResource, + AsyncLogoMatchesResource, + LogoMatchesResourceWithRawResponse, + AsyncLogoMatchesResourceWithRawResponse, + LogoMatchesResourceWithStreamingResponse, + AsyncLogoMatchesResourceWithStreamingResponse, +) +from .brand_protection import ( + BrandProtectionResource, + AsyncBrandProtectionResource, + BrandProtectionResourceWithRawResponse, + AsyncBrandProtectionResourceWithRawResponse, + BrandProtectionResourceWithStreamingResponse, + AsyncBrandProtectionResourceWithStreamingResponse, +) + +__all__ = [ + "QueriesResource", + "AsyncQueriesResource", + "QueriesResourceWithRawResponse", + "AsyncQueriesResourceWithRawResponse", + "QueriesResourceWithStreamingResponse", + "AsyncQueriesResourceWithStreamingResponse", + "MatchesResource", + "AsyncMatchesResource", + "MatchesResourceWithRawResponse", + "AsyncMatchesResourceWithRawResponse", + "MatchesResourceWithStreamingResponse", + "AsyncMatchesResourceWithStreamingResponse", + "LogosResource", + "AsyncLogosResource", + "LogosResourceWithRawResponse", + "AsyncLogosResourceWithRawResponse", + "LogosResourceWithStreamingResponse", + "AsyncLogosResourceWithStreamingResponse", + "LogoMatchesResource", + "AsyncLogoMatchesResource", + "LogoMatchesResourceWithRawResponse", + "AsyncLogoMatchesResourceWithRawResponse", + "LogoMatchesResourceWithStreamingResponse", + "AsyncLogoMatchesResourceWithStreamingResponse", + "BrandProtectionResource", + "AsyncBrandProtectionResource", + "BrandProtectionResourceWithRawResponse", + "AsyncBrandProtectionResourceWithRawResponse", + "BrandProtectionResourceWithStreamingResponse", + "AsyncBrandProtectionResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/brand_protection/brand_protection.py b/src/cloudflare/resources/brand_protection/brand_protection.py new file mode 100644 index 00000000000..efe44ec7d57 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/brand_protection.py @@ -0,0 +1,373 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .logos import ( + LogosResource, + AsyncLogosResource, + LogosResourceWithRawResponse, + AsyncLogosResourceWithRawResponse, + LogosResourceWithStreamingResponse, + AsyncLogosResourceWithStreamingResponse, +) +from .matches import ( + MatchesResource, + AsyncMatchesResource, + MatchesResourceWithRawResponse, + AsyncMatchesResourceWithRawResponse, + MatchesResourceWithStreamingResponse, + AsyncMatchesResourceWithStreamingResponse, +) +from .queries import ( + QueriesResource, + AsyncQueriesResource, + QueriesResourceWithRawResponse, + AsyncQueriesResourceWithRawResponse, + QueriesResourceWithStreamingResponse, + AsyncQueriesResourceWithStreamingResponse, +) +from ..._types import Body, Query, Headers, NotGiven, not_given +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSinglePage, AsyncSinglePage +from .logo_matches import ( + LogoMatchesResource, + AsyncLogoMatchesResource, + LogoMatchesResourceWithRawResponse, + AsyncLogoMatchesResourceWithRawResponse, + LogoMatchesResourceWithStreamingResponse, + AsyncLogoMatchesResourceWithStreamingResponse, +) +from ..._base_client import AsyncPaginator, make_request_options +from ...types.brand_protection.brand_protection_submit_response import BrandProtectionSubmitResponse +from ...types.brand_protection.brand_protection_url_info_response import BrandProtectionURLInfoResponse + +__all__ = ["BrandProtectionResource", "AsyncBrandProtectionResource"] + + +class BrandProtectionResource(SyncAPIResource): + @cached_property + def queries(self) -> QueriesResource: + return QueriesResource(self._client) + + @cached_property + def matches(self) -> MatchesResource: + return MatchesResource(self._client) + + @cached_property + def logos(self) -> LogosResource: + return LogosResource(self._client) + + @cached_property + def logo_matches(self) -> LogoMatchesResource: + return LogoMatchesResource(self._client) + + @cached_property + def with_raw_response(self) -> BrandProtectionResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return BrandProtectionResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrandProtectionResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return BrandProtectionResourceWithStreamingResponse(self) + + def submit( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BrandProtectionSubmitResponse: + """ + Return new URL submissions + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/brand-protection/submit", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BrandProtectionSubmitResponse, + ) + + def url_info( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSinglePage[BrandProtectionURLInfoResponse]: + """ + Return submitted URLs based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/brand-protection/url-info", + page=SyncSinglePage[BrandProtectionURLInfoResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=BrandProtectionURLInfoResponse, + ) + + +class AsyncBrandProtectionResource(AsyncAPIResource): + @cached_property + def queries(self) -> AsyncQueriesResource: + return AsyncQueriesResource(self._client) + + @cached_property + def matches(self) -> AsyncMatchesResource: + return AsyncMatchesResource(self._client) + + @cached_property + def logos(self) -> AsyncLogosResource: + return AsyncLogosResource(self._client) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResource: + return AsyncLogoMatchesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBrandProtectionResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncBrandProtectionResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrandProtectionResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncBrandProtectionResourceWithStreamingResponse(self) + + async def submit( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BrandProtectionSubmitResponse: + """ + Return new URL submissions + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/brand-protection/submit", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BrandProtectionSubmitResponse, + ) + + def url_info( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[BrandProtectionURLInfoResponse, AsyncSinglePage[BrandProtectionURLInfoResponse]]: + """ + Return submitted URLs based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/brand-protection/url-info", + page=AsyncSinglePage[BrandProtectionURLInfoResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=BrandProtectionURLInfoResponse, + ) + + +class BrandProtectionResourceWithRawResponse: + def __init__(self, brand_protection: BrandProtectionResource) -> None: + self._brand_protection = brand_protection + + self.submit = to_raw_response_wrapper( + brand_protection.submit, + ) + self.url_info = to_raw_response_wrapper( + brand_protection.url_info, + ) + + @cached_property + def queries(self) -> QueriesResourceWithRawResponse: + return QueriesResourceWithRawResponse(self._brand_protection.queries) + + @cached_property + def matches(self) -> MatchesResourceWithRawResponse: + return MatchesResourceWithRawResponse(self._brand_protection.matches) + + @cached_property + def logos(self) -> LogosResourceWithRawResponse: + return LogosResourceWithRawResponse(self._brand_protection.logos) + + @cached_property + def logo_matches(self) -> LogoMatchesResourceWithRawResponse: + return LogoMatchesResourceWithRawResponse(self._brand_protection.logo_matches) + + +class AsyncBrandProtectionResourceWithRawResponse: + def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: + self._brand_protection = brand_protection + + self.submit = async_to_raw_response_wrapper( + brand_protection.submit, + ) + self.url_info = async_to_raw_response_wrapper( + brand_protection.url_info, + ) + + @cached_property + def queries(self) -> AsyncQueriesResourceWithRawResponse: + return AsyncQueriesResourceWithRawResponse(self._brand_protection.queries) + + @cached_property + def matches(self) -> AsyncMatchesResourceWithRawResponse: + return AsyncMatchesResourceWithRawResponse(self._brand_protection.matches) + + @cached_property + def logos(self) -> AsyncLogosResourceWithRawResponse: + return AsyncLogosResourceWithRawResponse(self._brand_protection.logos) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResourceWithRawResponse: + return AsyncLogoMatchesResourceWithRawResponse(self._brand_protection.logo_matches) + + +class BrandProtectionResourceWithStreamingResponse: + def __init__(self, brand_protection: BrandProtectionResource) -> None: + self._brand_protection = brand_protection + + self.submit = to_streamed_response_wrapper( + brand_protection.submit, + ) + self.url_info = to_streamed_response_wrapper( + brand_protection.url_info, + ) + + @cached_property + def queries(self) -> QueriesResourceWithStreamingResponse: + return QueriesResourceWithStreamingResponse(self._brand_protection.queries) + + @cached_property + def matches(self) -> MatchesResourceWithStreamingResponse: + return MatchesResourceWithStreamingResponse(self._brand_protection.matches) + + @cached_property + def logos(self) -> LogosResourceWithStreamingResponse: + return LogosResourceWithStreamingResponse(self._brand_protection.logos) + + @cached_property + def logo_matches(self) -> LogoMatchesResourceWithStreamingResponse: + return LogoMatchesResourceWithStreamingResponse(self._brand_protection.logo_matches) + + +class AsyncBrandProtectionResourceWithStreamingResponse: + def __init__(self, brand_protection: AsyncBrandProtectionResource) -> None: + self._brand_protection = brand_protection + + self.submit = async_to_streamed_response_wrapper( + brand_protection.submit, + ) + self.url_info = async_to_streamed_response_wrapper( + brand_protection.url_info, + ) + + @cached_property + def queries(self) -> AsyncQueriesResourceWithStreamingResponse: + return AsyncQueriesResourceWithStreamingResponse(self._brand_protection.queries) + + @cached_property + def matches(self) -> AsyncMatchesResourceWithStreamingResponse: + return AsyncMatchesResourceWithStreamingResponse(self._brand_protection.matches) + + @cached_property + def logos(self) -> AsyncLogosResourceWithStreamingResponse: + return AsyncLogosResourceWithStreamingResponse(self._brand_protection.logos) + + @cached_property + def logo_matches(self) -> AsyncLogoMatchesResourceWithStreamingResponse: + return AsyncLogoMatchesResourceWithStreamingResponse(self._brand_protection.logo_matches) diff --git a/src/cloudflare/resources/brand_protection/logo_matches.py b/src/cloudflare/resources/brand_protection/logo_matches.py new file mode 100644 index 00000000000..abe100862e5 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/logo_matches.py @@ -0,0 +1,300 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from ...types.brand_protection import logo_match_get_params, logo_match_download_params +from ...types.brand_protection.logo_match_get_response import LogoMatchGetResponse +from ...types.brand_protection.logo_match_download_response import LogoMatchDownloadResponse + +__all__ = ["LogoMatchesResource", "AsyncLogoMatchesResource"] + + +class LogoMatchesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LogoMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LogoMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogoMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LogoMatchesResourceWithStreamingResponse(self) + + def download( + self, + *, + account_id: str, + limit: str | Omit = omit, + logo_id: SequenceNotStr[str] | Omit = omit, + offset: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchDownloadResponse: + """ + Return matches as CSV for logo queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/brand-protection/logo-matches/download", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "logo_id": logo_id, + "offset": offset, + }, + logo_match_download_params.LogoMatchDownloadParams, + ), + ), + cast_to=LogoMatchDownloadResponse, + ) + + def get( + self, + *, + account_id: str, + limit: str | Omit = omit, + logo_id: SequenceNotStr[str] | Omit = omit, + offset: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchGetResponse: + """ + Return matches for logo queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/brand-protection/logo-matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "logo_id": logo_id, + "offset": offset, + }, + logo_match_get_params.LogoMatchGetParams, + ), + ), + cast_to=LogoMatchGetResponse, + ) + + +class AsyncLogoMatchesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLogoMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLogoMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogoMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLogoMatchesResourceWithStreamingResponse(self) + + async def download( + self, + *, + account_id: str, + limit: str | Omit = omit, + logo_id: SequenceNotStr[str] | Omit = omit, + offset: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchDownloadResponse: + """ + Return matches as CSV for logo queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/brand-protection/logo-matches/download", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "limit": limit, + "logo_id": logo_id, + "offset": offset, + }, + logo_match_download_params.LogoMatchDownloadParams, + ), + ), + cast_to=LogoMatchDownloadResponse, + ) + + async def get( + self, + *, + account_id: str, + limit: str | Omit = omit, + logo_id: SequenceNotStr[str] | Omit = omit, + offset: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoMatchGetResponse: + """ + Return matches for logo queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/brand-protection/logo-matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "limit": limit, + "logo_id": logo_id, + "offset": offset, + }, + logo_match_get_params.LogoMatchGetParams, + ), + ), + cast_to=LogoMatchGetResponse, + ) + + +class LogoMatchesResourceWithRawResponse: + def __init__(self, logo_matches: LogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.download = to_raw_response_wrapper( + logo_matches.download, + ) + self.get = to_raw_response_wrapper( + logo_matches.get, + ) + + +class AsyncLogoMatchesResourceWithRawResponse: + def __init__(self, logo_matches: AsyncLogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.download = async_to_raw_response_wrapper( + logo_matches.download, + ) + self.get = async_to_raw_response_wrapper( + logo_matches.get, + ) + + +class LogoMatchesResourceWithStreamingResponse: + def __init__(self, logo_matches: LogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.download = to_streamed_response_wrapper( + logo_matches.download, + ) + self.get = to_streamed_response_wrapper( + logo_matches.get, + ) + + +class AsyncLogoMatchesResourceWithStreamingResponse: + def __init__(self, logo_matches: AsyncLogoMatchesResource) -> None: + self._logo_matches = logo_matches + + self.download = async_to_streamed_response_wrapper( + logo_matches.download, + ) + self.get = async_to_streamed_response_wrapper( + logo_matches.get, + ) diff --git a/src/cloudflare/resources/brand_protection/logos.py b/src/cloudflare/resources/brand_protection/logos.py new file mode 100644 index 00000000000..fb55402f7e7 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/logos.py @@ -0,0 +1,283 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from ...types.brand_protection import logo_create_params +from ...types.brand_protection.logo_create_response import LogoCreateResponse + +__all__ = ["LogosResource", "AsyncLogosResource"] + + +class LogosResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LogosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return LogosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return LogosResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + match_type: str | Omit = omit, + tag: str | Omit = omit, + threshold: float | Omit = omit, + image: FileTypes | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoCreateResponse: + """ + Return new saved logo queries created from image files + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/brand-protection/logos", + body=maybe_transform({"image": image}, logo_create_params.LogoCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "match_type": match_type, + "tag": tag, + "threshold": threshold, + }, + logo_create_params.LogoCreateParams, + ), + ), + cast_to=LogoCreateResponse, + ) + + def delete( + self, + logo_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after deleting saved logo queries by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not logo_id: + raise ValueError(f"Expected a non-empty value for `logo_id` but received {logo_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/accounts/{account_id}/brand-protection/logos/{logo_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncLogosResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLogosResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncLogosResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogosResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncLogosResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + match_type: str | Omit = omit, + tag: str | Omit = omit, + threshold: float | Omit = omit, + image: FileTypes | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> LogoCreateResponse: + """ + Return new saved logo queries created from image files + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/brand-protection/logos", + body=await async_maybe_transform({"image": image}, logo_create_params.LogoCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "match_type": match_type, + "tag": tag, + "threshold": threshold, + }, + logo_create_params.LogoCreateParams, + ), + ), + cast_to=LogoCreateResponse, + ) + + async def delete( + self, + logo_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after deleting saved logo queries by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not logo_id: + raise ValueError(f"Expected a non-empty value for `logo_id` but received {logo_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/accounts/{account_id}/brand-protection/logos/{logo_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class LogosResourceWithRawResponse: + def __init__(self, logos: LogosResource) -> None: + self._logos = logos + + self.create = to_raw_response_wrapper( + logos.create, + ) + self.delete = to_raw_response_wrapper( + logos.delete, + ) + + +class AsyncLogosResourceWithRawResponse: + def __init__(self, logos: AsyncLogosResource) -> None: + self._logos = logos + + self.create = async_to_raw_response_wrapper( + logos.create, + ) + self.delete = async_to_raw_response_wrapper( + logos.delete, + ) + + +class LogosResourceWithStreamingResponse: + def __init__(self, logos: LogosResource) -> None: + self._logos = logos + + self.create = to_streamed_response_wrapper( + logos.create, + ) + self.delete = to_streamed_response_wrapper( + logos.delete, + ) + + +class AsyncLogosResourceWithStreamingResponse: + def __init__(self, logos: AsyncLogosResource) -> None: + self._logos = logos + + self.create = async_to_streamed_response_wrapper( + logos.create, + ) + self.delete = async_to_streamed_response_wrapper( + logos.delete, + ) diff --git a/src/cloudflare/resources/brand_protection/matches.py b/src/cloudflare/resources/brand_protection/matches.py new file mode 100644 index 00000000000..cf18f113e32 --- /dev/null +++ b/src/cloudflare/resources/brand_protection/matches.py @@ -0,0 +1,308 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from ...types.brand_protection import match_get_params, match_download_params +from ...types.brand_protection.match_get_response import MatchGetResponse +from ...types.brand_protection.match_download_response import MatchDownloadResponse + +__all__ = ["MatchesResource", "AsyncMatchesResource"] + + +class MatchesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return MatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return MatchesResourceWithStreamingResponse(self) + + def download( + self, + *, + account_id: str, + id: str | Omit = omit, + include_domain_id: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchDownloadResponse: + """ + Return matches as CSV for string queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/brand-protection/matches/download", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + }, + match_download_params.MatchDownloadParams, + ), + ), + cast_to=MatchDownloadResponse, + ) + + def get( + self, + *, + account_id: str, + id: str | Omit = omit, + include_domain_id: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchGetResponse: + """ + Return matches for string queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/brand-protection/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + }, + match_get_params.MatchGetParams, + ), + ), + cast_to=MatchGetResponse, + ) + + +class AsyncMatchesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMatchesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncMatchesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMatchesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncMatchesResourceWithStreamingResponse(self) + + async def download( + self, + *, + account_id: str, + id: str | Omit = omit, + include_domain_id: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchDownloadResponse: + """ + Return matches as CSV for string queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/brand-protection/matches/download", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "id": id, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + }, + match_download_params.MatchDownloadParams, + ), + ), + cast_to=MatchDownloadResponse, + ) + + async def get( + self, + *, + account_id: str, + id: str | Omit = omit, + include_domain_id: bool | Omit = omit, + limit: int | Omit = omit, + offset: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> MatchGetResponse: + """ + Return matches for string queries based on ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/brand-protection/matches", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "id": id, + "include_domain_id": include_domain_id, + "limit": limit, + "offset": offset, + }, + match_get_params.MatchGetParams, + ), + ), + cast_to=MatchGetResponse, + ) + + +class MatchesResourceWithRawResponse: + def __init__(self, matches: MatchesResource) -> None: + self._matches = matches + + self.download = to_raw_response_wrapper( + matches.download, + ) + self.get = to_raw_response_wrapper( + matches.get, + ) + + +class AsyncMatchesResourceWithRawResponse: + def __init__(self, matches: AsyncMatchesResource) -> None: + self._matches = matches + + self.download = async_to_raw_response_wrapper( + matches.download, + ) + self.get = async_to_raw_response_wrapper( + matches.get, + ) + + +class MatchesResourceWithStreamingResponse: + def __init__(self, matches: MatchesResource) -> None: + self._matches = matches + + self.download = to_streamed_response_wrapper( + matches.download, + ) + self.get = to_streamed_response_wrapper( + matches.get, + ) + + +class AsyncMatchesResourceWithStreamingResponse: + def __init__(self, matches: AsyncMatchesResource) -> None: + self._matches = matches + + self.download = async_to_streamed_response_wrapper( + matches.download, + ) + self.get = async_to_streamed_response_wrapper( + matches.get, + ) diff --git a/src/cloudflare/resources/brand_protection/queries.py b/src/cloudflare/resources/brand_protection/queries.py new file mode 100644 index 00000000000..4b7ead75a1c --- /dev/null +++ b/src/cloudflare/resources/brand_protection/queries.py @@ -0,0 +1,419 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Iterable +from datetime import datetime + +import httpx + +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from ...types.brand_protection import query_bulk_params, query_create_params, query_delete_params + +__all__ = ["QueriesResource", "AsyncQueriesResource"] + + +class QueriesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> QueriesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return QueriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> QueriesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return QueriesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + id: str | Omit = omit, + query_scan: bool | Omit = omit, + query_tag: str | Omit = omit, + max_time: Union[str, datetime, None] | Omit = omit, + min_time: Union[str, datetime, None] | Omit = omit, + body_scan: bool | Omit = omit, + string_matches: object | Omit = omit, + body_tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after creating new saved string queries + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._post( + f"/accounts/{account_id}/brand-protection/queries", + body=maybe_transform( + { + "max_time": max_time, + "min_time": min_time, + "body_scan": body_scan, + "string_matches": string_matches, + "body_tag": body_tag, + }, + query_create_params.QueryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "query_scan": query_scan, + "query_tag": query_tag, + }, + query_create_params.QueryCreateParams, + ), + ), + cast_to=NoneType, + ) + + def delete( + self, + *, + account_id: str, + id: str | Omit = omit, + scan: bool | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after deleting saved string queries by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._delete( + f"/accounts/{account_id}/brand-protection/queries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "scan": scan, + "tag": tag, + }, + query_delete_params.QueryDeleteParams, + ), + ), + cast_to=NoneType, + ) + + def bulk( + self, + *, + account_id: str, + queries: Iterable[Dict[str, object]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after creating new saved string queries in bulk + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return self._post( + f"/accounts/{account_id}/brand-protection/queries/bulk", + body=maybe_transform({"queries": queries}, query_bulk_params.QueryBulkParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class AsyncQueriesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncQueriesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncQueriesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncQueriesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncQueriesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + id: str | Omit = omit, + query_scan: bool | Omit = omit, + query_tag: str | Omit = omit, + max_time: Union[str, datetime, None] | Omit = omit, + min_time: Union[str, datetime, None] | Omit = omit, + body_scan: bool | Omit = omit, + string_matches: object | Omit = omit, + body_tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after creating new saved string queries + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._post( + f"/accounts/{account_id}/brand-protection/queries", + body=await async_maybe_transform( + { + "max_time": max_time, + "min_time": min_time, + "body_scan": body_scan, + "string_matches": string_matches, + "body_tag": body_tag, + }, + query_create_params.QueryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "id": id, + "query_scan": query_scan, + "query_tag": query_tag, + }, + query_create_params.QueryCreateParams, + ), + ), + cast_to=NoneType, + ) + + async def delete( + self, + *, + account_id: str, + id: str | Omit = omit, + scan: bool | Omit = omit, + tag: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after deleting saved string queries by ID + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._delete( + f"/accounts/{account_id}/brand-protection/queries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "id": id, + "scan": scan, + "tag": tag, + }, + query_delete_params.QueryDeleteParams, + ), + ), + cast_to=NoneType, + ) + + async def bulk( + self, + *, + account_id: str, + queries: Iterable[Dict[str, object]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> None: + """ + Return a success message after creating new saved string queries in bulk + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + return await self._post( + f"/accounts/{account_id}/brand-protection/queries/bulk", + body=await async_maybe_transform({"queries": queries}, query_bulk_params.QueryBulkParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + +class QueriesResourceWithRawResponse: + def __init__(self, queries: QueriesResource) -> None: + self._queries = queries + + self.create = to_raw_response_wrapper( + queries.create, + ) + self.delete = to_raw_response_wrapper( + queries.delete, + ) + self.bulk = to_raw_response_wrapper( + queries.bulk, + ) + + +class AsyncQueriesResourceWithRawResponse: + def __init__(self, queries: AsyncQueriesResource) -> None: + self._queries = queries + + self.create = async_to_raw_response_wrapper( + queries.create, + ) + self.delete = async_to_raw_response_wrapper( + queries.delete, + ) + self.bulk = async_to_raw_response_wrapper( + queries.bulk, + ) + + +class QueriesResourceWithStreamingResponse: + def __init__(self, queries: QueriesResource) -> None: + self._queries = queries + + self.create = to_streamed_response_wrapper( + queries.create, + ) + self.delete = to_streamed_response_wrapper( + queries.delete, + ) + self.bulk = to_streamed_response_wrapper( + queries.bulk, + ) + + +class AsyncQueriesResourceWithStreamingResponse: + def __init__(self, queries: AsyncQueriesResource) -> None: + self._queries = queries + + self.create = async_to_streamed_response_wrapper( + queries.create, + ) + self.delete = async_to_streamed_response_wrapper( + queries.delete, + ) + self.bulk = async_to_streamed_response_wrapper( + queries.bulk, + ) diff --git a/src/cloudflare/resources/browser_rendering/__init__.py b/src/cloudflare/resources/browser_rendering/__init__.py new file mode 100644 index 00000000000..ca6102ced41 --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/__init__.py @@ -0,0 +1,131 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .pdf import ( + PDFResource, + AsyncPDFResource, + PDFResourceWithRawResponse, + AsyncPDFResourceWithRawResponse, + PDFResourceWithStreamingResponse, + AsyncPDFResourceWithStreamingResponse, +) +from .json import ( + JsonResource, + AsyncJsonResource, + JsonResourceWithRawResponse, + AsyncJsonResourceWithRawResponse, + JsonResourceWithStreamingResponse, + AsyncJsonResourceWithStreamingResponse, +) +from .links import ( + LinksResource, + AsyncLinksResource, + LinksResourceWithRawResponse, + AsyncLinksResourceWithRawResponse, + LinksResourceWithStreamingResponse, + AsyncLinksResourceWithStreamingResponse, +) +from .scrape import ( + ScrapeResource, + AsyncScrapeResource, + ScrapeResourceWithRawResponse, + AsyncScrapeResourceWithRawResponse, + ScrapeResourceWithStreamingResponse, + AsyncScrapeResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from .markdown import ( + MarkdownResource, + AsyncMarkdownResource, + MarkdownResourceWithRawResponse, + AsyncMarkdownResourceWithRawResponse, + MarkdownResourceWithStreamingResponse, + AsyncMarkdownResourceWithStreamingResponse, +) +from .snapshot import ( + SnapshotResource, + AsyncSnapshotResource, + SnapshotResourceWithRawResponse, + AsyncSnapshotResourceWithRawResponse, + SnapshotResourceWithStreamingResponse, + AsyncSnapshotResourceWithStreamingResponse, +) +from .screenshot import ( + ScreenshotResource, + AsyncScreenshotResource, + ScreenshotResourceWithRawResponse, + AsyncScreenshotResourceWithRawResponse, + ScreenshotResourceWithStreamingResponse, + AsyncScreenshotResourceWithStreamingResponse, +) +from .browser_rendering import ( + BrowserRenderingResource, + AsyncBrowserRenderingResource, + BrowserRenderingResourceWithRawResponse, + AsyncBrowserRenderingResourceWithRawResponse, + BrowserRenderingResourceWithStreamingResponse, + AsyncBrowserRenderingResourceWithStreamingResponse, +) + +__all__ = [ + "ContentResource", + "AsyncContentResource", + "ContentResourceWithRawResponse", + "AsyncContentResourceWithRawResponse", + "ContentResourceWithStreamingResponse", + "AsyncContentResourceWithStreamingResponse", + "PDFResource", + "AsyncPDFResource", + "PDFResourceWithRawResponse", + "AsyncPDFResourceWithRawResponse", + "PDFResourceWithStreamingResponse", + "AsyncPDFResourceWithStreamingResponse", + "ScrapeResource", + "AsyncScrapeResource", + "ScrapeResourceWithRawResponse", + "AsyncScrapeResourceWithRawResponse", + "ScrapeResourceWithStreamingResponse", + "AsyncScrapeResourceWithStreamingResponse", + "ScreenshotResource", + "AsyncScreenshotResource", + "ScreenshotResourceWithRawResponse", + "AsyncScreenshotResourceWithRawResponse", + "ScreenshotResourceWithStreamingResponse", + "AsyncScreenshotResourceWithStreamingResponse", + "SnapshotResource", + "AsyncSnapshotResource", + "SnapshotResourceWithRawResponse", + "AsyncSnapshotResourceWithRawResponse", + "SnapshotResourceWithStreamingResponse", + "AsyncSnapshotResourceWithStreamingResponse", + "JsonResource", + "AsyncJsonResource", + "JsonResourceWithRawResponse", + "AsyncJsonResourceWithRawResponse", + "JsonResourceWithStreamingResponse", + "AsyncJsonResourceWithStreamingResponse", + "LinksResource", + "AsyncLinksResource", + "LinksResourceWithRawResponse", + "AsyncLinksResourceWithRawResponse", + "LinksResourceWithStreamingResponse", + "AsyncLinksResourceWithStreamingResponse", + "MarkdownResource", + "AsyncMarkdownResource", + "MarkdownResourceWithRawResponse", + "AsyncMarkdownResourceWithRawResponse", + "MarkdownResourceWithStreamingResponse", + "AsyncMarkdownResourceWithStreamingResponse", + "BrowserRenderingResource", + "AsyncBrowserRenderingResource", + "BrowserRenderingResourceWithRawResponse", + "AsyncBrowserRenderingResourceWithRawResponse", + "BrowserRenderingResourceWithStreamingResponse", + "AsyncBrowserRenderingResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/browser_rendering/browser_rendering.py b/src/cloudflare/resources/browser_rendering/browser_rendering.py new file mode 100644 index 00000000000..bee931f57df --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/browser_rendering.py @@ -0,0 +1,326 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .pdf import ( + PDFResource, + AsyncPDFResource, + PDFResourceWithRawResponse, + AsyncPDFResourceWithRawResponse, + PDFResourceWithStreamingResponse, + AsyncPDFResourceWithStreamingResponse, +) +from .json import ( + JsonResource, + AsyncJsonResource, + JsonResourceWithRawResponse, + AsyncJsonResourceWithRawResponse, + JsonResourceWithStreamingResponse, + AsyncJsonResourceWithStreamingResponse, +) +from .links import ( + LinksResource, + AsyncLinksResource, + LinksResourceWithRawResponse, + AsyncLinksResourceWithRawResponse, + LinksResourceWithStreamingResponse, + AsyncLinksResourceWithStreamingResponse, +) +from .scrape import ( + ScrapeResource, + AsyncScrapeResource, + ScrapeResourceWithRawResponse, + AsyncScrapeResourceWithRawResponse, + ScrapeResourceWithStreamingResponse, + AsyncScrapeResourceWithStreamingResponse, +) +from .content import ( + ContentResource, + AsyncContentResource, + ContentResourceWithRawResponse, + AsyncContentResourceWithRawResponse, + ContentResourceWithStreamingResponse, + AsyncContentResourceWithStreamingResponse, +) +from .markdown import ( + MarkdownResource, + AsyncMarkdownResource, + MarkdownResourceWithRawResponse, + AsyncMarkdownResourceWithRawResponse, + MarkdownResourceWithStreamingResponse, + AsyncMarkdownResourceWithStreamingResponse, +) +from .snapshot import ( + SnapshotResource, + AsyncSnapshotResource, + SnapshotResourceWithRawResponse, + AsyncSnapshotResourceWithRawResponse, + SnapshotResourceWithStreamingResponse, + AsyncSnapshotResourceWithStreamingResponse, +) +from ..._compat import cached_property +from .screenshot import ( + ScreenshotResource, + AsyncScreenshotResource, + ScreenshotResourceWithRawResponse, + AsyncScreenshotResourceWithRawResponse, + ScreenshotResourceWithStreamingResponse, + AsyncScreenshotResourceWithStreamingResponse, +) +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["BrowserRenderingResource", "AsyncBrowserRenderingResource"] + + +class BrowserRenderingResource(SyncAPIResource): + @cached_property + def content(self) -> ContentResource: + return ContentResource(self._client) + + @cached_property + def pdf(self) -> PDFResource: + return PDFResource(self._client) + + @cached_property + def scrape(self) -> ScrapeResource: + return ScrapeResource(self._client) + + @cached_property + def screenshot(self) -> ScreenshotResource: + return ScreenshotResource(self._client) + + @cached_property + def snapshot(self) -> SnapshotResource: + return SnapshotResource(self._client) + + @cached_property + def json(self) -> JsonResource: + return JsonResource(self._client) + + @cached_property + def links(self) -> LinksResource: + return LinksResource(self._client) + + @cached_property + def markdown(self) -> MarkdownResource: + return MarkdownResource(self._client) + + @cached_property + def with_raw_response(self) -> BrowserRenderingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return BrowserRenderingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrowserRenderingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return BrowserRenderingResourceWithStreamingResponse(self) + + +class AsyncBrowserRenderingResource(AsyncAPIResource): + @cached_property + def content(self) -> AsyncContentResource: + return AsyncContentResource(self._client) + + @cached_property + def pdf(self) -> AsyncPDFResource: + return AsyncPDFResource(self._client) + + @cached_property + def scrape(self) -> AsyncScrapeResource: + return AsyncScrapeResource(self._client) + + @cached_property + def screenshot(self) -> AsyncScreenshotResource: + return AsyncScreenshotResource(self._client) + + @cached_property + def snapshot(self) -> AsyncSnapshotResource: + return AsyncSnapshotResource(self._client) + + @cached_property + def json(self) -> AsyncJsonResource: + return AsyncJsonResource(self._client) + + @cached_property + def links(self) -> AsyncLinksResource: + return AsyncLinksResource(self._client) + + @cached_property + def markdown(self) -> AsyncMarkdownResource: + return AsyncMarkdownResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncBrowserRenderingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncBrowserRenderingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrowserRenderingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncBrowserRenderingResourceWithStreamingResponse(self) + + +class BrowserRenderingResourceWithRawResponse: + def __init__(self, browser_rendering: BrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> ContentResourceWithRawResponse: + return ContentResourceWithRawResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> PDFResourceWithRawResponse: + return PDFResourceWithRawResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> ScrapeResourceWithRawResponse: + return ScrapeResourceWithRawResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> ScreenshotResourceWithRawResponse: + return ScreenshotResourceWithRawResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> SnapshotResourceWithRawResponse: + return SnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + + @cached_property + def json(self) -> JsonResourceWithRawResponse: + return JsonResourceWithRawResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> LinksResourceWithRawResponse: + return LinksResourceWithRawResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> MarkdownResourceWithRawResponse: + return MarkdownResourceWithRawResponse(self._browser_rendering.markdown) + + +class AsyncBrowserRenderingResourceWithRawResponse: + def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> AsyncContentResourceWithRawResponse: + return AsyncContentResourceWithRawResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> AsyncPDFResourceWithRawResponse: + return AsyncPDFResourceWithRawResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> AsyncScrapeResourceWithRawResponse: + return AsyncScrapeResourceWithRawResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> AsyncScreenshotResourceWithRawResponse: + return AsyncScreenshotResourceWithRawResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> AsyncSnapshotResourceWithRawResponse: + return AsyncSnapshotResourceWithRawResponse(self._browser_rendering.snapshot) + + @cached_property + def json(self) -> AsyncJsonResourceWithRawResponse: + return AsyncJsonResourceWithRawResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> AsyncLinksResourceWithRawResponse: + return AsyncLinksResourceWithRawResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> AsyncMarkdownResourceWithRawResponse: + return AsyncMarkdownResourceWithRawResponse(self._browser_rendering.markdown) + + +class BrowserRenderingResourceWithStreamingResponse: + def __init__(self, browser_rendering: BrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> ContentResourceWithStreamingResponse: + return ContentResourceWithStreamingResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> PDFResourceWithStreamingResponse: + return PDFResourceWithStreamingResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> ScrapeResourceWithStreamingResponse: + return ScrapeResourceWithStreamingResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> ScreenshotResourceWithStreamingResponse: + return ScreenshotResourceWithStreamingResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> SnapshotResourceWithStreamingResponse: + return SnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) + + @cached_property + def json(self) -> JsonResourceWithStreamingResponse: + return JsonResourceWithStreamingResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> LinksResourceWithStreamingResponse: + return LinksResourceWithStreamingResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> MarkdownResourceWithStreamingResponse: + return MarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) + + +class AsyncBrowserRenderingResourceWithStreamingResponse: + def __init__(self, browser_rendering: AsyncBrowserRenderingResource) -> None: + self._browser_rendering = browser_rendering + + @cached_property + def content(self) -> AsyncContentResourceWithStreamingResponse: + return AsyncContentResourceWithStreamingResponse(self._browser_rendering.content) + + @cached_property + def pdf(self) -> AsyncPDFResourceWithStreamingResponse: + return AsyncPDFResourceWithStreamingResponse(self._browser_rendering.pdf) + + @cached_property + def scrape(self) -> AsyncScrapeResourceWithStreamingResponse: + return AsyncScrapeResourceWithStreamingResponse(self._browser_rendering.scrape) + + @cached_property + def screenshot(self) -> AsyncScreenshotResourceWithStreamingResponse: + return AsyncScreenshotResourceWithStreamingResponse(self._browser_rendering.screenshot) + + @cached_property + def snapshot(self) -> AsyncSnapshotResourceWithStreamingResponse: + return AsyncSnapshotResourceWithStreamingResponse(self._browser_rendering.snapshot) + + @cached_property + def json(self) -> AsyncJsonResourceWithStreamingResponse: + return AsyncJsonResourceWithStreamingResponse(self._browser_rendering.json) + + @cached_property + def links(self) -> AsyncLinksResourceWithStreamingResponse: + return AsyncLinksResourceWithStreamingResponse(self._browser_rendering.links) + + @cached_property + def markdown(self) -> AsyncMarkdownResourceWithStreamingResponse: + return AsyncMarkdownResourceWithStreamingResponse(self._browser_rendering.markdown) diff --git a/src/cloudflare/resources/browser_rendering/content.py b/src/cloudflare/resources/browser_rendering/content.py new file mode 100644 index 00000000000..a70abd0583b --- /dev/null +++ b/src/cloudflare/resources/browser_rendering/content.py @@ -0,0 +1,895 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Type, Iterable, Optional, cast +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import required_args, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.browser_rendering import content_create_params +from ...types.browser_rendering.content_create_response import ContentCreateResponse + +__all__ = ["ContentResource", "AsyncContentResource"] + + +class ContentResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ContentResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ContentResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ContentResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ContentResourceWithStreamingResponse(self) + + @overload + def create( + self, + *, + account_id: str, + url: str, + cache_ttl: float | Omit = omit, + action_timeout: float | Omit = omit, + add_script_tag: Iterable[content_create_params.Variant0AddScriptTag] | Omit = omit, + add_style_tag: Iterable[content_create_params.Variant0AddStyleTag] | Omit = omit, + allow_request_pattern: SequenceNotStr[str] | Omit = omit, + allow_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | Omit = omit, + authenticate: content_create_params.Variant0Authenticate | Omit = omit, + best_attempt: bool | Omit = omit, + cookies: Iterable[content_create_params.Variant0Cookie] | Omit = omit, + emulate_media_type: str | Omit = omit, + goto_options: content_create_params.Variant0GotoOptions | Omit = omit, + reject_request_pattern: SequenceNotStr[str] | Omit = omit, + reject_resource_types: List[ + Literal[ + "document", + "stylesheet", + "image", + "media", + "font", + "script", + "texttrack", + "xhr", + "fetch", + "prefetch", + "eventsource", + "websocket", + "manifest", + "signedexchange", + "ping", + "cspviolationreport", + "preflight", + "other", + ] + ] + | Omit = omit, + set_extra_http_headers: Dict[str, str] | Omit = omit, + set_java_script_enabled: bool | Omit = omit, + user_agent: str | Omit = omit, + viewport: content_create_params.Variant0Viewport | Omit = omit, + wait_for_selector: content_create_params.Variant0WaitForSelector | Omit = omit, + wait_for_timeout: float | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> str: + """Fetches rendered HTML content from provided URL or HTML. + + Check available options + like `gotoOptions` and `waitFor*` to control page load behaviour. + + Args: + account_id: Account ID. + + url: URL to navigate to, eg. `https://example.com`. + + cache_ttl: Cache TTL default is 5s. Set to 0 to disable. + + action_timeout: The maximum duration allowed for the browser action to complete after the page + has loaded (such as taking screenshots, extracting content, or generating PDFs). + If this time limit is exceeded, the action stops and returns a timeout error. + + add_script_tag: Adds a `